com.oracle.truffle.api.frame.VirtualFrame Java Examples

The following examples show how to use com.oracle.truffle.api.frame.VirtualFrame. 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: ExecuteTopLevelContextNode.java    From trufflesqueak with MIT License 6 votes vote down vote up
@Override
public Object execute(final VirtualFrame frame) {
    try {
        executeLoop();
    } catch (final TopLevelReturn e) {
        return e.getReturnValue();
    } finally {
        if (isImageResuming) {
            image.interrupt.shutdown();
            if (image.hasDisplay()) {
                image.getDisplay().close();
            }
        }
    }
    throw SqueakException.create("Top level context did not return");
}
 
Example #2
Source File: SendBytecodes.java    From trufflesqueak with MIT License 6 votes vote down vote up
@Override
public final void executeVoid(final VirtualFrame frame) {
    final Object receiver = getReceiver(frame);
    final ClassObject rcvrClass = lookupClassNode.executeLookup(receiver);
    final Object lookupResult = lookupMethodNode.executeLookup(rcvrClass, selector);
    try {
        final Object result = dispatchSendNode.executeSend(frame, selector, lookupResult, receiver, rcvrClass);
        assert result != null : "Result of a message send should not be null";
        getPushNode().execute(frame, result);
    } catch (final NonLocalReturn nlr) {
        nlrProfile.enter();
        if (nlr.getTargetContextOrMarker() == getMarker(frame) || nlr.getTargetContextOrMarker() == getContext(frame)) {
            getPushNode().execute(frame, nlr.getReturnValue());
        } else {
            throw nlr;
        }
    } catch (final NonVirtualReturn nvr) {
        nvrProfile.enter();
        if (nvr.getTargetContext() == getContext(frame)) {
            getPushNode().execute(frame, nvr.getReturnValue());
        } else {
            throw nvr;
        }
    }
}
 
Example #3
Source File: SqueakBytecodeTest.java    From trufflesqueak with MIT License 6 votes vote down vote up
@Test
public void testExtendedPopIntoTemporaryVariables() {
    final int maxNumTemps = CONTEXT.MAX_STACK_SIZE - 2; // two stack slots required for code
    final Object[] literals = new Object[]{makeHeader(0, maxNumTemps, 0, false, true), NilObject.SINGLETON, NilObject.SINGLETON};
    final AbstractSqueakObject rcvr = image.specialObjectsArray;
    for (int i = 0; i < maxNumTemps; i++) {
        // push true, push 1, popIntoTemp i, pushTemp i, quickReturnTop
        final CompiledMethodObject method = makeMethod(literals, 113, 118, 130, 64 + i, 128, 64 + i, 124);
        final VirtualFrame frame = createTestFrame(method);
        try {
            assertSame(1L, createContext(method, rcvr).execute(frame));
        } catch (NonLocalReturn | NonVirtualReturn | ProcessSwitch e) {
            fail("broken test");
        }
    }
}
 
Example #4
Source File: HashemInvokeNode.java    From mr-hashemi with Universal Permissive License v1.0 6 votes vote down vote up
@ExplodeLoop
@Override
public Object executeGeneric(VirtualFrame frame) {
    Object function = functionNode.executeGeneric(frame);

    /*
     * The number of arguments is constant for one invoke node. During compilation, the loop is
     * unrolled and the execute methods of all arguments are inlined. This is triggered by the
     * ExplodeLoop annotation on the method. The compiler assertion below illustrates that the
     * array length is really constant.
     */
    CompilerAsserts.compilationConstant(argumentNodes.length);

    Object[] argumentValues = new Object[argumentNodes.length];
    for (int i = 0; i < argumentNodes.length; i++) {
        argumentValues[i] = argumentNodes[i].executeGeneric(frame);
    }

    try {
        return library.execute(function, argumentValues);
    } catch (ArityException | UnsupportedTypeException | UnsupportedMessageException e) {
        /* Execute was not successful. */
        throw HashemUndefinedNameException.undefinedBebin(this, function);
    }
}
 
Example #5
Source File: ReturnBytecodes.java    From trufflesqueak with MIT License 6 votes vote down vote up
@Specialization(guards = {"hasModifiedSender(frame)"})
protected final Object doNonLocalReturnClosure(final VirtualFrame frame,
                @Cached final GetActiveProcessNode getActiveProcessNode) {
    // Target is sender of closure's home context.
    final ContextObject homeContext = FrameAccess.getClosure(frame).getHomeContext();
    assert homeContext.getProcess() != null;
    final boolean homeContextNotOnTheStack = homeContext.getProcess() != getActiveProcessNode.execute();
    final Object caller = homeContext.getFrameSender();
    if (caller == NilObject.SINGLETON || homeContextNotOnTheStack) {
        CompilerDirectives.transferToInterpreter();
        final ContextObject contextObject = GetOrCreateContextNode.getOrCreateFromActiveProcessUncached(frame);
        lookupContext().cannotReturn.executeAsSymbolSlow(frame, contextObject, getReturnValue(frame));
        throw SqueakException.create("Should not reach");
    }
    throw new NonLocalReturn(getReturnValue(frame), caller);
}
 
Example #6
Source File: CallNode.java    From grcuda with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Specialization
Object doDefault(VirtualFrame frame,
                @CachedLibrary(limit = "2") InteropLibrary interop,
                @CachedContext(GrCUDALanguage.class) GrCUDAContext context) {
    String[] functionName = identifier.getIdentifierName();
    Namespace namespace = context.getRootNamespace();
    Optional<Object> maybeFunction = namespace.lookup(functionName);
    if (!maybeFunction.isPresent() || !(maybeFunction.get() instanceof Function)) {
        CompilerDirectives.transferToInterpreter();
        throw new GrCUDAException("function '" + GrCUDAException.format(functionName) + "' not found", this);
    }
    Function function = (Function) maybeFunction.get();
    Object[] argumentValues = new Object[argumentNodes.length];
    for (int i = 0; i < argumentNodes.length; i++) {
        argumentValues[i] = argumentNodes[i].execute(frame);
    }
    try {
        return interop.execute(function, argumentValues);
    } catch (ArityException | UnsupportedTypeException | UnsupportedMessageException e) {
        CompilerDirectives.transferToInterpreter();
        throw new GrCUDAException(e.getMessage(), this);
    }
}
 
Example #7
Source File: SqueakBytecodeTest.java    From trufflesqueak with MIT License 6 votes vote down vote up
@Test
public void testDoubleExtendedPushLiteralConstants() {
    final Object[] expectedResults = getTestObjects(255);
    final List<Object> literalsList = new ArrayList<>(Arrays.asList(new Object[]{68419598L}));
    literalsList.addAll(Arrays.asList(expectedResults));
    final AbstractSqueakObject rcvr = image.specialObjectsArray;
    for (int i = 0; i < expectedResults.length; i++) {
        final CompiledMethodObject method = makeMethod(literalsList.toArray(), 132, 96, i, 124);
        final VirtualFrame frame = createTestFrame(method);
        try {
            final Object result = createContext(method, rcvr).execute(frame);
            assertSame(expectedResults[i], result);
        } catch (NonLocalReturn | NonVirtualReturn | ProcessSwitch e) {
            fail("broken test");
        }
    }
}
 
Example #8
Source File: HashemReadLocalVariableNode.java    From mr-hashemi with Universal Permissive License v1.0 6 votes vote down vote up
@Specialization(replaces = {"readLong", "readBoolean"})
protected Object readObject(VirtualFrame frame) {
    if (!frame.isObject(getSlot())) {
        /*
         * The FrameSlotKind has been set to Object, so from now on all writes to the local
         * variable will be Object writes. However, now we are in a frame that still has an old
         * non-Object value. This is a slow-path operation: we read the non-Object value, and
         * write it immediately as an Object value so that we do not hit this path again
         * multiple times for the same variable of the same frame.
         */
        CompilerDirectives.transferToInterpreter();
        Object result = frame.getValue(getSlot());
        frame.setObject(getSlot(), result);
        return result;
    }

    return FrameUtil.getObjectSafe(frame, getSlot());
}
 
Example #9
Source File: BlockClosurePrimitives.java    From trufflesqueak with MIT License 6 votes vote down vote up
@SuppressWarnings("unused")
@Specialization(guards = {"!isNotProvided(arg5)", "closure.getCompiledBlock() == cachedBlock", "cachedBlock.getNumArgs() == 5"}, assumptions = {
                "cachedBlock.getCallTargetStable()"}, limit = "INLINE_CACHE_SIZE")
protected static final Object doValue5Direct(final VirtualFrame frame, final BlockClosureObject closure, final Object arg1, final Object arg2, final Object arg3, final Object arg4,
                final Object arg5,
                @Cached("closure.getCompiledBlock()") final CompiledBlockObject cachedBlock,
                @Cached final GetContextOrMarkerNode getContextOrMarkerNode,
                @Cached("create(cachedBlock.getCallTarget())") final DirectCallNode directCallNode) {
    final Object[] frameArguments = FrameAccess.newClosureArgumentsTemplate(closure, cachedBlock, getContextOrMarkerNode.execute(frame), 5);
    frameArguments[FrameAccess.getArgumentStartIndex()] = arg1;
    frameArguments[FrameAccess.getArgumentStartIndex() + 1] = arg2;
    frameArguments[FrameAccess.getArgumentStartIndex() + 2] = arg3;
    frameArguments[FrameAccess.getArgumentStartIndex() + 3] = arg4;
    frameArguments[FrameAccess.getArgumentStartIndex() + 4] = arg5;
    return directCallNode.call(frameArguments);
}
 
Example #10
Source File: FrameAccess.java    From trufflesqueak with MIT License 6 votes vote down vote up
@ExplodeLoop
public static Object[] newWith(final VirtualFrame frame, final CompiledMethodObject method, final Object sender, final BlockClosureObject closure,
                final FrameSlotReadNode[] receiverAndArgumentsNodes) {
    final int receiverAndArgumentsLength = receiverAndArgumentsNodes.length;
    final Object[] frameArguments = new Object[ArgumentIndicies.RECEIVER.ordinal() + receiverAndArgumentsLength];
    assert method != null : "Method should never be null";
    assert sender != null : "Sender should never be null";
    assert receiverAndArgumentsLength > 0 : "At least a receiver must be provided";
    frameArguments[ArgumentIndicies.METHOD.ordinal()] = method;
    frameArguments[ArgumentIndicies.SENDER_OR_SENDER_MARKER.ordinal()] = sender;
    frameArguments[ArgumentIndicies.CLOSURE_OR_NULL.ordinal()] = closure;
    for (int i = 0; i < receiverAndArgumentsNodes.length; i++) {
        frameArguments[ArgumentIndicies.RECEIVER.ordinal() + i] = receiverAndArgumentsNodes[i].executeRead(frame);
    }
    return frameArguments;
}
 
Example #11
Source File: SqueakBytecodeTest.java    From trufflesqueak with MIT License 6 votes vote down vote up
@Test
public void testDoubleExtendedPushLiteralVariables() {
    final Object[] expectedResults = getTestObjects(255);
    final List<Object> literalsList = new ArrayList<>(Arrays.asList(new Object[]{68419598L}));
    literalsList.addAll(Arrays.asList(expectedResults));
    final AbstractSqueakObject rcvr = image.specialObjectsArray;
    for (int i = 0; i < expectedResults.length; i++) {
        final CompiledMethodObject method = makeMethod(literalsList.toArray(), 132, 128, i, 124);
        final VirtualFrame frame = createTestFrame(method);
        try {
            final Object result = createContext(method, rcvr).execute(frame);
            assertSame(BooleanObject.FALSE, result);
        } catch (NonLocalReturn | NonVirtualReturn | ProcessSwitch e) {
            fail("broken test");
        }
    }
}
 
Example #12
Source File: BranchCoverage.java    From nodeprof.js with Apache License 2.0 6 votes vote down vote up
@Override
public void initCallbacks() {
    this.onCallback(ProfiledTagEnum.CF_BRANCH, new AnalysisFactory<BaseEventHandlerNode>() {
        @Override
        public BaseEventHandlerNode create(EventContext context) {
            return new ConditionalEventHandler(context) {

                @Child ReportEntryNode trueCounter = ReportEntryNodeGen.create(trueDB, new SimpleCounterReport.SimleReportFactory());
                @Child ReportEntryNode falseCounter = ReportEntryNodeGen.create(falseDB, new SimpleCounterReport.SimleReportFactory());

                @Override
                public void executePost(VirtualFrame frame, Object result, Object[] inputs) {
                    if (JSRuntime.toBoolean(result)) {
                        addDebugEvent("BC", getSourceIID(), ProfiledTagEnum.CF_BRANCH, true);
                        ((SimpleCounterReport) (trueCounter.execute(getSourceIID()))).incre();
                    } else {
                        addDebugEvent("BC", getSourceIID(), ProfiledTagEnum.CF_BRANCH, false);
                        ((SimpleCounterReport) (falseCounter.execute(getSourceIID()))).incre();
                    }
                }
            };
        }
    });
}
 
Example #13
Source File: DispatchEagerlyFromStackNode.java    From trufflesqueak with MIT License 5 votes vote down vote up
@Specialization(guards = {"cachedMethod.hasPrimitive()", "method == cachedMethod", "primitiveNode != null"}, //
                limit = "INLINE_CACHE_SIZE", assumptions = {"cachedMethod.getCallTargetStable()"}, rewriteOn = PrimitiveFailed.class)
protected final Object doPrimitiveEagerly(final VirtualFrame frame, @SuppressWarnings("unused") final CompiledMethodObject method,
                @SuppressWarnings("unused") @Cached("method") final CompiledMethodObject cachedMethod,
                @Cached("forIndex(cachedMethod, true, cachedMethod.primitiveIndex())") final AbstractPrimitiveNode primitiveNode,
                @Cached("getStackPointerSlot(frame)") final FrameSlot stackPointerSlot,
                @Cached("getStackPointer(frame, stackPointerSlot)") final int stackPointer,
                @Cached final PrimitiveFailedCounter failureCounter) {
    /**
     * Pretend that values are popped off the stack. Primitive nodes will read them using
     * ArgumentOnStackNodes.
     */
    FrameAccess.setStackPointer(frame, stackPointerSlot, stackPointer - 1 - argumentCount);
    try {
        return primitiveNode.executePrimitive(frame);
    } catch (final PrimitiveFailed pf) {
        CompilerDirectives.transferToInterpreterAndInvalidate();
        // Restore stackPointer.
        FrameAccess.setStackPointer(frame, stackPointerSlot, stackPointer);
        if (failureCounter.shouldNoLongerSendEagerly()) {
            throw pf; // Rewrite specialization.
        } else {
            // Slow path send to fallback code.
            final Object[] receiverAndArguments = FrameStackPopNNode.create(1 + argumentCount).execute(frame);
            return IndirectCallNode.getUncached().call(method.getCallTarget(),
                            FrameAccess.newWith(cachedMethod, FrameAccess.getContextOrMarkerSlow(frame), null, receiverAndArguments));
        }
    }
}
 
Example #14
Source File: ControlPrimitives.java    From trufflesqueak with MIT License 5 votes vote down vote up
@Specialization(guards = "selector == cachedSelector", limit = "2")
protected final Object performContextCached(final VirtualFrame frame, @SuppressWarnings("unused") final Object receiver, final Object target,
                @SuppressWarnings("unused") final NativeObject selector, final ArrayObject arguments, final ClassObject superClass,
                @Cached("selector") final NativeObject cachedSelector,
                @Cached final LookupMethodNode lookupMethodNode,
                @Cached("create(cachedSelector, getBlockOrMethod(frame))") final DispatchSendNode dispatchNode) {
    if (inheritsFromNode.execute(target, superClass)) {
        final Object lookupResult = lookupMethodNode.executeLookup(superClass, cachedSelector);
        return dispatchNode.executeSend(frame, cachedSelector, lookupResult, superClass, getObjectArrayNode.execute(target, arguments));
    } else {
        CompilerDirectives.transferToInterpreter();
        throw PrimitiveFailed.BAD_RECEIVER;
    }
}
 
Example #15
Source File: ForObjectFactory.java    From nodeprof.js with Apache License 2.0 5 votes vote down vote up
@Override
public BaseEventHandlerNode create(EventContext context) {
    return new LoopEventHandler(context) {
        @Node.Child private InteropLibrary preDispatch = (pre == null) ? null : createDispatchNode();

        @Override
        public void executePre(VirtualFrame frame,
                        Object[] inputs) throws InteropException {
            if (pre != null && (isForIn() || isForOf())) {
                wrappedDispatchExecution(this, preDispatch, pre, getSourceIID(), isForIn());
            }
        }
    };
}
 
Example #16
Source File: ExecuteContextNode.java    From trufflesqueak with MIT License 5 votes vote down vote up
@Override
public Object executeResumeInMiddle(final VirtualFrame frame, final long initialPC) {
    try {
        return resumeBytecode(frame, initialPC);
    } catch (final NonLocalReturn nlr) {
        /** {@link getHandleNonLocalReturnNode()} acts as {@link BranchProfile} */
        return getHandleNonLocalReturnNode().executeHandle(frame, nlr);
    } finally {
        code.image.lastSeenContext = null; // Stop materialization here.
    }
}
 
Example #17
Source File: ControlPrimitives.java    From trufflesqueak with MIT License 5 votes vote down vote up
@SuppressWarnings("unused")
@Specialization(guards = {"selector == cachedSelector", "!isNotProvided(object1)", "!isNotProvided(object2)"}, limit = "CACHE_LIMIT")
protected static final Object perform2Cached(final VirtualFrame frame, final Object receiver, final NativeObject selector, final Object object1, final Object object2,
                final NotProvided object3, final NotProvided object4, final NotProvided object5,
                @Cached("selector") final NativeObject cachedSelector,
                @Cached final SqueakObjectClassNode lookupClassNode,
                @Cached final LookupMethodNode lookupMethodNode,
                @Cached("create(cachedSelector, getBlockOrMethod(frame))") final DispatchSendNode dispatchNode) {
    return dispatchCached(frame, cachedSelector, new Object[]{receiver, object1, object2}, lookupClassNode, lookupMethodNode, dispatchNode);
}
 
Example #18
Source File: ControlPrimitives.java    From trufflesqueak with MIT License 5 votes vote down vote up
@Specialization(replaces = "performCached")
protected final Object perform(final VirtualFrame frame, final Object receiver, final NativeObject selector, final ArrayObject arguments,
                @Cached final SqueakObjectClassNode lookupClassNode,
                @Cached final LookupMethodNode lookupMethodNode,
                @Cached final DispatchSendSelectorNode dispatchNode) {
    final ClassObject rcvrClass = lookupClassNode.executeLookup(receiver);
    final Object lookupResult = lookupMethodNode.executeLookup(rcvrClass, selector);
    return dispatchNode.executeSend(frame, selector, lookupResult, rcvrClass, getObjectArrayNode.execute(receiver, arguments));
}
 
Example #19
Source File: InvokeNode.java    From mumbler with GNU General Public License v3.0 5 votes vote down vote up
@Override
@ExplodeLoop
public Object execute(VirtualFrame virtualFrame) {
    MumblerFunction function = this.evaluateFunction(virtualFrame);
    CompilerAsserts.compilationConstant(this.argumentNodes.length);
    CompilerAsserts.compilationConstant(this.isTail());

    Object[] argumentValues = new Object[this.argumentNodes.length + 1];
    argumentValues[0] = function.getLexicalScope();
    for (int i=0; i<this.argumentNodes.length; i++) {
        argumentValues[i+1] = this.argumentNodes[i].execute(virtualFrame);
    }

    return call(virtualFrame, function.callTarget, argumentValues);
}
 
Example #20
Source File: LambdaNode.java    From mumbler with GNU General Public License v3.0 5 votes vote down vote up
@Specialization
public Object getMumblerFunction(VirtualFrame virtualFrame) {
    MumblerFunction function = this.getFunction();
    if (!isScopeSet()) {
        CompilerDirectives.transferToInterpreterAndInvalidate();
        function.setLexicalScope(virtualFrame.materialize());
        this.scopeSet = true;
    }
    return function;
}
 
Example #21
Source File: ArgumentNodes.java    From trufflesqueak with MIT License 5 votes vote down vote up
@Override
public Object execute(final VirtualFrame frame) {
    if (readNode == null) {
        CompilerDirectives.transferToInterpreterAndInvalidate();
        final CompiledCodeObject blockOrMethod = FrameAccess.getBlockOrMethod(frame);
        final int stackPointer = FrameAccess.getStackPointer(frame, blockOrMethod);
        readNode = insert(FrameSlotReadNode.create(blockOrMethod.getStackSlot(stackPointer + argumentIndex)));
    }
    return readNode.executeRead(frame);
}
 
Example #22
Source File: ControlPrimitives.java    From trufflesqueak with MIT License 5 votes vote down vote up
@Specialization(guards = {"!ownerIsNil(mutex)", "!activeProcessMutexOwner(mutex, getActiveProcessNode)"}, limit = "1")
protected final Object doEnter(final VirtualFrame frame, final PointersObject mutex, @SuppressWarnings("unused") final NotProvided notProvided,
                @Shared("linkProcessToListNode") @Cached final LinkProcessToListNode linkProcessToListNode,
                @Shared("wakeHighestPriorityNode") @Cached final WakeHighestPriorityNode wakeHighestPriorityNode,
                @Shared("getActiveProcessNode") @Cached final GetActiveProcessNode getActiveProcessNode) {
    linkProcessToListNode.executeLink(getActiveProcessNode.execute(), mutex);
    try {
        wakeHighestPriorityNode.executeWake(frame);
    } catch (final ProcessSwitch ps) {
        /* Leave `false` as result on stack. */
        getFrameStackPushNode().execute(frame, BooleanObject.FALSE);
        throw ps;
    }
    return BooleanObject.FALSE;
}
 
Example #23
Source File: MultiEventHandler.java    From nodeprof.js with Apache License 2.0 5 votes vote down vote up
@Override
@ExplodeLoop
public void executeExceptionalCtrlFlow(VirtualFrame frame, Throwable exception, Object[] inputs) throws Exception {
    for (BaseEventHandlerNode handler : handlers) {
        handler.executeExceptionalCtrlFlow(frame, exception, inputs);
    }
}
 
Example #24
Source File: DefineNode.java    From mumbler with GNU General Public License v3.0 5 votes vote down vote up
@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 #25
Source File: TypedArray.java    From nodeprof.js with Apache License 2.0 5 votes vote down vote up
private AnalysisFactory<BaseEventHandlerNode> getInvokeOrNewFactory(boolean isInvoke) {
    ProfiledTagEnum tag = isInvoke ? ProfiledTagEnum.INVOKE : ProfiledTagEnum.NEW;
    return new AnalysisFactory<BaseEventHandlerNode>() {
        @Override
        public BaseEventHandlerNode create(
                        EventContext context) {
            return new FunctionCallEventHandler(context, tag) {
                @Child ReportEntryNode getReportNode = ReportEntryNodeGen.create(db, new TypedArrayFactory());

                @Child IsArrayFunctionNode arrayFunc = IsArrayFunctionNodeGen.create();

                @Override
                public void executePost(VirtualFrame frame,
                                Object result, Object[] inputs) {
                    Object funcObj = getFunction(inputs);
                    if (funcObj instanceof DynamicObject) {
                        Object constructor = GlobalObjectCache.getInstance().getArrayConstructor((DynamicObject) funcObj);
                        if (funcObj == constructor) {
                            trackAllocation(result, getSourceIID());
                            addDebugEvent("TA_ARRAY_ALLOC", getSourceIID(), tag);
                            getReportNode.execute(this.getSourceIID());
                        }
                    }
                }
            };
        }
    };
}
 
Example #26
Source File: BlockClosurePrimitives.java    From trufflesqueak with MIT License 5 votes vote down vote up
@Specialization(guards = {"closure.getNumArgs() == 4"}, replaces = "doValue4Direct")
protected static final Object doValue4Indirect(final VirtualFrame frame, final BlockClosureObject closure, final Object arg1, final Object arg2, final Object arg3, final Object arg4,
                @SuppressWarnings("unused") final NotProvided arg5,
                @Cached final GetContextOrMarkerNode getContextOrMarkerNode,
                @Cached final IndirectCallNode indirectCallNode) {
    final Object[] frameArguments = FrameAccess.newClosureArgumentsTemplate(closure, getContextOrMarkerNode.execute(frame), 4);
    frameArguments[FrameAccess.getArgumentStartIndex()] = arg1;
    frameArguments[FrameAccess.getArgumentStartIndex() + 1] = arg2;
    frameArguments[FrameAccess.getArgumentStartIndex() + 2] = arg3;
    frameArguments[FrameAccess.getArgumentStartIndex() + 3] = arg4;
    return indirectCallNode.call(closure.getCompiledBlock().getCallTarget(), frameArguments);
}
 
Example #27
Source File: ControlPrimitives.java    From trufflesqueak with MIT License 5 votes vote down vote up
@Specialization(replaces = "performCached")
protected final Object perform(final VirtualFrame frame, final Object receiver, final NativeObject selector, final ArrayObject arguments, final ClassObject superClass,
                @SuppressWarnings("unused") final NotProvided np,
                @Cached final LookupMethodNode lookupMethodNode,
                @Cached final DispatchSendSelectorNode dispatchNode) {
    if (inheritsFromNode.execute(receiver, superClass)) {
        final Object lookupResult = lookupMethodNode.executeLookup(superClass, selector);
        return dispatchNode.executeSend(frame, selector, lookupResult, superClass, getObjectArrayNode.execute(receiver, arguments));
    } else {
        CompilerDirectives.transferToInterpreter();
        throw PrimitiveFailed.BAD_RECEIVER;
    }
}
 
Example #28
Source File: MultiEventHandler.java    From nodeprof.js with Apache License 2.0 5 votes vote down vote up
@Override
@ExplodeLoop
public void executePost(VirtualFrame frame, Object result, Object[] inputs) throws Exception {
    for (BaseEventHandlerNode handler : handlers) {
        handler.executePost(frame, result, inputs);
        noChildHandlerUpdate = noChildHandlerUpdate && (handler.wantsToUpdateHandler() == handler);
    }
}
 
Example #29
Source File: DispatchSendFromStackNode.java    From trufflesqueak with MIT License 5 votes vote down vote up
@Specialization(guards = {"lookupResult == null"})
protected static final Object doDoesNotUnderstand(final VirtualFrame frame, final NativeObject selector, @SuppressWarnings("unused") final Object lookupResult, final Object receiver,
                final ClassObject rcvrClass,
                @Shared("writeNode") @Cached final AbstractPointersObjectWriteNode writeNode,
                @Cached final LookupMethodNode lookupNode,
                @Cached("create(argumentCount)") final FrameStackPopNNode popArguments,
                @Cached final FrameStackPopNode popReceiver,
                @Cached("create()") final DispatchEagerlyNode dispatchNode,
                @CachedContext(SqueakLanguage.class) final SqueakImageContext image) {
    final CompiledMethodObject doesNotUnderstandMethod = (CompiledMethodObject) lookupNode.executeLookup(rcvrClass, image.doesNotUnderstand);
    final PointersObject message = image.newMessage(writeNode, selector, rcvrClass, popArguments.execute(frame));
    final Object poppedReceiver = popReceiver.execute(frame);
    assert receiver == poppedReceiver;
    return dispatchNode.executeDispatch(frame, doesNotUnderstandMethod, new Object[]{receiver, message});
}
 
Example #30
Source File: ControlPrimitives.java    From trufflesqueak with MIT License 5 votes vote down vote up
@SuppressWarnings("unused")
@Specialization(guards = {"!isNotProvided(object1)", "!isNotProvided(object2)", "!isNotProvided(object3)"}, replaces = "perform3Cached")
protected static final Object perform3(final VirtualFrame frame, final Object receiver, final NativeObject selector, final Object object1, final Object object2,
                final Object object3, final NotProvided object4, final NotProvided object5,
                @Cached final SqueakObjectClassNode lookupClassNode,
                @Cached final LookupMethodNode lookupMethodNode,
                @Cached final DispatchSendSelectorNode dispatchNode) {
    return dispatchUncached(frame, selector, new Object[]{receiver, object1, object2, object3}, lookupClassNode, lookupMethodNode, dispatchNode);
}