annotate graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java @ 11790:70f43f67cdcb

StubForeignCallNode is not a DeoptimizingNode
author Gilles Duboscq <duboscq@ssw.jku.at>
date Wed, 25 Sep 2013 13:05:16 +0200
parents 88d8b348914b
children 97d6932a309b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1 /*
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4 *
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
8 *
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
13 * accompanied this code).
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
14 *
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
18 *
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
21 * questions.
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
22 */
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
23 package com.oracle.graal.hotspot.amd64;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
24
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
25 import static com.oracle.graal.amd64.AMD64.*;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
26 import static com.oracle.graal.api.code.ValueUtil.*;
9562
99ef9bcb3f32 replaced unwind_exception_call assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9560
diff changeset
27 import static com.oracle.graal.hotspot.HotSpotBackend.*;
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
28
9307
1e1d619487b9 Additional assertions to guard against calls to abstract methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9247
diff changeset
29 import java.lang.reflect.*;
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
30 import java.util.*;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
31
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
32 import com.oracle.graal.amd64.*;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
33 import com.oracle.graal.api.code.*;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
34 import com.oracle.graal.api.meta.*;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
35 import com.oracle.graal.asm.*;
8643
3d2c2b68fe93 lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents: 8641
diff changeset
36 import com.oracle.graal.asm.amd64.AMD64Address.Scale;
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
37 import com.oracle.graal.compiler.amd64.*;
8586
82f6a25321b8 modeling of lock state removed from LIR and runtime specific debug info for locks moved into runtime specific classes
Doug Simon <doug.simon@oracle.com>
parents: 8367
diff changeset
38 import com.oracle.graal.compiler.gen.*;
11786
4f0e0602c1c7 AMD64HotSpotLIRGenerator: ignore InfopointNodes with AFTER_BCI
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11760
diff changeset
39 import com.oracle.graal.debug.*;
8586
82f6a25321b8 modeling of lock state removed from LIR and runtime specific debug info for locks moved into runtime specific classes
Doug Simon <doug.simon@oracle.com>
parents: 8367
diff changeset
40 import com.oracle.graal.graph.*;
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
41 import com.oracle.graal.hotspot.*;
11474
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
42 import com.oracle.graal.hotspot.amd64.AMD64HotSpotMove.CompareAndSwapCompressedOp;
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
43 import com.oracle.graal.hotspot.amd64.AMD64HotSpotMove.LoadCompressedPointer;
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
44 import com.oracle.graal.hotspot.amd64.AMD64HotSpotMove.StoreCompressedConstantOp;
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
45 import com.oracle.graal.hotspot.amd64.AMD64HotSpotMove.StoreCompressedPointer;
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
46 import com.oracle.graal.hotspot.meta.*;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
47 import com.oracle.graal.hotspot.nodes.*;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
48 import com.oracle.graal.hotspot.stubs.*;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
49 import com.oracle.graal.lir.*;
9247
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
50 import com.oracle.graal.lir.StandardOp.PlaceholderOp;
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
51 import com.oracle.graal.lir.amd64.*;
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
52 import com.oracle.graal.lir.amd64.AMD64ControlFlow.CondMoveOp;
8643
3d2c2b68fe93 lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents: 8641
diff changeset
53 import com.oracle.graal.lir.amd64.AMD64Move.CompareAndSwapOp;
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
54 import com.oracle.graal.lir.amd64.AMD64Move.LoadOp;
8643
3d2c2b68fe93 lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents: 8641
diff changeset
55 import com.oracle.graal.lir.amd64.AMD64Move.MoveFromRegOp;
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
56 import com.oracle.graal.lir.amd64.AMD64Move.StoreConstantOp;
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
57 import com.oracle.graal.lir.amd64.AMD64Move.StoreOp;
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
58 import com.oracle.graal.nodes.*;
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
59 import com.oracle.graal.nodes.calc.*;
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
60 import com.oracle.graal.nodes.java.*;
8643
3d2c2b68fe93 lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents: 8641
diff changeset
61 import com.oracle.graal.nodes.java.MethodCallTargetNode.InvokeKind;
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
62
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
63 /**
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
64 * LIR generator specialized for AMD64 HotSpot.
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
65 */
9431
c0488f573091 Make AMD64 LIR generator extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9425
diff changeset
66 public class AMD64HotSpotLIRGenerator extends AMD64LIRGenerator implements HotSpotLIRGenerator {
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
67
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
68 private HotSpotRuntime runtime() {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
69 return (HotSpotRuntime) runtime;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
70 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
71
9613
0c17815817a4 removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents: 9612
diff changeset
72 protected AMD64HotSpotLIRGenerator(StructuredGraph graph, CodeCacheProvider runtime, TargetDescription target, FrameMap frameMap, CallingConvention cc, LIR lir) {
0c17815817a4 removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents: 9612
diff changeset
73 super(graph, runtime, target, frameMap, cc, lir);
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
74 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
75
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
76 /**
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
77 * The slot reserved for storing the original return address when a frame is marked for
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
78 * deoptimization. The return address slot in the callee is overwritten with the address of a
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
79 * deoptimization stub.
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
80 */
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
81 StackSlot deoptimizationRescueSlot;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
82
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
83 /**
9247
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
84 * Utility for emitting the instruction to save RBP.
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
85 */
9247
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
86 class SaveRbp {
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
87
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
88 final PlaceholderOp placeholder;
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
89
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
90 /**
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
91 * The slot reserved for saving RBP.
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
92 */
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
93 final StackSlot reservedSlot;
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
94
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
95 public SaveRbp(PlaceholderOp placeholder) {
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
96 this.placeholder = placeholder;
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
97 this.reservedSlot = frameMap.allocateSpillSlot(Kind.Long);
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
98 assert reservedSlot.getRawOffset() == -16 : reservedSlot.getRawOffset();
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
99 }
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
100
9247
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
101 /**
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
102 * Replaces this operation with the appropriate move for saving rbp.
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
103 *
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
104 * @param useStack specifies if rbp must be saved to the stack
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
105 */
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
106 public AllocatableValue finalize(boolean useStack) {
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
107 AllocatableValue dst;
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
108 if (useStack) {
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
109 dst = reservedSlot;
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
110 } else {
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
111 frameMap.freeSpillSlot(reservedSlot);
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
112 dst = newVariable(Kind.Long);
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
113 }
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
114
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
115 placeholder.replace(lir, new MoveFromRegOp(dst, rbp.asValue(Kind.Long)));
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
116 return dst;
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
117 }
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
118 }
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
119
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
120 private SaveRbp saveRbp;
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
121
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
122 /**
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
123 * List of epilogue operations that need to restore RBP.
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
124 */
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
125 List<AMD64HotSpotEpilogueOp> epilogueOps = new ArrayList<>(2);
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
126
9560
08d1414ac62d refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents: 9507
diff changeset
127 @Override
08d1414ac62d refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents: 9507
diff changeset
128 public void append(LIRInstruction op) {
08d1414ac62d refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents: 9507
diff changeset
129 super.append(op);
08d1414ac62d refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents: 9507
diff changeset
130 if (op instanceof AMD64HotSpotEpilogueOp) {
08d1414ac62d refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents: 9507
diff changeset
131 epilogueOps.add((AMD64HotSpotEpilogueOp) op);
08d1414ac62d refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents: 9507
diff changeset
132 }
08d1414ac62d refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents: 9507
diff changeset
133 }
08d1414ac62d refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents: 9507
diff changeset
134
8586
82f6a25321b8 modeling of lock state removed from LIR and runtime specific debug info for locks moved into runtime specific classes
Doug Simon <doug.simon@oracle.com>
parents: 8367
diff changeset
135 @SuppressWarnings("hiding")
82f6a25321b8 modeling of lock state removed from LIR and runtime specific debug info for locks moved into runtime specific classes
Doug Simon <doug.simon@oracle.com>
parents: 8367
diff changeset
136 @Override
82f6a25321b8 modeling of lock state removed from LIR and runtime specific debug info for locks moved into runtime specific classes
Doug Simon <doug.simon@oracle.com>
parents: 8367
diff changeset
137 protected DebugInfoBuilder createDebugInfoBuilder(NodeMap<Value> nodeOperands) {
82f6a25321b8 modeling of lock state removed from LIR and runtime specific debug info for locks moved into runtime specific classes
Doug Simon <doug.simon@oracle.com>
parents: 8367
diff changeset
138 assert runtime().config.basicLockSize == 8;
82f6a25321b8 modeling of lock state removed from LIR and runtime specific debug info for locks moved into runtime specific classes
Doug Simon <doug.simon@oracle.com>
parents: 8367
diff changeset
139 HotSpotLockStack lockStack = new HotSpotLockStack(frameMap, Kind.Long);
82f6a25321b8 modeling of lock state removed from LIR and runtime specific debug info for locks moved into runtime specific classes
Doug Simon <doug.simon@oracle.com>
parents: 8367
diff changeset
140 return new HotSpotDebugInfoBuilder(nodeOperands, lockStack);
82f6a25321b8 modeling of lock state removed from LIR and runtime specific debug info for locks moved into runtime specific classes
Doug Simon <doug.simon@oracle.com>
parents: 8367
diff changeset
141 }
82f6a25321b8 modeling of lock state removed from LIR and runtime specific debug info for locks moved into runtime specific classes
Doug Simon <doug.simon@oracle.com>
parents: 8367
diff changeset
142
82f6a25321b8 modeling of lock state removed from LIR and runtime specific debug info for locks moved into runtime specific classes
Doug Simon <doug.simon@oracle.com>
parents: 8367
diff changeset
143 @Override
82f6a25321b8 modeling of lock state removed from LIR and runtime specific debug info for locks moved into runtime specific classes
Doug Simon <doug.simon@oracle.com>
parents: 8367
diff changeset
144 public StackSlot getLockSlot(int lockDepth) {
82f6a25321b8 modeling of lock state removed from LIR and runtime specific debug info for locks moved into runtime specific classes
Doug Simon <doug.simon@oracle.com>
parents: 8367
diff changeset
145 return ((HotSpotDebugInfoBuilder) debugInfoBuilder).lockStack().makeLockSlot(lockDepth);
82f6a25321b8 modeling of lock state removed from LIR and runtime specific debug info for locks moved into runtime specific classes
Doug Simon <doug.simon@oracle.com>
parents: 8367
diff changeset
146 }
82f6a25321b8 modeling of lock state removed from LIR and runtime specific debug info for locks moved into runtime specific classes
Doug Simon <doug.simon@oracle.com>
parents: 8367
diff changeset
147
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
148 @Override
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
149 protected void emitPrologue() {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
150
9612
66db0353f55a compilation is explicitly given a CallingConvention for the graph being compiled instead of deriving it from a method
Doug Simon <doug.simon@oracle.com>
parents: 9562
diff changeset
151 CallingConvention incomingArguments = cc;
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
152
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
153 RegisterValue rbpParam = rbp.asValue(Kind.Long);
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
154 Value[] params = new Value[incomingArguments.getArgumentCount() + 1];
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
155 for (int i = 0; i < params.length - 1; i++) {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
156 params[i] = toStackKind(incomingArguments.getArgument(i));
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
157 if (isStackSlot(params[i])) {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
158 StackSlot slot = ValueUtil.asStackSlot(params[i]);
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
159 if (slot.isInCallerFrame() && !lir.hasArgInCallerFrame()) {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
160 lir.setHasArgInCallerFrame();
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
161 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
162 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
163 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
164 params[params.length - 1] = rbpParam;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
165
11537
7ce08e264abf Fixed registers that flow into a block need to be inputs of the LabelOp, otherwise the register allocator can insert spill moves before the definition of a fixed register.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 11474
diff changeset
166 emitIncomingValues(params);
9247
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
167
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
168 saveRbp = new SaveRbp(new PlaceholderOp(currentBlock, lir.lir(currentBlock).size()));
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
169 append(saveRbp.placeholder);
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
170
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
171 for (LocalNode local : graph.getNodes(LocalNode.class)) {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
172 Value param = params[local.index()];
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
173 assert param.getKind() == local.kind().getStackKind();
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
174 setResult(local, emitMove(param));
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
175 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
176 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
177
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
178 @Override
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
179 protected void emitReturn(Value input) {
11760
ce0b00597980 made safepoint-on-return use specialized HotSpot runtime support for such safepoints (which have no debug info attached)
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
180 append(new AMD64HotSpotReturnOp(input, getStub() != null));
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
181 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
182
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
183 @Override
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
184 protected boolean needOnlyOopMaps() {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
185 // Stubs only need oop maps
9613
0c17815817a4 removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents: 9612
diff changeset
186 return graph.start() instanceof StubStartNode;
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
187 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
188
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: 9247
diff changeset
189 /**
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: 9247
diff changeset
190 * Map from debug infos that need to be updated with callee save information to the operations
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: 9247
diff changeset
191 * that provide the information.
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: 9247
diff changeset
192 */
9491
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
193 Map<LIRFrameState, AMD64RegistersPreservationOp> calleeSaveInfo = new HashMap<>();
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: 9247
diff changeset
194
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: 9247
diff changeset
195 private LIRFrameState currentRuntimeCallInfo;
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: 9247
diff changeset
196
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: 9247
diff changeset
197 @Override
9742
cff1e11941c0 moved temporaries from CallingConvention to ForeignCallLinkage
Doug Simon <doug.simon@oracle.com>
parents: 9741
diff changeset
198 protected void emitForeignCall(ForeignCallLinkage linkage, Value result, Value[] arguments, Value[] temps, LIRFrameState info) {
9491
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
199 currentRuntimeCallInfo = info;
9742
cff1e11941c0 moved temporaries from CallingConvention to ForeignCallLinkage
Doug Simon <doug.simon@oracle.com>
parents: 9741
diff changeset
200 super.emitForeignCall(linkage, result, arguments, temps, info);
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: 9247
diff changeset
201 }
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: 9247
diff changeset
202
9507
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
203 protected AMD64SaveRegistersOp emitSaveRegisters(Register[] savedRegisters, StackSlot[] savedRegisterLocations) {
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
204 AMD64SaveRegistersOp save = new AMD64SaveRegistersOp(savedRegisters, savedRegisterLocations);
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
205 append(save);
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
206 return save;
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
207 }
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
208
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
209 protected void emitRestoreRegisters(AMD64SaveRegistersOp save) {
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
210 append(new AMD64RestoreRegistersOp(save.getSlots().clone(), save));
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
211 }
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
212
9613
0c17815817a4 removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents: 9612
diff changeset
213 Stub getStub() {
0c17815817a4 removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents: 9612
diff changeset
214 if (graph.start() instanceof StubStartNode) {
0c17815817a4 removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents: 9612
diff changeset
215 return ((StubStartNode) graph.start()).getStub();
0c17815817a4 removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents: 9612
diff changeset
216 }
0c17815817a4 removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents: 9612
diff changeset
217 return null;
0c17815817a4 removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents: 9612
diff changeset
218 }
0c17815817a4 removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents: 9612
diff changeset
219
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: 9247
diff changeset
220 @Override
9741
b27184f5f66b removed redundant parameter
Doug Simon <doug.simon@oracle.com>
parents: 9740
diff changeset
221 public Variable emitForeignCall(ForeignCallLinkage linkage, DeoptimizingNode info, Value... args) {
9613
0c17815817a4 removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents: 9612
diff changeset
222 Stub stub = getStub();
9870
c65bad5126b0 pull HotSpotForeignCallLinkage.isLeaf into ForeignCallLinkage and rename to canDeoptimize
Lukas Stadler <lukas.stadler@jku.at>
parents: 9768
diff changeset
223 boolean destroysRegisters = linkage.destroysRegisters();
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: 9247
diff changeset
224
9415
016523a011b7 simplified register preservation in compiled stubs to avoid the need for using ParametersOp
Doug Simon <doug.simon@oracle.com>
parents: 9352
diff changeset
225 AMD64SaveRegistersOp save = null;
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: 9247
diff changeset
226 StackSlot[] savedRegisterLocations = null;
9693
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9613
diff changeset
227 if (destroysRegisters) {
9731
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
228 if (stub != null) {
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
229 if (stub.preservesRegisters()) {
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
230 Register[] savedRegisters = frameMap.registerConfig.getAllocatableRegisters();
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
231 savedRegisterLocations = new StackSlot[savedRegisters.length];
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
232 for (int i = 0; i < savedRegisters.length; i++) {
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
233 PlatformKind kind = target.arch.getLargestStorableKind(savedRegisters[i].getRegisterCategory());
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
234 assert kind != Kind.Illegal;
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
235 StackSlot spillSlot = frameMap.allocateSpillSlot(kind);
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
236 savedRegisterLocations[i] = spillSlot;
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
237 }
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
238 save = emitSaveRegisters(savedRegisters, savedRegisterLocations);
9491
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
239 }
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: 9247
diff changeset
240 }
9731
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
241 }
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: 9247
diff changeset
242
9768
cbf274a92e5b a leaf foreign call does not need debug info
Doug Simon <doug.simon@oracle.com>
parents: 9742
diff changeset
243 Variable result;
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: 9247
diff changeset
244
9870
c65bad5126b0 pull HotSpotForeignCallLinkage.isLeaf into ForeignCallLinkage and rename to canDeoptimize
Lukas Stadler <lukas.stadler@jku.at>
parents: 9768
diff changeset
245 if (linkage.canDeoptimize()) {
11790
70f43f67cdcb StubForeignCallNode is not a DeoptimizingNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11788
diff changeset
246 assert info != null || stub != null;
9768
cbf274a92e5b a leaf foreign call does not need debug info
Doug Simon <doug.simon@oracle.com>
parents: 9742
diff changeset
247 append(new AMD64HotSpotCRuntimeCallPrologueOp());
cbf274a92e5b a leaf foreign call does not need debug info
Doug Simon <doug.simon@oracle.com>
parents: 9742
diff changeset
248 result = super.emitForeignCall(linkage, info, args);
9491
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
249 append(new AMD64HotSpotCRuntimeCallEpilogueOp());
9768
cbf274a92e5b a leaf foreign call does not need debug info
Doug Simon <doug.simon@oracle.com>
parents: 9742
diff changeset
250 } else {
cbf274a92e5b a leaf foreign call does not need debug info
Doug Simon <doug.simon@oracle.com>
parents: 9742
diff changeset
251 result = super.emitForeignCall(linkage, null, args);
9731
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
252 }
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: 9247
diff changeset
253
9731
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
254 if (destroysRegisters) {
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
255 if (stub != null) {
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
256 if (stub.preservesRegisters()) {
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
257 assert !calleeSaveInfo.containsKey(currentRuntimeCallInfo);
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
258 calleeSaveInfo.put(currentRuntimeCallInfo, save);
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
259
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
260 emitRestoreRegisters(save);
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
261 } else {
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
262 assert zapRegisters();
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
263 }
9491
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
264 }
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: 9247
diff changeset
265 }
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: 9247
diff changeset
266
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: 9247
diff changeset
267 return result;
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: 9247
diff changeset
268 }
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: 9247
diff changeset
269
9506
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
270 protected AMD64ZapRegistersOp emitZapRegisters(Register[] zappedRegisters, Constant[] zapValues) {
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
271 AMD64ZapRegistersOp zap = new AMD64ZapRegistersOp(zappedRegisters, zapValues);
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
272 append(zap);
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
273 return zap;
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
274 }
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
275
9491
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
276 protected boolean zapRegisters() {
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
277 Register[] zappedRegisters = frameMap.registerConfig.getAllocatableRegisters();
9506
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
278 Constant[] zapValues = new Constant[zappedRegisters.length];
9491
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
279 for (int i = 0; i < zappedRegisters.length; i++) {
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
280 PlatformKind kind = target.arch.getLargestStorableKind(zappedRegisters[i].getRegisterCategory());
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
281 assert kind != Kind.Illegal;
9506
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
282 zapValues[i] = zapValueForKind(kind);
9491
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
283 }
9506
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
284 calleeSaveInfo.put(currentRuntimeCallInfo, emitZapRegisters(zappedRegisters, zapValues));
9491
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
285 return true;
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
286 }
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
287
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
288 @Override
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
289 public void visitSafepointNode(SafepointNode i) {
8892
2c0c708a0ad6 Introduce DeoptimizingNode interface
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8643
diff changeset
290 LIRFrameState info = state(i);
11760
ce0b00597980 made safepoint-on-return use specialized HotSpot runtime support for such safepoints (which have no debug info attached)
Doug Simon <doug.simon@oracle.com>
parents: 11537
diff changeset
291 append(new AMD64HotSpotSafepointOp(info, runtime().config, this));
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
292 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
293
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
294 @SuppressWarnings("hiding")
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
295 @Override
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
296 public void visitDirectCompareAndSwap(DirectCompareAndSwapNode x) {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
297 Kind kind = x.newValue().kind();
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
298 assert kind == x.expectedValue().kind();
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
299
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
300 Value expected = loadNonConst(operand(x.expectedValue()));
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
301 Variable newVal = load(operand(x.newValue()));
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
302
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
303 int disp = 0;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
304 AMD64AddressValue address;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
305 Value index = operand(x.offset());
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
306 if (ValueUtil.isConstant(index) && NumUtil.isInt(ValueUtil.asConstant(index).asLong() + disp)) {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
307 assert !runtime.needsDataPatch(asConstant(index));
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
308 disp += (int) ValueUtil.asConstant(index).asLong();
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
309 address = new AMD64AddressValue(kind, load(operand(x.object())), disp);
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
310 } else {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
311 address = new AMD64AddressValue(kind, load(operand(x.object())), load(index), Scale.Times1, disp);
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
312 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
313
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
314 RegisterValue rax = AMD64.rax.asValue(kind);
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
315 emitMove(rax, expected);
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
316 append(new CompareAndSwapOp(rax, address, rax, newVal));
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
317
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
318 Variable result = newVariable(x.kind());
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
319 emitMove(result, rax);
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
320 setResult(x, result);
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
321 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
322
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
323 @Override
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
324 public void emitTailcall(Value[] args, Value address) {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
325 append(new AMD64TailcallOp(args, address));
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
326 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
327
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
328 @Override
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
329 protected void emitDirectCall(DirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState) {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
330 InvokeKind invokeKind = ((HotSpotDirectCallTargetNode) callTarget).invokeKind();
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
331 if (invokeKind == InvokeKind.Interface || invokeKind == InvokeKind.Virtual) {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
332 append(new AMD64HotspotDirectVirtualCallOp(callTarget.target(), result, parameters, temps, callState, invokeKind));
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
333 } else {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
334 assert invokeKind == InvokeKind.Static || invokeKind == InvokeKind.Special;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
335 HotSpotResolvedJavaMethod resolvedMethod = (HotSpotResolvedJavaMethod) callTarget.target();
9307
1e1d619487b9 Additional assertions to guard against calls to abstract methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9247
diff changeset
336 assert !Modifier.isAbstract(resolvedMethod.getModifiers()) : "Cannot make direct call to abstract method.";
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
337 Constant metaspaceMethod = resolvedMethod.getMetaspaceMethodConstant();
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
338 append(new AMD64HotspotDirectStaticCallOp(callTarget.target(), result, parameters, temps, callState, invokeKind, metaspaceMethod));
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
339 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
340 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
341
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
342 @Override
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
343 protected void emitIndirectCall(IndirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState) {
10654
d71c56c67921 Improve performance of calling Truffle call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10610
diff changeset
344 if (callTarget instanceof HotSpotIndirectCallTargetNode) {
d71c56c67921 Improve performance of calling Truffle call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10610
diff changeset
345 AllocatableValue metaspaceMethod = AMD64.rbx.asValue();
d71c56c67921 Improve performance of calling Truffle call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10610
diff changeset
346 emitMove(metaspaceMethod, operand(((HotSpotIndirectCallTargetNode) callTarget).metaspaceMethod()));
d71c56c67921 Improve performance of calling Truffle call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10610
diff changeset
347 AllocatableValue targetAddress = AMD64.rax.asValue();
d71c56c67921 Improve performance of calling Truffle call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10610
diff changeset
348 emitMove(targetAddress, operand(callTarget.computedAddress()));
d71c56c67921 Improve performance of calling Truffle call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10610
diff changeset
349 append(new AMD64IndirectCallOp(callTarget.target(), result, parameters, temps, metaspaceMethod, targetAddress, callState));
d71c56c67921 Improve performance of calling Truffle call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10610
diff changeset
350 } else {
d71c56c67921 Improve performance of calling Truffle call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10610
diff changeset
351 super.emitIndirectCall(callTarget, result, parameters, temps, callState);
d71c56c67921 Improve performance of calling Truffle call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10610
diff changeset
352 }
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
353 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
354
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
355 @Override
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
356 public void emitUnwind(Value exception) {
9739
4cd4926ec683 rename: RuntimeCallTarget -> ForeignCallLinkage
Doug Simon <doug.simon@oracle.com>
parents: 9731
diff changeset
357 ForeignCallLinkage linkage = getRuntime().lookupForeignCall(HotSpotBackend.UNWIND_EXCEPTION_TO_CALLER);
10873
de55425d3cf5 small cleanups and extra documentation around foreign call linkage
Doug Simon <doug.simon@oracle.com>
parents: 10870
diff changeset
358 CallingConvention outgoingCc = linkage.getOutgoingCallingConvention();
de55425d3cf5 small cleanups and extra documentation around foreign call linkage
Doug Simon <doug.simon@oracle.com>
parents: 10870
diff changeset
359 assert outgoingCc.getArgumentCount() == 2;
de55425d3cf5 small cleanups and extra documentation around foreign call linkage
Doug Simon <doug.simon@oracle.com>
parents: 10870
diff changeset
360 RegisterValue exceptionParameter = (RegisterValue) outgoingCc.getArgument(0);
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
361 emitMove(exceptionParameter, exception);
9562
99ef9bcb3f32 replaced unwind_exception_call assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9560
diff changeset
362 append(new AMD64HotSpotUnwindOp(exceptionParameter));
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
363 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
364
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
365 @Override
8892
2c0c708a0ad6 Introduce DeoptimizingNode interface
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8643
diff changeset
366 public void emitDeoptimize(DeoptimizationAction action, DeoptimizingNode deopting) {
2c0c708a0ad6 Introduce DeoptimizingNode interface
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8643
diff changeset
367 append(new AMD64DeoptimizeOp(action, deopting.getDeoptimizationReason(), state(deopting)));
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
368 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
369
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
370 @Override
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: 9247
diff changeset
371 public void emitDeoptimizeCaller(DeoptimizationAction action, DeoptimizationReason reason) {
9560
08d1414ac62d refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents: 9507
diff changeset
372 append(new AMD64HotSpotDeoptimizeCallerOp(action, reason));
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: 9247
diff changeset
373 }
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: 9247
diff changeset
374
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: 9247
diff changeset
375 @Override
9471
5fa54bf57f8c replaced exception_handler_nofpu assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9433
diff changeset
376 public void emitPatchReturnAddress(ValueNode address) {
9560
08d1414ac62d refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents: 9507
diff changeset
377 append(new AMD64HotSpotPatchReturnAddressOp(load(operand(address))));
9471
5fa54bf57f8c replaced exception_handler_nofpu assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9433
diff changeset
378 }
5fa54bf57f8c replaced exception_handler_nofpu assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9433
diff changeset
379
5fa54bf57f8c replaced exception_handler_nofpu assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9433
diff changeset
380 @Override
9562
99ef9bcb3f32 replaced unwind_exception_call assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9560
diff changeset
381 public void emitJumpToExceptionHandlerInCaller(ValueNode handlerInCallerPc, ValueNode exception, ValueNode exceptionPc) {
99ef9bcb3f32 replaced unwind_exception_call assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9560
diff changeset
382 Variable handler = load(operand(handlerInCallerPc));
9739
4cd4926ec683 rename: RuntimeCallTarget -> ForeignCallLinkage
Doug Simon <doug.simon@oracle.com>
parents: 9731
diff changeset
383 ForeignCallLinkage linkage = getRuntime().lookupForeignCall(EXCEPTION_HANDLER_IN_CALLER);
10873
de55425d3cf5 small cleanups and extra documentation around foreign call linkage
Doug Simon <doug.simon@oracle.com>
parents: 10870
diff changeset
384 CallingConvention outgoingCc = linkage.getOutgoingCallingConvention();
de55425d3cf5 small cleanups and extra documentation around foreign call linkage
Doug Simon <doug.simon@oracle.com>
parents: 10870
diff changeset
385 assert outgoingCc.getArgumentCount() == 2;
de55425d3cf5 small cleanups and extra documentation around foreign call linkage
Doug Simon <doug.simon@oracle.com>
parents: 10870
diff changeset
386 RegisterValue exceptionFixed = (RegisterValue) outgoingCc.getArgument(0);
de55425d3cf5 small cleanups and extra documentation around foreign call linkage
Doug Simon <doug.simon@oracle.com>
parents: 10870
diff changeset
387 RegisterValue exceptionPcFixed = (RegisterValue) outgoingCc.getArgument(1);
9562
99ef9bcb3f32 replaced unwind_exception_call assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9560
diff changeset
388 emitMove(exceptionFixed, operand(exception));
99ef9bcb3f32 replaced unwind_exception_call assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9560
diff changeset
389 emitMove(exceptionPcFixed, operand(exceptionPc));
99ef9bcb3f32 replaced unwind_exception_call assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9560
diff changeset
390 AMD64HotSpotJumpToExceptionHandlerInCallerOp op = new AMD64HotSpotJumpToExceptionHandlerInCallerOp(handler, exceptionFixed, exceptionPcFixed);
99ef9bcb3f32 replaced unwind_exception_call assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9560
diff changeset
391 append(op);
99ef9bcb3f32 replaced unwind_exception_call assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9560
diff changeset
392 }
99ef9bcb3f32 replaced unwind_exception_call assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9560
diff changeset
393
99ef9bcb3f32 replaced unwind_exception_call assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9560
diff changeset
394 @Override
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
395 public void beforeRegisterAllocation() {
9247
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
396 boolean hasDebugInfo = lir.hasDebugInfo();
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
397 AllocatableValue savedRbp = saveRbp.finalize(hasDebugInfo);
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
398 if (hasDebugInfo) {
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
399 deoptimizationRescueSlot = frameMap.allocateSpillSlot(Kind.Long);
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
400 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
401
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
402 for (AMD64HotSpotEpilogueOp op : epilogueOps) {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
403 op.savedRbp = savedRbp;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
404 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
405 }
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
406
11453
1092208e4986 Add Javadoc
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11452
diff changeset
407 /**
1092208e4986 Add Javadoc
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11452
diff changeset
408 * Returns whether or not the input access is a (de)compression candidate.
1092208e4986 Add Javadoc
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11452
diff changeset
409 */
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
410 private static boolean isCompressCandidate(DeoptimizingNode access) {
10831
000ee2d0c518 Method renaming
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10821
diff changeset
411 return access != null && ((HeapAccess) access).isCompressible();
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
412 }
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
413
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
414 @Override
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
415 public Variable emitLoad(Kind kind, Value address, DeoptimizingNode access) {
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
416 AMD64AddressValue loadAddress = asAddressValue(address);
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
417 Variable result = newVariable(kind);
9894
9d0031cf5df9 Fix Assertion in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9885
diff changeset
418 assert access == null || access instanceof HeapAccess;
11453
1092208e4986 Add Javadoc
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11452
diff changeset
419 /**
1092208e4986 Add Javadoc
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11452
diff changeset
420 * Currently, the (de)compression of pointers applies conditionally to some objects (oops,
1092208e4986 Add Javadoc
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11452
diff changeset
421 * kind==Object) and some addresses (klass pointers, kind==Long). Initially, the input
1092208e4986 Add Javadoc
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11452
diff changeset
422 * operation is checked to discover if it has been tagged as a potential "compression"
1092208e4986 Add Javadoc
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11452
diff changeset
423 * candidate. Consequently, depending on the appropriate kind, the specific (de)compression
1092208e4986 Add Javadoc
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11452
diff changeset
424 * functions are being called. Although, currently, the compression and decompression
1092208e4986 Add Javadoc
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11452
diff changeset
425 * algorithms of oops and klass pointers are identical, in hotspot, they are implemented as
1092208e4986 Add Javadoc
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11452
diff changeset
426 * separate methods. That means that in the future there might be the case where the
1092208e4986 Add Javadoc
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11452
diff changeset
427 * algorithms may differ.
1092208e4986 Add Javadoc
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11452
diff changeset
428 */
10731
40f6bda3f91d Add compressed klass pointers support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10718
diff changeset
429 if (isCompressCandidate(access)) {
11474
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
430 if (runtime().useCompressedOops() && kind == Kind.Object) {
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
431 append(new LoadCompressedPointer(kind, result, runtime().heapBaseRegister().asValue(), loadAddress, access != null ? state(access) : null, getNarrowOopBase(), getNarrowOopShift(),
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
432 getLogMinObjectAlignment()));
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
433 } else if (runtime().useCompressedKlassPointers() && kind == Kind.Long) {
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
434 append(new LoadCompressedPointer(kind, result, runtime().heapBaseRegister().asValue(), loadAddress, access != null ? state(access) : null, getNarrowKlassBase(), getNarrowKlassShift(),
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
435 getLogKlassAlignment()));
10731
40f6bda3f91d Add compressed klass pointers support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10718
diff changeset
436 } else {
40f6bda3f91d Add compressed klass pointers support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10718
diff changeset
437 append(new LoadOp(kind, result, loadAddress, access != null ? state(access) : null));
40f6bda3f91d Add compressed klass pointers support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10718
diff changeset
438 }
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
439 } else {
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
440 append(new LoadOp(kind, result, loadAddress, access != null ? state(access) : null));
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
441 }
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
442 return result;
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
443 }
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
444
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
445 @Override
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
446 public void emitStore(Kind kind, Value address, Value inputVal, DeoptimizingNode access) {
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
447 AMD64AddressValue storeAddress = asAddressValue(address);
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
448 LIRFrameState state = access != null ? state(access) : null;
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
449 if (isConstant(inputVal)) {
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
450 Constant c = asConstant(inputVal);
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
451 if (canStoreConstant(c)) {
11474
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
452 if (inputVal.getKind() == Kind.Object && runtime().useCompressedOops() && isCompressCandidate(access)) {
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
453 append(new StoreCompressedConstantOp(kind, storeAddress, c, state));
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
454 } else if (inputVal.getKind() == Kind.Long && runtime().useCompressedKlassPointers() && isCompressCandidate(access)) {
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
455 append(new StoreCompressedConstantOp(kind, storeAddress, c, state));
10731
40f6bda3f91d Add compressed klass pointers support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10718
diff changeset
456 } else {
11474
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
457 append(new StoreConstantOp(kind, storeAddress, c, state));
10731
40f6bda3f91d Add compressed klass pointers support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10718
diff changeset
458 }
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
459 return;
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
460 }
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
461 }
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
462 Variable input = load(inputVal);
10731
40f6bda3f91d Add compressed klass pointers support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10718
diff changeset
463 if (isCompressCandidate(access)) {
11474
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
464 if (runtime().useCompressedOops() && kind == Kind.Object) {
10747
3811d04d933e Do not re-compress oops that are already compressed.
Roland Schatz <roland.schatz@oracle.com>
parents: 10731
diff changeset
465 if (input.getKind() == Kind.Object) {
3811d04d933e Do not re-compress oops that are already compressed.
Roland Schatz <roland.schatz@oracle.com>
parents: 10731
diff changeset
466 Variable scratch = newVariable(Kind.Long);
11474
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
467 append(new StoreCompressedPointer(kind, storeAddress, input, scratch, state, getNarrowOopBase(), getNarrowOopShift(), getLogMinObjectAlignment()));
10747
3811d04d933e Do not re-compress oops that are already compressed.
Roland Schatz <roland.schatz@oracle.com>
parents: 10731
diff changeset
468 } else {
3811d04d933e Do not re-compress oops that are already compressed.
Roland Schatz <roland.schatz@oracle.com>
parents: 10731
diff changeset
469 // the input oop is already compressed
3811d04d933e Do not re-compress oops that are already compressed.
Roland Schatz <roland.schatz@oracle.com>
parents: 10731
diff changeset
470 append(new StoreOp(input.getKind(), storeAddress, input, state));
3811d04d933e Do not re-compress oops that are already compressed.
Roland Schatz <roland.schatz@oracle.com>
parents: 10731
diff changeset
471 }
11474
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
472 } else if (runtime().useCompressedKlassPointers() && kind == Kind.Long) {
10731
40f6bda3f91d Add compressed klass pointers support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10718
diff changeset
473 Variable scratch = newVariable(Kind.Long);
11474
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
474 append(new StoreCompressedPointer(kind, storeAddress, input, scratch, state, getNarrowKlassBase(), getNarrowKlassShift(), getLogKlassAlignment()));
10610
1db97e3de11c Do not re-compress oops that are already compressed.
Roland Schatz <roland.schatz@oracle.com>
parents: 9980
diff changeset
475 } else {
10731
40f6bda3f91d Add compressed klass pointers support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10718
diff changeset
476 append(new StoreOp(kind, storeAddress, input, state));
10610
1db97e3de11c Do not re-compress oops that are already compressed.
Roland Schatz <roland.schatz@oracle.com>
parents: 9980
diff changeset
477 }
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
478 } else {
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
479 append(new StoreOp(kind, storeAddress, input, state));
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
480 }
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
481 }
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
482
11474
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
483 private int getLogMinObjectAlignment() {
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
484 return runtime().config.logMinObjAlignment;
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
485 }
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
486
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
487 private int getNarrowOopShift() {
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
488 return runtime().config.narrowOopShift;
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
489 }
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
490
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
491 private long getNarrowOopBase() {
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
492 return runtime().config.narrowOopBase;
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
493 }
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
494
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
495 private int getLogKlassAlignment() {
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
496 return runtime().config.logKlassAlignment;
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
497 }
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
498
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
499 private int getNarrowKlassShift() {
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
500 return runtime().config.narrowKlassShift;
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
501 }
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
502
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
503 private long getNarrowKlassBase() {
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
504 return runtime().config.narrowKlassBase;
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
505 }
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
506
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
507 @Override
10850
e7679ec4f27f Lower CAS nodes to their lowered versions
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10831
diff changeset
508 public void visitCompareAndSwap(LoweredCompareAndSwapNode node, Value address) {
e7679ec4f27f Lower CAS nodes to their lowered versions
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10831
diff changeset
509 Kind kind = node.getNewValue().kind();
e7679ec4f27f Lower CAS nodes to their lowered versions
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10831
diff changeset
510 assert kind == node.getExpectedValue().kind();
e7679ec4f27f Lower CAS nodes to their lowered versions
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10831
diff changeset
511 Value expected = loadNonConst(operand(node.getExpectedValue()));
e7679ec4f27f Lower CAS nodes to their lowered versions
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10831
diff changeset
512 Variable newValue = load(operand(node.getNewValue()));
e7679ec4f27f Lower CAS nodes to their lowered versions
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10831
diff changeset
513 AMD64AddressValue addressValue = asAddressValue(address);
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
514 RegisterValue raxRes = AMD64.rax.asValue(kind);
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
515 emitMove(raxRes, expected);
11474
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
516 if (runtime().useCompressedOops() && node.isCompressible()) {
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
517 Variable scratch = newVariable(Kind.Long);
11474
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
518 append(new CompareAndSwapCompressedOp(raxRes, addressValue, raxRes, newValue, scratch, getNarrowOopBase(), getNarrowOopShift(), getLogMinObjectAlignment()));
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
519 } else {
10850
e7679ec4f27f Lower CAS nodes to their lowered versions
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10831
diff changeset
520 append(new CompareAndSwapOp(raxRes, addressValue, raxRes, newValue));
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
521 }
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
522 Variable result = newVariable(node.kind());
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
523 append(new CondMoveOp(result, Condition.EQ, load(Constant.TRUE), Constant.FALSE));
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
524 setResult(node, result);
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
525 }
11786
4f0e0602c1c7 AMD64HotSpotLIRGenerator: ignore InfopointNodes with AFTER_BCI
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11760
diff changeset
526
4f0e0602c1c7 AMD64HotSpotLIRGenerator: ignore InfopointNodes with AFTER_BCI
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11760
diff changeset
527 @Override
4f0e0602c1c7 AMD64HotSpotLIRGenerator: ignore InfopointNodes with AFTER_BCI
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11760
diff changeset
528 public void visitInfopointNode(InfopointNode i) {
11788
88d8b348914b Make InfopointNode a NodeWithState, it is not a StateSplit anymore
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11786
diff changeset
529 if (i.getState() != null && i.getState().bci == FrameState.AFTER_BCI) {
11786
4f0e0602c1c7 AMD64HotSpotLIRGenerator: ignore InfopointNodes with AFTER_BCI
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11760
diff changeset
530 Debug.log("Ignoring InfopointNode for AFTER_BCI");
4f0e0602c1c7 AMD64HotSpotLIRGenerator: ignore InfopointNodes with AFTER_BCI
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11760
diff changeset
531 } else {
4f0e0602c1c7 AMD64HotSpotLIRGenerator: ignore InfopointNodes with AFTER_BCI
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11760
diff changeset
532 super.visitInfopointNode(i);
4f0e0602c1c7 AMD64HotSpotLIRGenerator: ignore InfopointNodes with AFTER_BCI
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11760
diff changeset
533 }
4f0e0602c1c7 AMD64HotSpotLIRGenerator: ignore InfopointNodes with AFTER_BCI
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11760
diff changeset
534 }
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
535 }