Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java @ 13318:da0851712519
moved emitting code for LIR and queries about whether an edge goes to its lexical successor "inside" CompilationResultBuilder
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 13 Dec 2013 14:05:48 +0100 |
parents | 733cccc125ed |
children | fb7b39f07232 |
rev | line source |
---|---|
5233
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 */ |
6495
75f130f2b30f
moved AMD64 specific HotSpot code in com.oracle.graal.hotspot.amd64 project
Doug Simon <doug.simon@oracle.com>
parents:
6494
diff
changeset
|
23 package com.oracle.graal.hotspot.amd64; |
5233
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
6580
d56d600819fe
moved AMD64 into its own (new) project: com.oracle.graal.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
25 import static com.oracle.graal.amd64.AMD64.*; |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
26 import static com.oracle.graal.api.code.CallingConvention.Type.*; |
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
27 import static com.oracle.graal.api.code.ValueUtil.*; |
8290
9882af5c8504
AMD64 HotSpot backend now models RBP as an incoming parameter that must be preserved until the end of the method. For non-leaf methods, the value is preserved in the special stack slot required by the HotSpot runtime for walking/inspecting frames of such methods.
Doug Simon <doug.simon@oracle.com>
parents:
8282
diff
changeset
|
28 import static com.oracle.graal.phases.GraalOptions.*; |
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:
9615
diff
changeset
|
29 import static java.lang.reflect.Modifier.*; |
5233
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
30 |
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:
8370
diff
changeset
|
31 import java.util.*; |
5233
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
32 |
7841
674a8b9e62f8
Remove unused fields in TargetDescription. Use Unsafe.pageSize().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7839
diff
changeset
|
33 import sun.misc.*; |
674a8b9e62f8
Remove unused fields in TargetDescription. Use Unsafe.pageSize().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7839
diff
changeset
|
34 |
6580
d56d600819fe
moved AMD64 into its own (new) project: com.oracle.graal.amd64
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
35 import com.oracle.graal.amd64.*; |
5510
426c605c9d3c
Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5507
diff
changeset
|
36 import com.oracle.graal.api.code.*; |
5507
dc71b06d09f8
Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5506
diff
changeset
|
37 import com.oracle.graal.api.meta.*; |
6531
4afe23aa0a00
renamed packages: com.oracle.max.asm... -> com.oracle.graal.asm...
Doug Simon <doug.simon@oracle.com>
parents:
6525
diff
changeset
|
38 import com.oracle.graal.asm.*; |
8167
7f57c30575c8
Make AMD64Address a low-level representation for use by the assembler only.
Roland Schatz <roland.schatz@oracle.com>
parents:
8166
diff
changeset
|
39 import com.oracle.graal.asm.amd64.*; |
6950
41938af2b3d8
modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents:
6676
diff
changeset
|
40 import com.oracle.graal.asm.amd64.AMD64Assembler.ConditionFlag; |
5233
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
41 import com.oracle.graal.compiler.gen.*; |
12502
28f56bf7c06a
added support code for Truffle to inject special tail-call code into the prefix of OptimizedCallTarget.call(PackedFrame, Arguments)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
42 import com.oracle.graal.compiler.target.*; |
5233
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
43 import com.oracle.graal.hotspot.*; |
6462 | 44 import com.oracle.graal.hotspot.bridge.*; |
5548
8872bc0eebdf
Renaming hotspot.ri => hotspot.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5547
diff
changeset
|
45 import com.oracle.graal.hotspot.meta.*; |
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:
8370
diff
changeset
|
46 import com.oracle.graal.hotspot.stubs.*; |
5233
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 import com.oracle.graal.lir.*; |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
48 import com.oracle.graal.lir.amd64.*; |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
49 import com.oracle.graal.lir.asm.*; |
5236
f9aae727d035
removed XIR safepoint operation
Doug Simon <doug.simon@oracle.com>
parents:
5235
diff
changeset
|
50 import com.oracle.graal.nodes.*; |
5233
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
51 |
5844
a432e6d43aa1
fixed bugs related to -G:+InlineVTableStubs and re-enabled it by default
Doug Simon <doug.simon@oracle.com>
parents:
5841
diff
changeset
|
52 /** |
a432e6d43aa1
fixed bugs related to -G:+InlineVTableStubs and re-enabled it by default
Doug Simon <doug.simon@oracle.com>
parents:
5841
diff
changeset
|
53 * HotSpot AMD64 specific backend. |
a432e6d43aa1
fixed bugs related to -G:+InlineVTableStubs and re-enabled it by default
Doug Simon <doug.simon@oracle.com>
parents:
5841
diff
changeset
|
54 */ |
12580
7876c59a7a2f
refactored all deferred initialization of backends into HotSpotBackend
Doug Simon <doug.simon@oracle.com>
parents:
12557
diff
changeset
|
55 public class AMD64HotSpotBackend extends HotSpotHostBackend { |
5233
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
56 |
7841
674a8b9e62f8
Remove unused fields in TargetDescription. Use Unsafe.pageSize().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7839
diff
changeset
|
57 private static final Unsafe unsafe = Unsafe.getUnsafe(); |
7814
bab2a51f8dbe
Introduce marker interface InvokeTarget. Remove method lookupRuntimeCall from CodeCacheProvider.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7809
diff
changeset
|
58 |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
59 public AMD64HotSpotBackend(HotSpotGraalRuntime runtime, HotSpotProviders providers) { |
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
60 super(runtime, providers); |
6483
e11b2c8f374b
modified NewInstanceStubCall to use information provided by the (platform independent) backend instead of AMD64 specific nodes for linking the stub call
Doug Simon <doug.simon@oracle.com>
parents:
6482
diff
changeset
|
61 } |
5233
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
62 |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
63 @Override |
11775
b04b94b71649
Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents:
11537
diff
changeset
|
64 public boolean shouldAllocateRegisters() { |
b04b94b71649
Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents:
11537
diff
changeset
|
65 return true; |
b04b94b71649
Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents:
11537
diff
changeset
|
66 } |
b04b94b71649
Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents:
11537
diff
changeset
|
67 |
b04b94b71649
Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents:
11537
diff
changeset
|
68 @Override |
10956 | 69 public FrameMap newFrameMap() { |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12363
diff
changeset
|
70 return new AMD64FrameMap(getCodeCache()); |
10956 | 71 } |
72 | |
73 @Override | |
9613
0c17815817a4
removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents:
9612
diff
changeset
|
74 public LIRGenerator newLIRGenerator(StructuredGraph graph, FrameMap frameMap, CallingConvention cc, LIR lir) { |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
75 return new AMD64HotSpotLIRGenerator(graph, getProviders(), getRuntime().getConfig(), frameMap, cc, lir); |
5233
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
76 } |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
77 |
7808
932a45568706
Move stack banging code to the AMD64-specific code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
78 /** |
932a45568706
Move stack banging code to the AMD64-specific code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
79 * Emits code to do stack overflow checking. |
932a45568706
Move stack banging code to the AMD64-specific code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
80 * |
932a45568706
Move stack banging code to the AMD64-specific code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
81 * @param afterFrameInit specifies if the stack pointer has already been adjusted to allocate |
932a45568706
Move stack banging code to the AMD64-specific code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
82 * the current frame |
13223
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
83 * @param isVerifiedEntryPoint specifies if the code buffer is currently at the verified entry |
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
84 * point |
7808
932a45568706
Move stack banging code to the AMD64-specific code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
85 */ |
13310
733cccc125ed
added subqWide to AMD64Assembler
Doug Simon <doug.simon@oracle.com>
parents:
13252
diff
changeset
|
86 protected static void emitStackOverflowCheck(CompilationResultBuilder crb, int pagesToBang, boolean afterFrameInit, boolean isVerifiedEntryPoint) { |
733cccc125ed
added subqWide to AMD64Assembler
Doug Simon <doug.simon@oracle.com>
parents:
13252
diff
changeset
|
87 if (pagesToBang > 0) { |
7808
932a45568706
Move stack banging code to the AMD64-specific code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
88 |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13223
diff
changeset
|
89 AMD64MacroAssembler asm = (AMD64MacroAssembler) crb.asm; |
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13223
diff
changeset
|
90 int frameSize = crb.frameMap.frameSize(); |
7808
932a45568706
Move stack banging code to the AMD64-specific code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
91 if (frameSize > 0) { |
7841
674a8b9e62f8
Remove unused fields in TargetDescription. Use Unsafe.pageSize().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7839
diff
changeset
|
92 int lastFramePage = frameSize / unsafe.pageSize(); |
7808
932a45568706
Move stack banging code to the AMD64-specific code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
93 // emit multiple stack bangs for methods with frames larger than a page |
932a45568706
Move stack banging code to the AMD64-specific code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
94 for (int i = 0; i <= lastFramePage; i++) { |
13310
733cccc125ed
added subqWide to AMD64Assembler
Doug Simon <doug.simon@oracle.com>
parents:
13252
diff
changeset
|
95 int disp = (i + pagesToBang) * unsafe.pageSize(); |
7808
932a45568706
Move stack banging code to the AMD64-specific code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
96 if (afterFrameInit) { |
932a45568706
Move stack banging code to the AMD64-specific code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
97 disp -= frameSize; |
932a45568706
Move stack banging code to the AMD64-specific code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
98 } |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13223
diff
changeset
|
99 crb.blockComment("[stack overflow check]"); |
13223
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
100 int pos = asm.codeBuffer.position(); |
8167
7f57c30575c8
Make AMD64Address a low-level representation for use by the assembler only.
Roland Schatz <roland.schatz@oracle.com>
parents:
8166
diff
changeset
|
101 asm.movq(new AMD64Address(rsp, -disp), AMD64.rax); |
13223
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
102 assert i > 0 || !isVerifiedEntryPoint || asm.codeBuffer.position() - pos >= PATCHED_VERIFIED_ENTRY_POINT_INSTRUCTION_SIZE; |
7808
932a45568706
Move stack banging code to the AMD64-specific code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
103 } |
932a45568706
Move stack banging code to the AMD64-specific code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
104 } |
932a45568706
Move stack banging code to the AMD64-specific code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
105 } |
932a45568706
Move stack banging code to the AMD64-specific code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
106 } |
932a45568706
Move stack banging code to the AMD64-specific code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
107 |
13223
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
108 /** |
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
109 * The size of the instruction used to patch the verified entry point of an nmethod when the |
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
110 * nmethod is made non-entrant or a zombie (e.g. during deopt or class unloading). The first |
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
111 * instruction emitted at an nmethod's verified entry point must be at least this length to |
13245 | 112 * ensure mt-safe patching. |
13223
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
113 */ |
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
114 public static final int PATCHED_VERIFIED_ENTRY_POINT_INSTRUCTION_SIZE = 5; |
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
115 |
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
116 /** |
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
117 * Emits code at the verified entry point and return point(s) of a method. |
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
118 */ |
5233
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
119 class HotSpotFrameContext implements FrameContext { |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
120 |
9451
3ccda80d466b
stack overflow check and deopt/exception handler entry points are omitted from compiled stubs
Doug Simon <doug.simon@oracle.com>
parents:
9415
diff
changeset
|
121 final boolean isStub; |
13223
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
122 final boolean omitFrame; |
9451
3ccda80d466b
stack overflow check and deopt/exception handler entry points are omitted from compiled stubs
Doug Simon <doug.simon@oracle.com>
parents:
9415
diff
changeset
|
123 |
13223
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
124 HotSpotFrameContext(boolean isStub, boolean omitFrame) { |
9451
3ccda80d466b
stack overflow check and deopt/exception handler entry points are omitted from compiled stubs
Doug Simon <doug.simon@oracle.com>
parents:
9415
diff
changeset
|
125 this.isStub = isStub; |
13223
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
126 this.omitFrame = omitFrame; |
9451
3ccda80d466b
stack overflow check and deopt/exception handler entry points are omitted from compiled stubs
Doug Simon <doug.simon@oracle.com>
parents:
9415
diff
changeset
|
127 } |
3ccda80d466b
stack overflow check and deopt/exception handler entry points are omitted from compiled stubs
Doug Simon <doug.simon@oracle.com>
parents:
9415
diff
changeset
|
128 |
13234
7e237378923d
made the frameContext of a CompilationResultBuilder always non-null and added FrameContext.hasFrame() to determine if a frame is actually generated
Doug Simon <doug.simon@oracle.com>
parents:
13229
diff
changeset
|
129 public boolean hasFrame() { |
7e237378923d
made the frameContext of a CompilationResultBuilder always non-null and added FrameContext.hasFrame() to determine if a frame is actually generated
Doug Simon <doug.simon@oracle.com>
parents:
13229
diff
changeset
|
130 return !omitFrame; |
7e237378923d
made the frameContext of a CompilationResultBuilder always non-null and added FrameContext.hasFrame() to determine if a frame is actually generated
Doug Simon <doug.simon@oracle.com>
parents:
13229
diff
changeset
|
131 } |
7e237378923d
made the frameContext of a CompilationResultBuilder always non-null and added FrameContext.hasFrame() to determine if a frame is actually generated
Doug Simon <doug.simon@oracle.com>
parents:
13229
diff
changeset
|
132 |
5233
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
133 @Override |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13223
diff
changeset
|
134 public void enter(CompilationResultBuilder crb) { |
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13223
diff
changeset
|
135 FrameMap frameMap = crb.frameMap; |
5233
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
136 int frameSize = frameMap.frameSize(); |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13223
diff
changeset
|
137 AMD64MacroAssembler asm = (AMD64MacroAssembler) crb.asm; |
13223
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
138 if (omitFrame) { |
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
139 if (!isStub) { |
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
140 asm.nop(PATCHED_VERIFIED_ENTRY_POINT_INSTRUCTION_SIZE); |
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
141 } |
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
142 } else { |
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
143 int verifiedEntryPointOffset = asm.codeBuffer.position(); |
13310
733cccc125ed
added subqWide to AMD64Assembler
Doug Simon <doug.simon@oracle.com>
parents:
13252
diff
changeset
|
144 if (!isStub && pagesToBang > 0) { |
733cccc125ed
added subqWide to AMD64Assembler
Doug Simon <doug.simon@oracle.com>
parents:
13252
diff
changeset
|
145 emitStackOverflowCheck(crb, pagesToBang, false, true); |
13223
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
146 assert asm.codeBuffer.position() - verifiedEntryPointOffset >= PATCHED_VERIFIED_ENTRY_POINT_INSTRUCTION_SIZE; |
5233
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
147 } |
13223
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
148 if (!isStub && asm.codeBuffer.position() == verifiedEntryPointOffset) { |
13310
733cccc125ed
added subqWide to AMD64Assembler
Doug Simon <doug.simon@oracle.com>
parents:
13252
diff
changeset
|
149 asm.subqWide(rsp, frameSize); |
13223
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
150 assert asm.codeBuffer.position() - verifiedEntryPointOffset >= PATCHED_VERIFIED_ENTRY_POINT_INSTRUCTION_SIZE; |
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
151 } else { |
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
152 asm.decrementq(rsp, frameSize); |
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
153 } |
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
154 if (ZapStackOnMethodEntry.getValue()) { |
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
155 final int intSize = 4; |
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
156 for (int i = 0; i < frameSize / intSize; ++i) { |
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
157 asm.movl(new AMD64Address(rsp, i * intSize), 0xC1C1C1C1); |
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
158 } |
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
159 } |
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
160 CalleeSaveLayout csl = frameMap.registerConfig.getCalleeSaveLayout(); |
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
161 if (csl != null && csl.size != 0) { |
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
162 int frameToCSA = frameMap.offsetToCalleeSaveArea(); |
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
163 assert frameToCSA >= 0; |
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
164 asm.save(csl, frameToCSA); |
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
165 } |
5233
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
166 } |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
167 } |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
168 |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
169 @Override |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13223
diff
changeset
|
170 public void leave(CompilationResultBuilder crb) { |
13223
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
171 if (!omitFrame) { |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13223
diff
changeset
|
172 AMD64MacroAssembler asm = (AMD64MacroAssembler) crb.asm; |
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13223
diff
changeset
|
173 CalleeSaveLayout csl = crb.frameMap.registerConfig.getCalleeSaveLayout(); |
5233
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
174 |
13223
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
175 if (csl != null && csl.size != 0) { |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13223
diff
changeset
|
176 crb.compilationResult.setRegisterRestoreEpilogueOffset(asm.codeBuffer.position()); |
13223
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
177 // saved all registers, restore all registers |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13223
diff
changeset
|
178 int frameToCSA = crb.frameMap.offsetToCalleeSaveArea(); |
13223
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
179 asm.restore(csl, frameToCSA); |
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
180 } |
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
181 |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13223
diff
changeset
|
182 int frameSize = crb.frameMap.frameSize(); |
13223
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
183 asm.incrementq(rsp, frameSize); |
5233
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
184 } |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
185 } |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
186 } |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
187 |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
188 @Override |
9432
6680389bd36f
Make assembler creation in backend more extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
9415
diff
changeset
|
189 protected AbstractAssembler createAssembler(FrameMap frameMap) { |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12363
diff
changeset
|
190 return new AMD64MacroAssembler(getTarget(), frameMap.registerConfig); |
9432
6680389bd36f
Make assembler creation in backend more extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
9415
diff
changeset
|
191 } |
6680389bd36f
Make assembler creation in backend more extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
9415
diff
changeset
|
192 |
6680389bd36f
Make assembler creation in backend more extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
9415
diff
changeset
|
193 @Override |
13229
325b4e4efb60
added CompilationResultBuilderFactory to support peep-hole instrumentation of methods as their code is emitted
Doug Simon <doug.simon@oracle.com>
parents:
13227
diff
changeset
|
194 public CompilationResultBuilder newCompilationResultBuilder(LIRGenerator lirGen, CompilationResult compilationResult, CompilationResultBuilderFactory factory) { |
5251
467de393651a
optimization: frame prologue & epilogue ommitted for methods with no spills, no callee-saved registers, no incoming stack args and no debug info
Doug Simon <doug.simon@oracle.com>
parents:
5242
diff
changeset
|
195 // Omit the frame if the method: |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7300
diff
changeset
|
196 // - has no spill slots or other slots allocated during register allocation |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7300
diff
changeset
|
197 // - has no callee-saved registers |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7300
diff
changeset
|
198 // - has no incoming arguments passed on the stack |
10761
dd7a8807378b
cannot omit frame for compiled methods that make a foreign call (GRAAL-362)
Doug Simon <doug.simon@oracle.com>
parents:
10732
diff
changeset
|
199 // - has no deoptimization points |
dd7a8807378b
cannot omit frame for compiled methods that make a foreign call (GRAAL-362)
Doug Simon <doug.simon@oracle.com>
parents:
10732
diff
changeset
|
200 // - makes no foreign calls (which require an aligned stack) |
8367
ae15e5d0571b
rename: HotSpotAMD64LIRGenerator -> AMD64HotSpotLIRGenerator
Doug Simon <doug.simon@oracle.com>
parents:
8334
diff
changeset
|
201 AMD64HotSpotLIRGenerator gen = (AMD64HotSpotLIRGenerator) lirGen; |
8290
9882af5c8504
AMD64 HotSpot backend now models RBP as an incoming parameter that must be preserved until the end of the method. For non-leaf methods, the value is preserved in the special stack slot required by the HotSpot runtime for walking/inspecting frames of such methods.
Doug Simon <doug.simon@oracle.com>
parents:
8282
diff
changeset
|
202 FrameMap frameMap = gen.frameMap; |
9882af5c8504
AMD64 HotSpot backend now models RBP as an incoming parameter that must be preserved until the end of the method. For non-leaf methods, the value is preserved in the special stack slot required by the HotSpot runtime for walking/inspecting frames of such methods.
Doug Simon <doug.simon@oracle.com>
parents:
8282
diff
changeset
|
203 LIR lir = gen.lir; |
10761
dd7a8807378b
cannot omit frame for compiled methods that make a foreign call (GRAAL-362)
Doug Simon <doug.simon@oracle.com>
parents:
10732
diff
changeset
|
204 assert gen.deoptimizationRescueSlot == null || frameMap.frameNeedsAllocating() : "method that can deoptimize must have a frame"; |
dd7a8807378b
cannot omit frame for compiled methods that make a foreign call (GRAAL-362)
Doug Simon <doug.simon@oracle.com>
parents:
10732
diff
changeset
|
205 boolean omitFrame = CanOmitFrame.getValue() && !frameMap.frameNeedsAllocating() && !lir.hasArgInCallerFrame() && !gen.hasForeignCall(); |
5251
467de393651a
optimization: frame prologue & epilogue ommitted for methods with no spills, no callee-saved registers, no incoming stack args and no debug info
Doug Simon <doug.simon@oracle.com>
parents:
5242
diff
changeset
|
206 |
9613
0c17815817a4
removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents:
9612
diff
changeset
|
207 Stub stub = gen.getStub(); |
9432
6680389bd36f
Make assembler creation in backend more extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
9415
diff
changeset
|
208 AbstractAssembler masm = createAssembler(frameMap); |
13223
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
209 HotSpotFrameContext frameContext = new HotSpotFrameContext(stub != null, omitFrame); |
13229
325b4e4efb60
added CompilationResultBuilderFactory to support peep-hole instrumentation of methods as their code is emitted
Doug Simon <doug.simon@oracle.com>
parents:
13227
diff
changeset
|
210 CompilationResultBuilder crb = factory.createBuilder(getCodeCache(), getForeignCalls(), frameMap, masm, frameContext, compilationResult); |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13223
diff
changeset
|
211 crb.setFrameSize(frameMap.frameSize()); |
8290
9882af5c8504
AMD64 HotSpot backend now models RBP as an incoming parameter that must be preserved until the end of the method. For non-leaf methods, the value is preserved in the special stack slot required by the HotSpot runtime for walking/inspecting frames of such methods.
Doug Simon <doug.simon@oracle.com>
parents:
8282
diff
changeset
|
212 StackSlot deoptimizationRescueSlot = gen.deoptimizationRescueSlot; |
9451
3ccda80d466b
stack overflow check and deopt/exception handler entry points are omitted from compiled stubs
Doug Simon <doug.simon@oracle.com>
parents:
9415
diff
changeset
|
213 if (deoptimizationRescueSlot != null && stub == null) { |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13223
diff
changeset
|
214 crb.compilationResult.setCustomStackAreaOffset(frameMap.offsetForStackSlot(deoptimizationRescueSlot)); |
8282
59744882ddeb
moved logic for reserving a special area/slot in a frame (e.g., for use during deoptimization) out of FrameMap and into platform specific backend class
Doug Simon <doug.simon@oracle.com>
parents:
8281
diff
changeset
|
215 } |
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:
8370
diff
changeset
|
216 |
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:
8370
diff
changeset
|
217 if (stub != null) { |
12610
62fb4919edc9
cleaned up mechanism for saving registers and updating the callee save maps in stubs
Doug Simon <doug.simon@oracle.com>
parents:
12580
diff
changeset
|
218 Set<Register> definedRegisters = gatherDefinedRegisters(lir); |
62fb4919edc9
cleaned up mechanism for saving registers and updating the callee save maps in stubs
Doug Simon <doug.simon@oracle.com>
parents:
12580
diff
changeset
|
219 updateStub(stub, definedRegisters, gen.calleeSaveInfo, frameMap); |
9338
0266549ff6e0
added support from compiled stubs to be installed as RuntimeStubs and to be able to directly call C/C++ runtime functions (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9200
diff
changeset
|
220 } |
0266549ff6e0
added support from compiled stubs to be installed as RuntimeStubs and to be able to directly call C/C++ runtime functions (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9200
diff
changeset
|
221 |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13223
diff
changeset
|
222 return crb; |
9338
0266549ff6e0
added support from compiled stubs to be installed as RuntimeStubs and to be able to directly call C/C++ runtime functions (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9200
diff
changeset
|
223 } |
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:
8370
diff
changeset
|
224 |
5233
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
225 @Override |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13223
diff
changeset
|
226 public void emitCode(CompilationResultBuilder crb, LIRGenerator lirGen, ResolvedJavaMethod installedCodeOwner) { |
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13223
diff
changeset
|
227 AMD64MacroAssembler asm = (AMD64MacroAssembler) crb.asm; |
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13223
diff
changeset
|
228 FrameMap frameMap = crb.frameMap; |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
229 RegisterConfig regConfig = frameMap.registerConfig; |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
230 HotSpotVMConfig config = getRuntime().getConfig(); |
13245 | 231 Label verifiedEntry = new Label(); |
5233
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
232 |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
233 // Emit the prefix |
13245 | 234 emitCodePrefix(installedCodeOwner, crb, asm, regConfig, config, verifiedEntry); |
12502
28f56bf7c06a
added support code for Truffle to inject special tail-call code into the prefix of OptimizedCallTarget.call(PackedFrame, Arguments)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
235 |
28f56bf7c06a
added support code for Truffle to inject special tail-call code into the prefix of OptimizedCallTarget.call(PackedFrame, Arguments)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
236 // Emit code for the LIR |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13223
diff
changeset
|
237 emitCodeBody(installedCodeOwner, crb, lirGen); |
12502
28f56bf7c06a
added support code for Truffle to inject special tail-call code into the prefix of OptimizedCallTarget.call(PackedFrame, Arguments)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
238 |
28f56bf7c06a
added support code for Truffle to inject special tail-call code into the prefix of OptimizedCallTarget.call(PackedFrame, Arguments)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
239 // Emit the suffix |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13223
diff
changeset
|
240 emitCodeSuffix(installedCodeOwner, crb, lirGen, asm, frameMap); |
12502
28f56bf7c06a
added support code for Truffle to inject special tail-call code into the prefix of OptimizedCallTarget.call(PackedFrame, Arguments)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
241 } |
28f56bf7c06a
added support code for Truffle to inject special tail-call code into the prefix of OptimizedCallTarget.call(PackedFrame, Arguments)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
242 |
28f56bf7c06a
added support code for Truffle to inject special tail-call code into the prefix of OptimizedCallTarget.call(PackedFrame, Arguments)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
243 /** |
13223
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
244 * Emits the code prior to the verified entry point. |
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
245 * |
12502
28f56bf7c06a
added support code for Truffle to inject special tail-call code into the prefix of OptimizedCallTarget.call(PackedFrame, Arguments)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
246 * @param installedCodeOwner see {@link Backend#emitCode} |
28f56bf7c06a
added support code for Truffle to inject special tail-call code into the prefix of OptimizedCallTarget.call(PackedFrame, Arguments)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
247 */ |
13245 | 248 public void emitCodePrefix(ResolvedJavaMethod installedCodeOwner, CompilationResultBuilder crb, AMD64MacroAssembler asm, RegisterConfig regConfig, HotSpotVMConfig config, Label verifiedEntry) { |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12363
diff
changeset
|
249 HotSpotProviders providers = getProviders(); |
11825
463f51256c86
AMD64HotSpot: emit jump to IC miss handler directly instead of emitting it inside verfied_entry
Bernhard Urban <bernhard.urban@jku.at>
parents:
11775
diff
changeset
|
250 if (installedCodeOwner != null && !isStatic(installedCodeOwner.getModifiers())) { |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13223
diff
changeset
|
251 crb.recordMark(Marks.MARK_UNVERIFIED_ENTRY); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12363
diff
changeset
|
252 CallingConvention cc = regConfig.getCallingConvention(JavaCallee, null, new JavaType[]{providers.getMetaAccess().lookupJavaType(Object.class)}, getTarget(), false); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7300
diff
changeset
|
253 Register inlineCacheKlass = rax; // see definition of IC_Klass in |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7300
diff
changeset
|
254 // c1_LIRAssembler_x86.cpp |
6470
b1010f7bc0bf
expanded CallingConvention API class to also include the location of the value (if any) returned by a call
Doug Simon <doug.simon@oracle.com>
parents:
6462
diff
changeset
|
255 Register receiver = asRegister(cc.getArgument(0)); |
8167
7f57c30575c8
Make AMD64Address a low-level representation for use by the assembler only.
Roland Schatz <roland.schatz@oracle.com>
parents:
8166
diff
changeset
|
256 AMD64Address src = new AMD64Address(receiver, config.hubOffset); |
5233
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
257 |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12363
diff
changeset
|
258 if (config.useCompressedClassPointers) { |
10732
0bd794eb8222
Add compressed oop support in HotSpot Backend
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10666
diff
changeset
|
259 Register register = r10; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12363
diff
changeset
|
260 AMD64HotSpotMove.decodeKlassPointer(asm, register, providers.getRegisters().getHeapBaseRegister(), src, config.narrowKlassBase, config.narrowOopBase, config.narrowKlassShift, |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12363
diff
changeset
|
261 config.logKlassAlignment); |
10732
0bd794eb8222
Add compressed oop support in HotSpot Backend
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10666
diff
changeset
|
262 asm.cmpq(inlineCacheKlass, register); |
0bd794eb8222
Add compressed oop support in HotSpot Backend
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10666
diff
changeset
|
263 } else { |
0bd794eb8222
Add compressed oop support in HotSpot Backend
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10666
diff
changeset
|
264 asm.cmpq(inlineCacheKlass, src); |
0bd794eb8222
Add compressed oop support in HotSpot Backend
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10666
diff
changeset
|
265 } |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13223
diff
changeset
|
266 AMD64Call.directConditionalJmp(crb, asm, getForeignCalls().lookupForeignCall(IC_MISS_HANDLER), ConditionFlag.NotEqual); |
5233
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
267 } |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
268 |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
269 asm.align(config.codeEntryAlignment); |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13223
diff
changeset
|
270 crb.recordMark(Marks.MARK_OSR_ENTRY); |
13245 | 271 asm.bind(verifiedEntry); |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13223
diff
changeset
|
272 crb.recordMark(Marks.MARK_VERIFIED_ENTRY); |
12502
28f56bf7c06a
added support code for Truffle to inject special tail-call code into the prefix of OptimizedCallTarget.call(PackedFrame, Arguments)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
273 } |
5233
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
274 |
12502
28f56bf7c06a
added support code for Truffle to inject special tail-call code into the prefix of OptimizedCallTarget.call(PackedFrame, Arguments)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
275 /** |
13223
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
276 * Emits the code which starts at the verified entry point. |
78c808233ff1
ensure instruction at verified entry point is safely patchable (GRAAL-605)
Doug Simon <doug.simon@oracle.com>
parents:
12610
diff
changeset
|
277 * |
12502
28f56bf7c06a
added support code for Truffle to inject special tail-call code into the prefix of OptimizedCallTarget.call(PackedFrame, Arguments)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
278 * @param installedCodeOwner see {@link Backend#emitCode} |
28f56bf7c06a
added support code for Truffle to inject special tail-call code into the prefix of OptimizedCallTarget.call(PackedFrame, Arguments)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
279 */ |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13223
diff
changeset
|
280 public void emitCodeBody(ResolvedJavaMethod installedCodeOwner, CompilationResultBuilder crb, LIRGenerator lirGen) { |
13318
da0851712519
moved emitting code for LIR and queries about whether an edge goes to its lexical successor "inside" CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13310
diff
changeset
|
281 crb.emit(lirGen.lir); |
12502
28f56bf7c06a
added support code for Truffle to inject special tail-call code into the prefix of OptimizedCallTarget.call(PackedFrame, Arguments)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
282 } |
5233
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
283 |
12502
28f56bf7c06a
added support code for Truffle to inject special tail-call code into the prefix of OptimizedCallTarget.call(PackedFrame, Arguments)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
284 /** |
28f56bf7c06a
added support code for Truffle to inject special tail-call code into the prefix of OptimizedCallTarget.call(PackedFrame, Arguments)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
285 * @param installedCodeOwner see {@link Backend#emitCode} |
28f56bf7c06a
added support code for Truffle to inject special tail-call code into the prefix of OptimizedCallTarget.call(PackedFrame, Arguments)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
286 */ |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13223
diff
changeset
|
287 public void emitCodeSuffix(ResolvedJavaMethod installedCodeOwner, CompilationResultBuilder crb, LIRGenerator lirGen, AMD64MacroAssembler asm, FrameMap frameMap) { |
12502
28f56bf7c06a
added support code for Truffle to inject special tail-call code into the prefix of OptimizedCallTarget.call(PackedFrame, Arguments)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
288 HotSpotProviders providers = getProviders(); |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13223
diff
changeset
|
289 HotSpotFrameContext frameContext = (HotSpotFrameContext) crb.frameContext; |
13234
7e237378923d
made the frameContext of a CompilationResultBuilder always non-null and added FrameContext.hasFrame() to determine if a frame is actually generated
Doug Simon <doug.simon@oracle.com>
parents:
13229
diff
changeset
|
290 if (!frameContext.isStub) { |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12363
diff
changeset
|
291 HotSpotForeignCallsProvider foreignCalls = providers.getForeignCalls(); |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13223
diff
changeset
|
292 crb.recordMark(Marks.MARK_EXCEPTION_HANDLER_ENTRY); |
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13223
diff
changeset
|
293 AMD64Call.directCall(crb, asm, foreignCalls.lookupForeignCall(EXCEPTION_HANDLER), null, false, null); |
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13223
diff
changeset
|
294 crb.recordMark(Marks.MARK_DEOPT_HANDLER_ENTRY); |
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13223
diff
changeset
|
295 AMD64Call.directCall(crb, asm, foreignCalls.lookupForeignCall(DEOPT_HANDLER), null, false, null); |
5251
467de393651a
optimization: frame prologue & epilogue ommitted for methods with no spills, no callee-saved registers, no incoming stack args and no debug info
Doug Simon <doug.simon@oracle.com>
parents:
5242
diff
changeset
|
296 } else { |
467de393651a
optimization: frame prologue & epilogue ommitted for methods with no spills, no callee-saved registers, no incoming stack args and no debug info
Doug Simon <doug.simon@oracle.com>
parents:
5242
diff
changeset
|
297 // No need to emit the stubs for entries back into the method since |
467de393651a
optimization: frame prologue & epilogue ommitted for methods with no spills, no callee-saved registers, no incoming stack args and no debug info
Doug Simon <doug.simon@oracle.com>
parents:
5242
diff
changeset
|
298 // it has no calls that can cause such "return" entries |
9615
1089d63ef168
removed 'method' parameter from GraalCompiler.compiledMethod() and renamed the latter to 'compileGraph'.
Doug Simon <doug.simon@oracle.com>
parents:
9613
diff
changeset
|
299 assert !frameMap.accessesCallerFrame() : lirGen.getGraph(); |
5251
467de393651a
optimization: frame prologue & epilogue ommitted for methods with no spills, no callee-saved registers, no incoming stack args and no debug info
Doug Simon <doug.simon@oracle.com>
parents:
5242
diff
changeset
|
300 } |
5233
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
301 } |
efbb1e33e2f3
removed XIR prologue and epilogues - architecture and runtime specific subclass of Backend is now used instead
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
302 } |