annotate graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java @ 12431:7080a96be216

rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
author Doug Simon <doug.simon@oracle.com>
date Tue, 15 Oct 2013 22:21:01 +0200
parents 5124eeec1a7b
children f87c68d79f07
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.*;
11832
97d6932a309b CodeCacheProvider.encodeDeoptActionAndReason now returns a Constant
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11790
diff changeset
28 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
29
9307
1e1d619487b9 Additional assertions to guard against calls to abstract methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9247
diff changeset
30 import java.lang.reflect.*;
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
31 import java.util.*;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
32
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
33 import com.oracle.graal.amd64.*;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
34 import com.oracle.graal.api.code.*;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
35 import com.oracle.graal.api.meta.*;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
36 import com.oracle.graal.asm.*;
8643
3d2c2b68fe93 lower ExceptionObjectNode with a snippet (GRAAL-133)
Doug Simon <doug.simon@oracle.com>
parents: 8641
diff changeset
37 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
38 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
39 import com.oracle.graal.compiler.gen.*;
11786
4f0e0602c1c7 AMD64HotSpotLIRGenerator: ignore InfopointNodes with AFTER_BCI
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11760
diff changeset
40 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
41 import com.oracle.graal.graph.*;
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
42 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
43 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
44 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
45 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
46 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
47 import com.oracle.graal.hotspot.meta.*;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
48 import com.oracle.graal.hotspot.nodes.*;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
49 import com.oracle.graal.hotspot.stubs.*;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
50 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
51 import com.oracle.graal.lir.StandardOp.PlaceholderOp;
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
52 import com.oracle.graal.lir.amd64.*;
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
53 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
54 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
55 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
56 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
57 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
58 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
59 import com.oracle.graal.nodes.*;
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
60 import com.oracle.graal.nodes.calc.*;
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
61 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
62 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
63
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
64 /**
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
65 * LIR generator specialized for AMD64 HotSpot.
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
66 */
9431
c0488f573091 Make AMD64 LIR generator extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9425
diff changeset
67 public class AMD64HotSpotLIRGenerator extends AMD64LIRGenerator implements HotSpotLIRGenerator {
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
68
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
69 private final HotSpotVMConfig config;
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
70
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
71 protected AMD64HotSpotLIRGenerator(StructuredGraph graph, HotSpotProviders providers, HotSpotVMConfig config, FrameMap frameMap, CallingConvention cc, LIR lir) {
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
72 super(graph, providers, frameMap, cc, lir);
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
73 assert config.basicLockSize == 8;
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
74 this.config = config;
8303
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
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
77 @Override
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
78 protected HotSpotProviders getProviders() {
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
79 return (HotSpotProviders) super.getProviders();
8303
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
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 * 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
84 * 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
85 * deoptimization stub.
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
86 */
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
87 StackSlot deoptimizationRescueSlot;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
88
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
89 /**
9247
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
90 * 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
91 */
9247
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
92 class SaveRbp {
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
93
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
94 final PlaceholderOp placeholder;
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
95
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
96 /**
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
97 * 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
98 */
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
99 final StackSlot reservedSlot;
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
100
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
101 public SaveRbp(PlaceholderOp placeholder) {
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
102 this.placeholder = placeholder;
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
103 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
104 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
105 }
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
106
9247
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
107 /**
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
108 * 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
109 *
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
110 * @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
111 */
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
112 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
113 AllocatableValue dst;
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
114 if (useStack) {
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
115 dst = reservedSlot;
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
116 } else {
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
117 frameMap.freeSpillSlot(reservedSlot);
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
118 dst = newVariable(Kind.Long);
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
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
121 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
122 return dst;
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
123 }
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
124 }
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
125
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
126 private SaveRbp saveRbp;
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
127
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
128 /**
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
129 * 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
130 */
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
131 List<AMD64HotSpotEpilogueOp> epilogueOps = new ArrayList<>(2);
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
132
9560
08d1414ac62d refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents: 9507
diff changeset
133 @Override
08d1414ac62d refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents: 9507
diff changeset
134 public void append(LIRInstruction op) {
08d1414ac62d refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents: 9507
diff changeset
135 super.append(op);
08d1414ac62d refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents: 9507
diff changeset
136 if (op instanceof AMD64HotSpotEpilogueOp) {
08d1414ac62d refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents: 9507
diff changeset
137 epilogueOps.add((AMD64HotSpotEpilogueOp) op);
08d1414ac62d refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents: 9507
diff changeset
138 }
08d1414ac62d refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents: 9507
diff changeset
139 }
08d1414ac62d refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents: 9507
diff changeset
140
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
141 @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
142 @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
143 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
144 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
145 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
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
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
148 @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
149 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
150 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
151 }
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
152
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
153 @Override
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
154 protected void emitPrologue() {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
155
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
156 CallingConvention incomingArguments = cc;
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
157
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
158 RegisterValue rbpParam = rbp.asValue(Kind.Long);
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
159 Value[] params = new Value[incomingArguments.getArgumentCount() + 1];
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
160 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
161 params[i] = toStackKind(incomingArguments.getArgument(i));
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
162 if (isStackSlot(params[i])) {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
163 StackSlot slot = ValueUtil.asStackSlot(params[i]);
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
164 if (slot.isInCallerFrame() && !lir.hasArgInCallerFrame()) {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
165 lir.setHasArgInCallerFrame();
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
166 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
167 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
168 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
169 params[params.length - 1] = rbpParam;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
170
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
171 emitIncomingValues(params);
9247
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
172
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
173 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
174 append(saveRbp.placeholder);
8303
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 for (LocalNode local : graph.getNodes(LocalNode.class)) {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
177 Value param = params[local.index()];
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
178 assert param.getKind() == local.kind().getStackKind();
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
179 setResult(local, emitMove(param));
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
180 }
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 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
185 append(new AMD64HotSpotReturnOp(input, getStub() != null));
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
186 }
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 @Override
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
189 protected boolean needOnlyOopMaps() {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
190 // Stubs only need oop maps
9613
0c17815817a4 removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents: 9612
diff changeset
191 return graph.start() instanceof StubStartNode;
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
192 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
193
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 * 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
196 * 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
197 */
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
198 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
199
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
200 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
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 @Override
9742
cff1e11941c0 moved temporaries from CallingConvention to ForeignCallLinkage
Doug Simon <doug.simon@oracle.com>
parents: 9741
diff changeset
203 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
204 currentRuntimeCallInfo = info;
9742
cff1e11941c0 moved temporaries from CallingConvention to ForeignCallLinkage
Doug Simon <doug.simon@oracle.com>
parents: 9741
diff changeset
205 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
206 }
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
207
9507
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
208 protected AMD64SaveRegistersOp emitSaveRegisters(Register[] savedRegisters, StackSlot[] savedRegisterLocations) {
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
209 AMD64SaveRegistersOp save = new AMD64SaveRegistersOp(savedRegisters, savedRegisterLocations);
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
210 append(save);
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
211 return save;
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
212 }
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
213
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
214 protected void emitRestoreRegisters(AMD64SaveRegistersOp save) {
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
215 append(new AMD64RestoreRegistersOp(save.getSlots().clone(), save));
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
216 }
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
217
9613
0c17815817a4 removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents: 9612
diff changeset
218 Stub getStub() {
0c17815817a4 removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents: 9612
diff changeset
219 if (graph.start() instanceof StubStartNode) {
0c17815817a4 removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents: 9612
diff changeset
220 return ((StubStartNode) graph.start()).getStub();
0c17815817a4 removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents: 9612
diff changeset
221 }
0c17815817a4 removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents: 9612
diff changeset
222 return null;
0c17815817a4 removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents: 9612
diff changeset
223 }
0c17815817a4 removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents: 9612
diff changeset
224
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
225 @Override
9741
b27184f5f66b removed redundant parameter
Doug Simon <doug.simon@oracle.com>
parents: 9740
diff changeset
226 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
227 Stub stub = getStub();
9870
c65bad5126b0 pull HotSpotForeignCallLinkage.isLeaf into ForeignCallLinkage and rename to canDeoptimize
Lukas Stadler <lukas.stadler@jku.at>
parents: 9768
diff changeset
228 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
229
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
230 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
231 StackSlot[] savedRegisterLocations = null;
9693
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9613
diff changeset
232 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
233 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
234 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
235 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
236 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
237 for (int i = 0; i < savedRegisters.length; i++) {
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
238 PlatformKind kind = target().arch.getLargestStorableKind(savedRegisters[i].getRegisterCategory());
9731
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
239 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
240 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
241 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
242 }
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
243 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
244 }
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
245 }
9731
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
246 }
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
247
9768
cbf274a92e5b a leaf foreign call does not need debug info
Doug Simon <doug.simon@oracle.com>
parents: 9742
diff changeset
248 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
249
9870
c65bad5126b0 pull HotSpotForeignCallLinkage.isLeaf into ForeignCallLinkage and rename to canDeoptimize
Lukas Stadler <lukas.stadler@jku.at>
parents: 9768
diff changeset
250 if (linkage.canDeoptimize()) {
11790
70f43f67cdcb StubForeignCallNode is not a DeoptimizingNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11788
diff changeset
251 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
252 append(new AMD64HotSpotCRuntimeCallPrologueOp());
cbf274a92e5b a leaf foreign call does not need debug info
Doug Simon <doug.simon@oracle.com>
parents: 9742
diff changeset
253 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
254 append(new AMD64HotSpotCRuntimeCallEpilogueOp());
9768
cbf274a92e5b a leaf foreign call does not need debug info
Doug Simon <doug.simon@oracle.com>
parents: 9742
diff changeset
255 } else {
cbf274a92e5b a leaf foreign call does not need debug info
Doug Simon <doug.simon@oracle.com>
parents: 9742
diff changeset
256 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
257 }
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
258
9731
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
259 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
260 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
261 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
262 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
263 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
264
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
265 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
266 } else {
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
267 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
268 }
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
269 }
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
270 }
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
271
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
272 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
273 }
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
274
9506
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
275 protected AMD64ZapRegistersOp emitZapRegisters(Register[] zappedRegisters, Constant[] zapValues) {
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
276 AMD64ZapRegistersOp zap = new AMD64ZapRegistersOp(zappedRegisters, zapValues);
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
277 append(zap);
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
278 return zap;
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
279 }
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
280
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
281 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
282 Register[] zappedRegisters = frameMap.registerConfig.getAllocatableRegisters();
9506
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
283 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
284 for (int i = 0; i < zappedRegisters.length; i++) {
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
285 PlatformKind kind = target().arch.getLargestStorableKind(zappedRegisters[i].getRegisterCategory());
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
286 assert kind != Kind.Illegal;
9506
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
287 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
288 }
9506
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
289 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
290 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
291 }
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
292
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
293 @Override
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
294 public void visitSafepointNode(SafepointNode i) {
8892
2c0c708a0ad6 Introduce DeoptimizingNode interface
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8643
diff changeset
295 LIRFrameState info = state(i);
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
296 append(new AMD64HotSpotSafepointOp(info, config, this));
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
297 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
298
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
299 @SuppressWarnings("hiding")
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
300 @Override
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
301 public void visitDirectCompareAndSwap(DirectCompareAndSwapNode x) {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
302 Kind kind = x.newValue().kind();
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
303 assert kind == x.expectedValue().kind();
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
304
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
305 Value expected = loadNonConst(operand(x.expectedValue()));
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
306 Variable newVal = load(operand(x.newValue()));
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
307
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
308 int disp = 0;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
309 AMD64AddressValue address;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
310 Value index = operand(x.offset());
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
311 if (ValueUtil.isConstant(index) && NumUtil.isInt(ValueUtil.asConstant(index).asLong() + disp)) {
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
312 assert !getCodeCache().needsDataPatch(asConstant(index));
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
313 disp += (int) ValueUtil.asConstant(index).asLong();
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
314 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
315 } else {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
316 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
317 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
318
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
319 RegisterValue rax = AMD64.rax.asValue(kind);
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
320 emitMove(rax, expected);
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
321 append(new CompareAndSwapOp(rax, address, rax, newVal));
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 Variable result = newVariable(x.kind());
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
324 emitMove(result, rax);
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
325 setResult(x, result);
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 public void emitTailcall(Value[] args, Value address) {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
330 append(new AMD64TailcallOp(args, address));
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
331 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
332
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
333 @Override
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
334 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
335 InvokeKind invokeKind = ((HotSpotDirectCallTargetNode) callTarget).invokeKind();
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
336 if (invokeKind == InvokeKind.Interface || invokeKind == InvokeKind.Virtual) {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
337 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
338 } else {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
339 assert invokeKind == InvokeKind.Static || invokeKind == InvokeKind.Special;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
340 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
341 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
342 Constant metaspaceMethod = resolvedMethod.getMetaspaceMethodConstant();
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
343 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
344 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
345 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
346
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
347 @Override
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
348 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
349 if (callTarget instanceof HotSpotIndirectCallTargetNode) {
d71c56c67921 Improve performance of calling Truffle call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10610
diff changeset
350 AllocatableValue metaspaceMethod = AMD64.rbx.asValue();
d71c56c67921 Improve performance of calling Truffle call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10610
diff changeset
351 emitMove(metaspaceMethod, operand(((HotSpotIndirectCallTargetNode) callTarget).metaspaceMethod()));
d71c56c67921 Improve performance of calling Truffle call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10610
diff changeset
352 AllocatableValue targetAddress = AMD64.rax.asValue();
d71c56c67921 Improve performance of calling Truffle call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10610
diff changeset
353 emitMove(targetAddress, operand(callTarget.computedAddress()));
d71c56c67921 Improve performance of calling Truffle call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10610
diff changeset
354 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
355 } else {
d71c56c67921 Improve performance of calling Truffle call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10610
diff changeset
356 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
357 }
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
358 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
359
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
360 @Override
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
361 public void emitUnwind(Value exception) {
12363
78e5badf4b8e moved lookupForeignCall() from CodeCacheProvider to ForeignCallsProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12058
diff changeset
362 ForeignCallLinkage linkage = getForeignCalls().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
363 CallingConvention outgoingCc = linkage.getOutgoingCallingConvention();
de55425d3cf5 small cleanups and extra documentation around foreign call linkage
Doug Simon <doug.simon@oracle.com>
parents: 10870
diff changeset
364 assert outgoingCc.getArgumentCount() == 2;
de55425d3cf5 small cleanups and extra documentation around foreign call linkage
Doug Simon <doug.simon@oracle.com>
parents: 10870
diff changeset
365 RegisterValue exceptionParameter = (RegisterValue) outgoingCc.getArgument(0);
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
366 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
367 append(new AMD64HotSpotUnwindOp(exceptionParameter));
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
11836
d72c314260dc Add a DynamicDeoptimizeNode where the action and reason is a input node.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11834
diff changeset
370 private void moveDeoptimizationActionAndReasonToThread(Value actionAndReason) {
12431
7080a96be216 rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents: 12429
diff changeset
371 int pendingDeoptimizationOffset = runtime().getConfig().pendingDeoptimizationOffset;
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
372 Kind wordKind = getProviders().getCodeCache().getTarget().wordKind;
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
373 RegisterValue thread = getProviders().getRegisters().getThreadRegister().asValue(wordKind);
11836
d72c314260dc Add a DynamicDeoptimizeNode where the action and reason is a input node.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11834
diff changeset
374 AMD64AddressValue pendingDeoptAddress = new AMD64AddressValue(actionAndReason.getKind(), thread, pendingDeoptimizationOffset);
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
375 if (actionAndReason instanceof Constant && !getCodeCache().needsDataPatch((Constant) actionAndReason)) {
11836
d72c314260dc Add a DynamicDeoptimizeNode where the action and reason is a input node.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11834
diff changeset
376 Constant constantActionAndReason = (Constant) actionAndReason;
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
377 assert !getCodeCache().needsDataPatch(constantActionAndReason);
11836
d72c314260dc Add a DynamicDeoptimizeNode where the action and reason is a input node.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11834
diff changeset
378 append(new StoreConstantOp(constantActionAndReason.getKind(), pendingDeoptAddress, constantActionAndReason, null));
11832
97d6932a309b CodeCacheProvider.encodeDeoptActionAndReason now returns a Constant
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11790
diff changeset
379 } else {
11836
d72c314260dc Add a DynamicDeoptimizeNode where the action and reason is a input node.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11834
diff changeset
380 append(new StoreOp(actionAndReason.getKind(), pendingDeoptAddress, load(actionAndReason), null));
11832
97d6932a309b CodeCacheProvider.encodeDeoptActionAndReason now returns a Constant
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11790
diff changeset
381 }
97d6932a309b CodeCacheProvider.encodeDeoptActionAndReason now returns a Constant
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11790
diff changeset
382 }
97d6932a309b CodeCacheProvider.encodeDeoptActionAndReason now returns a Constant
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11790
diff changeset
383
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
384 @Override
11836
d72c314260dc Add a DynamicDeoptimizeNode where the action and reason is a input node.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11834
diff changeset
385 public void emitDeoptimize(Value actionAndReason, DeoptimizingNode deopting) {
d72c314260dc Add a DynamicDeoptimizeNode where the action and reason is a input node.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11834
diff changeset
386 moveDeoptimizationActionAndReasonToThread(actionAndReason);
11832
97d6932a309b CodeCacheProvider.encodeDeoptActionAndReason now returns a Constant
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11790
diff changeset
387 append(new AMD64DeoptimizeOp(state(deopting)));
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
388 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
389
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
390 @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
391 public void emitDeoptimizeCaller(DeoptimizationAction action, DeoptimizationReason reason) {
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
392 moveDeoptimizationActionAndReasonToThread(getMetaAccess().encodeDeoptActionAndReason(action, reason));
11832
97d6932a309b CodeCacheProvider.encodeDeoptActionAndReason now returns a Constant
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11790
diff changeset
393 append(new AMD64HotSpotDeoptimizeCallerOp());
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
394 }
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
395
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
396 @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
397 public void emitPatchReturnAddress(ValueNode address) {
9560
08d1414ac62d refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents: 9507
diff changeset
398 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
399 }
5fa54bf57f8c replaced exception_handler_nofpu assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9433
diff changeset
400
5fa54bf57f8c replaced exception_handler_nofpu assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9433
diff changeset
401 @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
402 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
403 Variable handler = load(operand(handlerInCallerPc));
12363
78e5badf4b8e moved lookupForeignCall() from CodeCacheProvider to ForeignCallsProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12058
diff changeset
404 ForeignCallLinkage linkage = getForeignCalls().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
405 CallingConvention outgoingCc = linkage.getOutgoingCallingConvention();
de55425d3cf5 small cleanups and extra documentation around foreign call linkage
Doug Simon <doug.simon@oracle.com>
parents: 10870
diff changeset
406 assert outgoingCc.getArgumentCount() == 2;
de55425d3cf5 small cleanups and extra documentation around foreign call linkage
Doug Simon <doug.simon@oracle.com>
parents: 10870
diff changeset
407 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
408 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
409 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
410 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
411 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
412 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
413 }
99ef9bcb3f32 replaced unwind_exception_call assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9560
diff changeset
414
99ef9bcb3f32 replaced unwind_exception_call assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9560
diff changeset
415 @Override
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
416 public void beforeRegisterAllocation() {
9247
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
417 boolean hasDebugInfo = lir.hasDebugInfo();
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
418 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
419 if (hasDebugInfo) {
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
420 deoptimizationRescueSlot = frameMap.allocateSpillSlot(Kind.Long);
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
421 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
422
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
423 for (AMD64HotSpotEpilogueOp op : epilogueOps) {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
424 op.savedRbp = savedRbp;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
425 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
426 }
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
427
11453
1092208e4986 Add Javadoc
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11452
diff changeset
428 /**
1092208e4986 Add Javadoc
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11452
diff changeset
429 * 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
430 */
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
431 private static boolean isCompressCandidate(DeoptimizingNode access) {
10831
000ee2d0c518 Method renaming
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10821
diff changeset
432 return access != null && ((HeapAccess) access).isCompressible();
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
433 }
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
434
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
435 @Override
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
436 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
437 AMD64AddressValue loadAddress = asAddressValue(address);
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
438 Variable result = newVariable(kind);
9894
9d0031cf5df9 Fix Assertion in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9885
diff changeset
439 assert access == null || access instanceof HeapAccess;
11453
1092208e4986 Add Javadoc
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11452
diff changeset
440 /**
1092208e4986 Add Javadoc
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11452
diff changeset
441 * 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
442 * 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
443 * 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
444 * candidate. Consequently, depending on the appropriate kind, the specific (de)compression
1092208e4986 Add Javadoc
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11452
diff changeset
445 * functions are being called. Although, currently, the compression and decompression
1092208e4986 Add Javadoc
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11452
diff changeset
446 * 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
447 * 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
448 * algorithms may differ.
1092208e4986 Add Javadoc
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11452
diff changeset
449 */
10731
40f6bda3f91d Add compressed klass pointers support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10718
diff changeset
450 if (isCompressCandidate(access)) {
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
451 if (config.useCompressedOops && kind == Kind.Object) {
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
452 append(new LoadCompressedPointer(kind, result, getProviders().getRegisters().getHeapBaseRegister().asValue(), loadAddress, access != null ? state(access) : null, getNarrowKlassBase(),
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
453 getNarrowOopBase(), getNarrowOopShift(), getLogMinObjectAlignment()));
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
454 } else if (config.useCompressedClassPointers && kind == Kind.Long) {
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
455 append(new LoadCompressedPointer(kind, result, getProviders().getRegisters().getHeapBaseRegister().asValue(), loadAddress, access != null ? state(access) : null, getNarrowKlassBase(),
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
456 getNarrowOopBase(), getNarrowKlassShift(), getLogKlassAlignment()));
10731
40f6bda3f91d Add compressed klass pointers support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10718
diff changeset
457 } else {
40f6bda3f91d Add compressed klass pointers support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10718
diff changeset
458 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
459 }
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
460 } else {
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
461 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
462 }
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
463 return result;
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
464 }
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
465
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
466 @Override
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
467 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
468 AMD64AddressValue storeAddress = asAddressValue(address);
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
469 LIRFrameState state = access != null ? state(access) : null;
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
470 if (isConstant(inputVal)) {
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
471 Constant c = asConstant(inputVal);
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
472 if (canStoreConstant(c)) {
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
473 if (inputVal.getKind() == Kind.Object && config.useCompressedOops && isCompressCandidate(access)) {
11474
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
474 append(new StoreCompressedConstantOp(kind, storeAddress, c, state));
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
475 } else if (inputVal.getKind() == Kind.Long && config.useCompressedClassPointers && isCompressCandidate(access)) {
11474
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
476 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
477 } else {
11474
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
478 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
479 }
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
480 return;
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 }
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
483 Variable input = load(inputVal);
10731
40f6bda3f91d Add compressed klass pointers support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10718
diff changeset
484 if (isCompressCandidate(access)) {
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
485 if (config.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
486 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
487 Variable scratch = newVariable(Kind.Long);
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
488 Register heapBaseReg = getProviders().getRegisters().getHeapBaseRegister();
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
489 append(new StoreCompressedPointer(kind, storeAddress, input, scratch, state, getNarrowKlassBase(), getNarrowOopBase(), getNarrowOopShift(), getLogMinObjectAlignment(), heapBaseReg));
10747
3811d04d933e Do not re-compress oops that are already compressed.
Roland Schatz <roland.schatz@oracle.com>
parents: 10731
diff changeset
490 } else {
3811d04d933e Do not re-compress oops that are already compressed.
Roland Schatz <roland.schatz@oracle.com>
parents: 10731
diff changeset
491 // 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
492 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
493 }
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
494 } else if (config.useCompressedClassPointers && kind == Kind.Long) {
10731
40f6bda3f91d Add compressed klass pointers support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10718
diff changeset
495 Variable scratch = newVariable(Kind.Long);
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
496 Register heapBaseReg = getProviders().getRegisters().getHeapBaseRegister();
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
497 append(new StoreCompressedPointer(kind, storeAddress, input, scratch, state, getNarrowKlassBase(), getNarrowOopBase(), getNarrowKlassShift(), getLogKlassAlignment(), heapBaseReg));
10610
1db97e3de11c Do not re-compress oops that are already compressed.
Roland Schatz <roland.schatz@oracle.com>
parents: 9980
diff changeset
498 } else {
10731
40f6bda3f91d Add compressed klass pointers support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10718
diff changeset
499 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
500 }
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
501 } else {
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
502 append(new StoreOp(kind, storeAddress, input, state));
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
503 }
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
504 }
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
505
11474
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
506 private int getLogMinObjectAlignment() {
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
507 return config.logMinObjAlignment;
11474
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
508 }
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
509
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
510 private int getNarrowOopShift() {
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
511 return config.narrowOopShift;
11474
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
512 }
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
513
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
514 private long getNarrowOopBase() {
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
515 return config.narrowOopBase;
11474
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
516 }
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
517
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
518 private int getLogKlassAlignment() {
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
519 return config.logKlassAlignment;
11474
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
520 }
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
521
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
522 private int getNarrowKlassShift() {
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
523 return config.narrowKlassShift;
11474
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
524 }
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
525
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
526 private long getNarrowKlassBase() {
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
527 return config.narrowKlassBase;
11474
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
528 }
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
529
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
530 @Override
10850
e7679ec4f27f Lower CAS nodes to their lowered versions
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10831
diff changeset
531 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
532 Kind kind = node.getNewValue().kind();
e7679ec4f27f Lower CAS nodes to their lowered versions
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10831
diff changeset
533 assert kind == node.getExpectedValue().kind();
e7679ec4f27f Lower CAS nodes to their lowered versions
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10831
diff changeset
534 Value expected = loadNonConst(operand(node.getExpectedValue()));
e7679ec4f27f Lower CAS nodes to their lowered versions
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10831
diff changeset
535 Variable newValue = load(operand(node.getNewValue()));
e7679ec4f27f Lower CAS nodes to their lowered versions
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10831
diff changeset
536 AMD64AddressValue addressValue = asAddressValue(address);
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
537 RegisterValue raxRes = AMD64.rax.asValue(kind);
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
538 emitMove(raxRes, expected);
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
539 if (config.useCompressedOops && node.isCompressible()) {
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
540 Variable scratch = newVariable(Kind.Long);
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
541 Register heapBaseReg = getProviders().getRegisters().getHeapBaseRegister();
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
542 append(new CompareAndSwapCompressedOp(raxRes, addressValue, raxRes, newValue, scratch, getNarrowOopBase(), getNarrowOopShift(), getLogMinObjectAlignment(), heapBaseReg));
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
543 } else {
10850
e7679ec4f27f Lower CAS nodes to their lowered versions
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10831
diff changeset
544 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
545 }
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
546 Variable result = newVariable(node.kind());
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
547 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
548 setResult(node, result);
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
549 }
11786
4f0e0602c1c7 AMD64HotSpotLIRGenerator: ignore InfopointNodes with AFTER_BCI
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11760
diff changeset
550
4f0e0602c1c7 AMD64HotSpotLIRGenerator: ignore InfopointNodes with AFTER_BCI
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11760
diff changeset
551 @Override
4f0e0602c1c7 AMD64HotSpotLIRGenerator: ignore InfopointNodes with AFTER_BCI
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11760
diff changeset
552 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
553 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
554 Debug.log("Ignoring InfopointNode for AFTER_BCI");
4f0e0602c1c7 AMD64HotSpotLIRGenerator: ignore InfopointNodes with AFTER_BCI
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11760
diff changeset
555 } else {
4f0e0602c1c7 AMD64HotSpotLIRGenerator: ignore InfopointNodes with AFTER_BCI
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11760
diff changeset
556 super.visitInfopointNode(i);
4f0e0602c1c7 AMD64HotSpotLIRGenerator: ignore InfopointNodes with AFTER_BCI
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11760
diff changeset
557 }
4f0e0602c1c7 AMD64HotSpotLIRGenerator: ignore InfopointNodes with AFTER_BCI
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11760
diff changeset
558 }
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
559 }