annotate graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java @ 12456:f87c68d79f07

improved support for co-existing, multiple backends (GRAAL-363)
author Doug Simon <doug.simon@oracle.com>
date Thu, 17 Oct 2013 01:08:17 +0200
parents 7080a96be216
children ae412befde21
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
12456
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
183 private Register findPollOnReturnScratchRegister() {
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
184 RegisterConfig regConfig = getProviders().getCodeCache().getRegisterConfig();
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
185 for (Register r : regConfig.getAllocatableRegisters(Kind.Long)) {
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
186 if (r != regConfig.getReturnRegister(Kind.Long) && r != AMD64.rbp) {
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
187 return r;
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
188 }
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
189 }
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
190 throw GraalInternalError.shouldNotReachHere();
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
191 }
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
192
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
193 private Register pollOnReturnScratchRegister;
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
194
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
195 @Override
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
196 protected void emitReturn(Value input) {
12456
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
197 if (pollOnReturnScratchRegister == null) {
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
198 pollOnReturnScratchRegister = findPollOnReturnScratchRegister();
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
199 }
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
200 append(new AMD64HotSpotReturnOp(input, getStub() != null, pollOnReturnScratchRegister));
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
201 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
202
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
203 @Override
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
204 protected boolean needOnlyOopMaps() {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
205 // Stubs only need oop maps
9613
0c17815817a4 removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents: 9612
diff changeset
206 return graph.start() instanceof StubStartNode;
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
207 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
208
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
209 /**
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
210 * 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
211 * 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
212 */
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
213 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
214
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
215 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
216
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
217 @Override
9742
cff1e11941c0 moved temporaries from CallingConvention to ForeignCallLinkage
Doug Simon <doug.simon@oracle.com>
parents: 9741
diff changeset
218 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
219 currentRuntimeCallInfo = info;
9742
cff1e11941c0 moved temporaries from CallingConvention to ForeignCallLinkage
Doug Simon <doug.simon@oracle.com>
parents: 9741
diff changeset
220 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
221 }
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
222
9507
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
223 protected AMD64SaveRegistersOp emitSaveRegisters(Register[] savedRegisters, StackSlot[] savedRegisterLocations) {
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
224 AMD64SaveRegistersOp save = new AMD64SaveRegistersOp(savedRegisters, savedRegisterLocations);
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
225 append(save);
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
226 return save;
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
227 }
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
228
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
229 protected void emitRestoreRegisters(AMD64SaveRegistersOp save) {
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
230 append(new AMD64RestoreRegistersOp(save.getSlots().clone(), save));
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
231 }
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
232
9613
0c17815817a4 removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents: 9612
diff changeset
233 Stub getStub() {
0c17815817a4 removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents: 9612
diff changeset
234 if (graph.start() instanceof StubStartNode) {
0c17815817a4 removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents: 9612
diff changeset
235 return ((StubStartNode) graph.start()).getStub();
0c17815817a4 removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents: 9612
diff changeset
236 }
0c17815817a4 removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents: 9612
diff changeset
237 return null;
0c17815817a4 removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents: 9612
diff changeset
238 }
0c17815817a4 removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents: 9612
diff changeset
239
9338
0266549ff6e0 added support from compiled stubs to be installed as RuntimeStubs and to be able to directly call C/C++ runtime functions (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9247
diff changeset
240 @Override
9741
b27184f5f66b removed redundant parameter
Doug Simon <doug.simon@oracle.com>
parents: 9740
diff changeset
241 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
242 Stub stub = getStub();
9870
c65bad5126b0 pull HotSpotForeignCallLinkage.isLeaf into ForeignCallLinkage and rename to canDeoptimize
Lukas Stadler <lukas.stadler@jku.at>
parents: 9768
diff changeset
243 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
244
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
245 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
246 StackSlot[] savedRegisterLocations = null;
9693
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9613
diff changeset
247 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
248 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
249 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
250 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
251 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
252 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
253 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
254 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
255 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
256 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
257 }
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
258 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
259 }
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
260 }
9731
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
261 }
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
262
9768
cbf274a92e5b a leaf foreign call does not need debug info
Doug Simon <doug.simon@oracle.com>
parents: 9742
diff changeset
263 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
264
9870
c65bad5126b0 pull HotSpotForeignCallLinkage.isLeaf into ForeignCallLinkage and rename to canDeoptimize
Lukas Stadler <lukas.stadler@jku.at>
parents: 9768
diff changeset
265 if (linkage.canDeoptimize()) {
11790
70f43f67cdcb StubForeignCallNode is not a DeoptimizingNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11788
diff changeset
266 assert info != null || stub != null;
12456
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
267 Register thread = getProviders().getRegisters().getThreadRegister();
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
268 append(new AMD64HotSpotCRuntimeCallPrologueOp(config.threadLastJavaSpOffset, thread));
9768
cbf274a92e5b a leaf foreign call does not need debug info
Doug Simon <doug.simon@oracle.com>
parents: 9742
diff changeset
269 result = super.emitForeignCall(linkage, info, args);
12456
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
270 append(new AMD64HotSpotCRuntimeCallEpilogueOp(config.threadLastJavaSpOffset, config.threadLastJavaFpOffset, thread));
9768
cbf274a92e5b a leaf foreign call does not need debug info
Doug Simon <doug.simon@oracle.com>
parents: 9742
diff changeset
271 } else {
cbf274a92e5b a leaf foreign call does not need debug info
Doug Simon <doug.simon@oracle.com>
parents: 9742
diff changeset
272 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
273 }
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
274
9731
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
275 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
276 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
277 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
278 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
279 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
280
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
281 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
282 } else {
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
283 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
284 }
9491
789cfd153265 a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents: 9471
diff changeset
285 }
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
286 }
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
287
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
288 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
289 }
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
290
9506
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
291 protected AMD64ZapRegistersOp emitZapRegisters(Register[] zappedRegisters, Constant[] zapValues) {
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
292 AMD64ZapRegistersOp zap = new AMD64ZapRegistersOp(zappedRegisters, zapValues);
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
293 append(zap);
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
294 return zap;
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
295 }
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
296
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
297 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
298 Register[] zappedRegisters = frameMap.registerConfig.getAllocatableRegisters();
9506
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
299 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
300 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
301 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
302 assert kind != Kind.Illegal;
9506
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
303 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
304 }
9506
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
305 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
306 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
307 }
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
308
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
309 @Override
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
310 public void visitSafepointNode(SafepointNode i) {
8892
2c0c708a0ad6 Introduce DeoptimizingNode interface
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 8643
diff changeset
311 LIRFrameState info = state(i);
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
312 append(new AMD64HotSpotSafepointOp(info, config, this));
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
313 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
314
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
315 @SuppressWarnings("hiding")
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
316 @Override
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
317 public void visitDirectCompareAndSwap(DirectCompareAndSwapNode x) {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
318 Kind kind = x.newValue().kind();
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
319 assert kind == x.expectedValue().kind();
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
320
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
321 Value expected = loadNonConst(operand(x.expectedValue()));
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
322 Variable newVal = load(operand(x.newValue()));
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
323
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
324 int disp = 0;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
325 AMD64AddressValue address;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
326 Value index = operand(x.offset());
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
327 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
328 assert !getCodeCache().needsDataPatch(asConstant(index));
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
329 disp += (int) ValueUtil.asConstant(index).asLong();
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
330 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
331 } else {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
332 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
333 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
334
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
335 RegisterValue rax = AMD64.rax.asValue(kind);
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
336 emitMove(rax, expected);
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
337 append(new CompareAndSwapOp(rax, address, rax, newVal));
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
338
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
339 Variable result = newVariable(x.kind());
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
340 emitMove(result, rax);
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
341 setResult(x, result);
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
342 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
343
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
344 @Override
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
345 public void emitTailcall(Value[] args, Value address) {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
346 append(new AMD64TailcallOp(args, address));
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
347 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
348
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
349 @Override
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
350 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
351 InvokeKind invokeKind = ((HotSpotDirectCallTargetNode) callTarget).invokeKind();
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
352 if (invokeKind == InvokeKind.Interface || invokeKind == InvokeKind.Virtual) {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
353 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
354 } else {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
355 assert invokeKind == InvokeKind.Static || invokeKind == InvokeKind.Special;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
356 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
357 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
358 Constant metaspaceMethod = resolvedMethod.getMetaspaceMethodConstant();
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
359 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
360 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
361 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
362
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
363 @Override
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
364 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
365 if (callTarget instanceof HotSpotIndirectCallTargetNode) {
d71c56c67921 Improve performance of calling Truffle call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10610
diff changeset
366 AllocatableValue metaspaceMethod = AMD64.rbx.asValue();
d71c56c67921 Improve performance of calling Truffle call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10610
diff changeset
367 emitMove(metaspaceMethod, operand(((HotSpotIndirectCallTargetNode) callTarget).metaspaceMethod()));
d71c56c67921 Improve performance of calling Truffle call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10610
diff changeset
368 AllocatableValue targetAddress = AMD64.rax.asValue();
d71c56c67921 Improve performance of calling Truffle call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10610
diff changeset
369 emitMove(targetAddress, operand(callTarget.computedAddress()));
d71c56c67921 Improve performance of calling Truffle call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10610
diff changeset
370 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
371 } else {
d71c56c67921 Improve performance of calling Truffle call targets.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10610
diff changeset
372 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
373 }
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
374 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
375
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
376 @Override
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
377 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
378 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
379 CallingConvention outgoingCc = linkage.getOutgoingCallingConvention();
de55425d3cf5 small cleanups and extra documentation around foreign call linkage
Doug Simon <doug.simon@oracle.com>
parents: 10870
diff changeset
380 assert outgoingCc.getArgumentCount() == 2;
de55425d3cf5 small cleanups and extra documentation around foreign call linkage
Doug Simon <doug.simon@oracle.com>
parents: 10870
diff changeset
381 RegisterValue exceptionParameter = (RegisterValue) outgoingCc.getArgument(0);
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
382 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
383 append(new AMD64HotSpotUnwindOp(exceptionParameter));
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
384 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
385
11836
d72c314260dc Add a DynamicDeoptimizeNode where the action and reason is a input node.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11834
diff changeset
386 private void moveDeoptimizationActionAndReasonToThread(Value actionAndReason) {
12431
7080a96be216 rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents: 12429
diff changeset
387 int pendingDeoptimizationOffset = runtime().getConfig().pendingDeoptimizationOffset;
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
388 Kind wordKind = getProviders().getCodeCache().getTarget().wordKind;
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
389 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
390 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
391 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
392 Constant constantActionAndReason = (Constant) actionAndReason;
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
393 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
394 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
395 } 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
396 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
397 }
97d6932a309b CodeCacheProvider.encodeDeoptActionAndReason now returns a Constant
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11790
diff changeset
398 }
97d6932a309b CodeCacheProvider.encodeDeoptActionAndReason now returns a Constant
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11790
diff changeset
399
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
400 @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
401 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
402 moveDeoptimizationActionAndReasonToThread(actionAndReason);
11832
97d6932a309b CodeCacheProvider.encodeDeoptActionAndReason now returns a Constant
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11790
diff changeset
403 append(new AMD64DeoptimizeOp(state(deopting)));
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
404 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
405
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
406 @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
407 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
408 moveDeoptimizationActionAndReasonToThread(getMetaAccess().encodeDeoptActionAndReason(action, reason));
11832
97d6932a309b CodeCacheProvider.encodeDeoptActionAndReason now returns a Constant
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11790
diff changeset
409 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
410 }
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
411
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
412 @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
413 public void emitPatchReturnAddress(ValueNode address) {
9560
08d1414ac62d refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents: 9507
diff changeset
414 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
415 }
5fa54bf57f8c replaced exception_handler_nofpu assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9433
diff changeset
416
5fa54bf57f8c replaced exception_handler_nofpu assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9433
diff changeset
417 @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
418 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
419 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
420 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
421 CallingConvention outgoingCc = linkage.getOutgoingCallingConvention();
de55425d3cf5 small cleanups and extra documentation around foreign call linkage
Doug Simon <doug.simon@oracle.com>
parents: 10870
diff changeset
422 assert outgoingCc.getArgumentCount() == 2;
de55425d3cf5 small cleanups and extra documentation around foreign call linkage
Doug Simon <doug.simon@oracle.com>
parents: 10870
diff changeset
423 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
424 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
425 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
426 emitMove(exceptionPcFixed, operand(exceptionPc));
12456
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
427 Register thread = getProviders().getRegisters().getThreadRegister();
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
428 AMD64HotSpotJumpToExceptionHandlerInCallerOp op = new AMD64HotSpotJumpToExceptionHandlerInCallerOp(handler, exceptionFixed, exceptionPcFixed, config.threadIsMethodHandleReturnOffset, thread);
9562
99ef9bcb3f32 replaced unwind_exception_call assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9560
diff changeset
429 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
430 }
99ef9bcb3f32 replaced unwind_exception_call assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9560
diff changeset
431
99ef9bcb3f32 replaced unwind_exception_call assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9560
diff changeset
432 @Override
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
433 public void beforeRegisterAllocation() {
9247
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
434 boolean hasDebugInfo = lir.hasDebugInfo();
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
435 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
436 if (hasDebugInfo) {
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
437 deoptimizationRescueSlot = frameMap.allocateSpillSlot(Kind.Long);
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
438 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
439
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
440 for (AMD64HotSpotEpilogueOp op : epilogueOps) {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
441 op.savedRbp = savedRbp;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
442 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
443 }
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
444
11453
1092208e4986 Add Javadoc
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11452
diff changeset
445 /**
1092208e4986 Add Javadoc
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11452
diff changeset
446 * 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
447 */
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
448 private static boolean isCompressCandidate(DeoptimizingNode access) {
10831
000ee2d0c518 Method renaming
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10821
diff changeset
449 return access != null && ((HeapAccess) access).isCompressible();
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
450 }
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
451
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
452 @Override
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
453 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
454 AMD64AddressValue loadAddress = asAddressValue(address);
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
455 Variable result = newVariable(kind);
9894
9d0031cf5df9 Fix Assertion in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9885
diff changeset
456 assert access == null || access instanceof HeapAccess;
11453
1092208e4986 Add Javadoc
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11452
diff changeset
457 /**
1092208e4986 Add Javadoc
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11452
diff changeset
458 * 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
459 * 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
460 * 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
461 * candidate. Consequently, depending on the appropriate kind, the specific (de)compression
1092208e4986 Add Javadoc
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11452
diff changeset
462 * functions are being called. Although, currently, the compression and decompression
1092208e4986 Add Javadoc
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11452
diff changeset
463 * 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
464 * 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
465 * algorithms may differ.
1092208e4986 Add Javadoc
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11452
diff changeset
466 */
10731
40f6bda3f91d Add compressed klass pointers support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10718
diff changeset
467 if (isCompressCandidate(access)) {
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
468 if (config.useCompressedOops && kind == Kind.Object) {
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
469 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
470 getNarrowOopBase(), getNarrowOopShift(), getLogMinObjectAlignment()));
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
471 } else if (config.useCompressedClassPointers && kind == Kind.Long) {
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
472 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
473 getNarrowOopBase(), getNarrowKlassShift(), getLogKlassAlignment()));
10731
40f6bda3f91d Add compressed klass pointers support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10718
diff changeset
474 } else {
40f6bda3f91d Add compressed klass pointers support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10718
diff changeset
475 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
476 }
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
477 } else {
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
478 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
479 }
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
480 return result;
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 @Override
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
484 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
485 AMD64AddressValue storeAddress = asAddressValue(address);
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
486 LIRFrameState state = access != null ? state(access) : null;
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
487 if (isConstant(inputVal)) {
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
488 Constant c = asConstant(inputVal);
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
489 if (canStoreConstant(c)) {
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
490 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
491 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
492 } 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
493 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
494 } else {
11474
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
495 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
496 }
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
497 return;
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
498 }
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
499 }
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
500 Variable input = load(inputVal);
10731
40f6bda3f91d Add compressed klass pointers support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10718
diff changeset
501 if (isCompressCandidate(access)) {
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
502 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
503 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
504 Variable scratch = newVariable(Kind.Long);
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
505 Register heapBaseReg = getProviders().getRegisters().getHeapBaseRegister();
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
506 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
507 } else {
3811d04d933e Do not re-compress oops that are already compressed.
Roland Schatz <roland.schatz@oracle.com>
parents: 10731
diff changeset
508 // 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
509 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
510 }
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
511 } 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
512 Variable scratch = newVariable(Kind.Long);
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
513 Register heapBaseReg = getProviders().getRegisters().getHeapBaseRegister();
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
514 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
515 } else {
10731
40f6bda3f91d Add compressed klass pointers support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10718
diff changeset
516 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
517 }
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
518 } else {
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
519 append(new StoreOp(kind, storeAddress, input, state));
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
520 }
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
521 }
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
522
11474
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
523 private int getLogMinObjectAlignment() {
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
524 return config.logMinObjAlignment;
11474
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
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
527 private int getNarrowOopShift() {
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
528 return config.narrowOopShift;
11474
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
529 }
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
530
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
531 private long getNarrowOopBase() {
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
532 return config.narrowOopBase;
11474
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
533 }
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
534
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
535 private int getLogKlassAlignment() {
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
536 return config.logKlassAlignment;
11474
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
537 }
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
538
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
539 private int getNarrowKlassShift() {
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
540 return config.narrowKlassShift;
11474
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
541 }
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
542
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
543 private long getNarrowKlassBase() {
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
544 return config.narrowKlassBase;
11474
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
545 }
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
546
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
547 @Override
10850
e7679ec4f27f Lower CAS nodes to their lowered versions
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10831
diff changeset
548 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
549 Kind kind = node.getNewValue().kind();
e7679ec4f27f Lower CAS nodes to their lowered versions
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10831
diff changeset
550 assert kind == node.getExpectedValue().kind();
e7679ec4f27f Lower CAS nodes to their lowered versions
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10831
diff changeset
551 Value expected = loadNonConst(operand(node.getExpectedValue()));
e7679ec4f27f Lower CAS nodes to their lowered versions
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10831
diff changeset
552 Variable newValue = load(operand(node.getNewValue()));
e7679ec4f27f Lower CAS nodes to their lowered versions
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10831
diff changeset
553 AMD64AddressValue addressValue = asAddressValue(address);
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
554 RegisterValue raxRes = AMD64.rax.asValue(kind);
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
555 emitMove(raxRes, expected);
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
556 if (config.useCompressedOops && node.isCompressible()) {
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
557 Variable scratch = newVariable(Kind.Long);
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
558 Register heapBaseReg = getProviders().getRegisters().getHeapBaseRegister();
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
559 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
560 } else {
10850
e7679ec4f27f Lower CAS nodes to their lowered versions
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10831
diff changeset
561 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
562 }
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
563 Variable result = newVariable(node.kind());
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
564 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
565 setResult(node, result);
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
566 }
11786
4f0e0602c1c7 AMD64HotSpotLIRGenerator: ignore InfopointNodes with AFTER_BCI
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11760
diff changeset
567
4f0e0602c1c7 AMD64HotSpotLIRGenerator: ignore InfopointNodes with AFTER_BCI
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11760
diff changeset
568 @Override
4f0e0602c1c7 AMD64HotSpotLIRGenerator: ignore InfopointNodes with AFTER_BCI
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11760
diff changeset
569 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
570 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
571 Debug.log("Ignoring InfopointNode for AFTER_BCI");
4f0e0602c1c7 AMD64HotSpotLIRGenerator: ignore InfopointNodes with AFTER_BCI
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11760
diff changeset
572 } else {
4f0e0602c1c7 AMD64HotSpotLIRGenerator: ignore InfopointNodes with AFTER_BCI
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11760
diff changeset
573 super.visitInfopointNode(i);
4f0e0602c1c7 AMD64HotSpotLIRGenerator: ignore InfopointNodes with AFTER_BCI
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11760
diff changeset
574 }
4f0e0602c1c7 AMD64HotSpotLIRGenerator: ignore InfopointNodes with AFTER_BCI
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11760
diff changeset
575 }
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
576 }