Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotNodeLIRBuilder.java @ 15021:9dcd5407a603
added support for overriding/complementing JMH arguments in jmh command with a JSON string
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 08 Apr 2014 16:04:59 +0200 |
parents | db4254246f9a |
children | 2ee777221036 |
rev | line source |
---|---|
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 */ |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
23 |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12363
diff
changeset
|
24 package com.oracle.graal.hotspot.hsail; |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
25 |
12742
40924dbc623b
HSAIL support for compare-and-swap and volatile load/store operations
Doug Simon <doug.simon@oracle.com>
parents:
12698
diff
changeset
|
26 import sun.misc.*; |
40924dbc623b
HSAIL support for compare-and-swap and volatile load/store operations
Doug Simon <doug.simon@oracle.com>
parents:
12698
diff
changeset
|
27 |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
28 import com.oracle.graal.api.meta.*; |
14809
73774616a6b3
Decoupled LIRGenerator and LIRGenerationResult.
Josef Eisl <josef.eisl@jku.at>
parents:
14003
diff
changeset
|
29 import com.oracle.graal.compiler.gen.*; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12363
diff
changeset
|
30 import com.oracle.graal.compiler.hsail.*; |
14850 | 31 import com.oracle.graal.graph.*; |
32 import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding; | |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14921
diff
changeset
|
33 import com.oracle.graal.hotspot.meta.*; |
14723
4c5ed5a670ed
HSAIL: implemented storing compressed constants and made HSAILHotSpotLIRGenerator implement HotSpotLIRGenerator
Doug Simon <doug.simon@oracle.com>
parents:
14633
diff
changeset
|
34 import com.oracle.graal.hotspot.nodes.*; |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
35 import com.oracle.graal.lir.*; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
36 import com.oracle.graal.lir.hsail.*; |
14846
43cd57700476
Apply LIRGenerator refactoring to HSAIL backend.
Josef Eisl <josef.eisl@jku.at>
parents:
14826
diff
changeset
|
37 import com.oracle.graal.lir.hsail.HSAILControlFlow.CondMoveOp; |
43cd57700476
Apply LIRGenerator refactoring to HSAIL backend.
Josef Eisl <josef.eisl@jku.at>
parents:
14826
diff
changeset
|
38 import com.oracle.graal.lir.hsail.HSAILMove.CompareAndSwapCompressedOp; |
43cd57700476
Apply LIRGenerator refactoring to HSAIL backend.
Josef Eisl <josef.eisl@jku.at>
parents:
14826
diff
changeset
|
39 import com.oracle.graal.lir.hsail.HSAILMove.CompareAndSwapOp; |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
40 import com.oracle.graal.nodes.*; |
12742
40924dbc623b
HSAIL support for compare-and-swap and volatile load/store operations
Doug Simon <doug.simon@oracle.com>
parents:
12698
diff
changeset
|
41 import com.oracle.graal.nodes.calc.*; |
40924dbc623b
HSAIL support for compare-and-swap and volatile load/store operations
Doug Simon <doug.simon@oracle.com>
parents:
12698
diff
changeset
|
42 import com.oracle.graal.nodes.java.*; |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
43 |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
44 /** |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12363
diff
changeset
|
45 * The HotSpot specific portion of the HSAIL LIR generator. |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
46 */ |
14888
f6630873316b
Rename NodeLIRGenerator (and related classes and interfaces) to NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents:
14853
diff
changeset
|
47 public class HSAILHotSpotNodeLIRBuilder extends HSAILNodeLIRBuilder { |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
48 |
14921
88dfaf6448e0
Remove LIRGenerationResult from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents:
14888
diff
changeset
|
49 public HSAILHotSpotNodeLIRBuilder(StructuredGraph graph, LIRGenerator lirGen) { |
88dfaf6448e0
Remove LIRGenerationResult from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents:
14888
diff
changeset
|
50 super(graph, lirGen); |
12698
d59a65c11feb
HSAIL support for difference between compression of oops and class pointers
Doug Simon <doug.simon@oracle.com>
parents:
12664
diff
changeset
|
51 } |
d59a65c11feb
HSAIL support for difference between compression of oops and class pointers
Doug Simon <doug.simon@oracle.com>
parents:
12664
diff
changeset
|
52 |
14846
43cd57700476
Apply LIRGenerator refactoring to HSAIL backend.
Josef Eisl <josef.eisl@jku.at>
parents:
14826
diff
changeset
|
53 private HSAILHotSpotLIRGenerator getGen() { |
43cd57700476
Apply LIRGenerator refactoring to HSAIL backend.
Josef Eisl <josef.eisl@jku.at>
parents:
14826
diff
changeset
|
54 return (HSAILHotSpotLIRGenerator) gen; |
13891
bc471f405eb8
HSAIL: support for storing immediates
Doug Simon <doug.simon@oracle.com>
parents:
13291
diff
changeset
|
55 } |
bc471f405eb8
HSAIL: support for storing immediates
Doug Simon <doug.simon@oracle.com>
parents:
13291
diff
changeset
|
56 |
12742
40924dbc623b
HSAIL support for compare-and-swap and volatile load/store operations
Doug Simon <doug.simon@oracle.com>
parents:
12698
diff
changeset
|
57 /** |
40924dbc623b
HSAIL support for compare-and-swap and volatile load/store operations
Doug Simon <doug.simon@oracle.com>
parents:
12698
diff
changeset
|
58 * Appends either a {@link CompareAndSwapOp} or a {@link CompareAndSwapCompressedOp} depending |
40924dbc623b
HSAIL support for compare-and-swap and volatile load/store operations
Doug Simon <doug.simon@oracle.com>
parents:
12698
diff
changeset
|
59 * on whether the memory location of a given {@link LoweredCompareAndSwapNode} contains a |
40924dbc623b
HSAIL support for compare-and-swap and volatile load/store operations
Doug Simon <doug.simon@oracle.com>
parents:
12698
diff
changeset
|
60 * compressed oop. For the {@link CompareAndSwapCompressedOp} case, allocates a number of |
40924dbc623b
HSAIL support for compare-and-swap and volatile load/store operations
Doug Simon <doug.simon@oracle.com>
parents:
12698
diff
changeset
|
61 * scratch registers. The result {@link #operand(ValueNode) operand} for {@code node} complies |
40924dbc623b
HSAIL support for compare-and-swap and volatile load/store operations
Doug Simon <doug.simon@oracle.com>
parents:
12698
diff
changeset
|
62 * with the API for {@link Unsafe#compareAndSwapInt(Object, long, int, int)}. |
14852 | 63 * |
12742
40924dbc623b
HSAIL support for compare-and-swap and volatile load/store operations
Doug Simon <doug.simon@oracle.com>
parents:
12698
diff
changeset
|
64 * @param address the memory location targeted by the operation |
40924dbc623b
HSAIL support for compare-and-swap and volatile load/store operations
Doug Simon <doug.simon@oracle.com>
parents:
12698
diff
changeset
|
65 */ |
40924dbc623b
HSAIL support for compare-and-swap and volatile load/store operations
Doug Simon <doug.simon@oracle.com>
parents:
12698
diff
changeset
|
66 @Override |
40924dbc623b
HSAIL support for compare-and-swap and volatile load/store operations
Doug Simon <doug.simon@oracle.com>
parents:
12698
diff
changeset
|
67 public void visitCompareAndSwap(LoweredCompareAndSwapNode node, Value address) { |
14633
da2431cc1506
Rename ValueNode kind() to getKind().
Josef Eisl <josef.eisl@jku.at>
parents:
14563
diff
changeset
|
68 Kind kind = node.getNewValue().getKind(); |
da2431cc1506
Rename ValueNode kind() to getKind().
Josef Eisl <josef.eisl@jku.at>
parents:
14563
diff
changeset
|
69 assert kind == node.getExpectedValue().getKind(); |
14846
43cd57700476
Apply LIRGenerator refactoring to HSAIL backend.
Josef Eisl <josef.eisl@jku.at>
parents:
14826
diff
changeset
|
70 Variable expected = gen.load(operand(node.getExpectedValue())); |
43cd57700476
Apply LIRGenerator refactoring to HSAIL backend.
Josef Eisl <josef.eisl@jku.at>
parents:
14826
diff
changeset
|
71 Variable newValue = gen.load(operand(node.getNewValue())); |
43cd57700476
Apply LIRGenerator refactoring to HSAIL backend.
Josef Eisl <josef.eisl@jku.at>
parents:
14826
diff
changeset
|
72 HSAILAddressValue addressValue = getGen().asAddressValue(address); |
12742
40924dbc623b
HSAIL support for compare-and-swap and volatile load/store operations
Doug Simon <doug.simon@oracle.com>
parents:
12698
diff
changeset
|
73 Variable casResult = newVariable(kind); |
14846
43cd57700476
Apply LIRGenerator refactoring to HSAIL backend.
Josef Eisl <josef.eisl@jku.at>
parents:
14826
diff
changeset
|
74 if (getGen().config.useCompressedOops && node.isCompressible()) { |
12742
40924dbc623b
HSAIL support for compare-and-swap and volatile load/store operations
Doug Simon <doug.simon@oracle.com>
parents:
12698
diff
changeset
|
75 // make 64-bit scratch variables for expected and new |
40924dbc623b
HSAIL support for compare-and-swap and volatile load/store operations
Doug Simon <doug.simon@oracle.com>
parents:
12698
diff
changeset
|
76 Variable scratchExpected64 = newVariable(Kind.Long); |
40924dbc623b
HSAIL support for compare-and-swap and volatile load/store operations
Doug Simon <doug.simon@oracle.com>
parents:
12698
diff
changeset
|
77 Variable scratchNewValue64 = newVariable(Kind.Long); |
40924dbc623b
HSAIL support for compare-and-swap and volatile load/store operations
Doug Simon <doug.simon@oracle.com>
parents:
12698
diff
changeset
|
78 // make 32-bit scratch variables for expected and new and result |
40924dbc623b
HSAIL support for compare-and-swap and volatile load/store operations
Doug Simon <doug.simon@oracle.com>
parents:
12698
diff
changeset
|
79 Variable scratchExpected32 = newVariable(Kind.Int); |
40924dbc623b
HSAIL support for compare-and-swap and volatile load/store operations
Doug Simon <doug.simon@oracle.com>
parents:
12698
diff
changeset
|
80 Variable scratchNewValue32 = newVariable(Kind.Int); |
40924dbc623b
HSAIL support for compare-and-swap and volatile load/store operations
Doug Simon <doug.simon@oracle.com>
parents:
12698
diff
changeset
|
81 Variable scratchCasResult32 = newVariable(Kind.Int); |
40924dbc623b
HSAIL support for compare-and-swap and volatile load/store operations
Doug Simon <doug.simon@oracle.com>
parents:
12698
diff
changeset
|
82 append(new CompareAndSwapCompressedOp(casResult, addressValue, expected, newValue, scratchExpected64, scratchNewValue64, scratchExpected32, scratchNewValue32, scratchCasResult32, |
14846
43cd57700476
Apply LIRGenerator refactoring to HSAIL backend.
Josef Eisl <josef.eisl@jku.at>
parents:
14826
diff
changeset
|
83 getGen().getNarrowOopBase(), getGen().getNarrowOopShift(), getGen().getLogMinObjectAlignment())); |
12742
40924dbc623b
HSAIL support for compare-and-swap and volatile load/store operations
Doug Simon <doug.simon@oracle.com>
parents:
12698
diff
changeset
|
84 } else { |
40924dbc623b
HSAIL support for compare-and-swap and volatile load/store operations
Doug Simon <doug.simon@oracle.com>
parents:
12698
diff
changeset
|
85 append(new CompareAndSwapOp(casResult, addressValue, expected, newValue)); |
40924dbc623b
HSAIL support for compare-and-swap and volatile load/store operations
Doug Simon <doug.simon@oracle.com>
parents:
12698
diff
changeset
|
86 } |
14633
da2431cc1506
Rename ValueNode kind() to getKind().
Josef Eisl <josef.eisl@jku.at>
parents:
14563
diff
changeset
|
87 Variable nodeResult = newVariable(node.getKind()); |
14846
43cd57700476
Apply LIRGenerator refactoring to HSAIL backend.
Josef Eisl <josef.eisl@jku.at>
parents:
14826
diff
changeset
|
88 append(new CondMoveOp(HSAILLIRGenerator.mapKindToCompareOp(kind), casResult, expected, nodeResult, Condition.EQ, Constant.INT_1, Constant.INT_0)); |
12742
40924dbc623b
HSAIL support for compare-and-swap and volatile load/store operations
Doug Simon <doug.simon@oracle.com>
parents:
12698
diff
changeset
|
89 setResult(node, nodeResult); |
40924dbc623b
HSAIL support for compare-and-swap and volatile load/store operations
Doug Simon <doug.simon@oracle.com>
parents:
12698
diff
changeset
|
90 } |
40924dbc623b
HSAIL support for compare-and-swap and volatile load/store operations
Doug Simon <doug.simon@oracle.com>
parents:
12698
diff
changeset
|
91 |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14723
diff
changeset
|
92 @Override |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14723
diff
changeset
|
93 protected void emitNode(ValueNode node) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14723
diff
changeset
|
94 if (node instanceof CurrentJavaThreadNode) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14723
diff
changeset
|
95 throw new GraalInternalError("HSAILHotSpotLIRGenerator cannot handle node: " + node); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14723
diff
changeset
|
96 } else { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14723
diff
changeset
|
97 super.emitNode(node); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14723
diff
changeset
|
98 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14723
diff
changeset
|
99 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14723
diff
changeset
|
100 |
14850 | 101 /** |
102 * @return a compressed version of the incoming constant lifted from AMD64HotSpotLIRGenerator | |
103 */ | |
104 protected static Constant compress(Constant c, CompressEncoding encoding) { | |
105 if (c.getKind() == Kind.Long) { | |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14921
diff
changeset
|
106 int compressedValue = (int) (((c.asLong() - encoding.base) >> encoding.shift) & 0xffffffffL); |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14921
diff
changeset
|
107 if (c instanceof HotSpotMetaspaceConstant) { |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14921
diff
changeset
|
108 return HotSpotMetaspaceConstant.forMetaspaceObject(Kind.Int, compressedValue, HotSpotMetaspaceConstant.getMetaspaceObject(c)); |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14921
diff
changeset
|
109 } else { |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14921
diff
changeset
|
110 return Constant.forIntegerKind(Kind.Int, compressedValue); |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14921
diff
changeset
|
111 } |
14850 | 112 } else { |
113 throw GraalInternalError.shouldNotReachHere(); | |
114 } | |
115 } | |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
116 } |