annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java @ 19250:8ab925a6f724

made Assumptions be part of a StructuredGraph
author Doug Simon <doug.simon@oracle.com>
date Wed, 11 Feb 2015 10:13:08 +0100
parents 66c60942c06c
children 2caf12d746a3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1 /*
18176
c2270ad35f57 Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents: 16895
diff changeset
2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4 *
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
8 *
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
13 * accompanied this code).
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
14 *
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
18 *
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
21 * questions.
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
22 */
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
23 package com.oracle.graal.hotspot.stubs;
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
24
13239
Doug Simon <doug.simon@oracle.com>
parents: 13233
diff changeset
25 import static com.oracle.graal.compiler.GraalCompiler.*;
9452
c1ba734c1ea0 more extensive checking of compiled stub invariants
Doug Simon <doug.simon@oracle.com>
parents: 9420
diff changeset
26 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
9232
bb2447c64055 strings used in compiled stubs are lowered to malloc'ed C strings so that there are no embedded oops (for the strings) in the resulting installed code
Doug Simon <doug.simon@oracle.com>
parents: 9200
diff changeset
27
9200
9be78aeab2e1 temporaries are recorded for compiled stubs, allowing for better register allocation around calls to such stubs (GRAAL-210)
Doug Simon <doug.simon@oracle.com>
parents: 9015
diff changeset
28 import java.util.*;
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
29
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
30 import com.oracle.graal.api.code.*;
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
31 import com.oracle.graal.api.meta.*;
15193
96bb07a5d667 Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents: 15161
diff changeset
32 import com.oracle.graal.compiler.common.*;
7836
a202f72872a4 Remove usage of left-over fields in GraalCompiler.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7835
diff changeset
33 import com.oracle.graal.compiler.target.*;
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
34 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: 12431
diff changeset
35 import com.oracle.graal.debug.Debug.Scope;
9200
9be78aeab2e1 temporaries are recorded for compiled stubs, allowing for better register allocation around calls to such stubs (GRAAL-210)
Doug Simon <doug.simon@oracle.com>
parents: 9015
diff changeset
36 import com.oracle.graal.debug.internal.*;
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
37 import com.oracle.graal.hotspot.*;
9654
18632807db02 RuntimeStub installation support is now more distinct from normal nmethod installation
Doug Simon <doug.simon@oracle.com>
parents: 9621
diff changeset
38 import com.oracle.graal.hotspot.bridge.CompilerToVM.CodeInstallResult;
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
39 import com.oracle.graal.hotspot.meta.*;
9417
ffa27c3058e9 minor simplifications for writing compiled stubs
Doug Simon <doug.simon@oracle.com>
parents: 9352
diff changeset
40 import com.oracle.graal.hotspot.nodes.*;
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
41 import com.oracle.graal.lir.asm.*;
19232
66c60942c06c GraalCompiler.emitLowLevel: use LowLevelSuites instead of LowLevelCompilerConfiguration.
Josef Eisl <josef.eisl@jku.at>
parents: 18959
diff changeset
42 import com.oracle.graal.lir.phases.*;
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
43 import com.oracle.graal.nodes.*;
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
44 import com.oracle.graal.phases.*;
15011
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14559
diff changeset
45 import com.oracle.graal.phases.schedule.*;
16458
162c6fba1168 start Stub compilation at mid tier
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16401
diff changeset
46 import com.oracle.graal.phases.tiers.*;
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
47
9342
e8dc8748f415 added check for JaCoCo methods being inserted into replacement methods
Doug Simon <doug.simon@oracle.com>
parents: 9338
diff changeset
48 //JaCoCo Exclude
e8dc8748f415 added check for JaCoCo methods being inserted into replacement methods
Doug Simon <doug.simon@oracle.com>
parents: 9338
diff changeset
49
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
50 /**
9617
c1ef2bf6848e removed the requirement that a compiled stub is implemented by a snippet
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
51 * Base class for implementing some low level code providing the out-of-line slow path for a snippet
c1ef2bf6848e removed the requirement that a compiled stub is implemented by a snippet
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
52 * and/or a callee saved call to a HotSpot C/C++ runtime function or even a another compiled Java
c1ef2bf6848e removed the requirement that a compiled stub is implemented by a snippet
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
53 * method.
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
54 */
9617
c1ef2bf6848e removed the requirement that a compiled stub is implemented by a snippet
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
55 public abstract class Stub {
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
56
18959
7efef7005e53 provide Stub.getStubs() method to access all installed stubs
Doug Simon <doug.simon@oracle.com>
parents: 18845
diff changeset
57 private static final List<Stub> stubs = new ArrayList<>();
7efef7005e53 provide Stub.getStubs() method to access all installed stubs
Doug Simon <doug.simon@oracle.com>
parents: 18845
diff changeset
58
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
59 /**
9660
c37c52445e75 javadoc fixes
Doug Simon <doug.simon@oracle.com>
parents: 9654
diff changeset
60 * The linkage information for a call to this stub from compiled code.
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
61 */
9740
c4b1aa93b9af rename: HotSpotRuntimeCallTarget -> HotSpotForeignCallLinkage
Doug Simon <doug.simon@oracle.com>
parents: 9669
diff changeset
62 protected final HotSpotForeignCallLinkage linkage;
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
63
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
64 /**
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
65 * The code installed for the stub.
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
66 */
9200
9be78aeab2e1 temporaries are recorded for compiled stubs, allowing for better register allocation around calls to such stubs (GRAAL-210)
Doug Simon <doug.simon@oracle.com>
parents: 9015
diff changeset
67 protected InstalledCode code;
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
68
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
69 /**
16182
0a7e9347f8d0 Add an ability to specify the signature of a C/C++ foreign function in HotSpotVMConfig and get the full symbol string; add a couple of convenience getters and setters for stubs with foreign call linkage.
bharadwaj
parents: 15259
diff changeset
70 * Compilation result from which {@link #code} was created.
0a7e9347f8d0 Add an ability to specify the signature of a C/C++ foreign function in HotSpotVMConfig and get the full symbol string; add a couple of convenience getters and setters for stubs with foreign call linkage.
bharadwaj
parents: 15259
diff changeset
71 */
0a7e9347f8d0 Add an ability to specify the signature of a C/C++ foreign function in HotSpotVMConfig and get the full symbol string; add a couple of convenience getters and setters for stubs with foreign call linkage.
bharadwaj
parents: 15259
diff changeset
72 protected CompilationResult compResult;
0a7e9347f8d0 Add an ability to specify the signature of a C/C++ foreign function in HotSpotVMConfig and get the full symbol string; add a couple of convenience getters and setters for stubs with foreign call linkage.
bharadwaj
parents: 15259
diff changeset
73
0a7e9347f8d0 Add an ability to specify the signature of a C/C++ foreign function in HotSpotVMConfig and get the full symbol string; add a couple of convenience getters and setters for stubs with foreign call linkage.
bharadwaj
parents: 15259
diff changeset
74 /**
9491
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
75 * The registers destroyed by this stub.
9200
9be78aeab2e1 temporaries are recorded for compiled stubs, allowing for better register allocation around calls to such stubs (GRAAL-210)
Doug Simon <doug.simon@oracle.com>
parents: 9015
diff changeset
76 */
9491
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
77 private Set<Register> destroyedRegisters;
9200
9be78aeab2e1 temporaries are recorded for compiled stubs, allowing for better register allocation around calls to such stubs (GRAAL-210)
Doug Simon <doug.simon@oracle.com>
parents: 9015
diff changeset
78
9491
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
79 public void initDestroyedRegisters(Set<Register> registers) {
9200
9be78aeab2e1 temporaries are recorded for compiled stubs, allowing for better register allocation around calls to such stubs (GRAAL-210)
Doug Simon <doug.simon@oracle.com>
parents: 9015
diff changeset
80 assert registers != null;
9491
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
81 assert destroyedRegisters == null || registers.equals(destroyedRegisters) : "cannot redefine";
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
82 destroyedRegisters = registers;
9200
9be78aeab2e1 temporaries are recorded for compiled stubs, allowing for better register allocation around calls to such stubs (GRAAL-210)
Doug Simon <doug.simon@oracle.com>
parents: 9015
diff changeset
83 }
9be78aeab2e1 temporaries are recorded for compiled stubs, allowing for better register allocation around calls to such stubs (GRAAL-210)
Doug Simon <doug.simon@oracle.com>
parents: 9015
diff changeset
84
9491
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
85 /**
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
86 * Gets the registers defined by this stub. These are the temporaries of this stub and must thus
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
87 * be caller saved by a callers of this stub.
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
88 */
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
89 public Set<Register> getDestroyedRegisters() {
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
90 assert destroyedRegisters != null : "not yet initialized";
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
91 return destroyedRegisters;
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
92 }
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
93
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
94 /**
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
95 * Determines if this stub preserves all registers apart from those it
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
96 * {@linkplain #getDestroyedRegisters() destroys}.
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
97 */
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
98 public boolean preservesRegisters() {
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
99 return true;
9200
9be78aeab2e1 temporaries are recorded for compiled stubs, allowing for better register allocation around calls to such stubs (GRAAL-210)
Doug Simon <doug.simon@oracle.com>
parents: 9015
diff changeset
100 }
9be78aeab2e1 temporaries are recorded for compiled stubs, allowing for better register allocation around calls to such stubs (GRAAL-210)
Doug Simon <doug.simon@oracle.com>
parents: 9015
diff changeset
101
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12362
diff changeset
102 protected final HotSpotProviders providers;
9617
c1ef2bf6848e removed the requirement that a compiled stub is implemented by a snippet
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
103
9200
9be78aeab2e1 temporaries are recorded for compiled stubs, allowing for better register allocation around calls to such stubs (GRAAL-210)
Doug Simon <doug.simon@oracle.com>
parents: 9015
diff changeset
104 /**
9617
c1ef2bf6848e removed the requirement that a compiled stub is implemented by a snippet
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
105 * Creates a new stub.
15161
2c940b1a48d8 Convert InstalledCode from an interface into an abstract class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15011
diff changeset
106 *
8627
75db7afee829 implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents: 8422
diff changeset
107 * @param linkage linkage details for a call to the stub
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
108 */
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12362
diff changeset
109 public Stub(HotSpotProviders providers, HotSpotForeignCallLinkage linkage) {
8627
75db7afee829 implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents: 8422
diff changeset
110 this.linkage = linkage;
12054
bba234a1670e grouped provider values/parameters into a Providers object (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12052
diff changeset
111 this.providers = providers;
18959
7efef7005e53 provide Stub.getStubs() method to access all installed stubs
Doug Simon <doug.simon@oracle.com>
parents: 18845
diff changeset
112 stubs.add(this);
7efef7005e53 provide Stub.getStubs() method to access all installed stubs
Doug Simon <doug.simon@oracle.com>
parents: 18845
diff changeset
113 }
7efef7005e53 provide Stub.getStubs() method to access all installed stubs
Doug Simon <doug.simon@oracle.com>
parents: 18845
diff changeset
114
7efef7005e53 provide Stub.getStubs() method to access all installed stubs
Doug Simon <doug.simon@oracle.com>
parents: 18845
diff changeset
115 /**
7efef7005e53 provide Stub.getStubs() method to access all installed stubs
Doug Simon <doug.simon@oracle.com>
parents: 18845
diff changeset
116 * Gets an immutable view of all stubs that have been created.
7efef7005e53 provide Stub.getStubs() method to access all installed stubs
Doug Simon <doug.simon@oracle.com>
parents: 18845
diff changeset
117 */
7efef7005e53 provide Stub.getStubs() method to access all installed stubs
Doug Simon <doug.simon@oracle.com>
parents: 18845
diff changeset
118 public static Collection<Stub> getStubs() {
7efef7005e53 provide Stub.getStubs() method to access all installed stubs
Doug Simon <doug.simon@oracle.com>
parents: 18845
diff changeset
119 return Collections.unmodifiableList(stubs);
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
120 }
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
121
9660
c37c52445e75 javadoc fixes
Doug Simon <doug.simon@oracle.com>
parents: 9654
diff changeset
122 /**
c37c52445e75 javadoc fixes
Doug Simon <doug.simon@oracle.com>
parents: 9654
diff changeset
123 * Gets the linkage for a call to this stub from compiled code.
c37c52445e75 javadoc fixes
Doug Simon <doug.simon@oracle.com>
parents: 9654
diff changeset
124 */
9740
c4b1aa93b9af rename: HotSpotRuntimeCallTarget -> HotSpotForeignCallLinkage
Doug Simon <doug.simon@oracle.com>
parents: 9669
diff changeset
125 public HotSpotForeignCallLinkage getLinkage() {
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
126 return linkage;
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
127 }
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
128
15011
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14559
diff changeset
129 public RegisterConfig getRegisterConfig() {
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14559
diff changeset
130 return null;
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14559
diff changeset
131 }
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14559
diff changeset
132
9660
c37c52445e75 javadoc fixes
Doug Simon <doug.simon@oracle.com>
parents: 9654
diff changeset
133 /**
c37c52445e75 javadoc fixes
Doug Simon <doug.simon@oracle.com>
parents: 9654
diff changeset
134 * Gets the graph that from which the code for this stub will be compiled.
c37c52445e75 javadoc fixes
Doug Simon <doug.simon@oracle.com>
parents: 9654
diff changeset
135 */
9617
c1ef2bf6848e removed the requirement that a compiled stub is implemented by a snippet
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
136 protected abstract StructuredGraph getGraph();
c1ef2bf6848e removed the requirement that a compiled stub is implemented by a snippet
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
137
c1ef2bf6848e removed the requirement that a compiled stub is implemented by a snippet
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
138 @Override
9654
18632807db02 RuntimeStub installation support is now more distinct from normal nmethod installation
Doug Simon <doug.simon@oracle.com>
parents: 9621
diff changeset
139 public String toString() {
18632807db02 RuntimeStub installation support is now more distinct from normal nmethod installation
Doug Simon <doug.simon@oracle.com>
parents: 9621
diff changeset
140 return "Stub<" + linkage.getDescriptor() + ">";
18632807db02 RuntimeStub installation support is now more distinct from normal nmethod installation
Doug Simon <doug.simon@oracle.com>
parents: 9621
diff changeset
141 }
9617
c1ef2bf6848e removed the requirement that a compiled stub is implemented by a snippet
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
142
c1ef2bf6848e removed the requirement that a compiled stub is implemented by a snippet
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
143 /**
15161
2c940b1a48d8 Convert InstalledCode from an interface into an abstract class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15011
diff changeset
144 * Gets the method the stub's code will be associated with once installed. This may be null.
9617
c1ef2bf6848e removed the requirement that a compiled stub is implemented by a snippet
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
145 */
9621
e97dc9bbfedc introduced installedCodeOwner parameter of type ResolvedJavaMethod to GraalCompiler.compileGraph to properly distinguish the source method of a graph from the method under which the code compiled for the graph will be installed
Doug Simon <doug.simon@oracle.com>
parents: 9620
diff changeset
146 protected abstract ResolvedJavaMethod getInstalledCodeOwner();
9617
c1ef2bf6848e removed the requirement that a compiled stub is implemented by a snippet
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
147
9654
18632807db02 RuntimeStub installation support is now more distinct from normal nmethod installation
Doug Simon <doug.simon@oracle.com>
parents: 9621
diff changeset
148 /**
18632807db02 RuntimeStub installation support is now more distinct from normal nmethod installation
Doug Simon <doug.simon@oracle.com>
parents: 9621
diff changeset
149 * Gets a context object for the debug scope created when producing the code for this stub.
18632807db02 RuntimeStub installation support is now more distinct from normal nmethod installation
Doug Simon <doug.simon@oracle.com>
parents: 9621
diff changeset
150 */
18632807db02 RuntimeStub installation support is now more distinct from normal nmethod installation
Doug Simon <doug.simon@oracle.com>
parents: 9621
diff changeset
151 protected abstract Object debugScopeContext();
9620
0eda2b7df748 fixed debug scope processing so that -G:MethodFilter option works as expected
Doug Simon <doug.simon@oracle.com>
parents: 9618
diff changeset
152
9418
8d3a7fb9eb5f moved binding of parameter locations to runtime call descriptors from platform specific code to shared code for stubs that are now compiled stubs
Doug Simon <doug.simon@oracle.com>
parents: 9417
diff changeset
153 /**
9200
9be78aeab2e1 temporaries are recorded for compiled stubs, allowing for better register allocation around calls to such stubs (GRAAL-210)
Doug Simon <doug.simon@oracle.com>
parents: 9015
diff changeset
154 * Gets the code for this stub, compiling it first if necessary.
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
155 */
9200
9be78aeab2e1 temporaries are recorded for compiled stubs, allowing for better register allocation around calls to such stubs (GRAAL-210)
Doug Simon <doug.simon@oracle.com>
parents: 9015
diff changeset
156 public synchronized InstalledCode getCode(final Backend backend) {
9be78aeab2e1 temporaries are recorded for compiled stubs, allowing for better register allocation around calls to such stubs (GRAAL-210)
Doug Simon <doug.simon@oracle.com>
parents: 9015
diff changeset
157 if (code == null) {
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: 12431
diff changeset
158 try (Scope d = Debug.sandbox("CompilingStub", DebugScope.getConfig(), providers.getCodeCache(), debugScopeContext())) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
159 final StructuredGraph graph = getGraph();
19250
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19232
diff changeset
160 assert !graph.getAssumptions().useOptimisticAssumptions();
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: 12431
diff changeset
161 if (!(graph.start() instanceof StubStartNode)) {
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18176
diff changeset
162 StubStartNode newStart = graph.add(new StubStartNode(Stub.this));
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: 12431
diff changeset
163 newStart.setStateAfter(graph.start().stateAfter());
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
164 graph.replaceFixed(graph.start(), newStart);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
165 }
9200
9be78aeab2e1 temporaries are recorded for compiled stubs, allowing for better register allocation around calls to such stubs (GRAAL-210)
Doug Simon <doug.simon@oracle.com>
parents: 9015
diff changeset
166
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: 12431
diff changeset
167 CodeCacheProvider codeCache = providers.getCodeCache();
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
168 // The stub itself needs the incoming calling convention.
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
169 CallingConvention incomingCc = linkage.getIncomingCallingConvention();
15011
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14559
diff changeset
170 TargetDescription target = codeCache.getTarget();
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14559
diff changeset
171
16401
347915b8cea8 Move name from HotSpotNmethod to InstalledCode to have a name again for truffle nmethods.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 16182
diff changeset
172 compResult = new CompilationResult(toString());
15011
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14559
diff changeset
173 try (Scope s0 = Debug.scope("StubCompilation", graph, providers.getCodeCache())) {
16458
162c6fba1168 start Stub compilation at mid tier
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16401
diff changeset
174 Suites defaultSuites = providers.getSuites().getDefaultSuites();
162c6fba1168 start Stub compilation at mid tier
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16401
diff changeset
175 Suites suites = new Suites(new PhaseSuite<>(), defaultSuites.getMidTier(), defaultSuites.getLowTier());
19250
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19232
diff changeset
176 SchedulePhase schedule = emitFrontEnd(providers, target, graph, null, providers.getSuites().getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL, getProfilingInfo(graph),
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19232
diff changeset
177 null, suites);
19232
66c60942c06c GraalCompiler.emitLowLevel: use LowLevelSuites instead of LowLevelCompilerConfiguration.
Josef Eisl <josef.eisl@jku.at>
parents: 18959
diff changeset
178 LowLevelSuites lowLevelSuites = providers.getSuites().getDefaultLowLevelSuites();
19250
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19232
diff changeset
179 emitBackEnd(graph, Stub.this, incomingCc, getInstalledCodeOwner(), backend, target, compResult, CompilationResultBuilderFactory.Default, schedule,
19232
66c60942c06c GraalCompiler.emitLowLevel: use LowLevelSuites instead of LowLevelCompilerConfiguration.
Josef Eisl <josef.eisl@jku.at>
parents: 18959
diff changeset
180 getRegisterConfig(), lowLevelSuites);
19250
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19232
diff changeset
181 } catch (Throwable e) {
15011
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14559
diff changeset
182 throw Debug.handle(e);
c8e575742f36 allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14559
diff changeset
183 }
9200
9be78aeab2e1 temporaries are recorded for compiled stubs, allowing for better register allocation around calls to such stubs (GRAAL-210)
Doug Simon <doug.simon@oracle.com>
parents: 9015
diff changeset
184
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: 12431
diff changeset
185 assert destroyedRegisters != null;
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
186 try (Scope s = Debug.scope("CodeInstall")) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
187 Stub stub = Stub.this;
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
188 HotSpotRuntimeStub installedCode = new HotSpotRuntimeStub(stub);
18176
c2270ad35f57 Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents: 16895
diff changeset
189 HotSpotCompiledCode hsCompResult = new HotSpotCompiledRuntimeStub(stub, compResult);
13233
8ea51438445c consolidated logging and dumping of InstalledCode to HotSpotCodeCacheProvider
Doug Simon <doug.simon@oracle.com>
parents: 13229
diff changeset
190
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: 12431
diff changeset
191 CodeInstallResult result = runtime().getCompilerToVM().installCode(hsCompResult, installedCode, null);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
192 if (result != CodeInstallResult.OK) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
193 throw new GraalInternalError("Error installing stub %s: %s", Stub.this, result);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
194 }
13233
8ea51438445c consolidated logging and dumping of InstalledCode to HotSpotCodeCacheProvider
Doug Simon <doug.simon@oracle.com>
parents: 13229
diff changeset
195 ((HotSpotCodeCacheProvider) codeCache).logOrDump(installedCode, compResult);
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: 12431
diff changeset
196 code = installedCode;
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
197 } 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: 12431
diff changeset
198 throw Debug.handle(e);
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
199 }
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: 12431
diff changeset
200 } 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: 12431
diff changeset
201 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: 12431
diff changeset
202 }
9617
c1ef2bf6848e removed the requirement that a compiled stub is implemented by a snippet
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
203 assert code != null : "error installing stub " + this;
8627
75db7afee829 implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents: 8422
diff changeset
204 }
16182
0a7e9347f8d0 Add an ability to specify the signature of a C/C++ foreign function in HotSpotVMConfig and get the full symbol string; add a couple of convenience getters and setters for stubs with foreign call linkage.
bharadwaj
parents: 15259
diff changeset
205
9200
9be78aeab2e1 temporaries are recorded for compiled stubs, allowing for better register allocation around calls to such stubs (GRAAL-210)
Doug Simon <doug.simon@oracle.com>
parents: 9015
diff changeset
206 return code;
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
207 }
16182
0a7e9347f8d0 Add an ability to specify the signature of a C/C++ foreign function in HotSpotVMConfig and get the full symbol string; add a couple of convenience getters and setters for stubs with foreign call linkage.
bharadwaj
parents: 15259
diff changeset
208
0a7e9347f8d0 Add an ability to specify the signature of a C/C++ foreign function in HotSpotVMConfig and get the full symbol string; add a couple of convenience getters and setters for stubs with foreign call linkage.
bharadwaj
parents: 15259
diff changeset
209 /**
0a7e9347f8d0 Add an ability to specify the signature of a C/C++ foreign function in HotSpotVMConfig and get the full symbol string; add a couple of convenience getters and setters for stubs with foreign call linkage.
bharadwaj
parents: 15259
diff changeset
210 * Gets the compilation result for this stub, compiling it first if necessary, and installing it
0a7e9347f8d0 Add an ability to specify the signature of a C/C++ foreign function in HotSpotVMConfig and get the full symbol string; add a couple of convenience getters and setters for stubs with foreign call linkage.
bharadwaj
parents: 15259
diff changeset
211 * in code.
0a7e9347f8d0 Add an ability to specify the signature of a C/C++ foreign function in HotSpotVMConfig and get the full symbol string; add a couple of convenience getters and setters for stubs with foreign call linkage.
bharadwaj
parents: 15259
diff changeset
212 */
0a7e9347f8d0 Add an ability to specify the signature of a C/C++ foreign function in HotSpotVMConfig and get the full symbol string; add a couple of convenience getters and setters for stubs with foreign call linkage.
bharadwaj
parents: 15259
diff changeset
213 public synchronized CompilationResult getCompilationResult(final Backend backend) {
0a7e9347f8d0 Add an ability to specify the signature of a C/C++ foreign function in HotSpotVMConfig and get the full symbol string; add a couple of convenience getters and setters for stubs with foreign call linkage.
bharadwaj
parents: 15259
diff changeset
214 if (code == null) {
0a7e9347f8d0 Add an ability to specify the signature of a C/C++ foreign function in HotSpotVMConfig and get the full symbol string; add a couple of convenience getters and setters for stubs with foreign call linkage.
bharadwaj
parents: 15259
diff changeset
215 getCode(backend);
0a7e9347f8d0 Add an ability to specify the signature of a C/C++ foreign function in HotSpotVMConfig and get the full symbol string; add a couple of convenience getters and setters for stubs with foreign call linkage.
bharadwaj
parents: 15259
diff changeset
216 }
0a7e9347f8d0 Add an ability to specify the signature of a C/C++ foreign function in HotSpotVMConfig and get the full symbol string; add a couple of convenience getters and setters for stubs with foreign call linkage.
bharadwaj
parents: 15259
diff changeset
217 return compResult;
0a7e9347f8d0 Add an ability to specify the signature of a C/C++ foreign function in HotSpotVMConfig and get the full symbol string; add a couple of convenience getters and setters for stubs with foreign call linkage.
bharadwaj
parents: 15259
diff changeset
218 }
7143
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
219 }