annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotHostBackend.java @ 19050:75da87c96605

initial commit of GraphBuilderPhase plugins
author Doug Simon <doug.simon@oracle.com>
date Sat, 31 Jan 2015 00:30:00 +0100
parents c538c2c6b7e2
children 006e321d592b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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;
12580
7876c59a7a2f refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
32 import com.oracle.graal.hotspot.meta.*;
15456
bb97b75d1d65 AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents: 15359
diff changeset
33 import com.oracle.graal.hotspot.stubs.*;
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18525
diff changeset
34 import com.oracle.graal.java.*;
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 /**
15456
bb97b75d1d65 AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents: 15359
diff changeset
43 * Descriptor for {@link DeoptimizationStub#deoptimizationHandler}.
bb97b75d1d65 AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents: 15359
diff changeset
44 */
bb97b75d1d65 AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents: 15359
diff changeset
45 public static final ForeignCallDescriptor DEOPTIMIZATION_HANDLER = new ForeignCallDescriptor("deoptimizationHandler", void.class);
bb97b75d1d65 AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents: 15359
diff changeset
46
bb97b75d1d65 AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents: 15359
diff changeset
47 /**
bb97b75d1d65 AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents: 15359
diff changeset
48 * Descriptor for {@link UncommonTrapStub#uncommonTrapHandler}.
bb97b75d1d65 AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents: 15359
diff changeset
49 */
bb97b75d1d65 AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents: 15359
diff changeset
50 public static final ForeignCallDescriptor UNCOMMON_TRAP_HANDLER = new ForeignCallDescriptor("uncommonTrapHandler", void.class);
bb97b75d1d65 AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents: 15359
diff changeset
51
bb97b75d1d65 AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents: 15359
diff changeset
52 /**
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
53 * 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
54 */
13310
733cccc125ed added subqWide to AMD64Assembler
Doug Simon <doug.simon@oracle.com>
parents: 13252
diff changeset
55 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
56
18525
c538c2c6b7e2 changed most references to HotSpotGraalRuntime to use HotSpotGraalRuntimeProvider instead
Doug Simon <doug.simon@oracle.com>
parents: 16691
diff changeset
57 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
58 super(runtime, providers);
13310
733cccc125ed added subqWide to AMD64Assembler
Doug Simon <doug.simon@oracle.com>
parents: 13252
diff changeset
59 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
60 }
7876c59a7a2f refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
61
7876c59a7a2f refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
62 @Override
7876c59a7a2f refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
63 public void completeInitialization() {
7876c59a7a2f refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
64 final HotSpotProviders providers = getProviders();
7876c59a7a2f refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
65 HotSpotVMConfig config = getRuntime().getConfig();
7876c59a7a2f refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
66 HotSpotHostForeignCallsProvider foreignCalls = (HotSpotHostForeignCallsProvider) providers.getForeignCalls();
12796
68ff7abbfae5 renamed HotSpotHostLoweringProvider to HotSpotLoweringProvider
Doug Simon <doug.simon@oracle.com>
parents: 12580
diff changeset
67 final HotSpotLoweringProvider lowerer = (HotSpotLoweringProvider) providers.getLowerer();
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
68
19050
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18525
diff changeset
69 try (InitTimer st = timer("graphBuilderPlugins.initialize")) {
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18525
diff changeset
70 GraphBuilderPhase phase = (GraphBuilderPhase) providers.getSuites().getDefaultGraphBuilderSuite().findPhase(GraphBuilderPhase.class).previous();
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18525
diff changeset
71 GraphBuilderPlugins plugins = phase.getGraphBuilderPlugins();
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18525
diff changeset
72 Iterable<GraphBuilderPluginsProvider> sl = Services.load(GraphBuilderPluginsProvider.class);
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18525
diff changeset
73 for (GraphBuilderPluginsProvider p : sl) {
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18525
diff changeset
74 p.registerPlugins(providers.getMetaAccess(), plugins);
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18525
diff changeset
75 }
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18525
diff changeset
76 }
75da87c96605 initial commit of GraphBuilderPhase plugins
Doug Simon <doug.simon@oracle.com>
parents: 18525
diff changeset
77
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
78 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
79 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
80 }
839cb35354e8 added timers for Graal runtime initialization steps (enabled with -Dgraal.runtime.TimeInit=true)
Doug Simon <doug.simon@oracle.com>
parents: 15456
diff changeset
81 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
82 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
83 }
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
84 HotSpotReplacementsImpl replacements = (HotSpotReplacementsImpl) providers.getReplacements();
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
85
12580
7876c59a7a2f refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
86 // Install intrinsics.
7876c59a7a2f refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
87 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
88 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
89 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
90 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
91 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
92 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
93 }
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
94 }
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 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
96 for (ResolvedJavaMethod method : replacements.getAllReplacements()) {
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 replacements.getMacroSubstitution(method);
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
98 replacements.getMethodSubstitution(method);
12580
7876c59a7a2f refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
99 }
7876c59a7a2f refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
100 }
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
101 } 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
102 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
103 }
12580
7876c59a7a2f refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
104 }
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
105 }
12580
7876c59a7a2f refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
106 }