本文整理汇总了Java中com.oracle.truffle.api.Truffle.getRuntime方法的典型用法代码示例。如果您正苦于以下问题:Java Truffle.getRuntime方法的具体用法?Java Truffle.getRuntime怎么用?Java Truffle.getRuntime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.oracle.truffle.api.Truffle
的用法示例。
在下文中一共展示了Truffle.getRuntime方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TruffleCompiler
import com.oracle.truffle.api.Truffle; //导入方法依赖的package包/类
public TruffleCompiler(Plugins plugins, Suites suites, LIRSuites lirSuites, Backend backend, SnippetReflectionProvider snippetReflection) {
GraalTruffleRuntime graalTruffleRuntime = ((GraalTruffleRuntime) Truffle.getRuntime());
this.compilationNotify = graalTruffleRuntime.getCompilationNotify();
this.backend = backend;
this.snippetReflection = snippetReflection;
this.providers = backend.getProviders();
this.suites = suites;
this.lirSuites = lirSuites;
ResolvedJavaType[] skippedExceptionTypes = getSkippedExceptionTypes(providers.getMetaAccess());
boolean needSourcePositions = graalTruffleRuntime.enableInfopoints() || TruffleCompilerOptions.getValue(TruffleEnableInfopoints) ||
TruffleCompilerOptions.getValue(TruffleInstrumentBranches) || TruffleCompilerOptions.getValue(TruffleInstrumentBoundaries);
GraphBuilderConfiguration baseConfig = GraphBuilderConfiguration.getDefault(new Plugins(plugins)).withNodeSourcePosition(needSourcePositions);
this.config = baseConfig.withSkippedExceptionTypes(skippedExceptionTypes).withOmitAssertions(TruffleCompilerOptions.getValue(TruffleExcludeAssertions)).withBytecodeExceptionMode(
BytecodeExceptionMode.ExplicitOnly);
this.partialEvaluator = createPartialEvaluator();
if (Debug.isEnabled()) {
DebugEnvironment.ensureInitialized(TruffleCompilerOptions.getOptions(), graalTruffleRuntime.getRequiredGraalCapability(SnippetReflectionProvider.class));
}
graalTruffleRuntime.reinstallStubs();
}
示例2: main
import com.oracle.truffle.api.Truffle; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
CharStream in = new ANTLRInputStream(new FileInputStream(args[0]));
TuberBasicLexer lexer = new TuberBasicLexer(in);
TokenStream tokens = new CommonTokenStream(lexer);
TuberBasicParser parser = new TuberBasicParser(tokens);
ParserRuleContext tree = parser.statements();
Visitor visitor = new Visitor();
TuberNode ast = visitor.visit(tree);
TruffleRuntime runtime = Truffle.getRuntime();
TuberRootNode rootNode = new TuberRootNode(ast);
CallTarget target = runtime.createCallTarget(rootNode);
Object result = target.call();
System.out.println(result);
}
示例3: interpret
import com.oracle.truffle.api.Truffle; //导入方法依赖的package包/类
public void interpret(Path path) throws IOException {
byte[] data = Files.readAllBytes(path);
TruffleRuntime runtime = Truffle.getRuntime();
System.out.println("using " + runtime.getName());
Parser parser = new Parser(data);
while(!parser.end()) {
List list = parser.parseList();
FrameDescriptor frameDescriptor = new FrameDescriptor();
Node node = createAST(list, frameDescriptor);
EvalNode evalNode = new EvalNode(node);
CallTarget callTarget = runtime.createCallTarget(evalNode, frameDescriptor);
callTarget.call();
}
}
示例4: testGetTVMCI
import com.oracle.truffle.api.Truffle; //导入方法依赖的package包/类
@Test
public void testGetTVMCI() {
TruffleRuntime runtime = Truffle.getRuntime();
TVMCI tvmci = runtime.getCapability(TVMCI.class);
assertNotNull("Truffle Virtual Machine Compiler Interface not found", tvmci);
assertEquals("GraalTVMCI", tvmci.getClass().getSimpleName());
abstract class TVMCISubclass extends TVMCI {
}
TVMCISubclass subclass = runtime.getCapability(TVMCISubclass.class);
assertNull("Expected null return value for TVMCI subclass", subclass);
}
示例5: testGetLayoutFactory
import com.oracle.truffle.api.Truffle; //导入方法依赖的package包/类
@Test
public void testGetLayoutFactory() {
TruffleRuntime runtime = Truffle.getRuntime();
LayoutFactory layoutFactory = runtime.getCapability(LayoutFactory.class);
assertNotNull("LayoutFactory not found", layoutFactory);
boolean java8OrEarlier = System.getProperty("java.specification.version").compareTo("1.9") < 0;
ClassLoader layoutFactoryCL = layoutFactory.getClass().getClassLoader();
if (java8OrEarlier) {
// Bootstrap class loader or JVMCI class loader
assertTrue(layoutFactoryCL == null || layoutFactoryCL == runtime.getClass().getClassLoader());
} else {
// Rely on modules to only load trusted service providers
}
}
示例6: waitForOptimization
import com.oracle.truffle.api.Truffle; //导入方法依赖的package包/类
@Specialization
public SLFunction waitForOptimization(SLFunction function, long timeout) {
OptimizedCallTarget target = (OptimizedCallTarget) function.getCallTarget();
GraalTruffleRuntime runtime = ((GraalTruffleRuntime) Truffle.getRuntime());
for (OptimizedCallTarget effectiveCallTarget : findDuplicateCallTargets(target)) {
try {
runtime.waitForCompilation(effectiveCallTarget, timeout);
} catch (ExecutionException | TimeoutException e) {
throw new RuntimeException(e);
}
}
return function;
}
示例7: PartialEvaluationTest
import com.oracle.truffle.api.Truffle; //导入方法依赖的package包/类
public PartialEvaluationTest() {
beforeInitialization();
GraalTruffleRuntime runtime = (GraalTruffleRuntime) Truffle.getRuntime();
this.truffleCompiler = DefaultTruffleCompiler.create(runtime);
DebugEnvironment.ensureInitialized(getInitialOptions(), runtime.getRequiredGraalCapability(SnippetReflectionProvider.class));
}
示例8: createNativeFunctionInterface
import com.oracle.truffle.api.Truffle; //导入方法依赖的package包/类
private static NativeFunctionInterface createNativeFunctionInterface() {
HotSpotTruffleRuntime runtime = (HotSpotTruffleRuntime) Truffle.getRuntime();
return runtime.createNativeFunctionInterface();
}
示例9: testRuntimeIsGraalRuntime
import com.oracle.truffle.api.Truffle; //导入方法依赖的package包/类
@Test
public void testRuntimeIsGraalRuntime() {
TruffleRuntime runtime = Truffle.getRuntime();
assertTrue(runtime.getClass() != DefaultTruffleRuntime.class);
}
示例10: SLGraalRuntimeBuiltin
import com.oracle.truffle.api.Truffle; //导入方法依赖的package包/类
protected SLGraalRuntimeBuiltin() {
if (!(Truffle.getRuntime() instanceof GraalTruffleRuntime)) {
throw new AssertionError("Graal runtime builtins can only be used inside of a Graal runtime.");
}
}
示例11: runtime
import com.oracle.truffle.api.Truffle; //导入方法依赖的package包/类
private static GraalTruffleRuntime runtime() {
return (GraalTruffleRuntime) Truffle.getRuntime();
}
示例12: getRuntime
import com.oracle.truffle.api.Truffle; //导入方法依赖的package包/类
/**
* Utility method that casts the singleton {@link TruffleRuntime}.
*/
public static GraalTruffleRuntime getRuntime() {
return (GraalTruffleRuntime) Truffle.getRuntime();
}