com.oracle.truffle.api.frame.FrameSlotKind Java Examples
The following examples show how to use
com.oracle.truffle.api.frame.FrameSlotKind.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HashemNodeFactory.java From mr-hashemi with Universal Permissive License v1.0 | 6 votes |
/** * Returns an {@link HashemWriteLocalVariableNode} 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 HashemExpressionNode createAssignment(HashemExpressionNode nameNode, HashemExpressionNode valueNode, Integer argumentIndex) { if (nameNode == null || valueNode == null) { return null; } String name = ((HashemStringLiteralNode) nameNode).executeGeneric(null); FrameSlot frameSlot = frameDescriptor.findOrAddFrameSlot( name, argumentIndex, FrameSlotKind.Illegal); lexicalScope.locals.put(name, frameSlot); final HashemExpressionNode result = HashemWriteLocalVariableNodeGen.create(valueNode, frameSlot); if (valueNode.hasSource()) { final int start = nameNode.getSourceCharIndex(); final int length = valueNode.getSourceEndIndex() - start; result.setSourceSection(start, length); } result.addExpressionTag(); return result; }
Example #2
Source File: FrameSlotWriteNode.java From trufflesqueak with MIT License | 5 votes |
@Specialization(guards = "isLongOrIllegal(frame)") protected final void writeLong(final Frame frame, final long value) { /* Initialize type on first write. No-op if kind is already Long. */ frame.getFrameDescriptor().setFrameSlotKind(getSlot(), FrameSlotKind.Long); frame.setLong(getSlot(), value); }
Example #3
Source File: DefineNode.java From mumbler with GNU General Public License v3.0 | 5 votes |
private boolean isKind(FrameSlot slot, FrameSlotKind kind) { if (slot.getKind() == kind) { return true; } if (slot.getKind() == FrameSlotKind.Illegal) { CompilerDirectives.transferToInterpreterAndInvalidate(); slot.setKind(kind); return true; } return false; }
Example #4
Source File: DefineNode.java From mumbler with GNU General Public License v3.0 | 5 votes |
@Specialization(replaces = {"writeLong", "writeBoolean"}) protected Object write(VirtualFrame virtualFrame, Object value) { FrameSlot slot = this.getSlot(); if (slot.getKind() != FrameSlotKind.Object) { CompilerDirectives.transferToInterpreterAndInvalidate(); slot.setKind(FrameSlotKind.Object); } virtualFrame.setObject(slot, value); return value; }
Example #5
Source File: FrameSlotWriteNode.java From trufflesqueak with MIT License | 5 votes |
@Specialization(guards = "isDoubleOrIllegal(frame)") protected final void writeDouble(final Frame frame, final double value) { /* Initialize type on first write. No-op if kind is already Double. */ frame.getFrameDescriptor().setFrameSlotKind(getSlot(), FrameSlotKind.Double); frame.setDouble(getSlot(), value); }
Example #6
Source File: FrameSlotWriteNode.java From trufflesqueak with MIT License | 5 votes |
@Specialization(guards = "isBooleanOrIllegal(frame)") protected final void writeBool(final Frame frame, final boolean value) { /* Initialize type on first write. No-op if kind is already Boolean. */ frame.getFrameDescriptor().setFrameSlotKind(getSlot(), FrameSlotKind.Boolean); frame.setBoolean(getSlot(), value); }
Example #7
Source File: CompiledCodeObject.java From trufflesqueak with MIT License | 5 votes |
@TruffleBoundary protected CompiledCodeObject(final SqueakImageContext image, final int hash, final int numCopiedValues) { super(image, hash); this.numCopiedValues = numCopiedValues; frameDescriptor = new FrameDescriptor(); thisMarkerSlot = frameDescriptor.addFrameSlot(SLOT_IDENTIFIER.THIS_MARKER, FrameSlotKind.Object); thisContextSlot = frameDescriptor.addFrameSlot(SLOT_IDENTIFIER.THIS_CONTEXT, FrameSlotKind.Illegal); instructionPointerSlot = frameDescriptor.addFrameSlot(SLOT_IDENTIFIER.INSTRUCTION_POINTER, FrameSlotKind.Int); stackPointerSlot = frameDescriptor.addFrameSlot(SLOT_IDENTIFIER.STACK_POINTER, FrameSlotKind.Int); }
Example #8
Source File: HashemWriteLocalVariableNode.java From mr-hashemi with Universal Permissive License v1.0 | 5 votes |
/** * Generic write method that works for all possible types. * <p> * Why is this method annotated with {@link Specialization} and not {@link Fallback}? For a * {@link Fallback} method, the Truffle DSL generated code would try all other specializations * first before calling this method. We know that all these specializations would fail their * guards, so there is no point in calling them. Since this method takes a value of type * {@link Object}, it is guaranteed to never fail, i.e., once we are in this specialization the * node will never be re-specialized. */ @Specialization(replaces = {"writeLong", "writeBoolean"}) protected Object write(VirtualFrame frame, Object value) { /* * Regardless of the type before, the new and final type of the local variable is Object. * Changing the slot kind also discards compiled code, because the variable type is * important when the compiler optimizes a method. * * No-op if kind is already Object. */ frame.getFrameDescriptor().setFrameSlotKind(getSlot(), FrameSlotKind.Object); frame.setObject(getSlot(), value); return value; }
Example #9
Source File: HashemWriteLocalVariableNode.java From mr-hashemi with Universal Permissive License v1.0 | 5 votes |
@Specialization(guards = "isBooleanOrIllegal(frame)") protected boolean writeBoolean(VirtualFrame frame, boolean value) { /* Initialize type on first write of the local variable. No-op if kind is already Long. */ frame.getFrameDescriptor().setFrameSlotKind(getSlot(), FrameSlotKind.Boolean); frame.setBoolean(getSlot(), value); return value; }
Example #10
Source File: HashemWriteLocalVariableNode.java From mr-hashemi with Universal Permissive License v1.0 | 5 votes |
/** * Specialized method to write a primitive {@code long} value. This is only possible if the * local variable also has currently the type {@code long} or was never written before, * therefore a Truffle DSL {@link #isLongOrIllegal(VirtualFrame) custom guard} is specified. */ @Specialization(guards = "isLongOrIllegal(frame)") protected long writeLong(VirtualFrame frame, long value) { /* Initialize type on first write of the local variable. No-op if kind is already Long. */ frame.getFrameDescriptor().setFrameSlotKind(getSlot(), FrameSlotKind.Long); frame.setLong(getSlot(), value); return value; }
Example #11
Source File: HashemWriteLocalVariableNode.java From mr-hashemi with Universal Permissive License v1.0 | 4 votes |
protected boolean isBooleanOrIllegal(VirtualFrame frame) { final FrameSlotKind kind = frame.getFrameDescriptor().getFrameSlotKind(getSlot()); return kind == FrameSlotKind.Boolean || kind == FrameSlotKind.Illegal; }
Example #12
Source File: FrameSlotWriteNode.java From trufflesqueak with MIT License | 4 votes |
protected final boolean isBooleanOrIllegal(final Frame frame) { final FrameSlotKind kind = frame.getFrameDescriptor().getFrameSlotKind(getSlot()); return kind == FrameSlotKind.Boolean || kind == FrameSlotKind.Illegal; }
Example #13
Source File: FrameSlotWriteNode.java From trufflesqueak with MIT License | 4 votes |
protected final boolean isLongOrIllegal(final Frame frame) { final FrameSlotKind kind = frame.getFrameDescriptor().getFrameSlotKind(getSlot()); return kind == FrameSlotKind.Long || kind == FrameSlotKind.Illegal; }
Example #14
Source File: FrameSlotWriteNode.java From trufflesqueak with MIT License | 4 votes |
protected final boolean isDoubleOrIllegal(final Frame frame) { final FrameSlotKind kind = frame.getFrameDescriptor().getFrameSlotKind(getSlot()); return kind == FrameSlotKind.Double || kind == FrameSlotKind.Illegal; }
Example #15
Source File: DefineNode.java From mumbler with GNU General Public License v3.0 | 4 votes |
protected boolean isLongKind() { return this.isKind(this.getSlot(), FrameSlotKind.Long); }
Example #16
Source File: DefineNode.java From mumbler with GNU General Public License v3.0 | 4 votes |
protected boolean isBooleanKind() { return this.isKind(this.getSlot(), FrameSlotKind.Boolean); }
Example #17
Source File: HashemWriteLocalVariableNode.java From mr-hashemi with Universal Permissive License v1.0 | 2 votes |
/** * Guard function that the local variable has the type {@code long}. * * @param frame The parameter seems unnecessary, but it is required: Without the parameter, the * Truffle DSL would not check the guard on every execution of the specialization. * Guards without parameters are assumed to be pure, but our guard depends on the * slot kind which can change. */ protected boolean isLongOrIllegal(VirtualFrame frame) { final FrameSlotKind kind = frame.getFrameDescriptor().getFrameSlotKind(getSlot()); return kind == FrameSlotKind.Long || kind == FrameSlotKind.Illegal; }