use of com.oracle.truffle.api.TruffleLanguage.Env in project graal by oracle.
the class UnwindInstrumentationReturnSnippets method parseInContext.
/**
* Evaluates source of (potentially different) language using the current context. The names of
* arguments are parameters for the resulting {#link CallTarget} that allow the
* <code>source</code> to reference the actual parameters passed to
* {@link CallTarget#call(java.lang.Object...)}.
*
* @param source the source to evaluate
* @param argumentNames the names of {@link CallTarget#call(java.lang.Object...)} arguments that
* can be referenced from the source
* @return the call target representing the parsed result
* @throws IOException if the parsing or evaluation fails for some reason
* @since 0.12
* @deprecated Use
* {@link TruffleInstrument.Env#parseInline(com.oracle.truffle.api.source.Source, com.oracle.truffle.api.nodes.Node, com.oracle.truffle.api.frame.MaterializedFrame)}
* with {@link #getInstrumentedNode()} instead.
*/
@Deprecated
public CallTarget parseInContext(Source source, String... argumentNames) throws IOException {
Node instrumentedNode = getInstrumentedNode();
LanguageInfo languageInfo = instrumentedNode.getRootNode().getLanguageInfo();
if (languageInfo == null) {
throw new IllegalArgumentException("No language available for given node.");
}
Env env = AccessorInstrumentHandler.engineAccess().getEnvForInstrument(languageInfo);
return AccessorInstrumentHandler.langAccess().parse(env, source, instrumentedNode, argumentNames);
}
use of com.oracle.truffle.api.TruffleLanguage.Env in project graal by oracle.
the class UnwindInstrumentationReturnSnippets method isLanguageContextInitialized.
/**
* Test if language context of the source of the event is initialized.
*
* @since 0.26
*/
public boolean isLanguageContextInitialized() {
CompilerAsserts.neverPartOfCompilation();
Node node = getInstrumentedNode();
if (node == null) {
return true;
}
RootNode root = node.getRootNode();
if (root == null) {
return true;
}
LanguageInfo languageInfo = root.getLanguageInfo();
Env env = AccessorInstrumentHandler.engineAccess().getEnvForInstrument(languageInfo);
return AccessorInstrumentHandler.langAccess().isContextInitialized(env);
}
use of com.oracle.truffle.api.TruffleLanguage.Env in project graal by oracle.
the class PolyglotLanguageContext method dispose.
boolean dispose() {
assert Thread.holdsLock(context);
Env localEnv = this.env;
if (localEnv != null) {
if (!activePolyglotThreads.isEmpty()) {
throw new AssertionError("The language did not complete all polyglot threads but should have: " + activePolyglotThreads);
}
for (PolyglotThreadInfo threadInfo : context.getSeenThreads().values()) {
assert threadInfo.thread != null;
if (threadInfo.isPolyglotThread(context)) {
// polyglot threads need to be cleaned up by the language
continue;
}
LANGUAGE.disposeThread(localEnv, threadInfo.thread);
}
LANGUAGE.dispose(localEnv);
env = null;
return true;
}
return false;
}
use of com.oracle.truffle.api.TruffleLanguage.Env in project graal by oracle.
the class PolyglotLanguageContext method finalizeContext.
boolean finalizeContext() {
Env localEnv = this.env;
if (localEnv != null && !finalized) {
finalized = true;
LANGUAGE.finalizeContext(localEnv);
if (eventsEnabled) {
VMAccessor.INSTRUMENT.notifyLanguageContextFinalized(context.engine, context.truffleContext, language.info);
}
return true;
}
return false;
}
use of com.oracle.truffle.api.TruffleLanguage.Env in project graal by oracle.
the class Accessor method findLanguageByClass.
/*
* Do not remove: This is accessed reflectively in AccessorTest
*/
static <T extends TruffleLanguage<?>> T findLanguageByClass(Object vm, Class<T> languageClass) {
Env env = SPI.findEnv(vm, languageClass, true);
TruffleLanguage<?> language = NODES.getLanguageSpi(API.getLanguageInfo(env));
return languageClass.cast(language);
}
Aggregations