diff --git a/mx.trufflesom/suite.py b/mx.trufflesom/suite.py index bea88949..8c5010ed 100644 --- a/mx.trufflesom/suite.py +++ b/mx.trufflesom/suite.py @@ -16,7 +16,7 @@ { "name": "truffle", "subdir": True, - "version": "3f874aee628ffeb8e5ba65a28d3e5aa612cbfbe3", + "version": "084ca7ee41dd2bd24a597475decf9f4180913c78", "urls": [{"url": "https://github.com/oracle/graal", "kind": "git"}], }, ] diff --git a/src/trufflesom/src/trufflesom/interpreter/nodes/FieldNode.java b/src/trufflesom/src/trufflesom/interpreter/nodes/FieldNode.java index 549bb17e..7de83f76 100644 --- a/src/trufflesom/src/trufflesom/interpreter/nodes/FieldNode.java +++ b/src/trufflesom/src/trufflesom/interpreter/nodes/FieldNode.java @@ -158,9 +158,7 @@ public void replaceAfterScopeChange(final ScopeAdaptationVisitor inliner) { @Override public void constructOperation(final OpBuilder opBuilder, boolean resultUsed) { if (self instanceof NonLocalArgumentReadNode arg) { - opBuilder.dsl.beginNonLocalReadField(getFieldIndex()); - getSelf().accept(opBuilder); - opBuilder.dsl.endNonLocalReadField(); + opBuilder.dsl.emitNonLocalReadField(getFieldIndex(), arg.contextLevel); return; } diff --git a/src/trufflesom/src/trufflesom/interpreter/operations/SomOperations.java b/src/trufflesom/src/trufflesom/interpreter/operations/SomOperations.java index a064ffc3..bddd993a 100644 --- a/src/trufflesom/src/trufflesom/interpreter/operations/SomOperations.java +++ b/src/trufflesom/src/trufflesom/interpreter/operations/SomOperations.java @@ -15,6 +15,7 @@ import com.oracle.truffle.api.bytecode.EpilogReturn; import com.oracle.truffle.api.bytecode.GenerateBytecode; import com.oracle.truffle.api.bytecode.LocalAccessor; +import com.oracle.truffle.api.bytecode.MaterializedLocalAccessor; import com.oracle.truffle.api.bytecode.Operation; import com.oracle.truffle.api.bytecode.OperationProxy; import com.oracle.truffle.api.bytecode.Variadic; @@ -489,32 +490,39 @@ public static Object readObject( @Operation @ConstantOperand(type = int.class) + @ConstantOperand(type = int.class) @ImportStatic(FieldAccessorNode.class) public static final class NonLocalReadField { @Specialization(rewriteOn = UnexpectedResultException.class) - public static long readLong( + public static long readLong(final VirtualFrame frame, @SuppressWarnings("unused") final int fieldIdx, - final SObject self, + final int contextLevel, @Cached("createRead(fieldIdx)") final AbstractReadFieldNode read) throws UnexpectedResultException { - return read.readLong(self); + MaterializedFrame ctx = ContextualNode.determineContext(frame, contextLevel); + SObject rcvr = (SObject) ctx.getArguments()[0]; + return read.readLong(rcvr); } @Specialization(rewriteOn = UnexpectedResultException.class) - public static double readDouble( + public static double readDouble(final VirtualFrame frame, @SuppressWarnings("unused") final int fieldIdx, - final SObject self, + final int contextLevel, @Cached("createRead(fieldIdx)") final AbstractReadFieldNode read) throws UnexpectedResultException { - return read.readDouble(self); + MaterializedFrame ctx = ContextualNode.determineContext(frame, contextLevel); + SObject rcvr = (SObject) ctx.getArguments()[0]; + return read.readDouble(rcvr); } @Specialization - public static Object readObject( + public static Object readObject(final VirtualFrame frame, @SuppressWarnings("unused") final int fieldIdx, - final SObject self, + final int contextLevel, @Cached("createRead(fieldIdx)") final AbstractReadFieldNode read) { - return read.read(self); + MaterializedFrame ctx = ContextualNode.determineContext(frame, contextLevel); + SObject rcvr = (SObject) ctx.getArguments()[0]; + return read.read(rcvr); } } @@ -677,13 +685,13 @@ private static String concatStr(final String a, final String b) { } @Operation - @ConstantOperand(type = LocalAccessor.class) + @ConstantOperand(type = MaterializedLocalAccessor.class) @ConstantOperand(type = int.class) @ImportStatic(ContextualNode.class) public static final class IncNonLocalVarWithExp { @Specialization public static long increment(final VirtualFrame frame, - final LocalAccessor accessor, + final MaterializedLocalAccessor accessor, final int contextLevel, final long incValue, @Cached(value = "determineContextNode(frame, contextLevel)", @@ -708,11 +716,11 @@ public static long increment(final VirtualFrame frame, @Specialization public static double increment(final VirtualFrame frame, - final LocalAccessor accessor, - final int contextLevel, - final double incValue, - @Cached(value = "determineContextNode(frame, contextLevel)", - adopt = false) BytecodeNode bytecodeNode) { + final MaterializedLocalAccessor accessor, + final int contextLevel, + final double incValue, + @Cached(value = "determineContextNode(frame, contextLevel)", + adopt = false) BytecodeNode bytecodeNode) { MaterializedFrame ctx = ContextualNode.determineContext(frame, contextLevel); try { double currentValue = accessor.getDouble(bytecodeNode, ctx); @@ -727,11 +735,11 @@ public static double increment(final VirtualFrame frame, @Specialization public static String concatStrings(final VirtualFrame frame, - final LocalAccessor accessor, - final int contextLevel, - final String incValue, - @Cached(value = "determineContextNode(frame, contextLevel)", - adopt = false) BytecodeNode bytecodeNode) { + final MaterializedLocalAccessor accessor, + final int contextLevel, + final String incValue, + @Cached(value = "determineContextNode(frame, contextLevel)", + adopt = false) BytecodeNode bytecodeNode) { MaterializedFrame ctx = ContextualNode.determineContext(frame, contextLevel); String currentValue = (String) accessor.getObject(bytecodeNode, ctx); String result = concatStr(currentValue, incValue); @@ -763,13 +771,13 @@ public static long increment(final VirtualFrame frame, @ImportStatic(ContextualNode.class) @Operation - @ConstantOperand(type = LocalAccessor.class) + @ConstantOperand(type = MaterializedLocalAccessor.class) @ConstantOperand(type = long.class) @ConstantOperand(type = int.class) public static final class IncNonLocalVarWithValue { @Specialization public static long increment(final VirtualFrame frame, - final LocalAccessor accessor, + final MaterializedLocalAccessor accessor, final long incValue, final int contextLevel, @Cached(value = "determineContextNode(frame, contextLevel)",