Mercurial > hg > truffle
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotHostBackend.java @ 21526:1da7aef31a08
created com.oracle.graal.hotspot.jvmci package and moved classes destined for future JVMCI module into it (JBS:GRAAL-53)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 19 May 2015 23:16:07 +0200 |
parents | 30cbb666e512 |
children | 07b088d61d5d |
rev | line source |
---|---|
12580
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 */ |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.hotspot; |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
15259
d90e5c22ba55
Move GraalOptions to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
14524
diff
changeset
|
25 import static com.oracle.graal.compiler.common.GraalOptions.*; |
16006
66a9286203a2
decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents:
15916
diff
changeset
|
26 import static com.oracle.graal.hotspot.InitTimer.*; |
12580
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
27 |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
28 import com.oracle.graal.api.meta.*; |
15916
6aa352b260f4
removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
15893
diff
changeset
|
29 import com.oracle.graal.api.runtime.*; |
12580
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
30 import com.oracle.graal.debug.*; |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12796
diff
changeset
|
31 import com.oracle.graal.debug.Debug.Scope; |
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:
20935
diff
changeset
|
32 import com.oracle.graal.hotspot.jvmci.*; |
12580
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
33 import com.oracle.graal.hotspot.meta.*; |
15456
bb97b75d1d65
AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents:
15359
diff
changeset
|
34 import com.oracle.graal.hotspot.stubs.*; |
12580
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
35 import com.oracle.graal.nodes.spi.*; |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
36 |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
37 /** |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
38 * Common functionality of HotSpot host backends. |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
39 */ |
16691
dd8449afc086
GNFI: move GNFI interfaces to oracle.nfi - interface does not depend on graal
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
16006
diff
changeset
|
40 public abstract class HotSpotHostBackend extends HotSpotBackend { |
12580
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
41 |
13252
5d2bc83e9d22
force long encoding of frame push instruction in a method without a stack bang; removed -G:StackShadowPages option
Doug Simon <doug.simon@oracle.com>
parents:
13197
diff
changeset
|
42 /** |
19462
33a783b15758
made use of Graal stubs instead of equivalent HotSpot stubs optional and off by default
Doug Simon <doug.simon@oracle.com>
parents:
19407
diff
changeset
|
43 * Descriptor for {@code SharedRuntime::deopt_blob()->unpack()} or |
33a783b15758
made use of Graal stubs instead of equivalent HotSpot stubs optional and off by default
Doug Simon <doug.simon@oracle.com>
parents:
19407
diff
changeset
|
44 * {@link DeoptimizationStub#deoptimizationHandler} depending on |
33a783b15758
made use of Graal stubs instead of equivalent HotSpot stubs optional and off by default
Doug Simon <doug.simon@oracle.com>
parents:
19407
diff
changeset
|
45 * {@link HotSpotBackend.Options#PreferGraalStubs}. |
15456
bb97b75d1d65
AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents:
15359
diff
changeset
|
46 */ |
19462
33a783b15758
made use of Graal stubs instead of equivalent HotSpot stubs optional and off by default
Doug Simon <doug.simon@oracle.com>
parents:
19407
diff
changeset
|
47 public static final ForeignCallDescriptor DEOPTIMIZATION_HANDLER = new ForeignCallDescriptor("deoptHandler", void.class); |
15456
bb97b75d1d65
AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents:
15359
diff
changeset
|
48 |
bb97b75d1d65
AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents:
15359
diff
changeset
|
49 /** |
19462
33a783b15758
made use of Graal stubs instead of equivalent HotSpot stubs optional and off by default
Doug Simon <doug.simon@oracle.com>
parents:
19407
diff
changeset
|
50 * Descriptor for {@code SharedRuntime::deopt_blob()->uncommon_trap()} or |
33a783b15758
made use of Graal stubs instead of equivalent HotSpot stubs optional and off by default
Doug Simon <doug.simon@oracle.com>
parents:
19407
diff
changeset
|
51 * {@link UncommonTrapStub#uncommonTrapHandler} depending on |
33a783b15758
made use of Graal stubs instead of equivalent HotSpot stubs optional and off by default
Doug Simon <doug.simon@oracle.com>
parents:
19407
diff
changeset
|
52 * {@link HotSpotBackend.Options#PreferGraalStubs}. |
15456
bb97b75d1d65
AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents:
15359
diff
changeset
|
53 */ |
bb97b75d1d65
AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents:
15359
diff
changeset
|
54 public static final ForeignCallDescriptor UNCOMMON_TRAP_HANDLER = new ForeignCallDescriptor("uncommonTrapHandler", void.class); |
bb97b75d1d65
AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents:
15359
diff
changeset
|
55 |
bb97b75d1d65
AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents:
15359
diff
changeset
|
56 /** |
13252
5d2bc83e9d22
force long encoding of frame push instruction in a method without a stack bang; removed -G:StackShadowPages option
Doug Simon <doug.simon@oracle.com>
parents:
13197
diff
changeset
|
57 * This will be 0 if stack banging is disabled. |
5d2bc83e9d22
force long encoding of frame push instruction in a method without a stack bang; removed -G:StackShadowPages option
Doug Simon <doug.simon@oracle.com>
parents:
13197
diff
changeset
|
58 */ |
13310
733cccc125ed
added subqWide to AMD64Assembler
Doug Simon <doug.simon@oracle.com>
parents:
13252
diff
changeset
|
59 protected final int pagesToBang; |
13252
5d2bc83e9d22
force long encoding of frame push instruction in a method without a stack bang; removed -G:StackShadowPages option
Doug Simon <doug.simon@oracle.com>
parents:
13197
diff
changeset
|
60 |
18525
c538c2c6b7e2
changed most references to HotSpotGraalRuntime to use HotSpotGraalRuntimeProvider instead
Doug Simon <doug.simon@oracle.com>
parents:
16691
diff
changeset
|
61 public HotSpotHostBackend(HotSpotGraalRuntimeProvider runtime, HotSpotProviders providers) { |
12580
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
62 super(runtime, providers); |
13310
733cccc125ed
added subqWide to AMD64Assembler
Doug Simon <doug.simon@oracle.com>
parents:
13252
diff
changeset
|
63 this.pagesToBang = runtime.getConfig().useStackBanging ? runtime.getConfig().stackShadowPages : 0; |
12580
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
64 } |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
65 |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
66 @Override |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
67 public void completeInitialization() { |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
68 final HotSpotProviders providers = getProviders(); |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
69 HotSpotVMConfig config = getRuntime().getConfig(); |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
70 HotSpotHostForeignCallsProvider foreignCalls = (HotSpotHostForeignCallsProvider) providers.getForeignCalls(); |
12796
68ff7abbfae5
renamed HotSpotHostLoweringProvider to HotSpotLoweringProvider
Doug Simon <doug.simon@oracle.com>
parents:
12580
diff
changeset
|
71 final HotSpotLoweringProvider lowerer = (HotSpotLoweringProvider) providers.getLowerer(); |
19791
14e703edb2ab
use GraphBuilderPlugins for method substitutions, intrinsics and snippets (GRAAL-982)
Doug Simon <doug.simon@oracle.com>
parents:
19787
diff
changeset
|
72 HotSpotReplacementsImpl replacements = (HotSpotReplacementsImpl) providers.getReplacements(); |
15893
839cb35354e8
added timers for Graal runtime initialization steps (enabled with -Dgraal.runtime.TimeInit=true)
Doug Simon <doug.simon@oracle.com>
parents:
15456
diff
changeset
|
73 |
839cb35354e8
added timers for Graal runtime initialization steps (enabled with -Dgraal.runtime.TimeInit=true)
Doug Simon <doug.simon@oracle.com>
parents:
15456
diff
changeset
|
74 try (InitTimer st = timer("foreignCalls.initialize")) { |
839cb35354e8
added timers for Graal runtime initialization steps (enabled with -Dgraal.runtime.TimeInit=true)
Doug Simon <doug.simon@oracle.com>
parents:
15456
diff
changeset
|
75 foreignCalls.initialize(providers, config); |
839cb35354e8
added timers for Graal runtime initialization steps (enabled with -Dgraal.runtime.TimeInit=true)
Doug Simon <doug.simon@oracle.com>
parents:
15456
diff
changeset
|
76 } |
839cb35354e8
added timers for Graal runtime initialization steps (enabled with -Dgraal.runtime.TimeInit=true)
Doug Simon <doug.simon@oracle.com>
parents:
15456
diff
changeset
|
77 try (InitTimer st = timer("lowerer.initialize")) { |
839cb35354e8
added timers for Graal runtime initialization steps (enabled with -Dgraal.runtime.TimeInit=true)
Doug Simon <doug.simon@oracle.com>
parents:
15456
diff
changeset
|
78 lowerer.initialize(providers, config); |
839cb35354e8
added timers for Graal runtime initialization steps (enabled with -Dgraal.runtime.TimeInit=true)
Doug Simon <doug.simon@oracle.com>
parents:
15456
diff
changeset
|
79 } |
13637
c07c88aca256
added mechanism for a (GPU) backend to override/supply the initial graph in the compilation pipeline
Doug Simon <doug.simon@oracle.com>
parents:
13310
diff
changeset
|
80 |
12580
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
81 // Install intrinsics. |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
82 if (Intrinsify.getValue()) { |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12796
diff
changeset
|
83 try (Scope s = Debug.scope("RegisterReplacements", new DebugDumpScope("RegisterReplacements"))) { |
15893
839cb35354e8
added timers for Graal runtime initialization steps (enabled with -Dgraal.runtime.TimeInit=true)
Doug Simon <doug.simon@oracle.com>
parents:
15456
diff
changeset
|
84 try (InitTimer st = timer("replacementsProviders.registerReplacements")) { |
15916
6aa352b260f4
removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents:
15893
diff
changeset
|
85 Iterable<ReplacementsProvider> sl = Services.load(ReplacementsProvider.class); |
15893
839cb35354e8
added timers for Graal runtime initialization steps (enabled with -Dgraal.runtime.TimeInit=true)
Doug Simon <doug.simon@oracle.com>
parents:
15456
diff
changeset
|
86 for (ReplacementsProvider replacementsProvider : sl) { |
839cb35354e8
added timers for Graal runtime initialization steps (enabled with -Dgraal.runtime.TimeInit=true)
Doug Simon <doug.simon@oracle.com>
parents:
15456
diff
changeset
|
87 replacementsProvider.registerReplacements(providers.getMetaAccess(), lowerer, providers.getSnippetReflection(), replacements, providers.getCodeCache().getTarget()); |
839cb35354e8
added timers for Graal runtime initialization steps (enabled with -Dgraal.runtime.TimeInit=true)
Doug Simon <doug.simon@oracle.com>
parents:
15456
diff
changeset
|
88 } |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12796
diff
changeset
|
89 } |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12796
diff
changeset
|
90 if (BootstrapReplacements.getValue()) { |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12796
diff
changeset
|
91 for (ResolvedJavaMethod method : replacements.getAllReplacements()) { |
20935
30cbb666e512
expand API for retrieving method substitution graphs to indicate the BCI of the invoke being inlined or -1 if the request is not in the context of inlining
Doug Simon <doug.simon@oracle.com>
parents:
20166
diff
changeset
|
92 replacements.getSubstitution(method, -1); |
12580
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
93 } |
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
94 } |
13197
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12796
diff
changeset
|
95 } catch (Throwable e) { |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12796
diff
changeset
|
96 throw Debug.handle(e); |
8569b9e047cd
change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents:
12796
diff
changeset
|
97 } |
12580
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
98 } |
13637
c07c88aca256
added mechanism for a (GPU) backend to override/supply the initial graph in the compilation pipeline
Doug Simon <doug.simon@oracle.com>
parents:
13310
diff
changeset
|
99 } |
12580
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
100 } |