/** @since 0.17 or earlier */ @Override public final boolean isLeaf() { Assumption assumption = leafAssumption; return assumption == null || assumption.isValid(); }
void notifyEngineDisposed() { if (singleContext.isValid()) { // do not invalidate assumptions if engine is disposed anyway cachedSingleContext = UNSET_CONTEXT; } } }
private synchronized Object getImplSlowPath() { if (!singleThread.isValid()) { return getTL(); } return null; }
OutputStreamList getOutList() { if (outListUnchanged.isValid()) { return outList; } else { CompilerDirectives.transferToInterpreterAndInvalidate(); return outList; } }
OutputStreamList getOutList() { if (outListUnchanged.isValid()) { return outList; } else { CompilerDirectives.transferToInterpreterAndInvalidate(); return outList; } }
public boolean isSet() { if (singleThread.isValid()) { boolean set = firstContext != null; return Thread.currentThread() == firstThread && set; } else { return getTL() != null; } }
/** @since 0.17 or earlier */ @Override public final boolean isValid() { return getValidAssumption().isValid(); }
private boolean assertGet(Object cachedSingle) { // avoid race between current context and single context assertion PolyglotContextImpl context = PolyglotContextImpl.requireContext(); if (!singleContext.isValid()) { return true; } Object verifyContext = lookupLanguageContext(context); if (cachedSingle != verifyContext) { throw new AssertionError(String.format("Expected %s but got %s.", cachedSingle, verifyContext)); } return true; }
public boolean isSet() { if (singleThread.isValid()) { boolean set = firstContext != null; return (TruffleOptions.AOT ? currentThread() : Thread.currentThread()) == firstThread && set; } else { return getTL() != null; } }
void profileIndirectCall() { Assumption argumentTypesAssumption = profiledArgumentTypesAssumption; if (argumentTypesAssumption != null && argumentTypesAssumption.isValid()) { // Argument profiling is not possible for targets of indirect calls. CompilerDirectives.transferToInterpreter(); argumentTypesAssumption.invalidate(); profiledArgumentTypes = null; } }
boolean needsEnter() { if (SINGLE_CONTEXT_STATE.singleContextAssumption.isValid()) { // if its a single context we know which one to enter return !SINGLE_CONTEXT_STATE.contextThreadLocal.isSet(); } else { return current() != this; } }
EventChainNode lazyUpdate(VirtualFrame frame) { Assumption localVersion = this.version; if (localVersion == null || !localVersion.isValid()) { CompilerDirectives.transferToInterpreterAndInvalidate(); // Ok to pass in the virtual frame as its instances are always materialized return lazyUpdatedImpl(frame); } return this.chain; }
private boolean assertGet(Object cachedSingle) { // avoid race between current context and single context assertion PolyglotContextImpl context = PolyglotContextImpl.requireContext(); if (!singleContext.isValid()) { return true; } return cachedSingle == lookupLanguageContext(context); }
EventChainNode lazyUpdate(VirtualFrame frame) { Assumption localVersion = this.version; if (localVersion == null || !localVersion.isValid()) { CompilerDirectives.transferToInterpreterAndInvalidate(); // Ok to pass in the virtual frame as its instances are always materialized return lazyUpdatedImpl(frame); } return this.chain; }
void initializeMultiContext() { assert !language.engine.singleContext.isValid(); if (language.cache.getPolicy() != ContextPolicy.EXCLUSIVE) { LANGUAGE.initializeMultiContext(spi); } }
private void transitionToMultiThreaded() { assert singleThreaded.isValid(); assert Thread.holdsLock(this); for (PolyglotLanguageContext context : contexts) { if (!context.isInitialized()) { continue; } LANGUAGE.initializeMultiThreading(context.env); } singleThreaded.invalidate(); singleThreadedConstant.invalidate(); }
Object[] injectArgumentProfile(Object[] originalArguments) { Assumption argumentTypesAssumption = profiledArgumentTypesAssumption; Object[] args = originalArguments; if (argumentTypesAssumption != null && argumentTypesAssumption.isValid()) { args = OptimizedCallTarget.unsafeCast(OptimizedCallTarget.castArrayFixedLength(args, profiledArgumentTypes.length), Object[].class, true, true, true); args = castArgumentsImpl(args); } return args; }
static PolyglotContextImpl current() { if (SINGLE_CONTEXT_STATE.singleContextAssumption.isValid()) { if (SINGLE_CONTEXT_STATE.contextThreadLocal.isSet()) { return SINGLE_CONTEXT_STATE.singleContext; } else { CompilerDirectives.transferToInterpreter(); return null; } } else { return (PolyglotContextImpl) SINGLE_CONTEXT_STATE.contextThreadLocal.get(); } }