Java Code Examples for com.oracle.truffle.api.instrumentation.TruffleInstrument#Env

The following examples show how to use com.oracle.truffle.api.instrumentation.TruffleInstrument#Env . 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: FunctionRootEventHandler.java    From nodeprof.js with Apache License 2.0 6 votes vote down vote up
public Object getReceiver(VirtualFrame frame, TruffleInstrument.Env env) {
    // cache the frame slot for `this`
    if (!thisSlotInitialized) {
        CompilerDirectives.transferToInterpreterAndInvalidate();
        thisSlot = JSFrameUtil.getThisSlot(frame.getFrameDescriptor());
        thisSlotInitialized = true;
    }
    // if function has a <this> slot and its value is not undefined, we have a shortcut to
    // `this`
    if (thisSlot != null) {
        Object maybeThis = frame.getValue(thisSlot);
        if (maybeThis != null && maybeThis != Undefined.instance) {
            return maybeThis;
        }
    }

    // otherwise, retrieve the current scope to look up this
    return getReceiverFromScope(frame.materialize(), env);
}
 
Example 2
Source File: FunctionRootEventHandler.java    From nodeprof.js with Apache License 2.0 5 votes vote down vote up
@TruffleBoundary
private Object getReceiverFromScope(MaterializedFrame frame, TruffleInstrument.Env env) {
    Iterable<Scope> scopes = env.findLocalScopes(context.getInstrumentedNode(), frame);
    assert scopes.iterator().hasNext();
    Object receiver = scopes.iterator().next().getReceiver();
    assert receiver != null;
    return receiver;
}
 
Example 3
Source File: HashemInstrumentTest.java    From mr-hashemi with Universal Permissive License v1.0 4 votes vote down vote up
@Override
protected void onCreate(final TruffleInstrument.Env env) {
    env.registerService(new Environment(env));
}
 
Example 4
Source File: HashemInstrumentTest.java    From mr-hashemi with Universal Permissive License v1.0 4 votes vote down vote up
Environment(TruffleInstrument.Env env) {
    this.env = env;
}
 
Example 5
Source File: EventLoggerTest.java    From nodeprof.js with Apache License 2.0 4 votes vote down vote up
@Override
public TestableNodeProfAnalysis getAnalysis(Instrumenter instrumenter, TruffleInstrument.Env env) {
    this.analysis = new EventLogger(instrumenter, env);
    return this.analysis;
}
 
Example 6
Source File: NonContiguousArrayTest.java    From nodeprof.js with Apache License 2.0 4 votes vote down vote up
@Override
public TestableNodeProfAnalysis getAnalysis(Instrumenter instrumenter, TruffleInstrument.Env env) {
    return new NonContiguousArray(instrumenter, env);
}
 
Example 7
Source File: TypedArrayTest.java    From nodeprof.js with Apache License 2.0 4 votes vote down vote up
@Override
public TestableNodeProfAnalysis getAnalysis(Instrumenter instrumenter, TruffleInstrument.Env env) {
    return new TypedArray(instrumenter, env);
}
 
Example 8
Source File: BCTest.java    From nodeprof.js with Apache License 2.0 4 votes vote down vote up
@Override
public TestableNodeProfAnalysis getAnalysis(Instrumenter instrumenter, TruffleInstrument.Env env) {
    return new BranchCoverage(instrumenter, env);
}
 
Example 9
Source File: TrivialTest.java    From nodeprof.js with Apache License 2.0 4 votes vote down vote up
@Override
public TestableNodeProfAnalysis getAnalysis(Instrumenter instrumenter, TruffleInstrument.Env env) {
    return new TrivialAnalysis(instrumenter, env);
}
 
Example 10
Source File: RootFactory.java    From nodeprof.js with Apache License 2.0 4 votes vote down vote up
public RootFactory(Object jalangiAnalysis, DynamicObject pre, DynamicObject post, TruffleInstrument.Env env) {
    super("function", jalangiAnalysis, pre, post);
    this.env = env;
}
 
Example 11
Source File: BasicAnalysisTest.java    From nodeprof.js with Apache License 2.0 votes vote down vote up
public abstract TestableNodeProfAnalysis getAnalysis(Instrumenter instrumenter, TruffleInstrument.Env env);