author | iveresov |
Tue, 10 Jan 2017 21:39:20 +0300 | |
changeset 43435 | 01521491ec10 |
parent 42649 | 28238583a459 |
permissions | -rw-r--r-- |
42649
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
1 |
/* |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
2 |
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
4 |
* |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
8 |
* |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
13 |
* accompanied this code). |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
14 |
* |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
18 |
* |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
21 |
* questions. |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
22 |
*/ |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
23 |
package org.graalvm.compiler.hotspot.amd64; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
24 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
25 |
import static org.graalvm.compiler.core.common.GraalOptions.CanOmitFrame; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
26 |
import static org.graalvm.compiler.core.common.GraalOptions.GeneratePIC; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
27 |
import static org.graalvm.compiler.core.common.GraalOptions.ZapStackOnMethodEntry; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
28 |
import static jdk.vm.ci.amd64.AMD64.r10; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
29 |
import static jdk.vm.ci.amd64.AMD64.rax; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
30 |
import static jdk.vm.ci.amd64.AMD64.rsp; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
31 |
import static jdk.vm.ci.code.ValueUtil.asRegister; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
32 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
33 |
import java.util.Set; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
34 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
35 |
import org.graalvm.compiler.asm.Assembler; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
36 |
import org.graalvm.compiler.asm.Label; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
37 |
import org.graalvm.compiler.asm.amd64.AMD64Address; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
38 |
import org.graalvm.compiler.asm.amd64.AMD64Assembler.ConditionFlag; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
39 |
import org.graalvm.compiler.asm.amd64.AMD64MacroAssembler; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
40 |
import org.graalvm.compiler.code.CompilationResult; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
41 |
import org.graalvm.compiler.core.amd64.AMD64NodeMatchRules; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
42 |
import org.graalvm.compiler.core.common.LIRKind; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
43 |
import org.graalvm.compiler.core.common.CompilationIdentifier; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
44 |
import org.graalvm.compiler.core.common.alloc.RegisterAllocationConfig; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
45 |
import org.graalvm.compiler.core.target.Backend; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
46 |
import org.graalvm.compiler.hotspot.GraalHotSpotVMConfig; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
47 |
import org.graalvm.compiler.hotspot.HotSpotDataBuilder; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
48 |
import org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
49 |
import org.graalvm.compiler.hotspot.HotSpotHostBackend; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
50 |
import org.graalvm.compiler.hotspot.HotSpotLIRGenerationResult; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
51 |
import org.graalvm.compiler.hotspot.meta.HotSpotConstantLoadAction; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
52 |
import org.graalvm.compiler.hotspot.meta.HotSpotForeignCallsProvider; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
53 |
import org.graalvm.compiler.hotspot.meta.HotSpotProviders; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
54 |
import org.graalvm.compiler.hotspot.stubs.Stub; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
55 |
import org.graalvm.compiler.lir.LIR; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
56 |
import org.graalvm.compiler.lir.amd64.AMD64Call; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
57 |
import org.graalvm.compiler.lir.amd64.AMD64FrameMap; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
58 |
import org.graalvm.compiler.lir.amd64.AMD64FrameMapBuilder; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
59 |
import org.graalvm.compiler.lir.asm.CompilationResultBuilder; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
60 |
import org.graalvm.compiler.lir.asm.CompilationResultBuilderFactory; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
61 |
import org.graalvm.compiler.lir.asm.DataBuilder; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
62 |
import org.graalvm.compiler.lir.asm.FrameContext; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
63 |
import org.graalvm.compiler.lir.framemap.FrameMap; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
64 |
import org.graalvm.compiler.lir.framemap.FrameMapBuilder; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
65 |
import org.graalvm.compiler.lir.gen.LIRGenerationResult; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
66 |
import org.graalvm.compiler.lir.gen.LIRGeneratorTool; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
67 |
import org.graalvm.compiler.nodes.StructuredGraph; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
68 |
import org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
69 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
70 |
import jdk.vm.ci.amd64.AMD64; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
71 |
import jdk.vm.ci.amd64.AMD64Kind; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
72 |
import jdk.vm.ci.code.CallingConvention; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
73 |
import jdk.vm.ci.code.Register; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
74 |
import jdk.vm.ci.code.RegisterConfig; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
75 |
import jdk.vm.ci.code.StackSlot; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
76 |
import jdk.vm.ci.hotspot.HotSpotCallingConventionType; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
77 |
import jdk.vm.ci.hotspot.HotSpotSentinelConstant; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
78 |
import jdk.vm.ci.meta.JavaKind; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
79 |
import jdk.vm.ci.meta.JavaType; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
80 |
import jdk.vm.ci.meta.ResolvedJavaMethod; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
81 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
82 |
/** |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
83 |
* HotSpot AMD64 specific backend. |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
84 |
*/ |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
85 |
public class AMD64HotSpotBackend extends HotSpotHostBackend { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
86 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
87 |
public AMD64HotSpotBackend(GraalHotSpotVMConfig config, HotSpotGraalRuntimeProvider runtime, HotSpotProviders providers) { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
88 |
super(config, runtime, providers); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
89 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
90 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
91 |
@Override |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
92 |
public FrameMapBuilder newFrameMapBuilder(RegisterConfig registerConfig) { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
93 |
RegisterConfig registerConfigNonNull = registerConfig == null ? getCodeCache().getRegisterConfig() : registerConfig; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
94 |
return new AMD64FrameMapBuilder(newFrameMap(registerConfigNonNull), getCodeCache(), registerConfigNonNull); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
95 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
96 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
97 |
@Override |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
98 |
public FrameMap newFrameMap(RegisterConfig registerConfig) { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
99 |
return new AMD64FrameMap(getCodeCache(), registerConfig, this); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
100 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
101 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
102 |
@Override |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
103 |
public LIRGeneratorTool newLIRGenerator(LIRGenerationResult lirGenRes) { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
104 |
return new AMD64HotSpotLIRGenerator(getProviders(), config, lirGenRes); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
105 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
106 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
107 |
@Override |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
108 |
public LIRGenerationResult newLIRGenerationResult(CompilationIdentifier compilationId, LIR lir, FrameMapBuilder frameMapBuilder, StructuredGraph graph, Object stub) { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
109 |
return new HotSpotLIRGenerationResult(compilationId, lir, frameMapBuilder, makeCallingConvention(graph, (Stub) stub), stub); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
110 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
111 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
112 |
@Override |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
113 |
public NodeLIRBuilderTool newNodeLIRBuilder(StructuredGraph graph, LIRGeneratorTool lirGen) { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
114 |
return new AMD64HotSpotNodeLIRBuilder(graph, lirGen, new AMD64NodeMatchRules(lirGen)); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
115 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
116 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
117 |
@Override |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
118 |
protected void bangStackWithOffset(CompilationResultBuilder crb, int bangOffset) { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
119 |
AMD64MacroAssembler asm = (AMD64MacroAssembler) crb.asm; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
120 |
int pos = asm.position(); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
121 |
asm.movl(new AMD64Address(rsp, -bangOffset), AMD64.rax); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
122 |
assert asm.position() - pos >= PATCHED_VERIFIED_ENTRY_POINT_INSTRUCTION_SIZE; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
123 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
124 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
125 |
/** |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
126 |
* The size of the instruction used to patch the verified entry point of an nmethod when the |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
127 |
* nmethod is made non-entrant or a zombie (e.g. during deopt or class unloading). The first |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
128 |
* instruction emitted at an nmethod's verified entry point must be at least this length to |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
129 |
* ensure mt-safe patching. |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
130 |
*/ |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
131 |
public static final int PATCHED_VERIFIED_ENTRY_POINT_INSTRUCTION_SIZE = 5; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
132 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
133 |
/** |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
134 |
* Emits code at the verified entry point and return point(s) of a method. |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
135 |
*/ |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
136 |
class HotSpotFrameContext implements FrameContext { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
137 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
138 |
final boolean isStub; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
139 |
final boolean omitFrame; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
140 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
141 |
HotSpotFrameContext(boolean isStub, boolean omitFrame) { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
142 |
this.isStub = isStub; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
143 |
this.omitFrame = omitFrame; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
144 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
145 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
146 |
@Override |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
147 |
public boolean hasFrame() { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
148 |
return !omitFrame; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
149 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
150 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
151 |
@Override |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
152 |
public void enter(CompilationResultBuilder crb) { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
153 |
FrameMap frameMap = crb.frameMap; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
154 |
int frameSize = frameMap.frameSize(); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
155 |
AMD64MacroAssembler asm = (AMD64MacroAssembler) crb.asm; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
156 |
if (omitFrame) { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
157 |
if (!isStub) { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
158 |
asm.nop(PATCHED_VERIFIED_ENTRY_POINT_INSTRUCTION_SIZE); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
159 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
160 |
} else { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
161 |
int verifiedEntryPointOffset = asm.position(); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
162 |
if (!isStub) { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
163 |
emitStackOverflowCheck(crb); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
164 |
// assert asm.position() - verifiedEntryPointOffset >= |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
165 |
// PATCHED_VERIFIED_ENTRY_POINT_INSTRUCTION_SIZE; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
166 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
167 |
if (!isStub && asm.position() == verifiedEntryPointOffset) { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
168 |
asm.subqWide(rsp, frameSize); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
169 |
assert asm.position() - verifiedEntryPointOffset >= PATCHED_VERIFIED_ENTRY_POINT_INSTRUCTION_SIZE; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
170 |
} else { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
171 |
asm.decrementq(rsp, frameSize); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
172 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
173 |
if (ZapStackOnMethodEntry.getValue()) { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
174 |
final int intSize = 4; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
175 |
for (int i = 0; i < frameSize / intSize; ++i) { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
176 |
asm.movl(new AMD64Address(rsp, i * intSize), 0xC1C1C1C1); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
177 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
178 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
179 |
assert frameMap.getRegisterConfig().getCalleeSaveRegisters() == null; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
180 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
181 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
182 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
183 |
@Override |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
184 |
public void leave(CompilationResultBuilder crb) { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
185 |
if (!omitFrame) { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
186 |
AMD64MacroAssembler asm = (AMD64MacroAssembler) crb.asm; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
187 |
assert crb.frameMap.getRegisterConfig().getCalleeSaveRegisters() == null; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
188 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
189 |
int frameSize = crb.frameMap.frameSize(); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
190 |
asm.incrementq(rsp, frameSize); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
191 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
192 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
193 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
194 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
195 |
@Override |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
196 |
protected Assembler createAssembler(FrameMap frameMap) { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
197 |
return new AMD64MacroAssembler(getTarget()); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
198 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
199 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
200 |
@Override |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
201 |
public CompilationResultBuilder newCompilationResultBuilder(LIRGenerationResult lirGenRen, FrameMap frameMap, CompilationResult compilationResult, CompilationResultBuilderFactory factory) { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
202 |
// Omit the frame if the method: |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
203 |
// - has no spill slots or other slots allocated during register allocation |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
204 |
// - has no callee-saved registers |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
205 |
// - has no incoming arguments passed on the stack |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
206 |
// - has no deoptimization points |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
207 |
// - makes no foreign calls (which require an aligned stack) |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
208 |
HotSpotLIRGenerationResult gen = (HotSpotLIRGenerationResult) lirGenRen; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
209 |
LIR lir = gen.getLIR(); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
210 |
assert gen.getDeoptimizationRescueSlot() == null || frameMap.frameNeedsAllocating() : "method that can deoptimize must have a frame"; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
211 |
boolean omitFrame = CanOmitFrame.getValue() && !frameMap.frameNeedsAllocating() && !lir.hasArgInCallerFrame() && !gen.hasForeignCall(); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
212 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
213 |
Stub stub = gen.getStub(); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
214 |
Assembler masm = createAssembler(frameMap); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
215 |
HotSpotFrameContext frameContext = new HotSpotFrameContext(stub != null, omitFrame); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
216 |
DataBuilder dataBuilder = new HotSpotDataBuilder(getCodeCache().getTarget()); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
217 |
CompilationResultBuilder crb = factory.createBuilder(getCodeCache(), getForeignCalls(), frameMap, masm, dataBuilder, frameContext, compilationResult); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
218 |
crb.setTotalFrameSize(frameMap.totalFrameSize()); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
219 |
crb.setMaxInterpreterFrameSize(gen.getMaxInterpreterFrameSize()); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
220 |
StackSlot deoptimizationRescueSlot = gen.getDeoptimizationRescueSlot(); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
221 |
if (deoptimizationRescueSlot != null && stub == null) { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
222 |
crb.compilationResult.setCustomStackAreaOffset(deoptimizationRescueSlot); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
223 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
224 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
225 |
if (stub != null) { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
226 |
Set<Register> destroyedCallerRegisters = gatherDestroyedCallerRegisters(lir); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
227 |
updateStub(stub, destroyedCallerRegisters, gen.getCalleeSaveInfo(), frameMap); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
228 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
229 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
230 |
return crb; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
231 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
232 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
233 |
@Override |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
234 |
public void emitCode(CompilationResultBuilder crb, LIR lir, ResolvedJavaMethod installedCodeOwner) { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
235 |
AMD64MacroAssembler asm = (AMD64MacroAssembler) crb.asm; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
236 |
FrameMap frameMap = crb.frameMap; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
237 |
RegisterConfig regConfig = frameMap.getRegisterConfig(); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
238 |
Label verifiedEntry = new Label(); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
239 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
240 |
// Emit the prefix |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
241 |
emitCodePrefix(installedCodeOwner, crb, asm, regConfig, verifiedEntry); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
242 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
243 |
// Emit code for the LIR |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
244 |
emitCodeBody(installedCodeOwner, crb, lir); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
245 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
246 |
// Emit the suffix |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
247 |
emitCodeSuffix(installedCodeOwner, crb, asm, frameMap); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
248 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
249 |
// Profile assembler instructions |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
250 |
profileInstructions(lir, crb); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
251 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
252 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
253 |
/** |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
254 |
* Emits the code prior to the verified entry point. |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
255 |
* |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
256 |
* @param installedCodeOwner see {@link Backend#emitCode} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
257 |
*/ |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
258 |
public void emitCodePrefix(ResolvedJavaMethod installedCodeOwner, CompilationResultBuilder crb, AMD64MacroAssembler asm, RegisterConfig regConfig, Label verifiedEntry) { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
259 |
HotSpotProviders providers = getProviders(); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
260 |
if (installedCodeOwner != null && !installedCodeOwner.isStatic()) { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
261 |
crb.recordMark(config.MARKID_UNVERIFIED_ENTRY); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
262 |
CallingConvention cc = regConfig.getCallingConvention(HotSpotCallingConventionType.JavaCallee, null, new JavaType[]{providers.getMetaAccess().lookupJavaType(Object.class)}, this); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
263 |
Register inlineCacheKlass = rax; // see definition of IC_Klass in |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
264 |
// c1_LIRAssembler_x86.cpp |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
265 |
Register receiver = asRegister(cc.getArgument(0)); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
266 |
AMD64Address src = new AMD64Address(receiver, config.hubOffset); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
267 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
268 |
if (config.useCompressedClassPointers) { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
269 |
Register register = r10; |
43435 | 270 |
AMD64HotSpotMove.decodeKlassPointer(crb, asm, register, providers.getRegisters().getHeapBaseRegister(), src, config); |
271 |
if (GeneratePIC.getValue()) { |
|
272 |
asm.movq(providers.getRegisters().getHeapBaseRegister(), asm.getPlaceholder(-1)); |
|
273 |
crb.recordMark(config.MARKID_NARROW_OOP_BASE_ADDRESS); |
|
274 |
} else { |
|
275 |
if (config.narrowKlassBase != 0) { |
|
276 |
// The heap base register was destroyed above, so restore it |
|
277 |
asm.movq(providers.getRegisters().getHeapBaseRegister(), config.narrowOopBase); |
|
278 |
} |
|
42649
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
279 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
280 |
asm.cmpq(inlineCacheKlass, register); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
281 |
} else { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
282 |
asm.cmpq(inlineCacheKlass, src); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
283 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
284 |
AMD64Call.directConditionalJmp(crb, asm, getForeignCalls().lookupForeignCall(IC_MISS_HANDLER), ConditionFlag.NotEqual); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
285 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
286 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
287 |
asm.align(config.codeEntryAlignment); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
288 |
crb.recordMark(config.MARKID_OSR_ENTRY); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
289 |
asm.bind(verifiedEntry); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
290 |
crb.recordMark(config.MARKID_VERIFIED_ENTRY); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
291 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
292 |
if (GeneratePIC.getValue()) { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
293 |
// Check for method state |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
294 |
HotSpotFrameContext frameContext = (HotSpotFrameContext) crb.frameContext; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
295 |
if (!frameContext.isStub) { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
296 |
crb.recordInlineDataInCodeWithNote(new HotSpotSentinelConstant(LIRKind.value(AMD64Kind.QWORD), JavaKind.Long), HotSpotConstantLoadAction.MAKE_NOT_ENTRANT); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
297 |
asm.movq(AMD64.rax, asm.getPlaceholder(-1)); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
298 |
asm.testq(AMD64.rax, AMD64.rax); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
299 |
AMD64Call.directConditionalJmp(crb, asm, getForeignCalls().lookupForeignCall(WRONG_METHOD_HANDLER), ConditionFlag.NotZero); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
300 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
301 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
302 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
303 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
304 |
/** |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
305 |
* Emits the code which starts at the verified entry point. |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
306 |
* |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
307 |
* @param installedCodeOwner see {@link Backend#emitCode} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
308 |
*/ |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
309 |
public void emitCodeBody(ResolvedJavaMethod installedCodeOwner, CompilationResultBuilder crb, LIR lir) { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
310 |
crb.emit(lir); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
311 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
312 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
313 |
/** |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
314 |
* @param installedCodeOwner see {@link Backend#emitCode} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
315 |
*/ |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
316 |
public void emitCodeSuffix(ResolvedJavaMethod installedCodeOwner, CompilationResultBuilder crb, AMD64MacroAssembler asm, FrameMap frameMap) { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
317 |
HotSpotProviders providers = getProviders(); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
318 |
HotSpotFrameContext frameContext = (HotSpotFrameContext) crb.frameContext; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
319 |
if (!frameContext.isStub) { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
320 |
HotSpotForeignCallsProvider foreignCalls = providers.getForeignCalls(); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
321 |
crb.recordMark(config.MARKID_EXCEPTION_HANDLER_ENTRY); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
322 |
AMD64Call.directCall(crb, asm, foreignCalls.lookupForeignCall(EXCEPTION_HANDLER), null, false, null); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
323 |
crb.recordMark(config.MARKID_DEOPT_HANDLER_ENTRY); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
324 |
AMD64Call.directCall(crb, asm, foreignCalls.lookupForeignCall(DEOPTIMIZATION_HANDLER), null, false, null); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
325 |
} else { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
326 |
// No need to emit the stubs for entries back into the method since |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
327 |
// it has no calls that can cause such "return" entries |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
328 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
329 |
if (frameContext.omitFrame) { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
330 |
// Cannot access slots in caller's frame if my frame is omitted |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
331 |
assert !frameMap.accessesCallerFrame(); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
332 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
333 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
334 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
335 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
336 |
@Override |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
337 |
public RegisterAllocationConfig newRegisterAllocationConfig(RegisterConfig registerConfig) { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
338 |
RegisterConfig registerConfigNonNull = registerConfig == null ? getCodeCache().getRegisterConfig() : registerConfig; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
339 |
return new AMD64HotSpotRegisterAllocationConfig(registerConfigNonNull); |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
340 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
341 |
|
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
342 |
@Override |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
343 |
public Set<Register> translateToCallerRegisters(Set<Register> calleeRegisters) { |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
344 |
return calleeRegisters; |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
345 |
} |
28238583a459
8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff
changeset
|
346 |
} |