Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRBuilder.java @ 15333:06ecedffb109
Use LIRGeneratorTool in Backend.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Wed, 23 Apr 2014 11:32:47 +0200 |
parents | 820c6d353358 |
children | 319deee16746 |
rev | line source |
---|---|
14841
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
1 /* |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
4 * |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
8 * |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
13 * accompanied this code). |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
14 * |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
18 * |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
21 * questions. |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
22 */ |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
23 package com.oracle.graal.hotspot.amd64; |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
24 |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
25 import static com.oracle.graal.amd64.AMD64.*; |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
26 import static com.oracle.graal.api.code.ValueUtil.*; |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
27 import static com.oracle.graal.hotspot.HotSpotBackend.*; |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
28 |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
29 import com.oracle.graal.amd64.*; |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
30 import com.oracle.graal.api.code.*; |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
31 import com.oracle.graal.api.meta.*; |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
32 import com.oracle.graal.asm.*; |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
33 import com.oracle.graal.asm.amd64.AMD64Address.Scale; |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
34 import com.oracle.graal.compiler.amd64.*; |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
35 import com.oracle.graal.compiler.gen.*; |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
36 import com.oracle.graal.debug.*; |
14842
f2e61bf2a2d8
Removed nodeOperands from LIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents:
14841
diff
changeset
|
37 import com.oracle.graal.graph.*; |
14841
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
38 import com.oracle.graal.hotspot.*; |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
39 import com.oracle.graal.hotspot.amd64.AMD64HotSpotLIRGenerator.SaveRbp; |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
40 import com.oracle.graal.hotspot.meta.*; |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
41 import com.oracle.graal.hotspot.nodes.*; |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
42 import com.oracle.graal.lir.*; |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
43 import com.oracle.graal.lir.StandardOp.NoOp; |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
44 import com.oracle.graal.lir.amd64.*; |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
45 import com.oracle.graal.lir.amd64.AMD64Move.CompareAndSwapOp; |
15297
3a6151ed5a25
Move LIRGenerator to graal.lir (errors).
Josef Eisl <josef.eisl@jku.at>
parents:
15296
diff
changeset
|
46 import com.oracle.graal.lir.gen.*; |
14841
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
47 import com.oracle.graal.nodes.*; |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
48 import com.oracle.graal.nodes.java.MethodCallTargetNode.InvokeKind; |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
49 |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
50 /** |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
51 * LIR generator specialized for AMD64 HotSpot. |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
52 */ |
14888
f6630873316b
Rename NodeLIRGenerator (and related classes and interfaces) to NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents:
14854
diff
changeset
|
53 public class AMD64HotSpotNodeLIRBuilder extends AMD64NodeLIRBuilder implements HotSpotNodeLIRBuilder { |
14841
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
54 |
15333
06ecedffb109
Use LIRGeneratorTool in Backend.
Josef Eisl <josef.eisl@jku.at>
parents:
15311
diff
changeset
|
55 public AMD64HotSpotNodeLIRBuilder(StructuredGraph graph, LIRGeneratorTool gen) { |
14921
88dfaf6448e0
Remove LIRGenerationResult from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents:
14888
diff
changeset
|
56 super(graph, gen); |
14850 | 57 memoryPeephole = new AMD64HotSpotMemoryPeephole(this); |
15293
adc7d7aad51c
Deprecate LIRGenerator.getDebugInfoBuilder().
Josef Eisl <josef.eisl@jku.at>
parents:
15263
diff
changeset
|
58 assert gen instanceof AMD64HotSpotLIRGenerator; |
adc7d7aad51c
Deprecate LIRGenerator.getDebugInfoBuilder().
Josef Eisl <josef.eisl@jku.at>
parents:
15263
diff
changeset
|
59 assert getDebugInfoBuilder() instanceof HotSpotDebugInfoBuilder; |
adc7d7aad51c
Deprecate LIRGenerator.getDebugInfoBuilder().
Josef Eisl <josef.eisl@jku.at>
parents:
15263
diff
changeset
|
60 ((AMD64HotSpotLIRGenerator) gen).setLockStack(((HotSpotDebugInfoBuilder) getDebugInfoBuilder()).lockStack()); |
14841
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
61 } |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
62 |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
63 private AMD64HotSpotLIRGenerator getGen() { |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
64 return (AMD64HotSpotLIRGenerator) gen; |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
65 } |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
66 |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
67 private SaveRbp getSaveRbp() { |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
68 return getGen().saveRbp; |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
69 } |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
70 |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
71 private void setSaveRbp(SaveRbp saveRbp) { |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
72 getGen().saveRbp = saveRbp; |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
73 } |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
74 |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
75 @Override |
14842
f2e61bf2a2d8
Removed nodeOperands from LIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents:
14841
diff
changeset
|
76 protected DebugInfoBuilder createDebugInfoBuilder(NodeMap<Value> nodeOperands) { |
14921
88dfaf6448e0
Remove LIRGenerationResult from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents:
14888
diff
changeset
|
77 HotSpotLockStack lockStack = new HotSpotLockStack(gen.getResult().getFrameMap(), Kind.Long); |
14842
f2e61bf2a2d8
Removed nodeOperands from LIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents:
14841
diff
changeset
|
78 return new HotSpotDebugInfoBuilder(nodeOperands, lockStack); |
f2e61bf2a2d8
Removed nodeOperands from LIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents:
14841
diff
changeset
|
79 } |
f2e61bf2a2d8
Removed nodeOperands from LIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents:
14841
diff
changeset
|
80 |
f2e61bf2a2d8
Removed nodeOperands from LIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents:
14841
diff
changeset
|
81 @Override |
14841
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
82 protected void emitPrologue(StructuredGraph graph) { |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
83 |
14843
dd75a505f1b6
Remove currentBlock from NodeLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents:
14842
diff
changeset
|
84 CallingConvention incomingArguments = gen.getCallingConvention(); |
14841
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
85 |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
86 Value[] params = new Value[incomingArguments.getArgumentCount() + 1]; |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
87 for (int i = 0; i < params.length - 1; i++) { |
14923
bcef7320c707
Remove more duplicate methods from NodeLIRBuilder and LIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents:
14921
diff
changeset
|
88 params[i] = LIRGenerator.toStackKind(incomingArguments.getArgument(i)); |
14841
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
89 if (isStackSlot(params[i])) { |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
90 StackSlot slot = ValueUtil.asStackSlot(params[i]); |
14921
88dfaf6448e0
Remove LIRGenerationResult from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents:
14888
diff
changeset
|
91 if (slot.isInCallerFrame() && !gen.getResult().getLIR().hasArgInCallerFrame()) { |
88dfaf6448e0
Remove LIRGenerationResult from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents:
14888
diff
changeset
|
92 gen.getResult().getLIR().setHasArgInCallerFrame(); |
14841
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
93 } |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
94 } |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
95 } |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
96 params[params.length - 1] = rbp.asValue(Kind.Long); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
97 |
14923
bcef7320c707
Remove more duplicate methods from NodeLIRBuilder and LIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents:
14921
diff
changeset
|
98 gen.emitIncomingValues(params); |
14841
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
99 |
14921
88dfaf6448e0
Remove LIRGenerationResult from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents:
14888
diff
changeset
|
100 setSaveRbp(((AMD64HotSpotLIRGenerator) gen).new SaveRbp(new NoOp(gen.getCurrentBlock(), gen.getResult().getLIR().getLIRforBlock(gen.getCurrentBlock()).size()))); |
14841
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
101 append(getSaveRbp().placeholder); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
102 |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
103 for (ParameterNode param : graph.getNodes(ParameterNode.class)) { |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
104 Value paramValue = params[param.index()]; |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
105 assert paramValue.getKind() == param.getKind().getStackKind(); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
106 setResult(param, gen.emitMove(paramValue)); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
107 } |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
108 } |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
109 |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
110 @Override |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
111 public void visitSafepointNode(SafepointNode i) { |
15296
c98708ec9663
Move state(DeoptimizingNode) from LIRGenerator to NodeLIRBuilder (errors).
Josef Eisl <josef.eisl@jku.at>
parents:
15293
diff
changeset
|
112 LIRFrameState info = state(i); |
14841
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
113 append(new AMD64HotSpotSafepointOp(info, getGen().config, this)); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
114 } |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
115 |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
116 @Override |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
117 protected void emitDirectCall(DirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState) { |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
118 InvokeKind invokeKind = ((HotSpotDirectCallTargetNode) callTarget).invokeKind(); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
119 if (invokeKind == InvokeKind.Interface || invokeKind == InvokeKind.Virtual) { |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
120 append(new AMD64HotspotDirectVirtualCallOp(callTarget.target(), result, parameters, temps, callState, invokeKind)); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
121 } else { |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
122 assert invokeKind == InvokeKind.Static || invokeKind == InvokeKind.Special; |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
123 HotSpotResolvedJavaMethod resolvedMethod = (HotSpotResolvedJavaMethod) callTarget.target(); |
15311
820c6d353358
added ModifiersProvider as superinterface for ResolvedJava[Method|Field|Type] and implemented all checks against modifiers as default methods
Doug Simon <doug.simon@oracle.com>
parents:
15297
diff
changeset
|
124 assert !resolvedMethod.isAbstract() : "Cannot make direct call to abstract method."; |
15046
5c71dcf0915d
use hotspot static stubs for call sites
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15024
diff
changeset
|
125 append(new AMD64HotspotDirectStaticCallOp(callTarget.target(), result, parameters, temps, callState, invokeKind)); |
14841
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
126 } |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
127 } |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
128 |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
129 @Override |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
130 protected void emitIndirectCall(IndirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState) { |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
131 if (callTarget instanceof HotSpotIndirectCallTargetNode) { |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
132 AllocatableValue metaspaceMethod = AMD64.rbx.asValue(); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
133 gen.emitMove(metaspaceMethod, operand(((HotSpotIndirectCallTargetNode) callTarget).metaspaceMethod())); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
134 AllocatableValue targetAddress = AMD64.rax.asValue(); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
135 gen.emitMove(targetAddress, operand(callTarget.computedAddress())); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
136 append(new AMD64IndirectCallOp(callTarget.target(), result, parameters, temps, metaspaceMethod, targetAddress, callState)); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
137 } else { |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
138 super.emitIndirectCall(callTarget, result, parameters, temps, callState); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
139 } |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
140 } |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
141 |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
142 @Override |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
143 public void emitPatchReturnAddress(ValueNode address) { |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
144 append(new AMD64HotSpotPatchReturnAddressOp(gen.load(operand(address)))); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
145 } |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
146 |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
147 @Override |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
148 public void emitJumpToExceptionHandlerInCaller(ValueNode handlerInCallerPc, ValueNode exception, ValueNode exceptionPc) { |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
149 Variable handler = gen.load(operand(handlerInCallerPc)); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
150 ForeignCallLinkage linkage = gen.getForeignCalls().lookupForeignCall(EXCEPTION_HANDLER_IN_CALLER); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
151 CallingConvention outgoingCc = linkage.getOutgoingCallingConvention(); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
152 assert outgoingCc.getArgumentCount() == 2; |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
153 RegisterValue exceptionFixed = (RegisterValue) outgoingCc.getArgument(0); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
154 RegisterValue exceptionPcFixed = (RegisterValue) outgoingCc.getArgument(1); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
155 gen.emitMove(exceptionFixed, operand(exception)); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
156 gen.emitMove(exceptionPcFixed, operand(exceptionPc)); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
157 Register thread = getGen().getProviders().getRegisters().getThreadRegister(); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
158 AMD64HotSpotJumpToExceptionHandlerInCallerOp op = new AMD64HotSpotJumpToExceptionHandlerInCallerOp(handler, exceptionFixed, exceptionPcFixed, getGen().config.threadIsMethodHandleReturnOffset, |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
159 thread); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
160 append(op); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
161 } |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
162 |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
163 @Override |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
164 public void visitInfopointNode(InfopointNode i) { |
15263
0b25b81414c9
Move various bci constants from FrameState (gral.nodes) to BytecodeFrame (graal.api.code)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15046
diff
changeset
|
165 if (i.getState() != null && i.getState().bci == BytecodeFrame.AFTER_BCI) { |
14841
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
166 Debug.log("Ignoring InfopointNode for AFTER_BCI"); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
167 } else { |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
168 super.visitInfopointNode(i); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
169 } |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
170 } |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
171 |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
172 public void emitPrefetchAllocate(ValueNode address, ValueNode distance) { |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
173 AMD64AddressValue addr = getGen().emitAddress(operand(address), 0, gen.loadNonConst(operand(distance)), 1); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
174 append(new AMD64PrefetchOp(addr, getGen().config.allocatePrefetchInstr)); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
175 } |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
176 |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
177 @Override |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
178 public void visitDirectCompareAndSwap(DirectCompareAndSwapNode x) { |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
179 Kind kind = x.newValue().getKind(); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
180 assert kind == x.expectedValue().getKind(); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
181 |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
182 Value expected = gen.loadNonConst(operand(x.expectedValue())); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
183 Variable newVal = gen.load(operand(x.newValue())); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
184 |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
185 int disp = 0; |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
186 AMD64AddressValue address; |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
187 Value index = operand(x.offset()); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
188 if (ValueUtil.isConstant(index) && NumUtil.isInt(ValueUtil.asConstant(index).asLong() + disp)) { |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
189 assert !gen.getCodeCache().needsDataPatch(asConstant(index)); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
190 disp += (int) ValueUtil.asConstant(index).asLong(); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
191 address = new AMD64AddressValue(kind, gen.load(operand(x.object())), disp); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
192 } else { |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
193 address = new AMD64AddressValue(kind, gen.load(operand(x.object())), gen.load(index), Scale.Times1, disp); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
194 } |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
195 |
14854 | 196 RegisterValue raxLocal = AMD64.rax.asValue(kind); |
197 gen.emitMove(raxLocal, expected); | |
15024
2ee777221036
Use high level CompressionNode in lowering of CompareAndSwapNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
14923
diff
changeset
|
198 append(new CompareAndSwapOp(kind, raxLocal, address, raxLocal, newVal)); |
14841
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
199 |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
200 Variable result = newVariable(x.getKind()); |
14854 | 201 gen.emitMove(result, raxLocal); |
14841
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
202 setResult(x, result); |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
203 } |
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
204 } |