annotate graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java @ 15251:de1d50c121cd

Unsafe.getAndAdd/Set method substitutions
author twisti
date Fri, 18 Apr 2014 16:50:52 -1000
parents 97eed257999b
children a38d791982e1
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.*;
11832
97d6932a309b CodeCacheProvider.encodeDeoptActionAndReason now returns a Constant
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11790
diff changeset
27 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
15104
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
28 import static com.oracle.graal.hotspot.nodes.UncommonTrapCallNode.*;
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
29
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
30 import java.util.*;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
31
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
32 import com.oracle.graal.amd64.*;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
33 import com.oracle.graal.api.code.*;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
34 import com.oracle.graal.api.meta.*;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
35 import com.oracle.graal.compiler.amd64.*;
15193
96bb07a5d667 Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents: 15104
diff changeset
36 import com.oracle.graal.compiler.common.*;
15200
97eed257999b Move Condition to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15193
diff changeset
37 import com.oracle.graal.compiler.common.calc.*;
8586
82f6a25321b8 modeling of lock state removed from LIR and runtime specific debug info for locks moved into runtime specific classes
Doug Simon <doug.simon@oracle.com>
parents: 8367
diff changeset
38 import com.oracle.graal.compiler.gen.*;
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
39 import com.oracle.graal.hotspot.*;
13520
fb7b39f07232 Embed compressed constants when possible and use more efficient patterns for encoding
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13313
diff changeset
40 import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding;
11474
df18a4214c7c Move compressed pointers' logic to HotSpot specific move
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11453
diff changeset
41 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
42 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
43 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
44 import com.oracle.graal.hotspot.meta.*;
14943
e5a55d280f24 Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 14921
diff changeset
45 import com.oracle.graal.hotspot.nodes.type.*;
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
46 import com.oracle.graal.hotspot.stubs.*;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
47 import com.oracle.graal.lir.*;
15104
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
48 import com.oracle.graal.lir.StandardOp.*;
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
49 import com.oracle.graal.lir.amd64.*;
15024
2ee777221036 Use high level CompressionNode in lowering of CompareAndSwapNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 15023
diff changeset
50 import com.oracle.graal.lir.amd64.AMD64ControlFlow.CondMoveOp;
2ee777221036 Use high level CompressionNode in lowering of CompareAndSwapNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 15023
diff changeset
51 import com.oracle.graal.lir.amd64.AMD64Move.CompareAndSwapOp;
14850
Josef Eisl <josef.eisl@jku.at>
parents: 14842 14707
diff changeset
52 import com.oracle.graal.lir.amd64.AMD64Move.LeaDataOp;
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.AMD64Move.LoadOp;
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.MoveFromRegOp;
14945
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
55 import com.oracle.graal.lir.amd64.AMD64Move.MoveToRegOp;
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
56 import com.oracle.graal.lir.amd64.AMD64Move.StoreConstantOp;
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
57 import com.oracle.graal.lir.amd64.AMD64Move.StoreOp;
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
58 import com.oracle.graal.nodes.*;
13291
01fd11e44f73 Access is not necessarily a DeoptimizingNode. In particular, FloatingAccessNodes are not DeoptimizingNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13255
diff changeset
59 import com.oracle.graal.nodes.extended.*;
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
60
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
61 /**
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
62 * LIR generator specialized for AMD64 HotSpot.
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
63 */
9431
c0488f573091 Make AMD64 LIR generator extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9425
diff changeset
64 public class AMD64HotSpotLIRGenerator extends AMD64LIRGenerator implements HotSpotLIRGenerator {
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
65
14841
47e4d2e01c6e Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents: 14834
diff changeset
66 final HotSpotVMConfig config;
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
67
14842
f2e61bf2a2d8 Removed nodeOperands from LIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14841
diff changeset
68 protected AMD64HotSpotLIRGenerator(HotSpotProviders providers, HotSpotVMConfig config, CallingConvention cc, LIRGenerationResult lirGenRes) {
f2e61bf2a2d8 Removed nodeOperands from LIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14841
diff changeset
69 super(providers, cc, lirGenRes);
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
70 assert config.basicLockSize == 8;
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
71 this.config = config;
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
72 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
73
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
74 @Override
12787
9b62c748c9ae get thread register from generator when lowering CurrentJavaThreadNode node instead of getting it from the host provider
Doug Simon <doug.simon@oracle.com>
parents: 12757
diff changeset
75 public HotSpotProviders getProviders() {
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
76 return (HotSpotProviders) super.getProviders();
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
77 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
78
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
79 /**
9247
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
80 * 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
81 */
9247
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
82 class SaveRbp {
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
83
13313
6dd9a1455e64 renamed PlaceholderOp to NoOp
Doug Simon <doug.simon@oracle.com>
parents: 13291
diff changeset
84 final NoOp placeholder;
9247
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
85
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
86 /**
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
87 * 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
88 */
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
89 final StackSlot reservedSlot;
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
90
13313
6dd9a1455e64 renamed PlaceholderOp to NoOp
Doug Simon <doug.simon@oracle.com>
parents: 13291
diff changeset
91 public SaveRbp(NoOp placeholder) {
9247
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
92 this.placeholder = placeholder;
14921
88dfaf6448e0 Remove LIRGenerationResult from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 14859
diff changeset
93 this.reservedSlot = getResult().getFrameMap().allocateSpillSlot(Kind.Long);
9247
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
94 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
95 }
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
96
9247
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
97 /**
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
98 * Replaces this operation with the appropriate move for saving rbp.
14859
4f5c312d676e Fix merge regressions.
Josef Eisl <josef.eisl@jku.at>
parents: 14850
diff changeset
99 *
9247
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
100 * @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
101 */
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
102 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
103 AllocatableValue dst;
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
104 if (useStack) {
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
105 dst = reservedSlot;
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
106 } else {
14921
88dfaf6448e0 Remove LIRGenerationResult from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 14859
diff changeset
107 getResult().getFrameMap().freeSpillSlot(reservedSlot);
9247
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
108 dst = newVariable(Kind.Long);
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
14945
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
111 placeholder.replace(getResult().getLIR(), new MoveFromRegOp(Kind.Long, dst, rbp.asValue(Kind.Long)));
9247
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
112 return dst;
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
113 }
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
114 }
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
115
14841
47e4d2e01c6e Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents: 14834
diff changeset
116 SaveRbp saveRbp;
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
117
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
118 /**
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
119 * 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
120 */
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
121 List<AMD64HotSpotEpilogueOp> epilogueOps = new ArrayList<>(2);
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
122
9560
08d1414ac62d refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents: 9507
diff changeset
123 @Override
08d1414ac62d refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents: 9507
diff changeset
124 public void append(LIRInstruction op) {
08d1414ac62d refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents: 9507
diff changeset
125 super.append(op);
08d1414ac62d refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents: 9507
diff changeset
126 if (op instanceof AMD64HotSpotEpilogueOp) {
08d1414ac62d refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents: 9507
diff changeset
127 epilogueOps.add((AMD64HotSpotEpilogueOp) op);
08d1414ac62d refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents: 9507
diff changeset
128 }
08d1414ac62d refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents: 9507
diff changeset
129 }
08d1414ac62d refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents: 9507
diff changeset
130
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
131 @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
132 public StackSlot getLockSlot(int lockDepth) {
14808
6352a2b94ca7 LIRGenerator: add getter for DebugInfoBuilder and CallingConvention.
Josef Eisl <josef.eisl@jku.at>
parents: 14807
diff changeset
133 return ((HotSpotDebugInfoBuilder) getDebugInfoBuilder()).lockStack().makeLockSlot(lockDepth);
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
134 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
135
12456
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
136 private Register findPollOnReturnScratchRegister() {
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
137 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
138 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
139 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
140 return r;
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
141 }
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
142 }
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
143 throw GraalInternalError.shouldNotReachHere();
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
144 }
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
145
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
146 private Register pollOnReturnScratchRegister;
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
147
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
148 @Override
14841
47e4d2e01c6e Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents: 14834
diff changeset
149 public void emitReturn(Value input) {
14949
b65036798097 Remove visitReturn from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 14945
diff changeset
150 AllocatableValue operand = Value.ILLEGAL;
b65036798097 Remove visitReturn from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 14945
diff changeset
151 if (input != null) {
b65036798097 Remove visitReturn from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 14945
diff changeset
152 operand = resultOperandFor(input.getKind());
b65036798097 Remove visitReturn from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 14945
diff changeset
153 emitMove(operand, input);
b65036798097 Remove visitReturn from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 14945
diff changeset
154 }
12456
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
155 if (pollOnReturnScratchRegister == null) {
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
156 pollOnReturnScratchRegister = findPollOnReturnScratchRegister();
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
157 }
14949
b65036798097 Remove visitReturn from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 14945
diff changeset
158 append(new AMD64HotSpotReturnOp(operand, getStub() != null, pollOnReturnScratchRegister));
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
159 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
160
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
161 @Override
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
162 protected boolean needOnlyOopMaps() {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
163 // Stubs only need oop maps
14921
88dfaf6448e0 Remove LIRGenerationResult from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 14859
diff changeset
164 return ((AMD64HotSpotLIRGenerationResult) getResult()).getStub() != null;
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
165 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
166
14859
4f5c312d676e Fix merge regressions.
Josef Eisl <josef.eisl@jku.at>
parents: 14850
diff changeset
167 @Override
14850
Josef Eisl <josef.eisl@jku.at>
parents: 14842 14707
diff changeset
168 public void emitData(AllocatableValue dst, byte[] data) {
Josef Eisl <josef.eisl@jku.at>
parents: 14842 14707
diff changeset
169 append(new LeaDataOp(dst, data));
Josef Eisl <josef.eisl@jku.at>
parents: 14842 14707
diff changeset
170 }
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
171
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
172 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
173
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
174 @Override
9742
cff1e11941c0 moved temporaries from CallingConvention to ForeignCallLinkage
Doug Simon <doug.simon@oracle.com>
parents: 9741
diff changeset
175 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
176 currentRuntimeCallInfo = info;
9742
cff1e11941c0 moved temporaries from CallingConvention to ForeignCallLinkage
Doug Simon <doug.simon@oracle.com>
parents: 9741
diff changeset
177 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
178 }
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
179
15104
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
180 public void emitLeaveCurrentStackFrame() {
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
181 append(new AMD64HotSpotLeaveCurrentStackFrameOp());
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
182 }
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
183
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
184 public void emitLeaveDeoptimizedStackFrame(Value frameSize, Value initialInfo) {
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
185 Variable frameSizeVariable = load(frameSize);
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
186 Variable initialInfoVariable = load(initialInfo);
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
187 append(new AMD64HotSpotLeaveDeoptimizedStackFrameOp(frameSizeVariable, initialInfoVariable));
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
188 }
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
189
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
190 public void emitEnterUnpackFramesStackFrame(Value framePc, Value senderSp, Value senderFp) {
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
191 Register thread = getProviders().getRegisters().getThreadRegister();
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
192 Variable framePcVariable = load(framePc);
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
193 Variable senderSpVariable = load(senderSp);
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
194 Variable senderFpVariable = load(senderFp);
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
195 append(new AMD64HotSpotEnterUnpackFramesStackFrameOp(thread, config.threadLastJavaSpOffset(), config.threadLastJavaPcOffset(), config.threadLastJavaFpOffset(), framePcVariable,
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
196 senderSpVariable, senderFpVariable));
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
197 }
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
198
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
199 public void emitLeaveUnpackFramesStackFrame() {
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
200 Register thread = getProviders().getRegisters().getThreadRegister();
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
201 append(new AMD64HotSpotLeaveUnpackFramesStackFrameOp(thread, config.threadLastJavaSpOffset(), config.threadLastJavaPcOffset(), config.threadLastJavaFpOffset()));
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
202 }
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
203
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
204 /**
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
205 * @param savedRegisters the registers saved by this operation which may be subject to pruning
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
206 * @param savedRegisterLocations the slots to which the registers are saved
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
207 * @param supportsRemove determines if registers can be pruned
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
208 */
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
209 protected AMD64SaveRegistersOp emitSaveRegisters(Register[] savedRegisters, StackSlot[] savedRegisterLocations, boolean supportsRemove) {
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
210 AMD64SaveRegistersOp save = new AMD64SaveRegistersOp(savedRegisters, savedRegisterLocations, supportsRemove);
9507
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
211 append(save);
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
212 return save;
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
213 }
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
214
15104
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
215 /**
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
216 * Adds a node to the graph that saves all allocatable registers to the stack.
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
217 *
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
218 * @param supportsRemove determines if registers can be pruned
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
219 * @return the register save node
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
220 */
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
221 private AMD64SaveRegistersOp emitSaveAllRegisters(Register[] savedRegisters, boolean supportsRemove) {
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
222 StackSlot[] savedRegisterLocations = new StackSlot[savedRegisters.length];
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
223 for (int i = 0; i < savedRegisters.length; i++) {
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
224 PlatformKind kind = target().arch.getLargestStorableKind(savedRegisters[i].getRegisterCategory());
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
225 assert kind != Kind.Illegal;
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
226 StackSlot spillSlot = getResult().getFrameMap().allocateSpillSlot(kind);
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
227 savedRegisterLocations[i] = spillSlot;
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
228 }
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
229 return emitSaveRegisters(savedRegisters, savedRegisterLocations, supportsRemove);
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
230 }
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
231
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
232 @Override
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
233 public SaveRegistersOp emitSaveAllRegisters() {
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
234 // We are saving all registers.
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
235 // TODO Save upper half of YMM registers.
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
236 return emitSaveAllRegisters(cpuxmmRegisters, false);
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
237 }
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
238
9507
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
239 protected void emitRestoreRegisters(AMD64SaveRegistersOp save) {
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
240 append(new AMD64RestoreRegistersOp(save.getSlots().clone(), save));
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
241 }
3df71c132731 Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 9506
diff changeset
242
14807
c3242028cc44 Introduce specialized LIRGenerationResults for Targets if needed.
Josef Eisl <josef.eisl@jku.at>
parents: 14806
diff changeset
243 public Stub getStub() {
14921
88dfaf6448e0 Remove LIRGenerationResult from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 14859
diff changeset
244 return ((AMD64HotSpotLIRGenerationResult) getResult()).getStub();
9613
0c17815817a4 removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents: 9612
diff changeset
245 }
0c17815817a4 removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents: 9612
diff changeset
246
9338
0266549ff6e0 added support from compiled stubs to be installed as RuntimeStubs and to be able to directly call C/C++ runtime functions (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9247
diff changeset
247 @Override
9741
b27184f5f66b removed redundant parameter
Doug Simon <doug.simon@oracle.com>
parents: 9740
diff changeset
248 public Variable emitForeignCall(ForeignCallLinkage linkage, DeoptimizingNode info, Value... args) {
14955
be6fc21b25f8 Add possibility to have HotSpot linkages which are LEAF but still require a last_java_sp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14949
diff changeset
249 HotSpotForeignCallLinkage hotspotLinkage = (HotSpotForeignCallLinkage) linkage;
be6fc21b25f8 Add possibility to have HotSpot linkages which are LEAF but still require a last_java_sp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14949
diff changeset
250 boolean destroysRegisters = hotspotLinkage.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
251
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
252 AMD64SaveRegistersOp save = null;
9693
d04944441454 cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents: 9613
diff changeset
253 if (destroysRegisters) {
14142
4eac66a9b87d Remove reference to graph in LIRGenerator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14003
diff changeset
254 if (getStub() != null) {
4eac66a9b87d Remove reference to graph in LIRGenerator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14003
diff changeset
255 if (getStub().preservesRegisters()) {
14921
88dfaf6448e0 Remove LIRGenerationResult from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 14859
diff changeset
256 Register[] savedRegisters = getResult().getFrameMap().registerConfig.getAllocatableRegisters();
15104
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
257 save = emitSaveAllRegisters(savedRegisters, true);
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
258 }
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
259 }
9731
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
260 }
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
261
9768
cbf274a92e5b a leaf foreign call does not need debug info
Doug Simon <doug.simon@oracle.com>
parents: 9742
diff changeset
262 Variable result;
14955
be6fc21b25f8 Add possibility to have HotSpot linkages which are LEAF but still require a last_java_sp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14949
diff changeset
263 DeoptimizingNode deoptInfo = null;
be6fc21b25f8 Add possibility to have HotSpot linkages which are LEAF but still require a last_java_sp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14949
diff changeset
264 if (hotspotLinkage.canDeoptimize()) {
be6fc21b25f8 Add possibility to have HotSpot linkages which are LEAF but still require a last_java_sp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14949
diff changeset
265 deoptInfo = info;
be6fc21b25f8 Add possibility to have HotSpot linkages which are LEAF but still require a last_java_sp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14949
diff changeset
266 assert deoptInfo != null || getStub() != null;
be6fc21b25f8 Add possibility to have HotSpot linkages which are LEAF but still require a last_java_sp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14949
diff changeset
267 assert hotspotLinkage.needsJavaFrameAnchor();
be6fc21b25f8 Add possibility to have HotSpot linkages which are LEAF but still require a last_java_sp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14949
diff changeset
268 }
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
269
14955
be6fc21b25f8 Add possibility to have HotSpot linkages which are LEAF but still require a last_java_sp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14949
diff changeset
270 if (hotspotLinkage.needsJavaFrameAnchor()) {
12456
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
271 Register thread = getProviders().getRegisters().getThreadRegister();
12559
ae412befde21 read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents: 12456
diff changeset
272 append(new AMD64HotSpotCRuntimeCallPrologueOp(config.threadLastJavaSpOffset(), thread));
14955
be6fc21b25f8 Add possibility to have HotSpot linkages which are LEAF but still require a last_java_sp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14949
diff changeset
273 result = super.emitForeignCall(hotspotLinkage, deoptInfo, args);
12559
ae412befde21 read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents: 12456
diff changeset
274 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
275 } else {
14955
be6fc21b25f8 Add possibility to have HotSpot linkages which are LEAF but still require a last_java_sp
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14949
diff changeset
276 result = super.emitForeignCall(hotspotLinkage, deoptInfo, 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
277 }
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
278
9731
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
279 if (destroysRegisters) {
14142
4eac66a9b87d Remove reference to graph in LIRGenerator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14003
diff changeset
280 if (getStub() != null) {
4eac66a9b87d Remove reference to graph in LIRGenerator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14003
diff changeset
281 if (getStub().preservesRegisters()) {
15104
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
282 AMD64HotSpotLIRGenerationResult generationResult = (AMD64HotSpotLIRGenerationResult) getResult();
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
283 assert !generationResult.getCalleeSaveInfo().containsKey(currentRuntimeCallInfo);
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
284 generationResult.getCalleeSaveInfo().put(currentRuntimeCallInfo, save);
9731
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
285 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
286 } else {
f7bd4594cbbf added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents: 9693
diff changeset
287 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
288 }
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
289 }
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
290 }
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
291
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
292 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
293 }
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
294
15104
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
295 public Value emitUncommonTrapCall(Value trapRequest, SaveRegistersOp saveRegisterOp) {
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
296 ForeignCallLinkage linkage = getForeignCalls().lookupForeignCall(UNCOMMON_TRAP);
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
297
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
298 Register thread = getProviders().getRegisters().getThreadRegister();
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
299 append(new AMD64HotSpotCRuntimeCallPrologueOp(config.threadLastJavaSpOffset(), thread));
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
300 Variable result = super.emitForeignCall(linkage, null, thread.asValue(Kind.Long), trapRequest);
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
301 append(new AMD64HotSpotCRuntimeCallEpilogueOp(config.threadLastJavaSpOffset(), config.threadLastJavaFpOffset(), thread));
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
302
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
303 Map<LIRFrameState, SaveRegistersOp> calleeSaveInfo = ((AMD64HotSpotLIRGenerationResult) getResult()).getCalleeSaveInfo();
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
304 assert !calleeSaveInfo.containsKey(currentRuntimeCallInfo);
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
305 calleeSaveInfo.put(currentRuntimeCallInfo, saveRegisterOp);
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
306
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
307 return result;
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
308 }
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
309
9506
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
310 protected AMD64ZapRegistersOp emitZapRegisters(Register[] zappedRegisters, Constant[] zapValues) {
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
311 AMD64ZapRegistersOp zap = new AMD64ZapRegistersOp(zappedRegisters, zapValues);
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
312 append(zap);
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
313 return zap;
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
314 }
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
315
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
316 protected boolean zapRegisters() {
14921
88dfaf6448e0 Remove LIRGenerationResult from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 14859
diff changeset
317 Register[] zappedRegisters = getResult().getFrameMap().registerConfig.getAllocatableRegisters();
9506
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
318 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
319 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
320 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
321 assert kind != Kind.Illegal;
9506
6703dca691d7 Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 9505
diff changeset
322 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
323 }
14921
88dfaf6448e0 Remove LIRGenerationResult from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 14859
diff changeset
324 ((AMD64HotSpotLIRGenerationResult) getResult()).getCalleeSaveInfo().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
325 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
326 }
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
327
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
328 @Override
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
329 public void emitTailcall(Value[] args, Value address) {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
330 append(new AMD64TailcallOp(args, address));
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
331 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
332
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
333 @Override
13837
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 13726
diff changeset
334 public void emitCCall(long address, CallingConvention nativeCallingConvention, Value[] args, int numberOfFloatingPointArguments) {
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 13726
diff changeset
335 Value[] argLocations = new Value[args.length];
14921
88dfaf6448e0 Remove LIRGenerationResult from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 14859
diff changeset
336 getResult().getFrameMap().callsMethod(nativeCallingConvention);
13839
5fb138b6a92f GNFI fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 13837
diff changeset
337 // TODO(mg): in case a native function uses floating point varargs, the ABI requires that
5fb138b6a92f GNFI fixes
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 13837
diff changeset
338 // RAX contains the length of the varargs
13837
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 13726
diff changeset
339 AllocatableValue numberOfFloatingPointArgumentsRegister = AMD64.rax.asValue();
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 13726
diff changeset
340 emitMove(numberOfFloatingPointArgumentsRegister, Constant.forInt(numberOfFloatingPointArguments));
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 13726
diff changeset
341 for (int i = 0; i < args.length; i++) {
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 13726
diff changeset
342 Value arg = args[i];
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 13726
diff changeset
343 AllocatableValue loc = nativeCallingConvention.getArgument(i);
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 13726
diff changeset
344 emitMove(loc, arg);
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 13726
diff changeset
345 argLocations[i] = loc;
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 13726
diff changeset
346 }
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 13726
diff changeset
347 Value ptr = emitMove(Constant.forLong(address));
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 13726
diff changeset
348 append(new AMD64CCall(nativeCallingConvention.getReturn(), ptr, numberOfFloatingPointArgumentsRegister, argLocations));
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 13726
diff changeset
349 }
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 13726
diff changeset
350
ed3a1471e133 Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 13726
diff changeset
351 @Override
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
352 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
353 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
354 CallingConvention outgoingCc = linkage.getOutgoingCallingConvention();
de55425d3cf5 small cleanups and extra documentation around foreign call linkage
Doug Simon <doug.simon@oracle.com>
parents: 10870
diff changeset
355 assert outgoingCc.getArgumentCount() == 2;
de55425d3cf5 small cleanups and extra documentation around foreign call linkage
Doug Simon <doug.simon@oracle.com>
parents: 10870
diff changeset
356 RegisterValue exceptionParameter = (RegisterValue) outgoingCc.getArgument(0);
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
357 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
358 append(new AMD64HotSpotUnwindOp(exceptionParameter));
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
359 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
360
13641
5a9afbf72714 Add a speculation oop for uncommon trap deoptimization. Save it in the SpeculationLog during deoptimization.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13614
diff changeset
361 private void moveDeoptValuesToThread(Value actionAndReason, Value speculation) {
5a9afbf72714 Add a speculation oop for uncommon trap deoptimization. Save it in the SpeculationLog during deoptimization.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13614
diff changeset
362 moveValueToThread(actionAndReason, runtime().getConfig().pendingDeoptimizationOffset);
5a9afbf72714 Add a speculation oop for uncommon trap deoptimization. Save it in the SpeculationLog during deoptimization.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13614
diff changeset
363 moveValueToThread(speculation, runtime().getConfig().pendingFailedSpeculationOffset);
5a9afbf72714 Add a speculation oop for uncommon trap deoptimization. Save it in the SpeculationLog during deoptimization.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13614
diff changeset
364 }
5a9afbf72714 Add a speculation oop for uncommon trap deoptimization. Save it in the SpeculationLog during deoptimization.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13614
diff changeset
365
5a9afbf72714 Add a speculation oop for uncommon trap deoptimization. Save it in the SpeculationLog during deoptimization.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13614
diff changeset
366 private void moveValueToThread(Value v, int offset) {
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
367 Kind wordKind = getProviders().getCodeCache().getTarget().wordKind;
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
368 RegisterValue thread = getProviders().getRegisters().getThreadRegister().asValue(wordKind);
13667
076e233aec3f Fix AMD64HotSpotLIRGenerator.moveValueToThread
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13641
diff changeset
369 AMD64AddressValue address = new AMD64AddressValue(v.getKind(), thread, offset);
076e233aec3f Fix AMD64HotSpotLIRGenerator.moveValueToThread
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13641
diff changeset
370 emitStore(v.getKind(), address, v, null);
11832
97d6932a309b CodeCacheProvider.encodeDeoptActionAndReason now returns a Constant
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11790
diff changeset
371 }
97d6932a309b CodeCacheProvider.encodeDeoptActionAndReason now returns a Constant
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11790
diff changeset
372
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
373 @Override
13641
5a9afbf72714 Add a speculation oop for uncommon trap deoptimization. Save it in the SpeculationLog during deoptimization.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13614
diff changeset
374 public void emitDeoptimize(Value actionAndReason, Value speculation, DeoptimizingNode deopting) {
5a9afbf72714 Add a speculation oop for uncommon trap deoptimization. Save it in the SpeculationLog during deoptimization.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13614
diff changeset
375 moveDeoptValuesToThread(actionAndReason, speculation);
11832
97d6932a309b CodeCacheProvider.encodeDeoptActionAndReason now returns a Constant
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11790
diff changeset
376 append(new AMD64DeoptimizeOp(state(deopting)));
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
377 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
378
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
379 @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
380 public void emitDeoptimizeCaller(DeoptimizationAction action, DeoptimizationReason reason) {
13641
5a9afbf72714 Add a speculation oop for uncommon trap deoptimization. Save it in the SpeculationLog during deoptimization.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13614
diff changeset
381 moveDeoptValuesToThread(getMetaAccess().encodeDeoptActionAndReason(action, reason, 0), Constant.NULL_OBJECT);
11832
97d6932a309b CodeCacheProvider.encodeDeoptActionAndReason now returns a Constant
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11790
diff changeset
382 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
383 }
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
384
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
385 @Override
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
386 public void beforeRegisterAllocation() {
13313
6dd9a1455e64 renamed PlaceholderOp to NoOp
Doug Simon <doug.simon@oracle.com>
parents: 13291
diff changeset
387 super.beforeRegisterAllocation();
14921
88dfaf6448e0 Remove LIRGenerationResult from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 14859
diff changeset
388 boolean hasDebugInfo = getResult().getLIR().hasDebugInfo();
9247
27c75e4016db clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents: 8892
diff changeset
389 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
390 if (hasDebugInfo) {
14921
88dfaf6448e0 Remove LIRGenerationResult from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 14859
diff changeset
391 ((AMD64HotSpotLIRGenerationResult) getResult()).setDeoptimizationRescueSlot(getResult().getFrameMap().allocateSpillSlot(Kind.Long));
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
392 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
393
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
394 for (AMD64HotSpotEpilogueOp op : epilogueOps) {
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
395 op.savedRbp = savedRbp;
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
396 }
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
397 }
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
398
11453
1092208e4986 Add Javadoc
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11452
diff changeset
399 /**
13520
fb7b39f07232 Embed compressed constants when possible and use more efficient patterns for encoding
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13313
diff changeset
400 * Returns whether or not the input access should be (de)compressed.
fb7b39f07232 Embed compressed constants when possible and use more efficient patterns for encoding
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13313
diff changeset
401 */
14945
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
402 private boolean isCompressedOperation(PlatformKind kind, Access access) {
13520
fb7b39f07232 Embed compressed constants when possible and use more efficient patterns for encoding
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13313
diff changeset
403 return access != null && access.isCompressible() && ((kind == Kind.Long && config.useCompressedClassPointers) || (kind == Kind.Object && config.useCompressedOops));
fb7b39f07232 Embed compressed constants when possible and use more efficient patterns for encoding
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13313
diff changeset
404 }
fb7b39f07232 Embed compressed constants when possible and use more efficient patterns for encoding
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13313
diff changeset
405
fb7b39f07232 Embed compressed constants when possible and use more efficient patterns for encoding
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13313
diff changeset
406 /**
fb7b39f07232 Embed compressed constants when possible and use more efficient patterns for encoding
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13313
diff changeset
407 * @return a compressed version of the incoming constant
11453
1092208e4986 Add Javadoc
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11452
diff changeset
408 */
13520
fb7b39f07232 Embed compressed constants when possible and use more efficient patterns for encoding
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13313
diff changeset
409 protected static Constant compress(Constant c, CompressEncoding encoding) {
fb7b39f07232 Embed compressed constants when possible and use more efficient patterns for encoding
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13313
diff changeset
410 if (c.getKind() == Kind.Long) {
15018
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14955
diff changeset
411 int compressedValue = (int) (((c.asLong() - encoding.base) >> encoding.shift) & 0xffffffffL);
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14955
diff changeset
412 if (c instanceof HotSpotMetaspaceConstant) {
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14955
diff changeset
413 return HotSpotMetaspaceConstant.forMetaspaceObject(Kind.Int, compressedValue, HotSpotMetaspaceConstant.getMetaspaceObject(c));
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14955
diff changeset
414 } else {
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14955
diff changeset
415 return Constant.forIntegerKind(Kind.Int, compressedValue);
db4254246f9a Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents: 14955
diff changeset
416 }
13520
fb7b39f07232 Embed compressed constants when possible and use more efficient patterns for encoding
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13313
diff changeset
417 } else {
fb7b39f07232 Embed compressed constants when possible and use more efficient patterns for encoding
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13313
diff changeset
418 throw GraalInternalError.shouldNotReachHere();
fb7b39f07232 Embed compressed constants when possible and use more efficient patterns for encoding
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13313
diff changeset
419 }
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
420 }
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
421
14945
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
422 private static Kind getMemoryKind(PlatformKind kind) {
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
423 if (kind == NarrowOopStamp.NarrowOop) {
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
424 return Kind.Int;
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
425 } else {
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
426 return (Kind) kind;
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
427 }
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
428 }
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
429
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
430 private static PlatformKind toStackKind(PlatformKind kind) {
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
431 if (kind instanceof Kind) {
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
432 return ((Kind) kind).getStackKind();
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
433 } else {
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
434 return kind;
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
435 }
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
436 }
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
437
15104
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
438 public void emitPushInterpreterFrame(Value frameSize, Value framePc, Value senderSp, Value initialInfo) {
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
439 Variable frameSizeVariable = load(frameSize);
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
440 Variable framePcVariable = load(framePc);
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
441 Variable senderSpVariable = load(senderSp);
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
442 Variable initialInfoVariable = load(initialInfo);
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
443 append(new AMD64HotSpotPushInterpreterFrameOp(frameSizeVariable, framePcVariable, senderSpVariable, initialInfoVariable));
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
444 }
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 15058
diff changeset
445
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
446 @Override
14945
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
447 public Variable emitLoad(PlatformKind kind, Value address, Access access) {
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
448 AMD64AddressValue loadAddress = asAddressValue(address);
14945
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
449 Variable result = newVariable(toStackKind(kind));
13291
01fd11e44f73 Access is not necessarily a DeoptimizingNode. In particular, FloatingAccessNodes are not DeoptimizingNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13255
diff changeset
450 LIRFrameState state = null;
01fd11e44f73 Access is not necessarily a DeoptimizingNode. In particular, FloatingAccessNodes are not DeoptimizingNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13255
diff changeset
451 if (access instanceof DeoptimizingNode) {
01fd11e44f73 Access is not necessarily a DeoptimizingNode. In particular, FloatingAccessNodes are not DeoptimizingNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13255
diff changeset
452 state = state((DeoptimizingNode) access);
01fd11e44f73 Access is not necessarily a DeoptimizingNode. In particular, FloatingAccessNodes are not DeoptimizingNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13255
diff changeset
453 }
11453
1092208e4986 Add Javadoc
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11452
diff changeset
454 /**
1092208e4986 Add Javadoc
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11452
diff changeset
455 * 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
456 * 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
457 * 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
458 * candidate. Consequently, depending on the appropriate kind, the specific (de)compression
13520
fb7b39f07232 Embed compressed constants when possible and use more efficient patterns for encoding
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13313
diff changeset
459 * functions are being called.
11453
1092208e4986 Add Javadoc
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 11452
diff changeset
460 */
13520
fb7b39f07232 Embed compressed constants when possible and use more efficient patterns for encoding
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13313
diff changeset
461 if (isCompressedOperation(kind, access)) {
fb7b39f07232 Embed compressed constants when possible and use more efficient patterns for encoding
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13313
diff changeset
462 if (kind == Kind.Object) {
14945
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
463 append(new LoadCompressedPointer(Kind.Object, result, getProviders().getRegisters().getHeapBaseRegister().asValue(), loadAddress, state, config.getOopEncoding()));
13520
fb7b39f07232 Embed compressed constants when possible and use more efficient patterns for encoding
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13313
diff changeset
464 } else if (kind == Kind.Long) {
fb7b39f07232 Embed compressed constants when possible and use more efficient patterns for encoding
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13313
diff changeset
465 Variable scratch = config.getKlassEncoding().base != 0 ? newVariable(Kind.Long) : null;
14945
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
466 append(new LoadCompressedPointer(Kind.Long, result, scratch, loadAddress, state, config.getKlassEncoding()));
10731
40f6bda3f91d Add compressed klass pointers support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10718
diff changeset
467 } else {
13520
fb7b39f07232 Embed compressed constants when possible and use more efficient patterns for encoding
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13313
diff changeset
468 throw GraalInternalError.shouldNotReachHere("can't handle: " + access);
10731
40f6bda3f91d Add compressed klass pointers support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10718
diff changeset
469 }
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
470 } else {
14945
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
471 append(new LoadOp(getMemoryKind(kind), result, loadAddress, state));
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
472 }
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
473 return result;
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
474 }
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
475
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
476 @Override
14945
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
477 public void emitStore(PlatformKind kind, Value address, Value inputVal, Access access) {
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
478 AMD64AddressValue storeAddress = asAddressValue(address);
13291
01fd11e44f73 Access is not necessarily a DeoptimizingNode. In particular, FloatingAccessNodes are not DeoptimizingNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13255
diff changeset
479 LIRFrameState state = null;
01fd11e44f73 Access is not necessarily a DeoptimizingNode. In particular, FloatingAccessNodes are not DeoptimizingNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13255
diff changeset
480 if (access instanceof DeoptimizingNode) {
01fd11e44f73 Access is not necessarily a DeoptimizingNode. In particular, FloatingAccessNodes are not DeoptimizingNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13255
diff changeset
481 state = state((DeoptimizingNode) access);
01fd11e44f73 Access is not necessarily a DeoptimizingNode. In particular, FloatingAccessNodes are not DeoptimizingNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13255
diff changeset
482 }
13520
fb7b39f07232 Embed compressed constants when possible and use more efficient patterns for encoding
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13313
diff changeset
483 boolean isCompressed = isCompressedOperation(kind, access);
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
484 if (isConstant(inputVal)) {
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
485 Constant c = asConstant(inputVal);
13542
da9d9823628f Enable more constant stores
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13520
diff changeset
486 if (canStoreConstant(c, isCompressed)) {
da9d9823628f Enable more constant stores
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13520
diff changeset
487 if (isCompressed) {
da9d9823628f Enable more constant stores
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13520
diff changeset
488 if (c.getKind() == Kind.Object) {
14945
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
489 append(new StoreCompressedConstantOp(Kind.Object, storeAddress, c, state));
13542
da9d9823628f Enable more constant stores
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13520
diff changeset
490 } else if (c.getKind() == Kind.Long) {
da9d9823628f Enable more constant stores
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13520
diff changeset
491 // It's always a good idea to directly store compressed constants since they
da9d9823628f Enable more constant stores
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13520
diff changeset
492 // have to be materialized as 64 bits encoded otherwise.
da9d9823628f Enable more constant stores
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13520
diff changeset
493 Constant value = compress(c, config.getKlassEncoding());
14945
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
494 append(new StoreCompressedConstantOp(Kind.Long, storeAddress, value, state));
13542
da9d9823628f Enable more constant stores
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13520
diff changeset
495 } else {
da9d9823628f Enable more constant stores
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13520
diff changeset
496 throw GraalInternalError.shouldNotReachHere("can't handle: " + access);
da9d9823628f Enable more constant stores
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13520
diff changeset
497 }
da9d9823628f Enable more constant stores
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13520
diff changeset
498 return;
10731
40f6bda3f91d Add compressed klass pointers support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10718
diff changeset
499 } else {
14945
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
500 append(new StoreConstantOp(getMemoryKind(kind), storeAddress, c, state));
13542
da9d9823628f Enable more constant stores
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13520
diff changeset
501 return;
10731
40f6bda3f91d Add compressed klass pointers support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10718
diff changeset
502 }
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
503 }
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
504 }
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
505 Variable input = load(inputVal);
13520
fb7b39f07232 Embed compressed constants when possible and use more efficient patterns for encoding
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13313
diff changeset
506 if (isCompressed) {
fb7b39f07232 Embed compressed constants when possible and use more efficient patterns for encoding
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13313
diff changeset
507 if (kind == Kind.Object) {
10747
3811d04d933e Do not re-compress oops that are already compressed.
Roland Schatz <roland.schatz@oracle.com>
parents: 10731
diff changeset
508 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
509 Variable scratch = newVariable(Kind.Long);
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
510 Register heapBaseReg = getProviders().getRegisters().getHeapBaseRegister();
14945
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
511 append(new StoreCompressedPointer(Kind.Object, storeAddress, input, scratch, state, config.getOopEncoding(), heapBaseReg));
10747
3811d04d933e Do not re-compress oops that are already compressed.
Roland Schatz <roland.schatz@oracle.com>
parents: 10731
diff changeset
512 } else {
3811d04d933e Do not re-compress oops that are already compressed.
Roland Schatz <roland.schatz@oracle.com>
parents: 10731
diff changeset
513 // 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
514 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
515 }
13520
fb7b39f07232 Embed compressed constants when possible and use more efficient patterns for encoding
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13313
diff changeset
516 } else if (kind == Kind.Long) {
10731
40f6bda3f91d Add compressed klass pointers support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10718
diff changeset
517 Variable scratch = newVariable(Kind.Long);
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
518 Register heapBaseReg = getProviders().getRegisters().getHeapBaseRegister();
14945
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
519 append(new StoreCompressedPointer(Kind.Long, storeAddress, input, scratch, state, config.getKlassEncoding(), heapBaseReg));
10610
1db97e3de11c Do not re-compress oops that are already compressed.
Roland Schatz <roland.schatz@oracle.com>
parents: 9980
diff changeset
520 } else {
14945
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
521 append(new StoreOp(getMemoryKind(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
522 }
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
523 } else {
14945
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
524 append(new StoreOp(getMemoryKind(kind), storeAddress, input, state));
9885
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
525 }
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
526 }
ed86945795d5 Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 9768
diff changeset
527
14943
e5a55d280f24 Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 14921
diff changeset
528 @Override
15058
895e9ecedfe8 Fix code generation for compressed metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15024
diff changeset
529 public Value emitCompress(Value pointer, CompressEncoding encoding, boolean nonNull) {
15023
652564fe42d5 Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15018
diff changeset
530 if (pointer.getPlatformKind() == Kind.Object) {
652564fe42d5 Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15018
diff changeset
531 Variable result = newVariable(NarrowOopStamp.NarrowOop);
15058
895e9ecedfe8 Fix code generation for compressed metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15024
diff changeset
532 append(new AMD64HotSpotMove.CompressPointer(result, asAllocatable(pointer), getProviders().getRegisters().getHeapBaseRegister().asValue(), encoding, nonNull));
15023
652564fe42d5 Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15018
diff changeset
533 return result;
652564fe42d5 Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15018
diff changeset
534 } else {
652564fe42d5 Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15018
diff changeset
535 assert pointer.getPlatformKind() == Kind.Long;
652564fe42d5 Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15018
diff changeset
536 Variable result = newVariable(Kind.Int);
652564fe42d5 Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15018
diff changeset
537 AllocatableValue base = Value.ILLEGAL;
652564fe42d5 Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15018
diff changeset
538 if (encoding.base != 0) {
652564fe42d5 Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15018
diff changeset
539 base = newVariable(Kind.Long);
652564fe42d5 Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15018
diff changeset
540 append(new AMD64Move.MoveToRegOp(Kind.Long, base, Constant.forLong(encoding.base)));
652564fe42d5 Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15018
diff changeset
541 }
15058
895e9ecedfe8 Fix code generation for compressed metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15024
diff changeset
542 append(new AMD64HotSpotMove.CompressPointer(result, asAllocatable(pointer), base, encoding, nonNull));
15023
652564fe42d5 Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15018
diff changeset
543 return result;
652564fe42d5 Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15018
diff changeset
544 }
14943
e5a55d280f24 Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 14921
diff changeset
545 }
e5a55d280f24 Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 14921
diff changeset
546
e5a55d280f24 Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 14921
diff changeset
547 @Override
15058
895e9ecedfe8 Fix code generation for compressed metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15024
diff changeset
548 public Value emitUncompress(Value pointer, CompressEncoding encoding, boolean nonNull) {
15023
652564fe42d5 Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15018
diff changeset
549 if (pointer.getPlatformKind() == NarrowOopStamp.NarrowOop) {
652564fe42d5 Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15018
diff changeset
550 Variable result = newVariable(Kind.Object);
15058
895e9ecedfe8 Fix code generation for compressed metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15024
diff changeset
551 append(new AMD64HotSpotMove.UncompressPointer(result, asAllocatable(pointer), getProviders().getRegisters().getHeapBaseRegister().asValue(), encoding, nonNull));
15023
652564fe42d5 Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15018
diff changeset
552 return result;
652564fe42d5 Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15018
diff changeset
553 } else {
652564fe42d5 Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15018
diff changeset
554 assert pointer.getPlatformKind() == Kind.Int;
652564fe42d5 Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15018
diff changeset
555 Variable result = newVariable(Kind.Long);
652564fe42d5 Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15018
diff changeset
556 AllocatableValue base = Value.ILLEGAL;
652564fe42d5 Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15018
diff changeset
557 if (encoding.base != 0) {
652564fe42d5 Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15018
diff changeset
558 base = newVariable(Kind.Long);
652564fe42d5 Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15018
diff changeset
559 append(new AMD64Move.MoveToRegOp(Kind.Long, base, Constant.forLong(encoding.base)));
652564fe42d5 Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15018
diff changeset
560 }
15058
895e9ecedfe8 Fix code generation for compressed metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15024
diff changeset
561 append(new AMD64HotSpotMove.UncompressPointer(result, asAllocatable(pointer), base, encoding, nonNull));
15023
652564fe42d5 Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15018
diff changeset
562 return result;
652564fe42d5 Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 15018
diff changeset
563 }
14943
e5a55d280f24 Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 14921
diff changeset
564 }
e5a55d280f24 Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents: 14921
diff changeset
565
14945
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
566 @Override
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
567 protected AMD64LIRInstruction createMove(AllocatableValue dst, Value src) {
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
568 if (dst.getPlatformKind() == NarrowOopStamp.NarrowOop) {
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
569 if (isRegister(src) || isStackSlot(dst)) {
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
570 return new MoveFromRegOp(Kind.Int, dst, src);
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
571 } else {
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
572 return new MoveToRegOp(Kind.Int, dst, src);
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
573 }
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
574 } else {
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
575 return super.createMove(dst, src);
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
576 }
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
577 }
b14cb2d9253d Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents: 14943
diff changeset
578
15024
2ee777221036 Use high level CompressionNode in lowering of CompareAndSwapNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 15023
diff changeset
579 public Value emitCompareAndSwap(Value address, Value expectedValue, Value newValue, Value trueValue, Value falseValue) {
2ee777221036 Use high level CompressionNode in lowering of CompareAndSwapNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 15023
diff changeset
580 PlatformKind kind = newValue.getPlatformKind();
2ee777221036 Use high level CompressionNode in lowering of CompareAndSwapNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 15023
diff changeset
581 assert kind == expectedValue.getPlatformKind();
2ee777221036 Use high level CompressionNode in lowering of CompareAndSwapNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 15023
diff changeset
582 Kind memKind = getMemoryKind(kind);
2ee777221036 Use high level CompressionNode in lowering of CompareAndSwapNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 15023
diff changeset
583
2ee777221036 Use high level CompressionNode in lowering of CompareAndSwapNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 15023
diff changeset
584 AMD64AddressValue addressValue = asAddressValue(address);
2ee777221036 Use high level CompressionNode in lowering of CompareAndSwapNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 15023
diff changeset
585 RegisterValue raxRes = AMD64.rax.asValue(kind);
2ee777221036 Use high level CompressionNode in lowering of CompareAndSwapNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 15023
diff changeset
586 emitMove(raxRes, expectedValue);
2ee777221036 Use high level CompressionNode in lowering of CompareAndSwapNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 15023
diff changeset
587 append(new CompareAndSwapOp(memKind, raxRes, addressValue, raxRes, asAllocatable(newValue)));
2ee777221036 Use high level CompressionNode in lowering of CompareAndSwapNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 15023
diff changeset
588
2ee777221036 Use high level CompressionNode in lowering of CompareAndSwapNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 15023
diff changeset
589 assert trueValue.getPlatformKind() == falseValue.getPlatformKind();
2ee777221036 Use high level CompressionNode in lowering of CompareAndSwapNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 15023
diff changeset
590 Variable result = newVariable(trueValue.getPlatformKind());
2ee777221036 Use high level CompressionNode in lowering of CompareAndSwapNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 15023
diff changeset
591 append(new CondMoveOp(result, Condition.EQ, asAllocatable(trueValue), falseValue));
2ee777221036 Use high level CompressionNode in lowering of CompareAndSwapNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 15023
diff changeset
592 return result;
2ee777221036 Use high level CompressionNode in lowering of CompareAndSwapNode.
Roland Schatz <roland.schatz@oracle.com>
parents: 15023
diff changeset
593 }
15251
de1d50c121cd Unsafe.getAndAdd/Set method substitutions
twisti
parents: 15200
diff changeset
594
de1d50c121cd Unsafe.getAndAdd/Set method substitutions
twisti
parents: 15200
diff changeset
595 public Value emitAtomicReadAndAdd(Value address, Value delta) {
de1d50c121cd Unsafe.getAndAdd/Set method substitutions
twisti
parents: 15200
diff changeset
596 PlatformKind kind = delta.getPlatformKind();
de1d50c121cd Unsafe.getAndAdd/Set method substitutions
twisti
parents: 15200
diff changeset
597 Kind memKind = getMemoryKind(kind);
de1d50c121cd Unsafe.getAndAdd/Set method substitutions
twisti
parents: 15200
diff changeset
598 Variable result = newVariable(kind);
de1d50c121cd Unsafe.getAndAdd/Set method substitutions
twisti
parents: 15200
diff changeset
599 AMD64AddressValue addressValue = asAddressValue(address);
de1d50c121cd Unsafe.getAndAdd/Set method substitutions
twisti
parents: 15200
diff changeset
600 append(new AMD64Move.AtomicReadAndAddOp(memKind, result, addressValue, asAllocatable(delta)));
de1d50c121cd Unsafe.getAndAdd/Set method substitutions
twisti
parents: 15200
diff changeset
601 return result;
de1d50c121cd Unsafe.getAndAdd/Set method substitutions
twisti
parents: 15200
diff changeset
602 }
de1d50c121cd Unsafe.getAndAdd/Set method substitutions
twisti
parents: 15200
diff changeset
603
de1d50c121cd Unsafe.getAndAdd/Set method substitutions
twisti
parents: 15200
diff changeset
604 public Value emitAtomicReadAndWrite(Value address, Value newValue) {
de1d50c121cd Unsafe.getAndAdd/Set method substitutions
twisti
parents: 15200
diff changeset
605 PlatformKind kind = newValue.getPlatformKind();
de1d50c121cd Unsafe.getAndAdd/Set method substitutions
twisti
parents: 15200
diff changeset
606 Kind memKind = getMemoryKind(kind);
de1d50c121cd Unsafe.getAndAdd/Set method substitutions
twisti
parents: 15200
diff changeset
607 Variable result = newVariable(kind);
de1d50c121cd Unsafe.getAndAdd/Set method substitutions
twisti
parents: 15200
diff changeset
608 AMD64AddressValue addressValue = asAddressValue(address);
de1d50c121cd Unsafe.getAndAdd/Set method substitutions
twisti
parents: 15200
diff changeset
609 append(new AMD64Move.AtomicReadAndWriteOp(memKind, result, addressValue, asAllocatable(newValue)));
de1d50c121cd Unsafe.getAndAdd/Set method substitutions
twisti
parents: 15200
diff changeset
610 return result;
de1d50c121cd Unsafe.getAndAdd/Set method substitutions
twisti
parents: 15200
diff changeset
611 }
de1d50c121cd Unsafe.getAndAdd/Set method substitutions
twisti
parents: 15200
diff changeset
612
8303
bb9fba66b6ef refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
613 }