annotate graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java @ 19473:b6d9486fcccb

Truffle: minor fix for multi-threaded compilation
author Andreas Woess <andreas.woess@oracle.com>
date Wed, 18 Feb 2015 12:12:28 +0100
parents ac5b08ea9a6a
children 16ad9711b44f 48eeda5dfdbf
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.*;
12529
23dc5dfdb9c7 Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 11934
diff changeset
40 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
41 import com.oracle.graal.debug.*;
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.Debug.Scope;
15211
59f71608aa9a Clean up of relationship between compilation policy and optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15210
diff changeset
43 import com.oracle.graal.hotspot.*;
15212
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
44 import com.oracle.graal.hotspot.meta.*;
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
45 import com.oracle.graal.hotspot.nodes.*;
12529
23dc5dfdb9c7 Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 11934
diff changeset
46 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
47 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
48 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
49 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
50 import com.oracle.graal.nodes.StructuredGraph.AllowAssumptions;
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
51 import com.oracle.graal.nodes.spi.*;
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.phases.*;
15470
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15222
diff changeset
53 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
54 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
55 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
56 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
57 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
58 import com.oracle.graal.truffle.*;
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
59 import com.oracle.graal.word.*;
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
60 import com.oracle.truffle.api.*;
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
61 import com.oracle.truffle.api.nodes.*;
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
62
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
63 /**
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
64 * 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
65 */
17192
d0d76deeacb9 Make more Truffle code HotSpot independent, and allow more customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17161
diff changeset
66 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
67
18961
afa70d3e8159 Allow users to provide their own TruffleRuntime implementation
Paul Woegerer <paul.woegerer@oracle.com>
parents: 18276
diff changeset
68 public static TruffleRuntime makeInstance() {
afa70d3e8159 Allow users to provide their own TruffleRuntime implementation
Paul Woegerer <paul.woegerer@oracle.com>
parents: 18276
diff changeset
69 if (GraalTruffleRuntime.alternateRuntime != null) {
afa70d3e8159 Allow users to provide their own TruffleRuntime implementation
Paul Woegerer <paul.woegerer@oracle.com>
parents: 18276
diff changeset
70 return GraalTruffleRuntime.alternateRuntime;
afa70d3e8159 Allow users to provide their own TruffleRuntime implementation
Paul Woegerer <paul.woegerer@oracle.com>
parents: 18276
diff changeset
71 }
15018
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14991
diff changeset
72 return new HotSpotTruffleRuntime();
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
73 }
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
74
15210
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
75 private TruffleCompilerImpl truffleCompiler;
10529
254fab64b343 Separate replacements for Truffle compilation
Andreas Woess <andreas.woess@jku.at>
parents: 10484
diff changeset
76 private Replacements truffleReplacements;
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
77 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
78 private final ThreadPoolExecutor compileQueue;
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
79
16992
5a1d764f6afc Truffle: added support for Runtime#getCallTargets()
Christian Humer <christian.humer@gmail.com>
parents: 16916
diff changeset
80 private final Map<RootCallTarget, Void> callTargets = Collections.synchronizedMap(new WeakHashMap<RootCallTarget, Void>());
15088
d3add9b82b71 change to StackIntrospection and Truffle getStackTrace implementation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15064
diff changeset
81
15018
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14991
diff changeset
82 private HotSpotTruffleRuntime() {
12529
23dc5dfdb9c7 Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 11934
diff changeset
83 installOptimizedCallTargetCallMethod();
17310
4bea75e99249 Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents: 17212
diff changeset
84 installOptimizedCallTargetCallDirect();
17192
d0d76deeacb9 Make more Truffle code HotSpot independent, and allow more customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17161
diff changeset
85 lookupCallMethods(getGraalProviders().getMetaAccess());
15210
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
86
18200
62de94d5cf73 Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents: 18199
diff changeset
87 installDefaultListeners();
62de94d5cf73 Truffle: refactor implementation of TraceTruffleCompilation, TraceTruffleCompilationDetails into separate classes.
Christian Humer <christian.humer@gmail.com>
parents: 18199
diff changeset
88
15210
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
89 // Create compilation queue.
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
90 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
91 public GraalDebugConfig getDebugConfig() {
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
92 if (Debug.isEnabled()) {
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
93 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
94 debugConfig.dumpHandlers().add(new TruffleTreeDumpHandler());
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
95 return debugConfig;
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
96 } else {
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
97 return null;
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
98 }
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
99 }
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
100 });
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
101 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
102 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
103 // 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
104 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
105 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
106 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
107 } 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
108 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
109 }
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 }
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 selectedProcessors = Math.max(1, selectedProcessors);
19473
b6d9486fcccb Truffle: minor fix for multi-threaded compilation
Andreas Woess <andreas.woess@oracle.com>
parents: 19447
diff changeset
112 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
113
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
114 }
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
115
17310
4bea75e99249 Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents: 17212
diff changeset
116 private static void installOptimizedCallTargetCallDirect() {
19360
dc59d2800470 Prototype Truffle inlining when FastPE is enabled.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19306
diff changeset
117 if (TruffleCompilerOptions.TruffleFunctionInlining.getValue() && !TruffleCompilerOptions.FastPE.getValue()) {
17313
d6e4c9031ff6 Truffle: fixed OptimizedCallTarget.callDirect was marked as not inlinable even if context sensitive inlining was not used.
Christian Humer <christian.humer@gmail.com>
parents: 17310
diff changeset
118 ((HotSpotResolvedJavaMethod) getGraalProviders().getMetaAccess().lookupJavaMethod(OptimizedCallTarget.getCallDirectMethod())).setNotInlineable();
d6e4c9031ff6 Truffle: fixed OptimizedCallTarget.callDirect was marked as not inlinable even if context sensitive inlining was not used.
Christian Humer <christian.humer@gmail.com>
parents: 17310
diff changeset
119 }
17310
4bea75e99249 Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents: 17212
diff changeset
120 }
4bea75e99249 Truffle: fixed callsite argument profiling was still done for inlined calls using context sensitive inlining.
Christian Humer <christian.humer@gmail.com>
parents: 17212
diff changeset
121
17192
d0d76deeacb9 Make more Truffle code HotSpot independent, and allow more customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17161
diff changeset
122 @Override
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
123 public String getName() {
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
124 return "Graal Truffle Runtime";
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
125 }
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
126
17192
d0d76deeacb9 Make more Truffle code HotSpot independent, and allow more customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17161
diff changeset
127 @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
128 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
129 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
130 }
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
131
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
132 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
133 CompilationPolicy compilationPolicy;
59f71608aa9a Clean up of relationship between compilation policy and optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15210
diff changeset
134 if (acceptForCompilation(rootNode)) {
18276
1f3ab088d958 Truffle: implemented defer compilation.
Christian Humer <christian.humer@gmail.com>
parents: 18212
diff changeset
135 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
136 } else {
59f71608aa9a Clean up of relationship between compilation policy and optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15210
diff changeset
137 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
138 }
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
139 OptimizedCallTarget target = new OptimizedCallTarget(source, rootNode, this, compilationPolicy, new HotSpotSpeculationLog());
16992
5a1d764f6afc Truffle: added support for Runtime#getCallTargets()
Christian Humer <christian.humer@gmail.com>
parents: 16916
diff changeset
140 callTargets.put(target, null);
18276
1f3ab088d958 Truffle: implemented defer compilation.
Christian Humer <christian.humer@gmail.com>
parents: 18212
diff changeset
141
16992
5a1d764f6afc Truffle: added support for Runtime#getCallTargets()
Christian Humer <christian.humer@gmail.com>
parents: 16916
diff changeset
142 return target;
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
143 }
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
144
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
145 @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
146 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
147 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
148 }
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
149
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
150 @Override
10529
254fab64b343 Separate replacements for Truffle compilation
Andreas Woess <andreas.woess@jku.at>
parents: 10484
diff changeset
151 public Replacements getReplacements() {
254fab64b343 Separate replacements for Truffle compilation
Andreas Woess <andreas.woess@jku.at>
parents: 10484
diff changeset
152 if (truffleReplacements == null) {
15018
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14991
diff changeset
153 truffleReplacements = HotSpotTruffleReplacements.makeInstance();
10529
254fab64b343 Separate replacements for Truffle compilation
Andreas Woess <andreas.woess@jku.at>
parents: 10484
diff changeset
154 }
254fab64b343 Separate replacements for Truffle compilation
Andreas Woess <andreas.woess@jku.at>
parents: 10484
diff changeset
155 return truffleReplacements;
254fab64b343 Separate replacements for Truffle compilation
Andreas Woess <andreas.woess@jku.at>
parents: 10484
diff changeset
156 }
254fab64b343 Separate replacements for Truffle compilation
Andreas Woess <andreas.woess@jku.at>
parents: 10484
diff changeset
157
15163
e5265dc8762f Truffle: Clean ups around optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
158 public static void installOptimizedCallTargetCallMethod() {
15165
cf49b4e72de5 Reused installed code object for optimized call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15163
diff changeset
159 Providers providers = getGraalProviders();
cf49b4e72de5 Reused installed code object for optimized call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15163
diff changeset
160 MetaAccessProvider metaAccess = providers.getMetaAccess();
15212
ea9d5b6044af Remove runtime-specific optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15211
diff changeset
161 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
162 for (ResolvedJavaMethod method : type.getDeclaredMethods()) {
cf49b4e72de5 Reused installed code object for optimized call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15163
diff changeset
163 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
164 CompilationResult compResult = compileMethod(method);
cf49b4e72de5 Reused installed code object for optimized call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15163
diff changeset
165 CodeCacheProvider codeCache = providers.getCodeCache();
cf49b4e72de5 Reused installed code object for optimized call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15163
diff changeset
166 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
167 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
168 } catch (Throwable e) {
1ac6b4879443 Enforce catch-blocks for Debug.Scopes with context objects.
Josef Eisl <josef.eisl@jku.at>
parents: 17192
diff changeset
169 throw Debug.handle(e);
15165
cf49b4e72de5 Reused installed code object for optimized call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15163
diff changeset
170 }
15163
e5265dc8762f Truffle: Clean ups around optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
171 }
e5265dc8762f Truffle: Clean ups around optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
172 }
12529
23dc5dfdb9c7 Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 11934
diff changeset
173 }
23dc5dfdb9c7 Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 11934
diff changeset
174
13231
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents: 13229
diff changeset
175 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
176 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
177 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
178 factory.setInstrumentedMethod(method);
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents: 13229
diff changeset
179 return factory;
12557
86c74ef1b6f5 Make AMD64HotSpotTruffleBackend a decorator for the default backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 12531
diff changeset
180 }
86c74ef1b6f5 Make AMD64HotSpotTruffleBackend a decorator for the default backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 12531
diff changeset
181 }
13231
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents: 13229
diff changeset
182 // 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
183 return CompilationResultBuilderFactory.Default;
12557
86c74ef1b6f5 Make AMD64HotSpotTruffleBackend a decorator for the default backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 12531
diff changeset
184 }
86c74ef1b6f5 Make AMD64HotSpotTruffleBackend a decorator for the default backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 12531
diff changeset
185
12531
7d5c3ffbee64 Refactoring of the frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 12529
diff changeset
186 private static CompilationResult compileMethod(ResolvedJavaMethod javaMethod) {
7d5c3ffbee64 Refactoring of the frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 12529
diff changeset
187 Providers providers = getGraalProviders();
12529
23dc5dfdb9c7 Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 11934
diff changeset
188 MetaAccessProvider metaAccess = providers.getMetaAccess();
13585
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
189 SuitesProvider suitesProvider = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getSuites();
f4f0a8a01ce0 remove PhasePlan
Lukas Stadler <lukas.stadler@jku.at>
parents: 13584
diff changeset
190 Suites suites = suitesProvider.createSuites();
19270
292442bed972 Rename LowLevelSuites to LIRSuites.
Josef Eisl <josef.eisl@jku.at>
parents: 19232
diff changeset
191 LIRSuites lirSuites = suitesProvider.createLIRSuites();
16850
d6c002f4d2a9 Truffle: fix NPE with -G:-Inline
Andreas Woess <andreas.woess@jku.at>
parents: 16535
diff changeset
192 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
193 StructuredGraph graph = new StructuredGraph(javaMethod, AllowAssumptions.NO);
19250
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19232
diff changeset
194 new GraphBuilderPhase.Instance(metaAccess, providers.getStampProvider(), providers.getConstantReflection(), GraphBuilderConfiguration.getEagerDefault(), OptimisticOptimizations.ALL).apply(graph);
17113
583bf03b3e1a apply CompilerToVM.shouldDebugNonSafepoints() to HotSpot Truffle compilations as well
Doug Simon <doug.simon@oracle.com>
parents: 17036
diff changeset
195 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
196 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
197 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
198 CompilationResultBuilderFactory factory = getOptimizedCallTargetInstrumentationFactory(backend.getTarget().arch.getName(), javaMethod);
19047
173bdcc85ab8 Remove unused parameter "stub" from GraalCompiler.compileGraph
Christian Wimmer <christian.wimmer@oracle.com>
parents: 18961
diff changeset
199 return compileGraph(graph, cc, javaMethod, providers, backend, providers.getCodeCache().getTarget(), null, graphBuilderSuite, OptimisticOptimizations.ALL, getProfilingInfo(graph), null,
19270
292442bed972 Rename LowLevelSuites to LIRSuites.
Josef Eisl <josef.eisl@jku.at>
parents: 19232
diff changeset
200 suites, lirSuites, new CompilationResult(), factory);
12529
23dc5dfdb9c7 Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 11934
diff changeset
201 }
23dc5dfdb9c7 Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 11934
diff changeset
202
23dc5dfdb9c7 Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 11934
diff changeset
203 private static Providers getGraalProviders() {
23dc5dfdb9c7 Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 11934
diff changeset
204 RuntimeProvider runtimeProvider = Graal.getRequiredCapability(RuntimeProvider.class);
23dc5dfdb9c7 Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 11934
diff changeset
205 return runtimeProvider.getHostBackend().getProviders();
23dc5dfdb9c7 Add OptimizedCallTarget.call(PackedFrame, Arguments) frame prologue injection
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 11934
diff changeset
206 }
15064
f675818d9ad0 new getStackTrace and getCurrentFrame functionality in TruffleRuntime
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15018
diff changeset
207
17113
583bf03b3e1a apply CompilerToVM.shouldDebugNonSafepoints() to HotSpot Truffle compilations as well
Doug Simon <doug.simon@oracle.com>
parents: 17036
diff changeset
208 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
209 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
210 return withSimpleDebugInfoIfRequested(graphBuilderSuite);
17113
583bf03b3e1a apply CompilerToVM.shouldDebugNonSafepoints() to HotSpot Truffle compilations as well
Doug Simon <doug.simon@oracle.com>
parents: 17036
diff changeset
211 }
583bf03b3e1a apply CompilerToVM.shouldDebugNonSafepoints() to HotSpot Truffle compilations as well
Doug Simon <doug.simon@oracle.com>
parents: 17036
diff changeset
212
16850
d6c002f4d2a9 Truffle: fix NPE with -G:-Inline
Andreas Woess <andreas.woess@jku.at>
parents: 16535
diff changeset
213 private static void removeInliningPhase(Suites suites) {
d6c002f4d2a9 Truffle: fix NPE with -G:-Inline
Andreas Woess <andreas.woess@jku.at>
parents: 16535
diff changeset
214 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
215 if (inliningPhase != null) {
d6c002f4d2a9 Truffle: fix NPE with -G:-Inline
Andreas Woess <andreas.woess@jku.at>
parents: 16535
diff changeset
216 inliningPhase.remove();
d6c002f4d2a9 Truffle: fix NPE with -G:-Inline
Andreas Woess <andreas.woess@jku.at>
parents: 16535
diff changeset
217 }
d6c002f4d2a9 Truffle: fix NPE with -G:-Inline
Andreas Woess <andreas.woess@jku.at>
parents: 16535
diff changeset
218 }
d6c002f4d2a9 Truffle: fix NPE with -G:-Inline
Andreas Woess <andreas.woess@jku.at>
parents: 16535
diff changeset
219
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
220 @Override
15210
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
221 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
222 if (truffleCompiler == null) {
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
223 truffleCompiler = new TruffleCompilerImpl();
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
224 }
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
225 Runnable r = new Runnable() {
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
226 @Override
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
227 public void run() {
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
228 try (Scope s = Debug.scope("Truffle", new TruffleDebugJavaMethod(optimizedCallTarget))) {
18199
c5c80abc3fc6 Truffle: add support for a CompilationListener in GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents: 18198
diff changeset
229 truffleCompiler.compileMethod(optimizedCallTarget);
18198
d7e40b20b030 Truffle: refactor notifications in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents: 18166
diff changeset
230 optimizedCallTarget.notifyCompilationFinished();
15210
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
231 } catch (Throwable e) {
18198
d7e40b20b030 Truffle: refactor notifications in OptimizedCallTarget.
Christian Humer <christian.humer@gmail.com>
parents: 18166
diff changeset
232 optimizedCallTarget.notifyCompilationFailed(e);
15210
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
233 }
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
234 }
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
235 };
17161
499804c831fc use compilation thread even for synchronous Truffle compilations
Lukas Stadler <lukas.stadler@oracle.com>
parents: 17153
diff changeset
236 Future<?> future = compileQueue.submit(r);
499804c831fc use compilation thread even for synchronous Truffle compilations
Lukas Stadler <lukas.stadler@oracle.com>
parents: 17153
diff changeset
237 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
238 getCompilationNotify().notifyCompilationQueued(optimizedCallTarget);
17161
499804c831fc use compilation thread even for synchronous Truffle compilations
Lukas Stadler <lukas.stadler@oracle.com>
parents: 17153
diff changeset
239
499804c831fc use compilation thread even for synchronous Truffle compilations
Lukas Stadler <lukas.stadler@oracle.com>
parents: 17153
diff changeset
240 if (!mayBeAsynchronous) {
499804c831fc use compilation thread even for synchronous Truffle compilations
Lukas Stadler <lukas.stadler@oracle.com>
parents: 17153
diff changeset
241 try {
499804c831fc use compilation thread even for synchronous Truffle compilations
Lukas Stadler <lukas.stadler@oracle.com>
parents: 17153
diff changeset
242 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
243 } catch (ExecutionException e) {
18166
44dab78fe6bb Truffle: do not throw permament compiler exceptions into guest languages.
Chris Seaton <chris.seaton@oracle.com>
parents: 18162
diff changeset
244 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
245 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
246 } 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
247 // 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
248 }
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
249 } catch (InterruptedException e) {
17161
499804c831fc use compilation thread even for synchronous Truffle compilations
Lukas Stadler <lukas.stadler@oracle.com>
parents: 17153
diff changeset
250 // silently ignored
499804c831fc use compilation thread even for synchronous Truffle compilations
Lukas Stadler <lukas.stadler@oracle.com>
parents: 17153
diff changeset
251 }
15210
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
252 }
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
253 }
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
254
17192
d0d76deeacb9 Make more Truffle code HotSpot independent, and allow more customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17161
diff changeset
255 @Override
18199
c5c80abc3fc6 Truffle: add support for a CompilationListener in GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents: 18198
diff changeset
256 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
257 Future<?> codeTask = this.compilations.get(optimizedCallTarget);
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
258 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
259 this.compilations.remove(optimizedCallTarget);
18199
c5c80abc3fc6 Truffle: add support for a CompilationListener in GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents: 18198
diff changeset
260 boolean result = codeTask.cancel(true);
c5c80abc3fc6 Truffle: add support for a CompilationListener in GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents: 18198
diff changeset
261 getCompilationNotify().notifyCompilationDequeued(optimizedCallTarget, source, reason);
c5c80abc3fc6 Truffle: add support for a CompilationListener in GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents: 18198
diff changeset
262 return result;
15210
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
263 }
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
264 return false;
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
265 }
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
266
17192
d0d76deeacb9 Make more Truffle code HotSpot independent, and allow more customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17161
diff changeset
267 @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
268 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
269 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
270 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
271 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
272 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
273 } 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
274 // 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
275 }
112ab4a3de3a Truffle: added Graal runtime API to wait for the completion of a compilation.
Christian Humer <christian.humer@gmail.com>
parents: 16992
diff changeset
276 }
112ab4a3de3a Truffle: added Graal runtime API to wait for the completion of a compilation.
Christian Humer <christian.humer@gmail.com>
parents: 16992
diff changeset
277 }
112ab4a3de3a Truffle: added Graal runtime API to wait for the completion of a compilation.
Christian Humer <christian.humer@gmail.com>
parents: 16992
diff changeset
278
17192
d0d76deeacb9 Make more Truffle code HotSpot independent, and allow more customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17161
diff changeset
279 @Override
18212
546cfe7a19b6 Truffle: add getQueuedCallTargets to GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents: 18200
diff changeset
280 public Collection<OptimizedCallTarget> getQueuedCallTargets() {
546cfe7a19b6 Truffle: add getQueuedCallTargets to GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents: 18200
diff changeset
281 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
282 }
546cfe7a19b6 Truffle: add getQueuedCallTargets to GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents: 18200
diff changeset
283
546cfe7a19b6 Truffle: add getQueuedCallTargets to GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents: 18200
diff changeset
284 @Override
15210
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
285 public boolean isCompiling(OptimizedCallTarget optimizedCallTarget) {
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
286 Future<?> codeTask = this.compilations.get(optimizedCallTarget);
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
287 if (codeTask != null) {
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
288 if (codeTask.isCancelled() || codeTask.isDone()) {
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
289 this.compilations.remove(optimizedCallTarget);
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
290 return false;
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
291 }
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
292 return true;
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
293 }
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
294 return false;
201f6858a4f3 Restructure the interaction between OptimizedCallTarget and GraalTruffleRuntime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15165
diff changeset
295 }
15211
59f71608aa9a Clean up of relationship between compilation policy and optimized call target.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15210
diff changeset
296
17192
d0d76deeacb9 Make more Truffle code HotSpot independent, and allow more customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17161
diff changeset
297 @Override
18199
c5c80abc3fc6 Truffle: add support for a CompilationListener in GraalTruffleRuntime.
Christian Humer <christian.humer@gmail.com>
parents: 18198
diff changeset
298 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
299 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
300 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
301 }
15222
58d2c5bdb9cd Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15219
diff changeset
302
17192
d0d76deeacb9 Make more Truffle code HotSpot independent, and allow more customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17161
diff changeset
303 @Override
15222
58d2c5bdb9cd Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15219
diff changeset
304 public void reinstallStubs() {
58d2c5bdb9cd Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15219
diff changeset
305 installOptimizedCallTargetCallMethod();
58d2c5bdb9cd Truffle: Add option TruffleReturnTypeSpeculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15219
diff changeset
306 }
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
307
16992
5a1d764f6afc Truffle: added support for Runtime#getCallTargets()
Christian Humer <christian.humer@gmail.com>
parents: 16916
diff changeset
308 @Override
17036
7b45e33b7986 Truffle: made TruffleRuntime#getCallTargets return a Collection and simplified its implementation.
Christian Humer <christian.humer@gmail.com>
parents: 17005
diff changeset
309 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
310 return Collections.unmodifiableSet(callTargets.keySet());
16992
5a1d764f6afc Truffle: added support for Runtime#getCallTargets()
Christian Humer <christian.humer@gmail.com>
parents: 16916
diff changeset
311 }
5a1d764f6afc Truffle: added support for Runtime#getCallTargets()
Christian Humer <christian.humer@gmail.com>
parents: 16916
diff changeset
312
17192
d0d76deeacb9 Make more Truffle code HotSpot independent, and allow more customization by subclasses
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17161
diff changeset
313 @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
314 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
315 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
316 if (TraceTruffleTransferToInterpreter.getValue()) {
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 Word thread = CurrentJavaThreadNode.get(HotSpotGraalRuntime.runtime().getTarget().wordKind);
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
318 boolean deoptimized = thread.readByte(HotSpotGraalRuntime.runtime().getConfig().pendingTransferToInterpreterOffset) != 0;
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 if (deoptimized) {
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 thread.writeByte(HotSpotGraalRuntime.runtime().getConfig().pendingTransferToInterpreterOffset, (byte) 0);
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 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
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 }
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
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
327 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
328 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
329 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
330 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
331 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
332 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
333 }
10484
0097fb11c16f Add basic version of Graal's Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
334 }