annotate graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java @ 21538:c1e2fdb5fea3

removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
author Doug Simon <doug.simon@oracle.com>
date Mon, 25 May 2015 17:20:39 +0200
parents 1da7aef31a08
children 5e868236654f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
15018
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14991
diff changeset
23 package com.oracle.graal.truffle.hotspot;
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
12529
23dc5dfdb9c7 Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 11934
diff changeset
25 import static com.oracle.graal.api.code.CodeUtil.*;
13239
Doug Simon <doug.simon@oracle.com>
parents: 13233
diff changeset
26 import static com.oracle.graal.compiler.GraalCompiler.*;
15551
33cedbce5b23 added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents: 15470
diff changeset
27 import static com.oracle.graal.graph.util.CollectionsAccess.*;
17153
646ddd52d79a only generate extra debug info if on HotSpot *and* compiling for HotSpot execution
Doug Simon <doug.simon@oracle.com>
parents: 17113
diff changeset
28 import static com.oracle.graal.hotspot.meta.HotSpotSuitesProvider.*;
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
29 import static com.oracle.graal.truffle.TruffleCompilerOptions.*;
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
30
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
31 import java.util.*;
15210
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
32 import java.util.concurrent.*;
16535
ada0a7729b6f Truffle: introduce debug option to print the stack trace when transferring to the interpreter
Andreas Woess <andreas.woess@jku.at>
parents: 16529
diff changeset
33 import java.util.stream.*;
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34
12529
23dc5dfdb9c7 Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 11934
diff changeset
35 import com.oracle.graal.api.code.*;
23dc5dfdb9c7 Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 11934
diff changeset
36 import com.oracle.graal.api.code.CallingConvention.Type;
23dc5dfdb9c7 Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 11934
diff changeset
37 import com.oracle.graal.api.meta.*;
23dc5dfdb9c7 Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 11934
diff changeset
38 import com.oracle.graal.api.runtime.*;
15210
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
39 import com.oracle.graal.compiler.*;
19893
4b6a65cb8ecd Truffle: repair TraceTruffleTransferToInterpreter option
Andreas Woess <andreas.woess@oracle.com>
parents: 19889
diff changeset
40 import com.oracle.graal.compiler.common.*;
12529
23dc5dfdb9c7 Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 11934
diff changeset
41 import com.oracle.graal.compiler.target.*;
13231
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents: 13229
diff changeset
42 import com.oracle.graal.debug.*;
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents: 13229
diff changeset
43 import com.oracle.graal.debug.Debug.Scope;
19822
b950967f74c7 replaced HashMap with a side-table (i.e., an array) for looking up InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 19819
diff changeset
44 import com.oracle.graal.graphbuilderconf.*;
b950967f74c7 replaced HashMap with a side-table (i.e., an array) for looking up InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 19819
diff changeset
45 import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins;
15211
59f71608aa9a Clean up of relationship between compilation policy and optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15210
diff changeset
46 import com.oracle.graal.hotspot.*;
21526
1da7aef31a08 created com.oracle.graal.hotspot.jvmci package and moved classes destined for future JVMCI module into it (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21394
diff changeset
47 import com.oracle.graal.hotspot.jvmci.*;
15212
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
48 import com.oracle.graal.hotspot.meta.*;
12529
23dc5dfdb9c7 Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 11934
diff changeset
49 import com.oracle.graal.java.*;
13229
325b4e4efb60 added CompilationResultBuilderFactory to support peep-hole instrumentation of methods as their code is emitted
Doug Simon <doug.simon@oracle.com>
parents: 13228
diff changeset
50 import com.oracle.graal.lir.asm.*;
19232
66c60942c06c GraalCompiler.emitLowLevel: use LowLevelSuites instead of LowLevelCompilerConfiguration.
Josef Eisl <josef.eisl@jku.at>
parents: 19116
diff changeset
51 import com.oracle.graal.lir.phases.*;
12529
23dc5dfdb9c7 Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 11934
diff changeset
52 import com.oracle.graal.nodes.*;
19306
a0a760b0fb5f pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19276
diff changeset
53 import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
12529
23dc5dfdb9c7 Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 11934
diff changeset
54 import com.oracle.graal.phases.*;
15470
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15222
diff changeset
55 import com.oracle.graal.phases.common.inlining.*;
12529
23dc5dfdb9c7 Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 11934
diff changeset
56 import com.oracle.graal.phases.tiers.*;
23dc5dfdb9c7 Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 11934
diff changeset
57 import com.oracle.graal.phases.util.*;
15210
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
58 import com.oracle.graal.printer.*;
12529
23dc5dfdb9c7 Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 11934
diff changeset
59 import com.oracle.graal.runtime.*;
15018
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14991
diff changeset
60 import com.oracle.graal.truffle.*;
20872
b1700db197c7 Move com.oracle.nfi implementation to graal.truffle.hotspot since it implements an interface that does not live in the graal class-loader
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20095
diff changeset
61 import com.oracle.graal.truffle.hotspot.nfi.*;
21538
c1e2fdb5fea3 removed more dependencies from JVMCI classes to non-JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21526
diff changeset
62 import com.oracle.jvmci.runtime.*;
20872
b1700db197c7 Move com.oracle.nfi implementation to graal.truffle.hotspot since it implements an interface that does not live in the graal class-loader
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20095
diff changeset
63 import com.oracle.nfi.api.*;
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
64 import com.oracle.truffle.api.*;
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
65 import com.oracle.truffle.api.nodes.*;
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
66
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
67 /**
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
68 * Implementation of the Truffle runtime when running on top of Graal.
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
69 */
17192
d0d76deeacb9 Make more Truffle code HotSpot independent, and allow more customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17161
diff changeset
70 public final class HotSpotTruffleRuntime extends GraalTruffleRuntime {
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
71
18961
afa70d3e8159 Allow users to provide their own TruffleRuntime implementation
Paul Woegerer <paul.woegerer@oracle.com>
parents: 18276
diff changeset
72 public static TruffleRuntime makeInstance() {
afa70d3e8159 Allow users to provide their own TruffleRuntime implementation
Paul Woegerer <paul.woegerer@oracle.com>
parents: 18276
diff changeset
73 if (GraalTruffleRuntime.alternateRuntime != null) {
afa70d3e8159 Allow users to provide their own TruffleRuntime implementation
Paul Woegerer <paul.woegerer@oracle.com>
parents: 18276
diff changeset
74 return GraalTruffleRuntime.alternateRuntime;
afa70d3e8159 Allow users to provide their own TruffleRuntime implementation
Paul Woegerer <paul.woegerer@oracle.com>
parents: 18276
diff changeset
75 }
15018
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14991
diff changeset
76 return new HotSpotTruffleRuntime();
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
77 }
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
78
15551
33cedbce5b23 added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents: 15470
diff changeset
79 private Map<OptimizedCallTarget, Future<?>> compilations = newIdentityMap();
15210
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
80 private final ThreadPoolExecutor compileQueue;
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
81
16992
5a1d764f6afc Truffle: added support for Runtime#getCallTargets()
Christian Humer <christian.humer@gmail.com>
parents: 16916
diff changeset
82 private final Map<RootCallTarget, Void> callTargets = Collections.synchronizedMap(new WeakHashMap<RootCallTarget, Void>());
19893
4b6a65cb8ecd Truffle: repair TraceTruffleTransferToInterpreter option
Andreas Woess <andreas.woess@oracle.com>
parents: 19889
diff changeset
83 private static final long THREAD_EETOP_OFFSET = eetopOffset();
15088
d3add9b82b71 change to StackIntrospection and Truffle getStackTrace implementation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15064
diff changeset
84
15018
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14991
diff changeset
85 private HotSpotTruffleRuntime() {
12529
23dc5dfdb9c7 Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 11934
diff changeset
86 installOptimizedCallTargetCallMethod();
17192
d0d76deeacb9 Make more Truffle code HotSpot independent, and allow more customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17161
diff changeset
87 lookupCallMethods(getGraalProviders().getMetaAccess());
15210
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
88
18200
62de94d5cf73 Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents: 18199
diff changeset
89 installDefaultListeners();
62de94d5cf73 Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents: 18199
diff changeset
90
15210
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
91 // Create compilation queue.
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
92 CompilerThreadFactory factory = new CompilerThreadFactory("TruffleCompilerThread", new CompilerThreadFactory.DebugConfigAccess() {
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
93 public GraalDebugConfig getDebugConfig() {
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
94 if (Debug.isEnabled()) {
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
95 GraalDebugConfig debugConfig = DebugEnvironment.initialize(TTY.out().out());
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
96 debugConfig.dumpHandlers().add(new TruffleTreeDumpHandler());
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
97 return debugConfig;
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
98 } else {
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
99 return null;
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
100 }
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
101 }
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
102 });
19447
ac5b08ea9a6a Make Truffle compilations multi-threaded on multi-core systems. Introduce TruffleCompilerThreads option for a manual override.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19360
diff changeset
103 int selectedProcessors = TruffleCompilerOptions.TruffleCompilerThreads.getValue();
ac5b08ea9a6a Make Truffle compilations multi-threaded on multi-core systems. Introduce TruffleCompilerThreads option for a manual override.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19360
diff changeset
104 if (selectedProcessors == 0) {
ac5b08ea9a6a Make Truffle compilations multi-threaded on multi-core systems. Introduce TruffleCompilerThreads option for a manual override.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19360
diff changeset
105 // No manual selection made, check how many processors are available.
ac5b08ea9a6a Make Truffle compilations multi-threaded on multi-core systems. Introduce TruffleCompilerThreads option for a manual override.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19360
diff changeset
106 int availableProcessors = Runtime.getRuntime().availableProcessors();
ac5b08ea9a6a Make Truffle compilations multi-threaded on multi-core systems. Introduce TruffleCompilerThreads option for a manual override.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19360
diff changeset
107 if (availableProcessors >= 4) {
ac5b08ea9a6a Make Truffle compilations multi-threaded on multi-core systems. Introduce TruffleCompilerThreads option for a manual override.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19360
diff changeset
108 selectedProcessors = 2;
ac5b08ea9a6a Make Truffle compilations multi-threaded on multi-core systems. Introduce TruffleCompilerThreads option for a manual override.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19360
diff changeset
109 } else if (availableProcessors >= 12) {
ac5b08ea9a6a Make Truffle compilations multi-threaded on multi-core systems. Introduce TruffleCompilerThreads option for a manual override.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19360
diff changeset
110 selectedProcessors = 4;
ac5b08ea9a6a Make Truffle compilations multi-threaded on multi-core systems. Introduce TruffleCompilerThreads option for a manual override.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19360
diff changeset
111 }
ac5b08ea9a6a Make Truffle compilations multi-threaded on multi-core systems. Introduce TruffleCompilerThreads option for a manual override.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19360
diff changeset
112 }
ac5b08ea9a6a Make Truffle compilations multi-threaded on multi-core systems. Introduce TruffleCompilerThreads option for a manual override.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19360
diff changeset
113 selectedProcessors = Math.max(1, selectedProcessors);
19473
b6d9486fcccb Truffle: minor fix for multi-threaded compilation
Andreas Woess <andreas.woess@oracle.com>
parents: 19447
diff changeset
114 compileQueue = new ThreadPoolExecutor(selectedProcessors, selectedProcessors, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(), factory);
18200
62de94d5cf73 Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents: 18199
diff changeset
115
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
116 }
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
117
17192
d0d76deeacb9 Make more Truffle code HotSpot independent, and allow more customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17161
diff changeset
118 @Override
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
119 public String getName() {
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
120 return "Graal Truffle Runtime";
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
121 }
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
122
17192
d0d76deeacb9 Make more Truffle code HotSpot independent, and allow more customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17161
diff changeset
123 @Override
13760
a12017c18d5d Truffle API cleanup: Reduce the visibility of classes and constructors that are not intended to be instantiated by guest language implementations; provide abstract class RootCallTarget as a CallTarget to a RootNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13705
diff changeset
124 public RootCallTarget createCallTarget(RootNode rootNode) {
18162
ab62800259ff Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 17596
diff changeset
125 return createCallTargetImpl(null, rootNode);
ab62800259ff Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 17596
diff changeset
126 }
ab62800259ff Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 17596
diff changeset
127
ab62800259ff Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 17596
diff changeset
128 private RootCallTarget createCallTargetImpl(OptimizedCallTarget source, RootNode rootNode) {
15211
59f71608aa9a Clean up of relationship between compilation policy and optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15210
diff changeset
129 CompilationPolicy compilationPolicy;
59f71608aa9a Clean up of relationship between compilation policy and optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15210
diff changeset
130 if (acceptForCompilation(rootNode)) {
18276
1f3ab088d958 Truffle: implemented defer compilation.
Christian Humer <christian.humer@gmail.com>
parents: 18212
diff changeset
131 compilationPolicy = new CounterAndTimeBasedCompilationPolicy();
15211
59f71608aa9a Clean up of relationship between compilation policy and optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15210
diff changeset
132 } else {
59f71608aa9a Clean up of relationship between compilation policy and optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15210
diff changeset
133 compilationPolicy = new InterpreterOnlyCompilationPolicy();
59f71608aa9a Clean up of relationship between compilation policy and optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15210
diff changeset
134 }
18162
ab62800259ff Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 17596
diff changeset
135 OptimizedCallTarget target = new OptimizedCallTarget(source, rootNode, this, compilationPolicy, new HotSpotSpeculationLog());
19710
48eeda5dfdbf Move linking of RootNode to CallTarget to ensure final semantics.
Benoit Daloze <benoit.daloze@jku.at>
parents: 19473
diff changeset
136 rootNode.setCallTarget(target);
16992
5a1d764f6afc Truffle: added support for Runtime#getCallTargets()
Christian Humer <christian.humer@gmail.com>
parents: 16916
diff changeset
137 callTargets.put(target, null);
18276
1f3ab088d958 Truffle: implemented defer compilation.
Christian Humer <christian.humer@gmail.com>
parents: 18212
diff changeset
138
16992
5a1d764f6afc Truffle: added support for Runtime#getCallTargets()
Christian Humer <christian.humer@gmail.com>
parents: 16916
diff changeset
139 return target;
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
140 }
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
141
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
142 @Override
18162
ab62800259ff Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 17596
diff changeset
143 public RootCallTarget createClonedCallTarget(OptimizedCallTarget source, RootNode root) {
ab62800259ff Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 17596
diff changeset
144 return createCallTargetImpl(source, root);
ab62800259ff Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 17596
diff changeset
145 }
ab62800259ff Truffle: renamed the splitting to callTargetCloning. Made RootNode cloning an implementation detail of the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 17596
diff changeset
146
15163
e5265dc8762f Truffle: Clean ups around optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
147 public static void installOptimizedCallTargetCallMethod() {
15165
cf49b4e72de5 Reused installed code object for optimized call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15163
diff changeset
148 Providers providers = getGraalProviders();
cf49b4e72de5 Reused installed code object for optimized call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15163
diff changeset
149 MetaAccessProvider metaAccess = providers.getMetaAccess();
15212
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
150 ResolvedJavaType type = metaAccess.lookupJavaType(OptimizedCallTarget.class);
15165
cf49b4e72de5 Reused installed code object for optimized call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15163
diff changeset
151 for (ResolvedJavaMethod method : type.getDeclaredMethods()) {
cf49b4e72de5 Reused installed code object for optimized call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15163
diff changeset
152 if (method.getAnnotation(TruffleCallBoundary.class) != null) {
cf49b4e72de5 Reused installed code object for optimized call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15163
diff changeset
153 CompilationResult compResult = compileMethod(method);
cf49b4e72de5 Reused installed code object for optimized call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15163
diff changeset
154 CodeCacheProvider codeCache = providers.getCodeCache();
cf49b4e72de5 Reused installed code object for optimized call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15163
diff changeset
155 try (Scope s = Debug.scope("CodeInstall", codeCache, method)) {
cf49b4e72de5 Reused installed code object for optimized call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15163
diff changeset
156 codeCache.setDefaultMethod(method, compResult);
17212
1ac6b4879443 Enforce catch-blocks for Debug.Scopes with context objects.
Josef Eisl <josef.eisl@jku.at>
parents: 17192
diff changeset
157 } catch (Throwable e) {
1ac6b4879443 Enforce catch-blocks for Debug.Scopes with context objects.
Josef Eisl <josef.eisl@jku.at>
parents: 17192
diff changeset
158 throw Debug.handle(e);
15165
cf49b4e72de5 Reused installed code object for optimized call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15163
diff changeset
159 }
15163
e5265dc8762f Truffle: Clean ups around optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
160 }
e5265dc8762f Truffle: Clean ups around optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
161 }
12529
23dc5dfdb9c7 Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 11934
diff changeset
162 }
23dc5dfdb9c7 Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 11934
diff changeset
163
13231
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents: 13229
diff changeset
164 private static CompilationResultBuilderFactory getOptimizedCallTargetInstrumentationFactory(String arch, ResolvedJavaMethod method) {
15966
27ff0792b048 made more services implement com.oracle.graal.api.runtime.Service for faster loading
Doug Simon <doug.simon@oracle.com>
parents: 15642
diff changeset
165 for (OptimizedCallTargetInstrumentationFactory factory : Services.load(OptimizedCallTargetInstrumentationFactory.class)) {
12557
86c74ef1b6f5 Make AMD64HotSpotTruffleBackend a decorator for the default backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 12531
diff changeset
166 if (factory.getArchitecture().equals(arch)) {
13231
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents: 13229
diff changeset
167 factory.setInstrumentedMethod(method);
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents: 13229
diff changeset
168 return factory;
12557
86c74ef1b6f5 Make AMD64HotSpotTruffleBackend a decorator for the default backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 12531
diff changeset
169 }
86c74ef1b6f5 Make AMD64HotSpotTruffleBackend a decorator for the default backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 12531
diff changeset
170 }
13231
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents: 13229
diff changeset
171 // No specialization of OptimizedCallTarget on this platform.
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents: 13229
diff changeset
172 return CompilationResultBuilderFactory.Default;
12557
86c74ef1b6f5 Make AMD64HotSpotTruffleBackend a decorator for the default backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 12531
diff changeset
173 }
86c74ef1b6f5 Make AMD64HotSpotTruffleBackend a decorator for the default backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 12531
diff changeset
174
12531
7d5c3ffbee64 Refactoring of the frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 12529
diff changeset
175 private static CompilationResult compileMethod(ResolvedJavaMethod javaMethod) {
19822
b950967f74c7 replaced HashMap with a side-table (i.e., an array) for looking up InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 19819
diff changeset
176 HotSpotProviders providers = getGraalProviders();
b950967f74c7 replaced HashMap with a side-table (i.e., an array) for looking up InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 19819
diff changeset
177 SuitesProvider suitesProvider = providers.getSuites();
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
178 Suites suites = suitesProvider.createSuites();
19270
292442bed972 Rename LowLevelSuites to LIRSuites.
Josef Eisl <josef.eisl@jku.at>
parents: 19232
diff changeset
179 LIRSuites lirSuites = suitesProvider.createLIRSuites();
16850
d6c002f4d2a9 Truffle: fix NPE with -G:-Inline
Andreas Woess <andreas.woess@jku.at>
parents: 16535
diff changeset
180 removeInliningPhase(suites);
19306
a0a760b0fb5f pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19276
diff changeset
181 StructuredGraph graph = new StructuredGraph(javaMethod, AllowAssumptions.NO);
19822
b950967f74c7 replaced HashMap with a side-table (i.e., an array) for looking up InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 19819
diff changeset
182
b950967f74c7 replaced HashMap with a side-table (i.e., an array) for looking up InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 19819
diff changeset
183 MetaAccessProvider metaAccess = providers.getMetaAccess();
b950967f74c7 replaced HashMap with a side-table (i.e., an array) for looking up InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 19819
diff changeset
184 Plugins plugins = new Plugins(new InvocationPlugins(metaAccess));
21157
31a1589aecdf Make Truffle respect -XX:+DebugNonSafepoints
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20872
diff changeset
185 boolean infoPoints = HotSpotGraalRuntime.runtime().getCompilerToVM().shouldDebugNonSafepoints();
31a1589aecdf Make Truffle respect -XX:+DebugNonSafepoints
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20872
diff changeset
186 GraphBuilderConfiguration config = infoPoints ? GraphBuilderConfiguration.getInfopointEagerDefault(plugins) : GraphBuilderConfiguration.getEagerDefault(plugins);
19822
b950967f74c7 replaced HashMap with a side-table (i.e., an array) for looking up InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 19819
diff changeset
187 new GraphBuilderPhase.Instance(metaAccess, providers.getStampProvider(), providers.getConstantReflection(), config, OptimisticOptimizations.ALL, null).apply(graph);
b950967f74c7 replaced HashMap with a side-table (i.e., an array) for looking up InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 19819
diff changeset
188
17113
583bf03b3e1a apply CompilerToVM.shouldDebugNonSafepoints() to HotSpot Truffle compilations as well
Doug Simon <doug.simon@oracle.com>
parents: 17036
diff changeset
189 PhaseSuite<HighTierContext> graphBuilderSuite = getGraphBuilderSuite(suitesProvider);
12529
23dc5dfdb9c7 Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 11934
diff changeset
190 CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, graph.method(), false);
23dc5dfdb9c7 Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 11934
diff changeset
191 Backend backend = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend();
13231
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents: 13229
diff changeset
192 CompilationResultBuilderFactory factory = getOptimizedCallTargetInstrumentationFactory(backend.getTarget().arch.getName(), javaMethod);
20068
cc3131ff7ce2 Remove GraphCache option.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20054
diff changeset
193 return compileGraph(graph, cc, javaMethod, providers, backend, providers.getCodeCache().getTarget(), graphBuilderSuite, OptimisticOptimizations.ALL, getProfilingInfo(graph), null, suites,
cc3131ff7ce2 Remove GraphCache option.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20054
diff changeset
194 lirSuites, new CompilationResult(), factory);
12529
23dc5dfdb9c7 Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 11934
diff changeset
195 }
23dc5dfdb9c7 Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 11934
diff changeset
196
19822
b950967f74c7 replaced HashMap with a side-table (i.e., an array) for looking up InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 19819
diff changeset
197 private static HotSpotProviders getGraalProviders() {
12529
23dc5dfdb9c7 Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 11934
diff changeset
198 RuntimeProvider runtimeProvider = Graal.getRequiredCapability(RuntimeProvider.class);
19822
b950967f74c7 replaced HashMap with a side-table (i.e., an array) for looking up InvocationPlugins
Doug Simon <doug.simon@oracle.com>
parents: 19819
diff changeset
199 return (HotSpotProviders) runtimeProvider.getHostBackend().getProviders();
12529
23dc5dfdb9c7 Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 11934
diff changeset
200 }
15064
f675818d9ad0 new getStackTrace and getCurrentFrame functionality in TruffleRuntime
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15018
diff changeset
201
17113
583bf03b3e1a apply CompilerToVM.shouldDebugNonSafepoints() to HotSpot Truffle compilations as well
Doug Simon <doug.simon@oracle.com>
parents: 17036
diff changeset
202 private static PhaseSuite<HighTierContext> getGraphBuilderSuite(SuitesProvider suitesProvider) {
583bf03b3e1a apply CompilerToVM.shouldDebugNonSafepoints() to HotSpot Truffle compilations as well
Doug Simon <doug.simon@oracle.com>
parents: 17036
diff changeset
203 PhaseSuite<HighTierContext> graphBuilderSuite = suitesProvider.getDefaultGraphBuilderSuite();
17153
646ddd52d79a only generate extra debug info if on HotSpot *and* compiling for HotSpot execution
Doug Simon <doug.simon@oracle.com>
parents: 17113
diff changeset
204 return withSimpleDebugInfoIfRequested(graphBuilderSuite);
17113
583bf03b3e1a apply CompilerToVM.shouldDebugNonSafepoints() to HotSpot Truffle compilations as well
Doug Simon <doug.simon@oracle.com>
parents: 17036
diff changeset
205 }
583bf03b3e1a apply CompilerToVM.shouldDebugNonSafepoints() to HotSpot Truffle compilations as well
Doug Simon <doug.simon@oracle.com>
parents: 17036
diff changeset
206
16850
d6c002f4d2a9 Truffle: fix NPE with -G:-Inline
Andreas Woess <andreas.woess@jku.at>
parents: 16535
diff changeset
207 private static void removeInliningPhase(Suites suites) {
d6c002f4d2a9 Truffle: fix NPE with -G:-Inline
Andreas Woess <andreas.woess@jku.at>
parents: 16535
diff changeset
208 ListIterator<BasePhase<? super HighTierContext>> inliningPhase = suites.getHighTier().findPhase(InliningPhase.class);
d6c002f4d2a9 Truffle: fix NPE with -G:-Inline
Andreas Woess <andreas.woess@jku.at>
parents: 16535
diff changeset
209 if (inliningPhase != null) {
d6c002f4d2a9 Truffle: fix NPE with -G:-Inline
Andreas Woess <andreas.woess@jku.at>
parents: 16535
diff changeset
210 inliningPhase.remove();
d6c002f4d2a9 Truffle: fix NPE with -G:-Inline
Andreas Woess <andreas.woess@jku.at>
parents: 16535
diff changeset
211 }
d6c002f4d2a9 Truffle: fix NPE with -G:-Inline
Andreas Woess <andreas.woess@jku.at>
parents: 16535
diff changeset
212 }
d6c002f4d2a9 Truffle: fix NPE with -G:-Inline
Andreas Woess <andreas.woess@jku.at>
parents: 16535
diff changeset
213
16529
f6ac86d3334e Change API for stack walking to a visitor: TruffleRuntime#iterateFrames replaces TruffleRuntime#getStackTrace
Christian Wimmer <christian.wimmer@oracle.com>
parents: 16065
diff changeset
214 @Override
15210
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
215 public void compile(OptimizedCallTarget optimizedCallTarget, boolean mayBeAsynchronous) {
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
216 if (truffleCompiler == null) {
21394
706ffad4d773 Allow subclasses of TruffleCompiler
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21296
diff changeset
217 truffleCompiler = DefaultTruffleCompiler.create();
15210
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
218 }
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
219 Runnable r = new Runnable() {
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
220 @Override
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
221 public void run() {
21394
706ffad4d773 Allow subclasses of TruffleCompiler
Christian Wimmer <christian.wimmer@oracle.com>
parents: 21296
diff changeset
222 doCompile(optimizedCallTarget);
15210
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
223 }
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
224 };
17161
499804c831fc use compilation thread even for synchronous Truffle compilations
Lukas Stadler <lukas.stadler@oracle.com>
parents: 17153
diff changeset
225 Future<?> future = compileQueue.submit(r);
499804c831fc use compilation thread even for synchronous Truffle compilations
Lukas Stadler <lukas.stadler@oracle.com>
parents: 17153
diff changeset
226 this.compilations.put(optimizedCallTarget, future);
18199
c5c80abc3fc6 Truffle: add support for a CompilationListener in GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents: 18198
diff changeset
227 getCompilationNotify().notifyCompilationQueued(optimizedCallTarget);
17161
499804c831fc use compilation thread even for synchronous Truffle compilations
Lukas Stadler <lukas.stadler@oracle.com>
parents: 17153
diff changeset
228
499804c831fc use compilation thread even for synchronous Truffle compilations
Lukas Stadler <lukas.stadler@oracle.com>
parents: 17153
diff changeset
229 if (!mayBeAsynchronous) {
499804c831fc use compilation thread even for synchronous Truffle compilations
Lukas Stadler <lukas.stadler@oracle.com>
parents: 17153
diff changeset
230 try {
499804c831fc use compilation thread even for synchronous Truffle compilations
Lukas Stadler <lukas.stadler@oracle.com>
parents: 17153
diff changeset
231 future.get();
17424
34f6995b1d90 Truffle: don't silently ignore exceptions in the compiler if we want to throw them.
Chris Seaton <chris.seaton@oracle.com>
parents: 17416
diff changeset
232 } catch (ExecutionException e) {
19886
00ee00de0491 fix faulty check in HotSpotTruffleRuntime
Lukas Stadler <lukas.stadler@oracle.com>
parents: 19775
diff changeset
233 if (TruffleCompilationExceptionsAreThrown.getValue() && !(e.getCause() instanceof BailoutException && !((BailoutException) e.getCause()).isPermanent())) {
17424
34f6995b1d90 Truffle: don't silently ignore exceptions in the compiler if we want to throw them.
Chris Seaton <chris.seaton@oracle.com>
parents: 17416
diff changeset
234 throw new RuntimeException(e.getCause());
34f6995b1d90 Truffle: don't silently ignore exceptions in the compiler if we want to throw them.
Chris Seaton <chris.seaton@oracle.com>
parents: 17416
diff changeset
235 } else {
34f6995b1d90 Truffle: don't silently ignore exceptions in the compiler if we want to throw them.
Chris Seaton <chris.seaton@oracle.com>
parents: 17416
diff changeset
236 // silently ignored
34f6995b1d90 Truffle: don't silently ignore exceptions in the compiler if we want to throw them.
Chris Seaton <chris.seaton@oracle.com>
parents: 17416
diff changeset
237 }
19925
72afcc30c4a0 Truffle: truffle compilation might result in a CancellationException.
Christian Humer <christian.humer@gmail.com>
parents: 19893
diff changeset
238 } catch (InterruptedException | CancellationException e) {
17161
499804c831fc use compilation thread even for synchronous Truffle compilations
Lukas Stadler <lukas.stadler@oracle.com>
parents: 17153
diff changeset
239 // silently ignored
499804c831fc use compilation thread even for synchronous Truffle compilations
Lukas Stadler <lukas.stadler@oracle.com>
parents: 17153
diff changeset
240 }
15210
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
241 }
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
242 }
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
243
17192
d0d76deeacb9 Make more Truffle code HotSpot independent, and allow more customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17161
diff changeset
244 @Override
18199
c5c80abc3fc6 Truffle: add support for a CompilationListener in GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents: 18198
diff changeset
245 public boolean cancelInstalledTask(OptimizedCallTarget optimizedCallTarget, Object source, CharSequence reason) {
15210
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
246 Future<?> codeTask = this.compilations.get(optimizedCallTarget);
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
247 if (codeTask != null && isCompiling(optimizedCallTarget)) {
15219
3e6cbf843040 Truffle: Fixed a bug causing compilation not be cleared from the Truffle queue.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15212
diff changeset
248 this.compilations.remove(optimizedCallTarget);
18199
c5c80abc3fc6 Truffle: add support for a CompilationListener in GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents: 18198
diff changeset
249 boolean result = codeTask.cancel(true);
20095
c7c799f40c1e Truffle: cache compiling flag in OptimizedCallTarget to speed up check in the interpreter;
Christian Humer <christian.humer@gmail.com>
parents: 20080
diff changeset
250 if (result) {
c7c799f40c1e Truffle: cache compiling flag in OptimizedCallTarget to speed up check in the interpreter;
Christian Humer <christian.humer@gmail.com>
parents: 20080
diff changeset
251 optimizedCallTarget.notifyCompilationFinished(false);
c7c799f40c1e Truffle: cache compiling flag in OptimizedCallTarget to speed up check in the interpreter;
Christian Humer <christian.humer@gmail.com>
parents: 20080
diff changeset
252 getCompilationNotify().notifyCompilationDequeued(optimizedCallTarget, source, reason);
c7c799f40c1e Truffle: cache compiling flag in OptimizedCallTarget to speed up check in the interpreter;
Christian Humer <christian.humer@gmail.com>
parents: 20080
diff changeset
253 }
18199
c5c80abc3fc6 Truffle: add support for a CompilationListener in GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents: 18198
diff changeset
254 return result;
15210
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
255 }
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
256 return false;
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
257 }
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
258
17192
d0d76deeacb9 Make more Truffle code HotSpot independent, and allow more customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17161
diff changeset
259 @Override
17005
112ab4a3de3a Truffle: added Graal runtime API to wait for the completion of a compilation.
Christian Humer <christian.humer@gmail.com>
parents: 16992
diff changeset
260 public void waitForCompilation(OptimizedCallTarget optimizedCallTarget, long timeout) throws ExecutionException, TimeoutException {
112ab4a3de3a Truffle: added Graal runtime API to wait for the completion of a compilation.
Christian Humer <christian.humer@gmail.com>
parents: 16992
diff changeset
261 Future<?> codeTask = this.compilations.get(optimizedCallTarget);
112ab4a3de3a Truffle: added Graal runtime API to wait for the completion of a compilation.
Christian Humer <christian.humer@gmail.com>
parents: 16992
diff changeset
262 if (codeTask != null && isCompiling(optimizedCallTarget)) {
112ab4a3de3a Truffle: added Graal runtime API to wait for the completion of a compilation.
Christian Humer <christian.humer@gmail.com>
parents: 16992
diff changeset
263 try {
112ab4a3de3a Truffle: added Graal runtime API to wait for the completion of a compilation.
Christian Humer <christian.humer@gmail.com>
parents: 16992
diff changeset
264 codeTask.get(timeout, TimeUnit.MILLISECONDS);
112ab4a3de3a Truffle: added Graal runtime API to wait for the completion of a compilation.
Christian Humer <christian.humer@gmail.com>
parents: 16992
diff changeset
265 } catch (InterruptedException e) {
112ab4a3de3a Truffle: added Graal runtime API to wait for the completion of a compilation.
Christian Humer <christian.humer@gmail.com>
parents: 16992
diff changeset
266 // ignore interrupted
112ab4a3de3a Truffle: added Graal runtime API to wait for the completion of a compilation.
Christian Humer <christian.humer@gmail.com>
parents: 16992
diff changeset
267 }
112ab4a3de3a Truffle: added Graal runtime API to wait for the completion of a compilation.
Christian Humer <christian.humer@gmail.com>
parents: 16992
diff changeset
268 }
112ab4a3de3a Truffle: added Graal runtime API to wait for the completion of a compilation.
Christian Humer <christian.humer@gmail.com>
parents: 16992
diff changeset
269 }
112ab4a3de3a Truffle: added Graal runtime API to wait for the completion of a compilation.
Christian Humer <christian.humer@gmail.com>
parents: 16992
diff changeset
270
17192
d0d76deeacb9 Make more Truffle code HotSpot independent, and allow more customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17161
diff changeset
271 @Override
18212
546cfe7a19b6 Truffle: add getQueuedCallTargets to GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents: 18200
diff changeset
272 public Collection<OptimizedCallTarget> getQueuedCallTargets() {
546cfe7a19b6 Truffle: add getQueuedCallTargets to GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents: 18200
diff changeset
273 return compilations.keySet().stream().filter(e -> !compilations.get(e).isDone()).collect(Collectors.toList());
546cfe7a19b6 Truffle: add getQueuedCallTargets to GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents: 18200
diff changeset
274 }
546cfe7a19b6 Truffle: add getQueuedCallTargets to GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents: 18200
diff changeset
275
546cfe7a19b6 Truffle: add getQueuedCallTargets to GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents: 18200
diff changeset
276 @Override
15210
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
277 public boolean isCompiling(OptimizedCallTarget optimizedCallTarget) {
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
278 Future<?> codeTask = this.compilations.get(optimizedCallTarget);
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
279 if (codeTask != null) {
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
280 if (codeTask.isCancelled() || codeTask.isDone()) {
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
281 this.compilations.remove(optimizedCallTarget);
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
282 return false;
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
283 }
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
284 return true;
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
285 }
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
286 return false;
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
287 }
15211
59f71608aa9a Clean up of relationship between compilation policy and optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15210
diff changeset
288
17192
d0d76deeacb9 Make more Truffle code HotSpot independent, and allow more customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17161
diff changeset
289 @Override
18199
c5c80abc3fc6 Truffle: add support for a CompilationListener in GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents: 18198
diff changeset
290 public void invalidateInstalledCode(OptimizedCallTarget optimizedCallTarget, Object source, CharSequence reason) {
15211
59f71608aa9a Clean up of relationship between compilation policy and optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15210
diff changeset
291 HotSpotGraalRuntime.runtime().getCompilerToVM().invalidateInstalledCode(optimizedCallTarget);
18199
c5c80abc3fc6 Truffle: add support for a CompilationListener in GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents: 18198
diff changeset
292 getCompilationNotify().notifyCompilationInvalidated(optimizedCallTarget, source, reason);
15211
59f71608aa9a Clean up of relationship between compilation policy and optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15210
diff changeset
293 }
15222
58d2c5bdb9cd Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15219
diff changeset
294
17192
d0d76deeacb9 Make more Truffle code HotSpot independent, and allow more customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17161
diff changeset
295 @Override
15222
58d2c5bdb9cd Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15219
diff changeset
296 public void reinstallStubs() {
58d2c5bdb9cd Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15219
diff changeset
297 installOptimizedCallTargetCallMethod();
58d2c5bdb9cd Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15219
diff changeset
298 }
16535
ada0a7729b6f Truffle: introduce debug option to print the stack trace when transferring to the interpreter
Andreas Woess <andreas.woess@jku.at>
parents: 16529
diff changeset
299
16992
5a1d764f6afc Truffle: added support for Runtime#getCallTargets()
Christian Humer <christian.humer@gmail.com>
parents: 16916
diff changeset
300 @Override
21296
c3a6c85aec82 Add flag for Truffle infopoints
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 21157
diff changeset
301 public boolean platformEnableInfopoints() {
21157
31a1589aecdf Make Truffle respect -XX:+DebugNonSafepoints
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20872
diff changeset
302 return HotSpotGraalRuntime.runtime().getCompilerToVM().shouldDebugNonSafepoints();
31a1589aecdf Make Truffle respect -XX:+DebugNonSafepoints
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20872
diff changeset
303 }
31a1589aecdf Make Truffle respect -XX:+DebugNonSafepoints
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20872
diff changeset
304
31a1589aecdf Make Truffle respect -XX:+DebugNonSafepoints
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 20872
diff changeset
305 @Override
17036
7b45e33b7986 Truffle: made TruffleRuntime#getCallTargets return a Collection and simplified its implementation.
Christian Humer <christian.humer@gmail.com>
parents: 17005
diff changeset
306 public Collection<RootCallTarget> getCallTargets() {
7b45e33b7986 Truffle: made TruffleRuntime#getCallTargets return a Collection and simplified its implementation.
Christian Humer <christian.humer@gmail.com>
parents: 17005
diff changeset
307 return Collections.unmodifiableSet(callTargets.keySet());
16992
5a1d764f6afc Truffle: added support for Runtime#getCallTargets()
Christian Humer <christian.humer@gmail.com>
parents: 16916
diff changeset
308 }
5a1d764f6afc Truffle: added support for Runtime#getCallTargets()
Christian Humer <christian.humer@gmail.com>
parents: 16916
diff changeset
309
17192
d0d76deeacb9 Make more Truffle code HotSpot independent, and allow more customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17161
diff changeset
310 @Override
16535
ada0a7729b6f Truffle: introduce debug option to print the stack trace when transferring to the interpreter
Andreas Woess <andreas.woess@jku.at>
parents: 16529
diff changeset
311 public void notifyTransferToInterpreter() {
ada0a7729b6f Truffle: introduce debug option to print the stack trace when transferring to the interpreter
Andreas Woess <andreas.woess@jku.at>
parents: 16529
diff changeset
312 CompilerAsserts.neverPartOfCompilation();
ada0a7729b6f Truffle: introduce debug option to print the stack trace when transferring to the interpreter
Andreas Woess <andreas.woess@jku.at>
parents: 16529
diff changeset
313 if (TraceTruffleTransferToInterpreter.getValue()) {
19893
4b6a65cb8ecd Truffle: repair TraceTruffleTransferToInterpreter option
Andreas Woess <andreas.woess@oracle.com>
parents: 19889
diff changeset
314 long thread = UnsafeAccess.unsafe.getLong(Thread.currentThread(), THREAD_EETOP_OFFSET);
4b6a65cb8ecd Truffle: repair TraceTruffleTransferToInterpreter option
Andreas Woess <andreas.woess@oracle.com>
parents: 19889
diff changeset
315 long pendingTransferToInterpreterAddress = thread + HotSpotGraalRuntime.runtime().getConfig().pendingTransferToInterpreterOffset;
4b6a65cb8ecd Truffle: repair TraceTruffleTransferToInterpreter option
Andreas Woess <andreas.woess@oracle.com>
parents: 19889
diff changeset
316 boolean deoptimized = UnsafeAccess.unsafe.getByte(pendingTransferToInterpreterAddress) != 0;
16535
ada0a7729b6f Truffle: introduce debug option to print the stack trace when transferring to the interpreter
Andreas Woess <andreas.woess@jku.at>
parents: 16529
diff changeset
317 if (deoptimized) {
19893
4b6a65cb8ecd Truffle: repair TraceTruffleTransferToInterpreter option
Andreas Woess <andreas.woess@oracle.com>
parents: 19889
diff changeset
318 UnsafeAccess.unsafe.putByte(pendingTransferToInterpreterAddress, (byte) 0);
16535
ada0a7729b6f Truffle: introduce debug option to print the stack trace when transferring to the interpreter
Andreas Woess <andreas.woess@jku.at>
parents: 16529
diff changeset
319
ada0a7729b6f Truffle: introduce debug option to print the stack trace when transferring to the interpreter
Andreas Woess <andreas.woess@jku.at>
parents: 16529
diff changeset
320 logTransferToInterpreter();
ada0a7729b6f Truffle: introduce debug option to print the stack trace when transferring to the interpreter
Andreas Woess <andreas.woess@jku.at>
parents: 16529
diff changeset
321 }
ada0a7729b6f Truffle: introduce debug option to print the stack trace when transferring to the interpreter
Andreas Woess <andreas.woess@jku.at>
parents: 16529
diff changeset
322 }
ada0a7729b6f Truffle: introduce debug option to print the stack trace when transferring to the interpreter
Andreas Woess <andreas.woess@jku.at>
parents: 16529
diff changeset
323 }
ada0a7729b6f Truffle: introduce debug option to print the stack trace when transferring to the interpreter
Andreas Woess <andreas.woess@jku.at>
parents: 16529
diff changeset
324
ada0a7729b6f Truffle: introduce debug option to print the stack trace when transferring to the interpreter
Andreas Woess <andreas.woess@jku.at>
parents: 16529
diff changeset
325 private static void logTransferToInterpreter() {
ada0a7729b6f Truffle: introduce debug option to print the stack trace when transferring to the interpreter
Andreas Woess <andreas.woess@jku.at>
parents: 16529
diff changeset
326 final int skip = 2;
17416
f7ba2423fbc3 Truffle: make TraceTruffleTransferToInterpreter and TraceTruffleAssumptions stack trace limit configurable
Andreas Woess <andreas.woess@jku.at>
parents: 17400
diff changeset
327 final int limit = TraceTruffleStackTraceLimit.getValue();
16535
ada0a7729b6f Truffle: introduce debug option to print the stack trace when transferring to the interpreter
Andreas Woess <andreas.woess@jku.at>
parents: 16529
diff changeset
328 StackTraceElement[] stackTrace = new Throwable().getStackTrace();
ada0a7729b6f Truffle: introduce debug option to print the stack trace when transferring to the interpreter
Andreas Woess <andreas.woess@jku.at>
parents: 16529
diff changeset
329 String suffix = stackTrace.length > skip + limit ? "\n ..." : "";
ada0a7729b6f Truffle: introduce debug option to print the stack trace when transferring to the interpreter
Andreas Woess <andreas.woess@jku.at>
parents: 16529
diff changeset
330 TTY.out().out().println(Arrays.stream(stackTrace).skip(skip).limit(limit).map(StackTraceElement::toString).collect(Collectors.joining("\n ", "", suffix)));
ada0a7729b6f Truffle: introduce debug option to print the stack trace when transferring to the interpreter
Andreas Woess <andreas.woess@jku.at>
parents: 16529
diff changeset
331 }
19893
4b6a65cb8ecd Truffle: repair TraceTruffleTransferToInterpreter option
Andreas Woess <andreas.woess@oracle.com>
parents: 19889
diff changeset
332
4b6a65cb8ecd Truffle: repair TraceTruffleTransferToInterpreter option
Andreas Woess <andreas.woess@oracle.com>
parents: 19889
diff changeset
333 private static long eetopOffset() {
4b6a65cb8ecd Truffle: repair TraceTruffleTransferToInterpreter option
Andreas Woess <andreas.woess@oracle.com>
parents: 19889
diff changeset
334 try {
4b6a65cb8ecd Truffle: repair TraceTruffleTransferToInterpreter option
Andreas Woess <andreas.woess@oracle.com>
parents: 19889
diff changeset
335 return UnsafeAccess.unsafe.objectFieldOffset(Thread.class.getDeclaredField("eetop"));
4b6a65cb8ecd Truffle: repair TraceTruffleTransferToInterpreter option
Andreas Woess <andreas.woess@oracle.com>
parents: 19889
diff changeset
336 } catch (Exception e) {
4b6a65cb8ecd Truffle: repair TraceTruffleTransferToInterpreter option
Andreas Woess <andreas.woess@oracle.com>
parents: 19889
diff changeset
337 throw new GraalInternalError(e);
4b6a65cb8ecd Truffle: repair TraceTruffleTransferToInterpreter option
Andreas Woess <andreas.woess@oracle.com>
parents: 19889
diff changeset
338 }
4b6a65cb8ecd Truffle: repair TraceTruffleTransferToInterpreter option
Andreas Woess <andreas.woess@oracle.com>
parents: 19889
diff changeset
339 }
20872
b1700db197c7 Move com.oracle.nfi implementation to graal.truffle.hotspot since it implements an interface that does not live in the graal class-loader
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20095
diff changeset
340
b1700db197c7 Move com.oracle.nfi implementation to graal.truffle.hotspot since it implements an interface that does not live in the graal class-loader
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20095
diff changeset
341 private static RawNativeCallNodeFactory getRawNativeCallNodeFactory(String arch) {
b1700db197c7 Move com.oracle.nfi implementation to graal.truffle.hotspot since it implements an interface that does not live in the graal class-loader
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20095
diff changeset
342 for (RawNativeCallNodeFactory factory : Services.load(RawNativeCallNodeFactory.class)) {
b1700db197c7 Move com.oracle.nfi implementation to graal.truffle.hotspot since it implements an interface that does not live in the graal class-loader
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20095
diff changeset
343 if (factory.getArchitecture().equals(arch)) {
b1700db197c7 Move com.oracle.nfi implementation to graal.truffle.hotspot since it implements an interface that does not live in the graal class-loader
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20095
diff changeset
344 return factory;
b1700db197c7 Move com.oracle.nfi implementation to graal.truffle.hotspot since it implements an interface that does not live in the graal class-loader
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20095
diff changeset
345 }
b1700db197c7 Move com.oracle.nfi implementation to graal.truffle.hotspot since it implements an interface that does not live in the graal class-loader
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20095
diff changeset
346 }
b1700db197c7 Move com.oracle.nfi implementation to graal.truffle.hotspot since it implements an interface that does not live in the graal class-loader
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20095
diff changeset
347 // No RawNativeCallNodeFactory on this platform.
b1700db197c7 Move com.oracle.nfi implementation to graal.truffle.hotspot since it implements an interface that does not live in the graal class-loader
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20095
diff changeset
348 return null;
b1700db197c7 Move com.oracle.nfi implementation to graal.truffle.hotspot since it implements an interface that does not live in the graal class-loader
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20095
diff changeset
349 }
b1700db197c7 Move com.oracle.nfi implementation to graal.truffle.hotspot since it implements an interface that does not live in the graal class-loader
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20095
diff changeset
350
b1700db197c7 Move com.oracle.nfi implementation to graal.truffle.hotspot since it implements an interface that does not live in the graal class-loader
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20095
diff changeset
351 /**
b1700db197c7 Move com.oracle.nfi implementation to graal.truffle.hotspot since it implements an interface that does not live in the graal class-loader
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20095
diff changeset
352 * Called from the VM.
b1700db197c7 Move com.oracle.nfi implementation to graal.truffle.hotspot since it implements an interface that does not live in the graal class-loader
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20095
diff changeset
353 */
b1700db197c7 Move com.oracle.nfi implementation to graal.truffle.hotspot since it implements an interface that does not live in the graal class-loader
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20095
diff changeset
354 public static NativeFunctionInterface createNativeFunctionInterface() {
b1700db197c7 Move com.oracle.nfi implementation to graal.truffle.hotspot since it implements an interface that does not live in the graal class-loader
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20095
diff changeset
355 HotSpotVMConfig config = HotSpotGraalRuntime.runtime().getConfig();
b1700db197c7 Move com.oracle.nfi implementation to graal.truffle.hotspot since it implements an interface that does not live in the graal class-loader
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20095
diff changeset
356 Backend backend = HotSpotGraalRuntime.runtime().getHostBackend();
b1700db197c7 Move com.oracle.nfi implementation to graal.truffle.hotspot since it implements an interface that does not live in the graal class-loader
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20095
diff changeset
357 RawNativeCallNodeFactory factory = getRawNativeCallNodeFactory(backend.getTarget().arch.getName());
b1700db197c7 Move com.oracle.nfi implementation to graal.truffle.hotspot since it implements an interface that does not live in the graal class-loader
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20095
diff changeset
358 if (factory == null) {
b1700db197c7 Move com.oracle.nfi implementation to graal.truffle.hotspot since it implements an interface that does not live in the graal class-loader
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20095
diff changeset
359 return null;
b1700db197c7 Move com.oracle.nfi implementation to graal.truffle.hotspot since it implements an interface that does not live in the graal class-loader
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20095
diff changeset
360 }
b1700db197c7 Move com.oracle.nfi implementation to graal.truffle.hotspot since it implements an interface that does not live in the graal class-loader
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20095
diff changeset
361 return new HotSpotNativeFunctionInterface(HotSpotGraalRuntime.runtime().getHostProviders(), factory, backend, config.dllLoad, config.dllLookup, config.rtldDefault);
b1700db197c7 Move com.oracle.nfi implementation to graal.truffle.hotspot since it implements an interface that does not live in the graal class-loader
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 20095
diff changeset
362 }
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
363 }