private TruffleOptInstrumentNode(AbstractInstrumentNode nextNode) { super(nextNode); this.isCompiled = CompilerDirectives.inCompiledCode(); }
public void enter(Node node, VirtualFrame vFrame) { if (this.isCompiled != CompilerDirectives.inCompiledCode()) { this.isCompiled = CompilerDirectives.inCompiledCode(); TruffleOptInstrument.this.toolOptListener.notifyIsCompiled(this.isCompiled); } if (nextInstrumentNode != null) { nextInstrumentNode.enter(node, vFrame); } }
@Override protected void onEnter(VirtualFrame frame) { if (CompilerDirectives.inCompiledCode() && ignoreInlinedRoots && isAttachedToRootTag && !CompilerDirectives.inCompilationRoot()) { return; } doOnEnter(); }
@Override public boolean inject(boolean condition) { if (CompilerDirectives.inCompiledCode()) { return CompilerDirectives.injectBranchProbability(calculateProbability(trueCount, falseCount), condition); } else { return condition; } }
@Override public boolean inject(boolean condition) { if (CompilerDirectives.inCompiledCode()) { return CompilerDirectives.injectBranchProbability(calculateProbability(trueCount, falseCount), condition); } else { return condition; } }
Object injectReturnValueProfile(Object result) { Class<?> klass = profiledReturnType; if (klass != null && CompilerDirectives.inCompiledCode() && profiledReturnTypeAssumption.isValid()) { return OptimizedCallTarget.unsafeCast(result, klass, true, true, true); } return result; }
/** * Returns the size of an array which is needed for storing all the frame slots. (The number may * be bigger than the number of slots, if some slots are removed.) * * @return the size of the frame * @since 0.8 or earlier */ public int getSize() { if (CompilerDirectives.inCompiledCode()) { if (!this.version.isValid()) { CompilerDirectives.transferToInterpreterAndInvalidate(); } } return this.size; }
PolyglotEngine get() { // can be used on the fast path PolyglotEngine store; if (constantStoreAssumption.isValid()) { // we can skip the constantEntered check in compiled code, because we are assume we are // always entered in such cases. store = (CompilerDirectives.inCompiledCode() || constantEntered > 0) ? constantStore.get() : null; } else if (dynamicStoreAssumption.isValid()) { // multiple context single thread store = dynamicStore; } else { // multiple context multiple threads store = getThreadLocalStore(threadStore); } return store; }
public final Object callDirect(Object... args) { getCompilationProfile().profileDirectCall(args); try { Object result = doInvoke(args); if (CompilerDirectives.inCompiledCode()) { result = compilationProfile.injectReturnValueProfile(result); } return result; } catch (Throwable t) { throw rethrow(compilationProfile.profileExceptionType(t)); } }
protected final Object callRoot(Object[] originalArguments) { if (GraalCompilerDirectives.inFirstTier()) { getCompilationProfile().firstTierCall(this); } Object[] args = originalArguments; OptimizedCompilationProfile profile = this.compilationProfile; if (CompilerDirectives.inCompiledCode() && profile != null) { args = profile.injectArgumentProfile(originalArguments); } Object result = callProxy(createFrame(getRootNode().getFrameDescriptor(), args)); if (profile != null) { profile.profileReturnValue(result); } return result; }
@Override protected void onReturnValue(VirtualFrame frame, Object result) { if (ignoreInlinedRoots) { if (CompilerDirectives.inCompiledCode()) { if (isAttachedToRootTag && !CompilerDirectives.inCompilationRoot()) { return; } } else { // This is needed to control for the case that an invalidation happened in an // inlined root. // Than there should be no stack pop until we exit the original compilation // root. // Not needed if stack overflowed final ThreadLocalStack stack = getStack(); if (!stack.hasStackOverflowed() && stack.top().getInstrumentedNode() != interpretedLocation.getInstrumentedNode()) { return; } } } if (seenOtherThreads) { popSlow(compiledLocation); } else if (cachedThread == Thread.currentThread()) { cachedStack.pop(compiledLocation); } else { CompilerDirectives.transferToInterpreterAndInvalidate(); seenOtherThreads = true; popSlow(compiledLocation); } }