Mercurial > hg > truffle
annotate graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java @ 18481:f91e40c4bb47
Create separate stamps for Klass* and Method*, and make them hotspot specific.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Thu, 20 Nov 2014 15:23:46 +0100 |
parents | 06624c98ed8b |
children | ca81508f2a19 |
rev | line source |
---|---|
8303
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16083
diff
changeset
|
2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. |
8303
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.*; |
15926
af0e42dad358
reduced time to initialize ForeignCallProviders by avoiding triggering class initialization of Node subclasses as well as making annotation parsing lazy in SnippetInfo
Doug Simon <doug.simon@oracle.com>
parents:
15910
diff
changeset
|
27 import static com.oracle.graal.hotspot.HotSpotBackend.*; |
11832
97d6932a309b
CodeCacheProvider.encodeDeoptActionAndReason now returns a Constant
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11790
diff
changeset
|
28 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; |
8303
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
29 |
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.*; |
18390
ce15cc6af5fe
Additional constructor for AMD64HotSpotLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
18358
diff
changeset
|
38 import com.oracle.graal.compiler.common.spi.*; |
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; |
15909
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
15554
diff
changeset
|
41 import com.oracle.graal.hotspot.amd64.AMD64HotSpotMove.HotSpotStoreConstantOp; |
8303
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
42 import com.oracle.graal.hotspot.meta.*; |
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
43 import com.oracle.graal.hotspot.stubs.*; |
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
44 import com.oracle.graal.lir.*; |
15301
468b2428c403
Change DeoptimizingNode and Access to LIRFrameState in *LIRGenerator*.
Josef Eisl <josef.eisl@jku.at>
parents:
15297
diff
changeset
|
45 import com.oracle.graal.lir.StandardOp.NoOp; |
468b2428c403
Change DeoptimizingNode and Access to LIRFrameState in *LIRGenerator*.
Josef Eisl <josef.eisl@jku.at>
parents:
15297
diff
changeset
|
46 import com.oracle.graal.lir.StandardOp.SaveRegistersOp; |
8303
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 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
|
48 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
|
49 import com.oracle.graal.lir.amd64.AMD64Move.CompareAndSwapOp; |
14850 | 50 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
|
51 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
|
52 import com.oracle.graal.lir.amd64.AMD64Move.MoveFromRegOp; |
9885
ed86945795d5
Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
9768
diff
changeset
|
53 import com.oracle.graal.lir.amd64.AMD64Move.StoreOp; |
15292
a38d791982e1
Move LIRGenerationResult* to graal.lir.
Josef Eisl <josef.eisl@jku.at>
parents:
15251
diff
changeset
|
54 import com.oracle.graal.lir.gen.*; |
17314
3b6759c384a9
Introduce emitLoadConstant in LIRGeneratorTool.
Roland Schatz <roland.schatz@oracle.com>
parents:
16785
diff
changeset
|
55 import com.oracle.graal.phases.util.*; |
8303
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
56 |
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
57 /** |
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
58 * LIR generator specialized for AMD64 HotSpot. |
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
59 */ |
9431
c0488f573091
Make AMD64 LIR generator extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
9425
diff
changeset
|
60 public class AMD64HotSpotLIRGenerator extends AMD64LIRGenerator implements HotSpotLIRGenerator { |
8303
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
61 |
14841
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
14834
diff
changeset
|
62 final HotSpotVMConfig config; |
15293
adc7d7aad51c
Deprecate LIRGenerator.getDebugInfoBuilder().
Josef Eisl <josef.eisl@jku.at>
parents:
15292
diff
changeset
|
63 private HotSpotLockStack lockStack; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12363
diff
changeset
|
64 |
14842
f2e61bf2a2d8
Removed nodeOperands from LIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents:
14841
diff
changeset
|
65 protected AMD64HotSpotLIRGenerator(HotSpotProviders providers, HotSpotVMConfig config, CallingConvention cc, LIRGenerationResult lirGenRes) { |
18481
f91e40c4bb47
Create separate stamps for Klass* and Method*, and make them hotspot specific.
Roland Schatz <roland.schatz@oracle.com>
parents:
18434
diff
changeset
|
66 this(new DefaultLIRKindTool(providers.getCodeCache().getTarget().wordKind), providers, config, cc, lirGenRes); |
18390
ce15cc6af5fe
Additional constructor for AMD64HotSpotLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
18358
diff
changeset
|
67 } |
ce15cc6af5fe
Additional constructor for AMD64HotSpotLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
18358
diff
changeset
|
68 |
ce15cc6af5fe
Additional constructor for AMD64HotSpotLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
18358
diff
changeset
|
69 protected AMD64HotSpotLIRGenerator(LIRKindTool lirKindTool, HotSpotProviders providers, HotSpotVMConfig config, CallingConvention cc, LIRGenerationResult lirGenRes) { |
ce15cc6af5fe
Additional constructor for AMD64HotSpotLIRGenerator.
Roland Schatz <roland.schatz@oracle.com>
parents:
18358
diff
changeset
|
70 super(lirKindTool, providers, cc, lirGenRes); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12363
diff
changeset
|
71 assert config.basicLockSize == 8; |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12363
diff
changeset
|
72 this.config = config; |
8303
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
73 } |
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
74 |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12363
diff
changeset
|
75 @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
|
76 public HotSpotProviders getProviders() { |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12363
diff
changeset
|
77 return (HotSpotProviders) super.getProviders(); |
8303
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 |
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
80 /** |
9247
27c75e4016db
clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents:
8892
diff
changeset
|
81 * 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
|
82 */ |
9247
27c75e4016db
clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents:
8892
diff
changeset
|
83 class SaveRbp { |
27c75e4016db
clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents:
8892
diff
changeset
|
84 |
13313
6dd9a1455e64
renamed PlaceholderOp to NoOp
Doug Simon <doug.simon@oracle.com>
parents:
13291
diff
changeset
|
85 final NoOp placeholder; |
9247
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 /** |
27c75e4016db
clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents:
8892
diff
changeset
|
88 * 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
|
89 */ |
18434
06624c98ed8b
Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents:
18426
diff
changeset
|
90 final StackSlot reservedSlot; |
9247
27c75e4016db
clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents:
8892
diff
changeset
|
91 |
13313
6dd9a1455e64
renamed PlaceholderOp to NoOp
Doug Simon <doug.simon@oracle.com>
parents:
13291
diff
changeset
|
92 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
|
93 this.placeholder = placeholder; |
18424
5afaa02c53dd
Introduce AMD64FrameMapBuilder to support special stack slot allocation for RBP.
Josef Eisl <josef.eisl@jku.at>
parents:
18390
diff
changeset
|
94 AMD64FrameMapBuilder frameMapBuilder = (AMD64FrameMapBuilder) getResult().getFrameMapBuilder(); |
5afaa02c53dd
Introduce AMD64FrameMapBuilder to support special stack slot allocation for RBP.
Josef Eisl <josef.eisl@jku.at>
parents:
18390
diff
changeset
|
95 this.reservedSlot = frameMapBuilder.allocateRBPSpillSlot(); |
9247
27c75e4016db
clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents:
8892
diff
changeset
|
96 } |
8303
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
97 |
9247
27c75e4016db
clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents:
8892
diff
changeset
|
98 /** |
27c75e4016db
clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents:
8892
diff
changeset
|
99 * Replaces this operation with the appropriate move for saving rbp. |
14859 | 100 * |
9247
27c75e4016db
clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents:
8892
diff
changeset
|
101 * @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
|
102 */ |
27c75e4016db
clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents:
8892
diff
changeset
|
103 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
|
104 AllocatableValue dst; |
27c75e4016db
clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents:
8892
diff
changeset
|
105 if (useStack) { |
27c75e4016db
clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents:
8892
diff
changeset
|
106 dst = reservedSlot; |
27c75e4016db
clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents:
8892
diff
changeset
|
107 } else { |
18434
06624c98ed8b
Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents:
18426
diff
changeset
|
108 ((AMD64FrameMapBuilder) getResult().getFrameMapBuilder()).freeRBPSpillSlot(); |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16083
diff
changeset
|
109 dst = newVariable(LIRKind.value(Kind.Long)); |
9247
27c75e4016db
clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents:
8892
diff
changeset
|
110 } |
27c75e4016db
clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents:
8892
diff
changeset
|
111 |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16083
diff
changeset
|
112 placeholder.replace(getResult().getLIR(), new MoveFromRegOp(Kind.Long, dst, rbp.asValue(LIRKind.value(Kind.Long)))); |
9247
27c75e4016db
clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents:
8892
diff
changeset
|
113 return dst; |
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 } |
27c75e4016db
clarified code for emitting LIR code to save RBP
Doug Simon <doug.simon@oracle.com>
parents:
8892
diff
changeset
|
116 |
14841
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
14834
diff
changeset
|
117 SaveRbp saveRbp; |
8303
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 /** |
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
120 * 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
|
121 */ |
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
122 List<AMD64HotSpotEpilogueOp> epilogueOps = new ArrayList<>(2); |
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
123 |
9560
08d1414ac62d
refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents:
9507
diff
changeset
|
124 @Override |
08d1414ac62d
refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents:
9507
diff
changeset
|
125 public void append(LIRInstruction op) { |
08d1414ac62d
refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents:
9507
diff
changeset
|
126 super.append(op); |
08d1414ac62d
refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents:
9507
diff
changeset
|
127 if (op instanceof AMD64HotSpotEpilogueOp) { |
08d1414ac62d
refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents:
9507
diff
changeset
|
128 epilogueOps.add((AMD64HotSpotEpilogueOp) op); |
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 } |
08d1414ac62d
refactored common code in subclasses into AMD64HotSpotEpilogueOp
Doug Simon <doug.simon@oracle.com>
parents:
9507
diff
changeset
|
131 |
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
|
132 @Override |
18425
b856446ff7e0
Introduce StackSlotValue and VirtualStackSlot.
Josef Eisl <josef.eisl@jku.at>
parents:
18424
diff
changeset
|
133 public StackSlotValue getLockSlot(int lockDepth) { |
15293
adc7d7aad51c
Deprecate LIRGenerator.getDebugInfoBuilder().
Josef Eisl <josef.eisl@jku.at>
parents:
15292
diff
changeset
|
134 return getLockStack().makeLockSlot(lockDepth); |
adc7d7aad51c
Deprecate LIRGenerator.getDebugInfoBuilder().
Josef Eisl <josef.eisl@jku.at>
parents:
15292
diff
changeset
|
135 } |
adc7d7aad51c
Deprecate LIRGenerator.getDebugInfoBuilder().
Josef Eisl <josef.eisl@jku.at>
parents:
15292
diff
changeset
|
136 |
adc7d7aad51c
Deprecate LIRGenerator.getDebugInfoBuilder().
Josef Eisl <josef.eisl@jku.at>
parents:
15292
diff
changeset
|
137 private HotSpotLockStack getLockStack() { |
adc7d7aad51c
Deprecate LIRGenerator.getDebugInfoBuilder().
Josef Eisl <josef.eisl@jku.at>
parents:
15292
diff
changeset
|
138 assert lockStack != null; |
adc7d7aad51c
Deprecate LIRGenerator.getDebugInfoBuilder().
Josef Eisl <josef.eisl@jku.at>
parents:
15292
diff
changeset
|
139 return lockStack; |
adc7d7aad51c
Deprecate LIRGenerator.getDebugInfoBuilder().
Josef Eisl <josef.eisl@jku.at>
parents:
15292
diff
changeset
|
140 } |
adc7d7aad51c
Deprecate LIRGenerator.getDebugInfoBuilder().
Josef Eisl <josef.eisl@jku.at>
parents:
15292
diff
changeset
|
141 |
adc7d7aad51c
Deprecate LIRGenerator.getDebugInfoBuilder().
Josef Eisl <josef.eisl@jku.at>
parents:
15292
diff
changeset
|
142 protected void setLockStack(HotSpotLockStack lockStack) { |
adc7d7aad51c
Deprecate LIRGenerator.getDebugInfoBuilder().
Josef Eisl <josef.eisl@jku.at>
parents:
15292
diff
changeset
|
143 assert this.lockStack == null; |
adc7d7aad51c
Deprecate LIRGenerator.getDebugInfoBuilder().
Josef Eisl <josef.eisl@jku.at>
parents:
15292
diff
changeset
|
144 this.lockStack = lockStack; |
8303
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
145 } |
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
146 |
12456
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
147 private Register findPollOnReturnScratchRegister() { |
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
148 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
|
149 for (Register r : regConfig.getAllocatableRegisters(Kind.Long)) { |
18357
09550eb6ddfb
replace use of '==' with .equals()
Doug Simon <doug.simon@oracle.com>
parents:
18289
diff
changeset
|
150 if (!r.equals(regConfig.getReturnRegister(Kind.Long)) && !r.equals(AMD64.rbp)) { |
12456
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
151 return r; |
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
152 } |
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
153 } |
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
154 throw GraalInternalError.shouldNotReachHere(); |
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
155 } |
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
156 |
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
157 private Register pollOnReturnScratchRegister; |
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
158 |
8303
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
159 @Override |
14841
47e4d2e01c6e
Split LIRGenerator and fix AMD64 backend.
Josef Eisl <josef.eisl@jku.at>
parents:
14834
diff
changeset
|
160 public void emitReturn(Value input) { |
14949
b65036798097
Remove visitReturn from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents:
14945
diff
changeset
|
161 AllocatableValue operand = Value.ILLEGAL; |
b65036798097
Remove visitReturn from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents:
14945
diff
changeset
|
162 if (input != null) { |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16083
diff
changeset
|
163 operand = resultOperandFor(input.getLIRKind()); |
14949
b65036798097
Remove visitReturn from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents:
14945
diff
changeset
|
164 emitMove(operand, input); |
b65036798097
Remove visitReturn from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents:
14945
diff
changeset
|
165 } |
12456
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
166 if (pollOnReturnScratchRegister == null) { |
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
167 pollOnReturnScratchRegister = findPollOnReturnScratchRegister(); |
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
168 } |
14949
b65036798097
Remove visitReturn from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents:
14945
diff
changeset
|
169 append(new AMD64HotSpotReturnOp(operand, getStub() != null, pollOnReturnScratchRegister)); |
8303
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
170 } |
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
171 |
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
172 @Override |
15297
3a6151ed5a25
Move LIRGenerator to graal.lir (errors).
Josef Eisl <josef.eisl@jku.at>
parents:
15293
diff
changeset
|
173 public boolean needOnlyOopMaps() { |
8303
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
174 // Stubs only need oop maps |
14921
88dfaf6448e0
Remove LIRGenerationResult from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents:
14859
diff
changeset
|
175 return ((AMD64HotSpotLIRGenerationResult) getResult()).getStub() != null; |
8303
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
176 } |
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
177 |
14859 | 178 @Override |
14850 | 179 public void emitData(AllocatableValue dst, byte[] data) { |
180 append(new LeaDataOp(dst, data)); | |
181 } | |
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
|
182 |
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
|
183 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
|
184 |
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
|
185 @Override |
9742
cff1e11941c0
moved temporaries from CallingConvention to ForeignCallLinkage
Doug Simon <doug.simon@oracle.com>
parents:
9741
diff
changeset
|
186 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
|
187 currentRuntimeCallInfo = info; |
9742
cff1e11941c0
moved temporaries from CallingConvention to ForeignCallLinkage
Doug Simon <doug.simon@oracle.com>
parents:
9741
diff
changeset
|
188 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
|
189 } |
0266549ff6e0
added support from compiled stubs to be installed as RuntimeStubs and to be able to directly call C/C++ runtime functions (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9247
diff
changeset
|
190 |
15456
bb97b75d1d65
AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents:
15412
diff
changeset
|
191 public void emitLeaveCurrentStackFrame(SaveRegistersOp saveRegisterOp) { |
bb97b75d1d65
AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents:
15412
diff
changeset
|
192 append(new AMD64HotSpotLeaveCurrentStackFrameOp(saveRegisterOp)); |
15104 | 193 } |
194 | |
195 public void emitLeaveDeoptimizedStackFrame(Value frameSize, Value initialInfo) { | |
196 Variable frameSizeVariable = load(frameSize); | |
197 Variable initialInfoVariable = load(initialInfo); | |
198 append(new AMD64HotSpotLeaveDeoptimizedStackFrameOp(frameSizeVariable, initialInfoVariable)); | |
199 } | |
200 | |
15456
bb97b75d1d65
AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents:
15412
diff
changeset
|
201 public void emitEnterUnpackFramesStackFrame(Value framePc, Value senderSp, Value senderFp, SaveRegistersOp saveRegisterOp) { |
bb97b75d1d65
AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents:
15412
diff
changeset
|
202 Register threadRegister = getProviders().getRegisters().getThreadRegister(); |
15104 | 203 Variable framePcVariable = load(framePc); |
204 Variable senderSpVariable = load(senderSp); | |
205 Variable senderFpVariable = load(senderFp); | |
15456
bb97b75d1d65
AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents:
15412
diff
changeset
|
206 append(new AMD64HotSpotEnterUnpackFramesStackFrameOp(threadRegister, config.threadLastJavaSpOffset(), config.threadLastJavaPcOffset(), config.threadLastJavaFpOffset(), framePcVariable, |
bb97b75d1d65
AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents:
15412
diff
changeset
|
207 senderSpVariable, senderFpVariable, saveRegisterOp)); |
15104 | 208 } |
209 | |
15456
bb97b75d1d65
AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents:
15412
diff
changeset
|
210 public void emitLeaveUnpackFramesStackFrame(SaveRegistersOp saveRegisterOp) { |
bb97b75d1d65
AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents:
15412
diff
changeset
|
211 Register threadRegister = getProviders().getRegisters().getThreadRegister(); |
bb97b75d1d65
AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents:
15412
diff
changeset
|
212 append(new AMD64HotSpotLeaveUnpackFramesStackFrameOp(threadRegister, config.threadLastJavaSpOffset(), config.threadLastJavaPcOffset(), config.threadLastJavaFpOffset(), saveRegisterOp)); |
15104 | 213 } |
214 | |
215 /** | |
216 * @param savedRegisters the registers saved by this operation which may be subject to pruning | |
217 * @param savedRegisterLocations the slots to which the registers are saved | |
218 * @param supportsRemove determines if registers can be pruned | |
219 */ | |
18425
b856446ff7e0
Introduce StackSlotValue and VirtualStackSlot.
Josef Eisl <josef.eisl@jku.at>
parents:
18424
diff
changeset
|
220 protected AMD64SaveRegistersOp emitSaveRegisters(Register[] savedRegisters, StackSlotValue[] savedRegisterLocations, boolean supportsRemove) { |
15104 | 221 AMD64SaveRegistersOp save = new AMD64SaveRegistersOp(savedRegisters, savedRegisterLocations, supportsRemove); |
9507
3df71c132731
Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
9506
diff
changeset
|
222 append(save); |
3df71c132731
Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
9506
diff
changeset
|
223 return save; |
3df71c132731
Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
9506
diff
changeset
|
224 } |
3df71c132731
Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
9506
diff
changeset
|
225 |
15104 | 226 /** |
227 * Adds a node to the graph that saves all allocatable registers to the stack. | |
228 * | |
229 * @param supportsRemove determines if registers can be pruned | |
230 * @return the register save node | |
231 */ | |
232 private AMD64SaveRegistersOp emitSaveAllRegisters(Register[] savedRegisters, boolean supportsRemove) { | |
18425
b856446ff7e0
Introduce StackSlotValue and VirtualStackSlot.
Josef Eisl <josef.eisl@jku.at>
parents:
18424
diff
changeset
|
233 StackSlotValue[] savedRegisterLocations = new StackSlotValue[savedRegisters.length]; |
15104 | 234 for (int i = 0; i < savedRegisters.length; i++) { |
235 PlatformKind kind = target().arch.getLargestStorableKind(savedRegisters[i].getRegisterCategory()); | |
236 assert kind != Kind.Illegal; | |
18425
b856446ff7e0
Introduce StackSlotValue and VirtualStackSlot.
Josef Eisl <josef.eisl@jku.at>
parents:
18424
diff
changeset
|
237 VirtualStackSlot spillSlot = getResult().getFrameMapBuilder().allocateSpillSlot(LIRKind.value(kind)); |
15104 | 238 savedRegisterLocations[i] = spillSlot; |
239 } | |
240 return emitSaveRegisters(savedRegisters, savedRegisterLocations, supportsRemove); | |
241 } | |
242 | |
243 @Override | |
244 public SaveRegistersOp emitSaveAllRegisters() { | |
245 // We are saving all registers. | |
246 // TODO Save upper half of YMM registers. | |
247 return emitSaveAllRegisters(cpuxmmRegisters, false); | |
248 } | |
249 | |
9507
3df71c132731
Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
9506
diff
changeset
|
250 protected void emitRestoreRegisters(AMD64SaveRegistersOp save) { |
3df71c132731
Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
9506
diff
changeset
|
251 append(new AMD64RestoreRegistersOp(save.getSlots().clone(), save)); |
3df71c132731
Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
9506
diff
changeset
|
252 } |
3df71c132731
Make register saving extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
9506
diff
changeset
|
253 |
14807
c3242028cc44
Introduce specialized LIRGenerationResults for Targets if needed.
Josef Eisl <josef.eisl@jku.at>
parents:
14806
diff
changeset
|
254 public Stub getStub() { |
14921
88dfaf6448e0
Remove LIRGenerationResult from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents:
14859
diff
changeset
|
255 return ((AMD64HotSpotLIRGenerationResult) getResult()).getStub(); |
9613
0c17815817a4
removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents:
9612
diff
changeset
|
256 } |
0c17815817a4
removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents:
9612
diff
changeset
|
257 |
9338
0266549ff6e0
added support from compiled stubs to be installed as RuntimeStubs and to be able to directly call C/C++ runtime functions (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9247
diff
changeset
|
258 @Override |
15301
468b2428c403
Change DeoptimizingNode and Access to LIRFrameState in *LIRGenerator*.
Josef Eisl <josef.eisl@jku.at>
parents:
15297
diff
changeset
|
259 public Variable emitForeignCall(ForeignCallLinkage linkage, LIRFrameState state, 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
|
260 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
|
261 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
|
262 |
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
|
263 AMD64SaveRegistersOp save = null; |
9693
d04944441454
cleaned up and simplified runtime call mechanisms
Doug Simon <doug.simon@oracle.com>
parents:
9613
diff
changeset
|
264 if (destroysRegisters) { |
14142
4eac66a9b87d
Remove reference to graph in LIRGenerator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14003
diff
changeset
|
265 if (getStub() != null) { |
4eac66a9b87d
Remove reference to graph in LIRGenerator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14003
diff
changeset
|
266 if (getStub().preservesRegisters()) { |
18149
c6086a18c9ce
Rename LIRGenerationResult.getFrameMap() to getFrameMapBuilder().
Josef Eisl <josef.eisl@jku.at>
parents:
18123
diff
changeset
|
267 Register[] savedRegisters = getResult().getFrameMapBuilder().getRegisterConfig().getAllocatableRegisters(); |
15104 | 268 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
|
269 } |
9338
0266549ff6e0
added support from compiled stubs to be installed as RuntimeStubs and to be able to directly call C/C++ runtime functions (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9247
diff
changeset
|
270 } |
9731
f7bd4594cbbf
added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents:
9693
diff
changeset
|
271 } |
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
|
272 |
9768
cbf274a92e5b
a leaf foreign call does not need debug info
Doug Simon <doug.simon@oracle.com>
parents:
9742
diff
changeset
|
273 Variable result; |
15301
468b2428c403
Change DeoptimizingNode and Access to LIRFrameState in *LIRGenerator*.
Josef Eisl <josef.eisl@jku.at>
parents:
15297
diff
changeset
|
274 // TODO (je) check if we can remove this |
468b2428c403
Change DeoptimizingNode and Access to LIRFrameState in *LIRGenerator*.
Josef Eisl <josef.eisl@jku.at>
parents:
15297
diff
changeset
|
275 LIRFrameState deoptInfo = null; |
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 if (hotspotLinkage.canDeoptimize()) { |
15301
468b2428c403
Change DeoptimizingNode and Access to LIRFrameState in *LIRGenerator*.
Josef Eisl <josef.eisl@jku.at>
parents:
15297
diff
changeset
|
277 deoptInfo = state; |
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
|
278 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
|
279 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
|
280 } |
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
|
281 |
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
|
282 if (hotspotLinkage.needsJavaFrameAnchor()) { |
12456
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
283 Register thread = getProviders().getRegisters().getThreadRegister(); |
12559
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
284 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
|
285 result = super.emitForeignCall(hotspotLinkage, deoptInfo, args); |
12559
ae412befde21
read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents:
12456
diff
changeset
|
286 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
|
287 } else { |
15377
ad5c1c4434ed
AMD64HotSpotLIRGenerator.emitForeignCall: add assert
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15370
diff
changeset
|
288 assert deoptInfo == null; |
ad5c1c4434ed
AMD64HotSpotLIRGenerator.emitForeignCall: add assert
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15370
diff
changeset
|
289 result = super.emitForeignCall(hotspotLinkage, null, args); |
9731
f7bd4594cbbf
added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents:
9693
diff
changeset
|
290 } |
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
|
291 |
9731
f7bd4594cbbf
added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents:
9693
diff
changeset
|
292 if (destroysRegisters) { |
14142
4eac66a9b87d
Remove reference to graph in LIRGenerator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14003
diff
changeset
|
293 if (getStub() != null) { |
4eac66a9b87d
Remove reference to graph in LIRGenerator.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14003
diff
changeset
|
294 if (getStub().preservesRegisters()) { |
15104 | 295 AMD64HotSpotLIRGenerationResult generationResult = (AMD64HotSpotLIRGenerationResult) getResult(); |
296 assert !generationResult.getCalleeSaveInfo().containsKey(currentRuntimeCallInfo); | |
297 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
|
298 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
|
299 } else { |
f7bd4594cbbf
added support for declaring a foreign function call to be a leaf
Doug Simon <doug.simon@oracle.com>
parents:
9693
diff
changeset
|
300 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
|
301 } |
9491
789cfd153265
a compiled stub can now specify whether it needs to preserve registers. If a stub does not preserve registers and assertions are enabled, then all non-temporary registers are zapped after a C runtime call from the stub.
Doug Simon <doug.simon@oracle.com>
parents:
9471
diff
changeset
|
302 } |
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
|
303 } |
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
|
304 |
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
|
305 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
|
306 } |
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
|
307 |
15104 | 308 public Value emitUncommonTrapCall(Value trapRequest, SaveRegistersOp saveRegisterOp) { |
309 ForeignCallLinkage linkage = getForeignCalls().lookupForeignCall(UNCOMMON_TRAP); | |
310 | |
311 Register thread = getProviders().getRegisters().getThreadRegister(); | |
312 append(new AMD64HotSpotCRuntimeCallPrologueOp(config.threadLastJavaSpOffset(), thread)); | |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16083
diff
changeset
|
313 Variable result = super.emitForeignCall(linkage, null, thread.asValue(LIRKind.value(Kind.Long)), trapRequest); |
15104 | 314 append(new AMD64HotSpotCRuntimeCallEpilogueOp(config.threadLastJavaSpOffset(), config.threadLastJavaFpOffset(), thread)); |
315 | |
316 Map<LIRFrameState, SaveRegistersOp> calleeSaveInfo = ((AMD64HotSpotLIRGenerationResult) getResult()).getCalleeSaveInfo(); | |
317 assert !calleeSaveInfo.containsKey(currentRuntimeCallInfo); | |
318 calleeSaveInfo.put(currentRuntimeCallInfo, saveRegisterOp); | |
319 | |
320 return result; | |
321 } | |
322 | |
15456
bb97b75d1d65
AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents:
15412
diff
changeset
|
323 public Value emitDeoptimizationFetchUnrollInfoCall(SaveRegistersOp saveRegisterOp) { |
15968
42eaa579e134
more improvements to runtime initialization:
Doug Simon <doug.simon@oracle.com>
parents:
15947
diff
changeset
|
324 ForeignCallLinkage linkage = getForeignCalls().lookupForeignCall(FETCH_UNROLL_INFO); |
15456
bb97b75d1d65
AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents:
15412
diff
changeset
|
325 |
bb97b75d1d65
AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents:
15412
diff
changeset
|
326 Register thread = getProviders().getRegisters().getThreadRegister(); |
bb97b75d1d65
AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents:
15412
diff
changeset
|
327 append(new AMD64HotSpotCRuntimeCallPrologueOp(config.threadLastJavaSpOffset(), thread)); |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16083
diff
changeset
|
328 Variable result = super.emitForeignCall(linkage, null, thread.asValue(LIRKind.value(Kind.Long))); |
15456
bb97b75d1d65
AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents:
15412
diff
changeset
|
329 append(new AMD64HotSpotCRuntimeCallEpilogueOp(config.threadLastJavaSpOffset(), config.threadLastJavaFpOffset(), thread)); |
bb97b75d1d65
AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents:
15412
diff
changeset
|
330 |
bb97b75d1d65
AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents:
15412
diff
changeset
|
331 Map<LIRFrameState, SaveRegistersOp> calleeSaveInfo = ((AMD64HotSpotLIRGenerationResult) getResult()).getCalleeSaveInfo(); |
bb97b75d1d65
AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents:
15412
diff
changeset
|
332 assert !calleeSaveInfo.containsKey(currentRuntimeCallInfo); |
bb97b75d1d65
AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents:
15412
diff
changeset
|
333 calleeSaveInfo.put(currentRuntimeCallInfo, saveRegisterOp); |
bb97b75d1d65
AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents:
15412
diff
changeset
|
334 |
bb97b75d1d65
AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents:
15412
diff
changeset
|
335 return result; |
bb97b75d1d65
AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents:
15412
diff
changeset
|
336 } |
bb97b75d1d65
AMD64: implemented DeoptimizationStub.deoptimizationHandler
twisti
parents:
15412
diff
changeset
|
337 |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
338 protected AMD64ZapRegistersOp emitZapRegisters(Register[] zappedRegisters, JavaConstant[] zapValues) { |
9506
6703dca691d7
Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents:
9505
diff
changeset
|
339 AMD64ZapRegistersOp zap = new AMD64ZapRegistersOp(zappedRegisters, zapValues); |
6703dca691d7
Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents:
9505
diff
changeset
|
340 append(zap); |
6703dca691d7
Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents:
9505
diff
changeset
|
341 return zap; |
6703dca691d7
Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents:
9505
diff
changeset
|
342 } |
6703dca691d7
Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents:
9505
diff
changeset
|
343 |
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
|
344 protected boolean zapRegisters() { |
18149
c6086a18c9ce
Rename LIRGenerationResult.getFrameMap() to getFrameMapBuilder().
Josef Eisl <josef.eisl@jku.at>
parents:
18123
diff
changeset
|
345 Register[] zappedRegisters = getResult().getFrameMapBuilder().getRegisterConfig().getAllocatableRegisters(); |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
346 JavaConstant[] zapValues = new JavaConstant[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
|
347 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
|
348 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
|
349 assert kind != Kind.Illegal; |
9506
6703dca691d7
Restructure register zapping.
Roland Schatz <roland.schatz@oracle.com>
parents:
9505
diff
changeset
|
350 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
|
351 } |
14921
88dfaf6448e0
Remove LIRGenerationResult from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents:
14859
diff
changeset
|
352 ((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
|
353 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
|
354 } |
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
|
355 |
8303
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
356 @Override |
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
357 public void emitTailcall(Value[] args, Value address) { |
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
358 append(new AMD64TailcallOp(args, address)); |
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 |
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
361 @Override |
13837
ed3a1471e133
Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
13726
diff
changeset
|
362 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
|
363 Value[] argLocations = new Value[args.length]; |
18149
c6086a18c9ce
Rename LIRGenerationResult.getFrameMap() to getFrameMapBuilder().
Josef Eisl <josef.eisl@jku.at>
parents:
18123
diff
changeset
|
364 getResult().getFrameMapBuilder().callsMethod(nativeCallingConvention); |
13839 | 365 // TODO(mg): in case a native function uses floating point varargs, the ABI requires that |
366 // 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
|
367 AllocatableValue numberOfFloatingPointArgumentsRegister = AMD64.rax.asValue(); |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
368 emitMove(numberOfFloatingPointArgumentsRegister, JavaConstant.forInt(numberOfFloatingPointArguments)); |
13837
ed3a1471e133
Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
13726
diff
changeset
|
369 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
|
370 Value arg = args[i]; |
ed3a1471e133
Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
13726
diff
changeset
|
371 AllocatableValue loc = nativeCallingConvention.getArgument(i); |
ed3a1471e133
Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
13726
diff
changeset
|
372 emitMove(loc, arg); |
ed3a1471e133
Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
13726
diff
changeset
|
373 argLocations[i] = loc; |
ed3a1471e133
Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
13726
diff
changeset
|
374 } |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
375 Value ptr = emitMove(JavaConstant.forLong(address)); |
13837
ed3a1471e133
Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
13726
diff
changeset
|
376 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
|
377 } |
ed3a1471e133
Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
13726
diff
changeset
|
378 |
ed3a1471e133
Add the Graal Native Function Interface
Matthias Grimmer <grimmer@ssw.jku.at>
parents:
13726
diff
changeset
|
379 @Override |
8303
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
380 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
|
381 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
|
382 CallingConvention outgoingCc = linkage.getOutgoingCallingConvention(); |
de55425d3cf5
small cleanups and extra documentation around foreign call linkage
Doug Simon <doug.simon@oracle.com>
parents:
10870
diff
changeset
|
383 assert outgoingCc.getArgumentCount() == 2; |
de55425d3cf5
small cleanups and extra documentation around foreign call linkage
Doug Simon <doug.simon@oracle.com>
parents:
10870
diff
changeset
|
384 RegisterValue exceptionParameter = (RegisterValue) outgoingCc.getArgument(0); |
8303
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
385 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
|
386 append(new AMD64HotSpotUnwindOp(exceptionParameter)); |
8303
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
387 } |
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
388 |
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
|
389 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
|
390 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
|
391 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
|
392 } |
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
|
393 |
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
|
394 private void moveValueToThread(Value v, int offset) { |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16083
diff
changeset
|
395 LIRKind wordKind = LIRKind.value(getProviders().getCodeCache().getTarget().wordKind); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12363
diff
changeset
|
396 RegisterValue thread = getProviders().getRegisters().getThreadRegister().asValue(wordKind); |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16083
diff
changeset
|
397 AMD64AddressValue address = new AMD64AddressValue(wordKind, thread, offset); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16083
diff
changeset
|
398 emitStore(v.getLIRKind(), address, v, null); |
11832
97d6932a309b
CodeCacheProvider.encodeDeoptActionAndReason now returns a Constant
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11790
diff
changeset
|
399 } |
97d6932a309b
CodeCacheProvider.encodeDeoptActionAndReason now returns a Constant
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11790
diff
changeset
|
400 |
8303
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
401 @Override |
15301
468b2428c403
Change DeoptimizingNode and Access to LIRFrameState in *LIRGenerator*.
Josef Eisl <josef.eisl@jku.at>
parents:
15297
diff
changeset
|
402 public void emitDeoptimize(Value actionAndReason, Value speculation, LIRFrameState state) { |
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
|
403 moveDeoptValuesToThread(actionAndReason, speculation); |
15301
468b2428c403
Change DeoptimizingNode and Access to LIRFrameState in *LIRGenerator*.
Josef Eisl <josef.eisl@jku.at>
parents:
15297
diff
changeset
|
404 append(new AMD64DeoptimizeOp(state)); |
8303
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
405 } |
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
406 |
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
407 @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
|
408 public void emitDeoptimizeCaller(DeoptimizationAction action, DeoptimizationReason reason) { |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
409 moveDeoptValuesToThread(getMetaAccess().encodeDeoptActionAndReason(action, reason, 0), JavaConstant.NULL_OBJECT); |
11832
97d6932a309b
CodeCacheProvider.encodeDeoptActionAndReason now returns a Constant
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11790
diff
changeset
|
410 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
|
411 } |
0266549ff6e0
added support from compiled stubs to be installed as RuntimeStubs and to be able to directly call C/C++ runtime functions (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9247
diff
changeset
|
412 |
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
|
413 @Override |
8303
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
414 public void beforeRegisterAllocation() { |
13313
6dd9a1455e64
renamed PlaceholderOp to NoOp
Doug Simon <doug.simon@oracle.com>
parents:
13291
diff
changeset
|
415 super.beforeRegisterAllocation(); |
14921
88dfaf6448e0
Remove LIRGenerationResult from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents:
14859
diff
changeset
|
416 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
|
417 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
|
418 if (hasDebugInfo) { |
18434
06624c98ed8b
Handel RBP and deoptimization rescue slot in AMD64FrameMapBuilder.
Josef Eisl <josef.eisl@jku.at>
parents:
18426
diff
changeset
|
419 ((AMD64HotSpotLIRGenerationResult) getResult()).setDeoptimizationRescueSlot(((AMD64FrameMapBuilder) getResult().getFrameMapBuilder()).allocateDeoptimizationRescueSlot()); |
8303
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
420 } |
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
421 |
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
422 for (AMD64HotSpotEpilogueOp op : epilogueOps) { |
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
423 op.savedRbp = savedRbp; |
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
424 } |
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
425 } |
9885
ed86945795d5
Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
9768
diff
changeset
|
426 |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16083
diff
changeset
|
427 private static LIRKind toStackKind(LIRKind kind) { |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16083
diff
changeset
|
428 if (kind.getPlatformKind() instanceof Kind) { |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16083
diff
changeset
|
429 Kind stackKind = ((Kind) kind.getPlatformKind()).getStackKind(); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16083
diff
changeset
|
430 return kind.changeType(stackKind); |
14945
b14cb2d9253d
Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
14943
diff
changeset
|
431 } else { |
b14cb2d9253d
Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
14943
diff
changeset
|
432 return kind; |
b14cb2d9253d
Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
14943
diff
changeset
|
433 } |
b14cb2d9253d
Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
14943
diff
changeset
|
434 } |
b14cb2d9253d
Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
14943
diff
changeset
|
435 |
15104 | 436 public void emitPushInterpreterFrame(Value frameSize, Value framePc, Value senderSp, Value initialInfo) { |
437 Variable frameSizeVariable = load(frameSize); | |
438 Variable framePcVariable = load(framePc); | |
439 Variable senderSpVariable = load(senderSp); | |
440 Variable initialInfoVariable = load(initialInfo); | |
441 append(new AMD64HotSpotPushInterpreterFrameOp(frameSizeVariable, framePcVariable, senderSpVariable, initialInfoVariable)); | |
442 } | |
443 | |
9885
ed86945795d5
Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
9768
diff
changeset
|
444 @Override |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16083
diff
changeset
|
445 public Variable emitLoad(LIRKind kind, Value address, LIRFrameState state) { |
9885
ed86945795d5
Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
9768
diff
changeset
|
446 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
|
447 Variable result = newVariable(toStackKind(kind)); |
16116
9e5a323e0a1e
Remove hotspot specific NarrowOop kind, use LIRKind.reference(Kind.Int) instead.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
448 append(new LoadOp((Kind) kind.getPlatformKind(), result, loadAddress, state)); |
9885
ed86945795d5
Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
9768
diff
changeset
|
449 return result; |
ed86945795d5
Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
9768
diff
changeset
|
450 } |
ed86945795d5
Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
9768
diff
changeset
|
451 |
17314
3b6759c384a9
Introduce emitLoadConstant in LIRGeneratorTool.
Roland Schatz <roland.schatz@oracle.com>
parents:
16785
diff
changeset
|
452 /** |
3b6759c384a9
Introduce emitLoadConstant in LIRGeneratorTool.
Roland Schatz <roland.schatz@oracle.com>
parents:
16785
diff
changeset
|
453 * Checks whether the supplied constant can be used without loading it into a register for store |
3b6759c384a9
Introduce emitLoadConstant in LIRGeneratorTool.
Roland Schatz <roland.schatz@oracle.com>
parents:
16785
diff
changeset
|
454 * operations, i.e., on the right hand side of a memory access. |
3b6759c384a9
Introduce emitLoadConstant in LIRGeneratorTool.
Roland Schatz <roland.schatz@oracle.com>
parents:
16785
diff
changeset
|
455 * |
3b6759c384a9
Introduce emitLoadConstant in LIRGeneratorTool.
Roland Schatz <roland.schatz@oracle.com>
parents:
16785
diff
changeset
|
456 * @param c The constant to check. |
3b6759c384a9
Introduce emitLoadConstant in LIRGeneratorTool.
Roland Schatz <roland.schatz@oracle.com>
parents:
16785
diff
changeset
|
457 * @return True if the constant can be used directly, false if the constant needs to be in a |
3b6759c384a9
Introduce emitLoadConstant in LIRGeneratorTool.
Roland Schatz <roland.schatz@oracle.com>
parents:
16785
diff
changeset
|
458 * register. |
3b6759c384a9
Introduce emitLoadConstant in LIRGeneratorTool.
Roland Schatz <roland.schatz@oracle.com>
parents:
16785
diff
changeset
|
459 */ |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
460 protected boolean canStoreConstant(JavaConstant c) { |
17314
3b6759c384a9
Introduce emitLoadConstant in LIRGeneratorTool.
Roland Schatz <roland.schatz@oracle.com>
parents:
16785
diff
changeset
|
461 // there is no immediate move of 64-bit constants on Intel |
3b6759c384a9
Introduce emitLoadConstant in LIRGeneratorTool.
Roland Schatz <roland.schatz@oracle.com>
parents:
16785
diff
changeset
|
462 switch (c.getKind()) { |
3b6759c384a9
Introduce emitLoadConstant in LIRGeneratorTool.
Roland Schatz <roland.schatz@oracle.com>
parents:
16785
diff
changeset
|
463 case Long: |
3b6759c384a9
Introduce emitLoadConstant in LIRGeneratorTool.
Roland Schatz <roland.schatz@oracle.com>
parents:
16785
diff
changeset
|
464 return Util.isInt(c.asLong()) && !getCodeCache().needsDataPatch(c); |
3b6759c384a9
Introduce emitLoadConstant in LIRGeneratorTool.
Roland Schatz <roland.schatz@oracle.com>
parents:
16785
diff
changeset
|
465 case Double: |
3b6759c384a9
Introduce emitLoadConstant in LIRGeneratorTool.
Roland Schatz <roland.schatz@oracle.com>
parents:
16785
diff
changeset
|
466 return false; |
3b6759c384a9
Introduce emitLoadConstant in LIRGeneratorTool.
Roland Schatz <roland.schatz@oracle.com>
parents:
16785
diff
changeset
|
467 case Object: |
3b6759c384a9
Introduce emitLoadConstant in LIRGeneratorTool.
Roland Schatz <roland.schatz@oracle.com>
parents:
16785
diff
changeset
|
468 return c.isNull(); |
3b6759c384a9
Introduce emitLoadConstant in LIRGeneratorTool.
Roland Schatz <roland.schatz@oracle.com>
parents:
16785
diff
changeset
|
469 default: |
3b6759c384a9
Introduce emitLoadConstant in LIRGeneratorTool.
Roland Schatz <roland.schatz@oracle.com>
parents:
16785
diff
changeset
|
470 return true; |
3b6759c384a9
Introduce emitLoadConstant in LIRGeneratorTool.
Roland Schatz <roland.schatz@oracle.com>
parents:
16785
diff
changeset
|
471 } |
3b6759c384a9
Introduce emitLoadConstant in LIRGeneratorTool.
Roland Schatz <roland.schatz@oracle.com>
parents:
16785
diff
changeset
|
472 } |
3b6759c384a9
Introduce emitLoadConstant in LIRGeneratorTool.
Roland Schatz <roland.schatz@oracle.com>
parents:
16785
diff
changeset
|
473 |
9885
ed86945795d5
Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
9768
diff
changeset
|
474 @Override |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16083
diff
changeset
|
475 public void emitStore(LIRKind kind, Value address, Value inputVal, LIRFrameState state) { |
9885
ed86945795d5
Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
9768
diff
changeset
|
476 AMD64AddressValue storeAddress = asAddressValue(address); |
ed86945795d5
Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
9768
diff
changeset
|
477 if (isConstant(inputVal)) { |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
478 JavaConstant c = asConstant(inputVal); |
15947
3eedf7a653ea
Remove unused oop compression code from backends.
Roland Schatz <roland.schatz@oracle.com>
parents:
15926
diff
changeset
|
479 if (canStoreConstant(c)) { |
16116
9e5a323e0a1e
Remove hotspot specific NarrowOop kind, use LIRKind.reference(Kind.Int) instead.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
480 append(new HotSpotStoreConstantOp((Kind) kind.getPlatformKind(), storeAddress, c, state)); |
15302
b3e4b32cb9f5
Remove deprecated isCompressed* checks from *HotSpotLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents:
15301
diff
changeset
|
481 return; |
9885
ed86945795d5
Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
9768
diff
changeset
|
482 } |
ed86945795d5
Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
9768
diff
changeset
|
483 } |
ed86945795d5
Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
9768
diff
changeset
|
484 Variable input = load(inputVal); |
16116
9e5a323e0a1e
Remove hotspot specific NarrowOop kind, use LIRKind.reference(Kind.Int) instead.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
485 append(new StoreOp((Kind) kind.getPlatformKind(), storeAddress, input, state)); |
9885
ed86945795d5
Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
9768
diff
changeset
|
486 } |
ed86945795d5
Add Compressed Oops support in LIR
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
9768
diff
changeset
|
487 |
14943
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
14921
diff
changeset
|
488 @Override |
15058
895e9ecedfe8
Fix code generation for compressed metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15024
diff
changeset
|
489 public Value emitCompress(Value pointer, CompressEncoding encoding, boolean nonNull) { |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16083
diff
changeset
|
490 LIRKind inputKind = pointer.getLIRKind(); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16083
diff
changeset
|
491 assert inputKind.getPlatformKind() == Kind.Long || inputKind.getPlatformKind() == Kind.Object; |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16083
diff
changeset
|
492 if (inputKind.isReference(0)) { |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16083
diff
changeset
|
493 // oop |
16116
9e5a323e0a1e
Remove hotspot specific NarrowOop kind, use LIRKind.reference(Kind.Int) instead.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
494 Variable result = newVariable(LIRKind.reference(Kind.Int)); |
15058
895e9ecedfe8
Fix code generation for compressed metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15024
diff
changeset
|
495 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
|
496 return result; |
652564fe42d5
Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
497 } else { |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16083
diff
changeset
|
498 // metaspace pointer |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16083
diff
changeset
|
499 Variable result = newVariable(LIRKind.value(Kind.Int)); |
15023
652564fe42d5
Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
500 AllocatableValue base = Value.ILLEGAL; |
652564fe42d5
Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
501 if (encoding.base != 0) { |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
502 base = emitMove(JavaConstant.forLong(encoding.base)); |
15023
652564fe42d5
Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
503 } |
15058
895e9ecedfe8
Fix code generation for compressed metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15024
diff
changeset
|
504 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
|
505 return result; |
652564fe42d5
Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
506 } |
14943
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
14921
diff
changeset
|
507 } |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
14921
diff
changeset
|
508 |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
14921
diff
changeset
|
509 @Override |
15058
895e9ecedfe8
Fix code generation for compressed metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15024
diff
changeset
|
510 public Value emitUncompress(Value pointer, CompressEncoding encoding, boolean nonNull) { |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16083
diff
changeset
|
511 LIRKind inputKind = pointer.getLIRKind(); |
16116
9e5a323e0a1e
Remove hotspot specific NarrowOop kind, use LIRKind.reference(Kind.Int) instead.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
512 assert inputKind.getPlatformKind() == Kind.Int; |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16083
diff
changeset
|
513 if (inputKind.isReference(0)) { |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16083
diff
changeset
|
514 // oop |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16083
diff
changeset
|
515 Variable result = newVariable(LIRKind.reference(Kind.Object)); |
15058
895e9ecedfe8
Fix code generation for compressed metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15024
diff
changeset
|
516 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
|
517 return result; |
652564fe42d5
Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
518 } else { |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16083
diff
changeset
|
519 // metaspace pointer |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16083
diff
changeset
|
520 Variable result = newVariable(LIRKind.value(Kind.Long)); |
15023
652564fe42d5
Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
521 AllocatableValue base = Value.ILLEGAL; |
652564fe42d5
Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
522 if (encoding.base != 0) { |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
523 base = emitMove(JavaConstant.forLong(encoding.base)); |
15023
652564fe42d5
Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
524 } |
15058
895e9ecedfe8
Fix code generation for compressed metaspace pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15024
diff
changeset
|
525 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
|
526 return result; |
652564fe42d5
Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
527 } |
14943
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
14921
diff
changeset
|
528 } |
e5a55d280f24
Floating nodes for compressing and uncompressing pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
14921
diff
changeset
|
529 |
14945
b14cb2d9253d
Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
14943
diff
changeset
|
530 @Override |
b14cb2d9253d
Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
14943
diff
changeset
|
531 protected AMD64LIRInstruction createMove(AllocatableValue dst, Value src) { |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
532 if (src instanceof JavaConstant) { |
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
533 return new AMD64HotSpotMove.HotSpotLoadConstantOp(dst, (JavaConstant) src); |
14945
b14cb2d9253d
Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
14943
diff
changeset
|
534 } else { |
b14cb2d9253d
Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
14943
diff
changeset
|
535 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
|
536 } |
b14cb2d9253d
Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
14943
diff
changeset
|
537 } |
b14cb2d9253d
Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
14943
diff
changeset
|
538 |
15024
2ee777221036
Use high level CompressionNode in lowering of CompareAndSwapNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
15023
diff
changeset
|
539 public Value emitCompareAndSwap(Value address, Value expectedValue, Value newValue, Value trueValue, Value falseValue) { |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16083
diff
changeset
|
540 LIRKind kind = newValue.getLIRKind(); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16083
diff
changeset
|
541 assert kind.equals(expectedValue.getLIRKind()); |
16116
9e5a323e0a1e
Remove hotspot specific NarrowOop kind, use LIRKind.reference(Kind.Int) instead.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
542 Kind memKind = (Kind) kind.getPlatformKind(); |
15024
2ee777221036
Use high level CompressionNode in lowering of CompareAndSwapNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
15023
diff
changeset
|
543 |
2ee777221036
Use high level CompressionNode in lowering of CompareAndSwapNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
15023
diff
changeset
|
544 AMD64AddressValue addressValue = asAddressValue(address); |
2ee777221036
Use high level CompressionNode in lowering of CompareAndSwapNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
15023
diff
changeset
|
545 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
|
546 emitMove(raxRes, expectedValue); |
2ee777221036
Use high level CompressionNode in lowering of CompareAndSwapNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
15023
diff
changeset
|
547 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
|
548 |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16083
diff
changeset
|
549 assert trueValue.getLIRKind().equals(falseValue.getLIRKind()); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16083
diff
changeset
|
550 Variable result = newVariable(trueValue.getLIRKind()); |
15024
2ee777221036
Use high level CompressionNode in lowering of CompareAndSwapNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
15023
diff
changeset
|
551 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
|
552 return result; |
2ee777221036
Use high level CompressionNode in lowering of CompareAndSwapNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
15023
diff
changeset
|
553 } |
15251 | 554 |
555 public Value emitAtomicReadAndAdd(Value address, Value delta) { | |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16083
diff
changeset
|
556 LIRKind kind = delta.getLIRKind(); |
16116
9e5a323e0a1e
Remove hotspot specific NarrowOop kind, use LIRKind.reference(Kind.Int) instead.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
557 Kind memKind = (Kind) kind.getPlatformKind(); |
15251 | 558 Variable result = newVariable(kind); |
559 AMD64AddressValue addressValue = asAddressValue(address); | |
560 append(new AMD64Move.AtomicReadAndAddOp(memKind, result, addressValue, asAllocatable(delta))); | |
561 return result; | |
562 } | |
563 | |
564 public Value emitAtomicReadAndWrite(Value address, Value newValue) { | |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16083
diff
changeset
|
565 LIRKind kind = newValue.getLIRKind(); |
16116
9e5a323e0a1e
Remove hotspot specific NarrowOop kind, use LIRKind.reference(Kind.Int) instead.
Roland Schatz <roland.schatz@oracle.com>
parents:
16104
diff
changeset
|
566 Kind memKind = (Kind) kind.getPlatformKind(); |
15251 | 567 Variable result = newVariable(kind); |
568 AMD64AddressValue addressValue = asAddressValue(address); | |
569 append(new AMD64Move.AtomicReadAndWriteOp(memKind, result, addressValue, asAllocatable(newValue))); | |
570 return result; | |
571 } | |
572 | |
15554
cf994cc23b54
Move emitNullCheck from NodeLIRBuilderTool to LIRGeneratorTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15456
diff
changeset
|
573 public void emitNullCheck(Value address, LIRFrameState state) { |
16710
56bcde831179
support for compressed inputs to NullCheckNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16116
diff
changeset
|
574 if (address.getLIRKind().getPlatformKind() == Kind.Int) { |
56bcde831179
support for compressed inputs to NullCheckNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16116
diff
changeset
|
575 CompressEncoding encoding = config.getOopEncoding(); |
56bcde831179
support for compressed inputs to NullCheckNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16116
diff
changeset
|
576 if (encoding.shift <= 3) { |
56bcde831179
support for compressed inputs to NullCheckNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16116
diff
changeset
|
577 AMD64AddressValue uncompressionAddress = emitAddress(getProviders().getRegisters().getHeapBaseRegister().asValue(), 0, load(address), 1 << encoding.shift); |
56bcde831179
support for compressed inputs to NullCheckNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16116
diff
changeset
|
578 append(new AMD64HotSpotMove.CompressedNullCheckOp(uncompressionAddress, state)); |
56bcde831179
support for compressed inputs to NullCheckNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16116
diff
changeset
|
579 } else { |
56bcde831179
support for compressed inputs to NullCheckNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16116
diff
changeset
|
580 Value uncompress = emitUncompress(address, encoding, false); |
56bcde831179
support for compressed inputs to NullCheckNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16116
diff
changeset
|
581 append(new AMD64Move.NullCheckOp(load(uncompress), state)); |
56bcde831179
support for compressed inputs to NullCheckNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16116
diff
changeset
|
582 } |
56bcde831179
support for compressed inputs to NullCheckNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16116
diff
changeset
|
583 } else { |
56bcde831179
support for compressed inputs to NullCheckNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16116
diff
changeset
|
584 assert address.getKind() == Kind.Object : address + " - " + address.getKind() + " not an object!"; |
56bcde831179
support for compressed inputs to NullCheckNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16116
diff
changeset
|
585 append(new AMD64Move.NullCheckOp(load(address), state)); |
56bcde831179
support for compressed inputs to NullCheckNode
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16116
diff
changeset
|
586 } |
15554
cf994cc23b54
Move emitNullCheck from NodeLIRBuilderTool to LIRGeneratorTool.
Josef Eisl <josef.eisl@jku.at>
parents:
15456
diff
changeset
|
587 } |
15909
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
15554
diff
changeset
|
588 |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
15554
diff
changeset
|
589 @Override |
16104
4dd2cedc7f57
Revert using LIRKind.reference(Kind.Int) instead of hotspot specific NarrowOop kind (part of c0b8d395368b).
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
590 protected void emitCompareOp(PlatformKind cmpKind, Variable left, Value right) { |
15910
79a0d9065849
Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
591 if (right instanceof HotSpotConstant) { |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
592 append(new AMD64HotSpotCompare.HotSpotCompareConstantOp(left, (JavaConstant) right)); |
15910
79a0d9065849
Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
593 } else { |
79a0d9065849
Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
594 super.emitCompareOp(cmpKind, left, right); |
79a0d9065849
Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
595 } |
79a0d9065849
Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
596 } |
79a0d9065849
Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
597 |
79a0d9065849
Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
598 @Override |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
599 protected void emitCompareMemoryConOp(Kind kind, AMD64AddressValue address, JavaConstant value, LIRFrameState state) { |
15910
79a0d9065849
Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
600 if (value instanceof HotSpotConstant) { |
79a0d9065849
Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
601 append(new AMD64HotSpotCompare.HotSpotCompareMemoryConstantOp(kind, address, value, state)); |
79a0d9065849
Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
602 } else { |
79a0d9065849
Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
603 super.emitCompareMemoryConOp(kind, address, value, state); |
79a0d9065849
Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
604 } |
79a0d9065849
Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
605 } |
79a0d9065849
Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
606 |
79a0d9065849
Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15909
diff
changeset
|
607 @Override |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
608 public boolean canInlineConstant(JavaConstant c) { |
15909
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
15554
diff
changeset
|
609 if (HotSpotCompressedNullConstant.COMPRESSED_NULL.equals(c)) { |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
15554
diff
changeset
|
610 return true; |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
15554
diff
changeset
|
611 } else if (c instanceof HotSpotObjectConstant) { |
18289
7acff34abbf7
replaced HotSpotObjectConstantImpl.isCompressed() with HotSpotObjectConstant.isCompressed()
Doug Simon <doug.simon@oracle.com>
parents:
18266
diff
changeset
|
612 return ((HotSpotObjectConstant) c).isCompressed(); |
15909
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
15554
diff
changeset
|
613 } else { |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
15554
diff
changeset
|
614 return super.canInlineConstant(c); |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
15554
diff
changeset
|
615 } |
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
15554
diff
changeset
|
616 } |
8303
bb9fba66b6ef
refactored HotSpotAMD64LIRGenerator into its own file
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
617 } |