annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java @ 9968:3df534c97af1

Create Suites instance in runtime.
author Roland Schatz <roland.schatz@oracle.com>
date Mon, 10 Jun 2013 16:06:09 +0200
parents c010c12ab682
children 9c7d9e2c8326
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 /*
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
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
9452
c1ba734c1ea0 more extensive checking of compiled stub invariants
Doug Simon <doug.simon@oracle.com>
parents: 9420
diff changeset
25 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
26
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
27 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
28 import java.util.concurrent.*;
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.*;
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
32 import com.oracle.graal.compiler.*;
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.*;
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
35 import com.oracle.graal.debug.internal.*;
9654
18632807db02 RuntimeStub installation support is now more distinct from normal nmethod installation
Doug Simon <doug.simon@oracle.com>
parents: 9621
diff changeset
36 import com.oracle.graal.graph.*;
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.*;
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
41 import com.oracle.graal.java.*;
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
42 import com.oracle.graal.nodes.*;
8637
ce5750014c3d moved Replacements and MacroSubstitution from the graal.api.replacements project to graal.nodes project and reversed the dependency between these two projects (the latter now/again depends on the former)
Doug Simon <doug.simon@oracle.com>
parents: 8636
diff changeset
43 import com.oracle.graal.nodes.spi.*;
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
44 import com.oracle.graal.phases.*;
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
45 import com.oracle.graal.phases.PhasePlan.PhasePosition;
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
46
9342
e8dc8748f415 added check for JaCoCo methods being inserted into replacement methods
Doug Simon <doug.simon@oracle.com>
parents: 9338
diff changeset
47 //JaCoCo Exclude
e8dc8748f415 added check for JaCoCo methods being inserted into replacement methods
Doug Simon <doug.simon@oracle.com>
parents: 9338
diff changeset
48
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
49 /**
9617
c1ef2bf6848e removed the requirement that a compiled stub is implemented by a snippet
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
50 * 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
51 * 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
52 * 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
53 */
9617
c1ef2bf6848e removed the requirement that a compiled stub is implemented by a snippet
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
54 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
55
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 /**
9660
c37c52445e75 javadoc fixes
Doug Simon <doug.simon@oracle.com>
parents: 9654
diff changeset
57 * 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
58 */
9740
c4b1aa93b9af rename: HotSpotRuntimeCallTarget -> HotSpotForeignCallLinkage
Doug Simon <doug.simon@oracle.com>
parents: 9669
diff changeset
59 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
60
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 /**
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
62 * 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
63 */
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
64 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
65
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 /**
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
67 * 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
68 */
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
69 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
70
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
71 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
72 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
73 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
74 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
75 }
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 /**
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
78 * 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
79 * 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
80 */
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 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
82 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
83 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
84 }
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 /**
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 * 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
88 * {@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
89 */
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 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
91 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
92 }
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
93
9617
c1ef2bf6848e removed the requirement that a compiled stub is implemented by a snippet
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
94 protected final HotSpotRuntime runtime;
c1ef2bf6848e removed the requirement that a compiled stub is implemented by a snippet
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
95
c1ef2bf6848e removed the requirement that a compiled stub is implemented by a snippet
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
96 protected final Replacements replacements;
c1ef2bf6848e removed the requirement that a compiled stub is implemented by a snippet
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
97
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
98 /**
9617
c1ef2bf6848e removed the requirement that a compiled stub is implemented by a snippet
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
99 * Creates a new stub.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7144
diff changeset
100 *
8627
75db7afee829 implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents: 8422
diff changeset
101 * @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
102 */
9740
c4b1aa93b9af rename: HotSpotRuntimeCallTarget -> HotSpotForeignCallLinkage
Doug Simon <doug.simon@oracle.com>
parents: 9669
diff changeset
103 public Stub(HotSpotRuntime runtime, Replacements replacements, HotSpotForeignCallLinkage linkage) {
8627
75db7afee829 implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents: 8422
diff changeset
104 this.linkage = linkage;
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 this.runtime = runtime;
c1ef2bf6848e removed the requirement that a compiled stub is implemented by a snippet
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
106 this.replacements = replacements;
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
107 }
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
9660
c37c52445e75 javadoc fixes
Doug Simon <doug.simon@oracle.com>
parents: 9654
diff changeset
109 /**
c37c52445e75 javadoc fixes
Doug Simon <doug.simon@oracle.com>
parents: 9654
diff changeset
110 * 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
111 */
9740
c4b1aa93b9af rename: HotSpotRuntimeCallTarget -> HotSpotForeignCallLinkage
Doug Simon <doug.simon@oracle.com>
parents: 9669
diff changeset
112 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
113 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
114 }
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
115
9660
c37c52445e75 javadoc fixes
Doug Simon <doug.simon@oracle.com>
parents: 9654
diff changeset
116 /**
c37c52445e75 javadoc fixes
Doug Simon <doug.simon@oracle.com>
parents: 9654
diff changeset
117 * 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
118 */
9617
c1ef2bf6848e removed the requirement that a compiled stub is implemented by a snippet
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
119 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
120
c1ef2bf6848e removed the requirement that a compiled stub is implemented by a snippet
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
121 @Override
9654
18632807db02 RuntimeStub installation support is now more distinct from normal nmethod installation
Doug Simon <doug.simon@oracle.com>
parents: 9621
diff changeset
122 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
123 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
124 }
9617
c1ef2bf6848e removed the requirement that a compiled stub is implemented by a snippet
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
125
c1ef2bf6848e removed the requirement that a compiled stub is implemented by a snippet
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
126 /**
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
127 * Gets the method the stub's code will be {@linkplain InstalledCode#getMethod() associated}
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
128 * 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
129 */
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
130 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
131
9654
18632807db02 RuntimeStub installation support is now more distinct from normal nmethod installation
Doug Simon <doug.simon@oracle.com>
parents: 9621
diff changeset
132 /**
18632807db02 RuntimeStub installation support is now more distinct from normal nmethod installation
Doug Simon <doug.simon@oracle.com>
parents: 9621
diff changeset
133 * 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
134 */
18632807db02 RuntimeStub installation support is now more distinct from normal nmethod installation
Doug Simon <doug.simon@oracle.com>
parents: 9621
diff changeset
135 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
136
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
137 /**
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
138 * 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
139 */
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
140 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
141 if (code == null) {
9620
0eda2b7df748 fixed debug scope processing so that -G:MethodFilter option works as expected
Doug Simon <doug.simon@oracle.com>
parents: 9618
diff changeset
142 Debug.sandbox("CompilingStub", new Object[]{runtime, debugScopeContext()}, DebugScope.getConfig(), new Runnable() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7144
diff changeset
143
8627
75db7afee829 implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents: 8422
diff changeset
144 @Override
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
145 public void run() {
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
146
9620
0eda2b7df748 fixed debug scope processing so that -G:MethodFilter option works as expected
Doug Simon <doug.simon@oracle.com>
parents: 9618
diff changeset
147 final StructuredGraph graph = getGraph();
9654
18632807db02 RuntimeStub installation support is now more distinct from normal nmethod installation
Doug Simon <doug.simon@oracle.com>
parents: 9621
diff changeset
148 if (!(graph.start() instanceof StubStartNode)) {
18632807db02 RuntimeStub installation support is now more distinct from normal nmethod installation
Doug Simon <doug.simon@oracle.com>
parents: 9621
diff changeset
149 StubStartNode newStart = graph.add(new StubStartNode(Stub.this));
18632807db02 RuntimeStub installation support is now more distinct from normal nmethod installation
Doug Simon <doug.simon@oracle.com>
parents: 9621
diff changeset
150 newStart.setStateAfter(graph.start().stateAfter());
18632807db02 RuntimeStub installation support is now more distinct from normal nmethod installation
Doug Simon <doug.simon@oracle.com>
parents: 9621
diff changeset
151 graph.replaceFixed(graph.start(), newStart);
18632807db02 RuntimeStub installation support is now more distinct from normal nmethod installation
Doug Simon <doug.simon@oracle.com>
parents: 9621
diff changeset
152 }
9613
0c17815817a4 removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents: 9612
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 PhasePlan phasePlan = new PhasePlan();
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
155 GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.ALL);
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 phasePlan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase);
9612
66db0353f55a compilation is explicitly given a CallingConvention for the graph being compiled instead of deriving it from a method
Doug Simon <doug.simon@oracle.com>
parents: 9582
diff changeset
157 CallingConvention cc = linkage.getCallingConvention();
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
158 final CompilationResult compResult = GraalCompiler.compileGraph(graph, cc, getInstalledCodeOwner(), runtime, replacements, backend, runtime.getTarget(), null, phasePlan,
9968
3df534c97af1 Create Suites instance in runtime.
Roland Schatz <roland.schatz@oracle.com>
parents: 9813
diff changeset
159 OptimisticOptimizations.ALL, new SpeculationLog(), runtime.getDefaultSuites());
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
160
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
161 assert destroyedRegisters != null;
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
162 code = Debug.scope("CodeInstall", new Callable<InstalledCode>() {
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
163
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
164 @Override
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
165 public InstalledCode call() {
9654
18632807db02 RuntimeStub installation support is now more distinct from normal nmethod installation
Doug Simon <doug.simon@oracle.com>
parents: 9621
diff changeset
166 Stub stub = Stub.this;
9668
fe9a18fbb15e added subclasses for HotSpotInstalledCode: HotSpotNmethod and HotSpotRuntimeStub
Doug Simon <doug.simon@oracle.com>
parents: 9660
diff changeset
167 HotSpotRuntimeStub installedCode = new HotSpotRuntimeStub(stub);
9669
ed6202820ecf renamed HotSpotCompilationResult to HotSpotCompiledCode and added subclasses HotSpotCompiledNmethod and HotSpotCompiledRuntimeStub
Doug Simon <doug.simon@oracle.com>
parents: 9668
diff changeset
168 HotSpotCompiledCode hsCompResult = new HotSpotCompiledRuntimeStub(stub, compResult);
9654
18632807db02 RuntimeStub installation support is now more distinct from normal nmethod installation
Doug Simon <doug.simon@oracle.com>
parents: 9621
diff changeset
169 CodeInstallResult result = graalRuntime().getCompilerToVM().installCode(hsCompResult, installedCode, null);
18632807db02 RuntimeStub installation support is now more distinct from normal nmethod installation
Doug Simon <doug.simon@oracle.com>
parents: 9621
diff changeset
170 if (result != CodeInstallResult.OK) {
18632807db02 RuntimeStub installation support is now more distinct from normal nmethod installation
Doug Simon <doug.simon@oracle.com>
parents: 9621
diff changeset
171 throw new GraalInternalError("Error installing stub %s: %s", Stub.this, result);
18632807db02 RuntimeStub installation support is now more distinct from normal nmethod installation
Doug Simon <doug.simon@oracle.com>
parents: 9621
diff changeset
172 }
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
173 if (Debug.isDumpEnabled()) {
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
174 Debug.dump(new Object[]{compResult, installedCode}, "After code installation");
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
175 }
9813
c010c12ab682 put disassembling of installed code under the control of Debug.log(); use -G:Log=CodeInstall to show disassembly for all installed code
Doug Simon <doug.simon@oracle.com>
parents: 9740
diff changeset
176 if (Debug.isLogEnabled()) {
c010c12ab682 put disassembling of installed code under the control of Debug.log(); use -G:Log=CodeInstall to show disassembly for all installed code
Doug Simon <doug.simon@oracle.com>
parents: 9740
diff changeset
177 Debug.log("%s", runtime.disassemble(installedCode));
c010c12ab682 put disassembling of installed code under the control of Debug.log(); use -G:Log=CodeInstall to show disassembly for all installed code
Doug Simon <doug.simon@oracle.com>
parents: 9740
diff changeset
178 }
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
179 return installedCode;
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
180 }
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
181 });
9654
18632807db02 RuntimeStub installation support is now more distinct from normal nmethod installation
Doug Simon <doug.simon@oracle.com>
parents: 9621
diff changeset
182
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
183 }
8627
75db7afee829 implemented lazy installation of replacements (GRAAL-137)
Doug Simon <doug.simon@oracle.com>
parents: 8422
diff changeset
184 });
9617
c1ef2bf6848e removed the requirement that a compiled stub is implemented by a snippet
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
185 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
186 }
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
187 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
188 }
445193cc2a7d added support for writing stubs in Java and wrote the TLAB fast refill stub
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
189 }