Mercurial > hg > truffle
annotate graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java @ 16694:a53c26c989d0
HSAIL: miscellaneous HSAIL test tweaks and fixes:
- mark some tests as requiring ObjectAllocation so they will not fail when UseHSAILDeoptimization is turned off
- mark some tests as not to run on hardware until some hardware problems are fixed.
- Fix code sequence in HSAILHotSpotBackend.java for hardware which has more strict HSAIL assembler (no longer allows ld_u32 into a $d register)
- in HSAILAssembler.mapAddress, handle case where there is no base register
Contributed-by: Tom Deneau <tom.deneau@amd.com>
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 05 Aug 2014 20:57:38 +0200 |
parents | d780f8b87d89 |
children | a29e6e7b7a86 |
rev | line source |
---|---|
10662
4ef92b67aeae
added HSAIL backend and tests
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:
16077
diff
changeset
|
2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. |
10662
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 */ |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12363
diff
changeset
|
23 package com.oracle.graal.hotspot.hsail; |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
25 import static com.oracle.graal.api.code.CallingConvention.Type.*; |
13784
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
26 import static com.oracle.graal.api.code.CodeUtil.*; |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
27 import static com.oracle.graal.api.code.ValueUtil.*; |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14969
diff
changeset
|
28 import static com.oracle.graal.api.meta.LocationIdentity.*; |
13784
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
29 import static com.oracle.graal.compiler.GraalCompiler.*; |
15157
f4e31f06b019
Create com.oracle.graal.cfg project and move CFG related files.
Josef Eisl <josef.eisl@jku.at>
parents:
15152
diff
changeset
|
30 import static com.oracle.graal.hotspot.hsail.HSAILHotSpotBackend.Options.*; |
f4e31f06b019
Create com.oracle.graal.cfg project and move CFG related files.
Josef Eisl <josef.eisl@jku.at>
parents:
15152
diff
changeset
|
31 import static com.oracle.graal.hotspot.hsail.replacements.HSAILNewObjectSnippets.Options.*; |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
32 |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12363
diff
changeset
|
33 import java.lang.reflect.*; |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12363
diff
changeset
|
34 import java.util.*; |
15640
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
35 import java.util.Map.Entry; |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
36 import java.util.function.*; |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
37 import java.util.stream.*; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12363
diff
changeset
|
38 |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
39 import com.amd.okra.*; |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
40 import com.oracle.graal.api.code.*; |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
41 import com.oracle.graal.api.code.Assumptions.Assumption; |
13784
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
42 import com.oracle.graal.api.code.CallingConvention.Type; |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
43 import com.oracle.graal.api.code.CompilationResult.Call; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
44 import com.oracle.graal.api.code.CompilationResult.CodeAnnotation; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
45 import com.oracle.graal.api.code.CompilationResult.DataPatch; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
46 import com.oracle.graal.api.code.CompilationResult.ExceptionHandler; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
47 import com.oracle.graal.api.code.CompilationResult.Infopoint; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
48 import com.oracle.graal.api.code.CompilationResult.Mark; |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
49 import com.oracle.graal.api.meta.*; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
50 import com.oracle.graal.asm.*; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
51 import com.oracle.graal.asm.hsail.*; |
15193
96bb07a5d667
Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents:
15192
diff
changeset
|
52 import com.oracle.graal.compiler.common.*; |
15192
644dfe49c0f4
Move packages com.oracle.graal.cfg to com.oracle.graal.compiler.common.cfg.
Josef Eisl <josef.eisl@jku.at>
parents:
15180
diff
changeset
|
53 import com.oracle.graal.compiler.common.cfg.*; |
15261
882f4cb7cfcf
Move Stamps to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15251
diff
changeset
|
54 import com.oracle.graal.compiler.common.type.*; |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
55 import com.oracle.graal.debug.*; |
13784
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
56 import com.oracle.graal.debug.Debug.Scope; |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
57 import com.oracle.graal.gpu.*; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12363
diff
changeset
|
58 import com.oracle.graal.hotspot.*; |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
59 import com.oracle.graal.hotspot.bridge.CompilerToVM.CodeInstallResult; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12363
diff
changeset
|
60 import com.oracle.graal.hotspot.meta.*; |
14853 | 61 import com.oracle.graal.hotspot.nodes.*; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12363
diff
changeset
|
62 import com.oracle.graal.hsail.*; |
13784
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
63 import com.oracle.graal.java.*; |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
64 import com.oracle.graal.lir.*; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
65 import com.oracle.graal.lir.asm.*; |
15292
a38d791982e1
Move LIRGenerationResult* to graal.lir.
Josef Eisl <josef.eisl@jku.at>
parents:
15261
diff
changeset
|
66 import com.oracle.graal.lir.gen.*; |
10956 | 67 import com.oracle.graal.lir.hsail.*; |
15177
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15157
diff
changeset
|
68 import com.oracle.graal.lir.hsail.HSAILControlFlow.DeoptimizingOp; |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
69 import com.oracle.graal.nodes.*; |
14853 | 70 import com.oracle.graal.nodes.StructuredGraph.GuardsStage; |
71 import com.oracle.graal.nodes.extended.*; | |
72 import com.oracle.graal.nodes.java.*; | |
15337
c4be3c1b2d6d
Use NodeLIRBuilderTool instead of NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents:
15333
diff
changeset
|
73 import com.oracle.graal.nodes.spi.*; |
15640
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
74 import com.oracle.graal.nodes.virtual.*; |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
75 import com.oracle.graal.options.*; |
13784
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
76 import com.oracle.graal.phases.*; |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
77 import com.oracle.graal.phases.tiers.*; |
15640
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
78 import com.oracle.graal.virtual.nodes.*; |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
79 |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
80 /** |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
81 * HSAIL specific backend. |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
82 */ |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12363
diff
changeset
|
83 public class HSAILHotSpotBackend extends HotSpotBackend { |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
84 |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
85 public static class Options { |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
86 |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
87 // @formatter:off |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
88 @Option(help = "Number of donor threads for HSAIL kernel dispatch") |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
89 static public final OptionValue<Integer> HsailDonorThreads = new OptionValue<>(4); |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
90 // @formatter:on |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
91 } |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
92 |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
93 private Map<String, String> paramTypeMap = new HashMap<>(); |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
94 private final boolean deviceInitialized; |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
95 // TODO: get maximum Concurrency from okra |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
96 private int maxDeoptIndex = 8 * 40 * 64; // see gpu_hsail.hpp |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
97 |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
98 public HSAILHotSpotBackend(HotSpotGraalRuntime runtime, HotSpotProviders providers) { |
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
99 super(runtime, providers); |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
100 paramTypeMap.put("HotSpotResolvedPrimitiveType<int>", "s32"); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
101 paramTypeMap.put("HotSpotResolvedPrimitiveType<float>", "f32"); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
102 paramTypeMap.put("HotSpotResolvedPrimitiveType<double>", "f64"); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
103 paramTypeMap.put("HotSpotResolvedPrimitiveType<long>", "s64"); |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
104 |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
105 /* |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
106 * The order of the conjunction below is important: the OkraUtil call may provision the |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
107 * native library required by the initialize() call |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
108 */ |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
109 deviceInitialized = OkraUtil.okraLibExists() && initialize(); |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
110 } |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
111 |
11775
b04b94b71649
Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents:
11739
diff
changeset
|
112 @Override |
b04b94b71649
Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents:
11739
diff
changeset
|
113 public boolean shouldAllocateRegisters() { |
b04b94b71649
Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents:
11739
diff
changeset
|
114 return true; |
b04b94b71649
Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents:
11739
diff
changeset
|
115 } |
b04b94b71649
Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents:
11739
diff
changeset
|
116 |
13308
d3b3c6e17d40
HSAIL: added Math intrinsifications
Doug Simon <doug.simon@oracle.com>
parents:
13234
diff
changeset
|
117 /** |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
118 * Initializes the GPU device. |
14774
8594b26fc5d8
fixed incorrect uses of Debug.log API
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
119 * |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
120 * @return whether or not initialization was successful |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
121 */ |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
122 private static native boolean initialize(); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
123 |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
124 /** |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
125 * Determines if the GPU device (or simulator) is available and initialized. |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
126 */ |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
127 public boolean isDeviceInitialized() { |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
128 return deviceInitialized; |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
129 } |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
130 |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
131 /** |
13308
d3b3c6e17d40
HSAIL: added Math intrinsifications
Doug Simon <doug.simon@oracle.com>
parents:
13234
diff
changeset
|
132 * Completes the initialization of the HSAIL backend. This includes initializing the providers |
d3b3c6e17d40
HSAIL: added Math intrinsifications
Doug Simon <doug.simon@oracle.com>
parents:
13234
diff
changeset
|
133 * and registering any method substitutions specified by the HSAIL backend. |
d3b3c6e17d40
HSAIL: added Math intrinsifications
Doug Simon <doug.simon@oracle.com>
parents:
13234
diff
changeset
|
134 */ |
12797
5341a7fca039
made HSAIL reuse HotSpotLoweringProvider, just with a different set of registers
Doug Simon <doug.simon@oracle.com>
parents:
12664
diff
changeset
|
135 @Override |
5341a7fca039
made HSAIL reuse HotSpotLoweringProvider, just with a different set of registers
Doug Simon <doug.simon@oracle.com>
parents:
12664
diff
changeset
|
136 public void completeInitialization() { |
5341a7fca039
made HSAIL reuse HotSpotLoweringProvider, just with a different set of registers
Doug Simon <doug.simon@oracle.com>
parents:
12664
diff
changeset
|
137 final HotSpotProviders providers = getProviders(); |
5341a7fca039
made HSAIL reuse HotSpotLoweringProvider, just with a different set of registers
Doug Simon <doug.simon@oracle.com>
parents:
12664
diff
changeset
|
138 HotSpotVMConfig config = getRuntime().getConfig(); |
13308
d3b3c6e17d40
HSAIL: added Math intrinsifications
Doug Simon <doug.simon@oracle.com>
parents:
13234
diff
changeset
|
139 // Initialize the lowering provider. |
12797
5341a7fca039
made HSAIL reuse HotSpotLoweringProvider, just with a different set of registers
Doug Simon <doug.simon@oracle.com>
parents:
12664
diff
changeset
|
140 final HotSpotLoweringProvider lowerer = (HotSpotLoweringProvider) providers.getLowerer(); |
5341a7fca039
made HSAIL reuse HotSpotLoweringProvider, just with a different set of registers
Doug Simon <doug.simon@oracle.com>
parents:
12664
diff
changeset
|
141 lowerer.initialize(providers, config); |
13308
d3b3c6e17d40
HSAIL: added Math intrinsifications
Doug Simon <doug.simon@oracle.com>
parents:
13234
diff
changeset
|
142 |
d3b3c6e17d40
HSAIL: added Math intrinsifications
Doug Simon <doug.simon@oracle.com>
parents:
13234
diff
changeset
|
143 // Register the replacements used by the HSAIL backend. |
13902
bdeadcd7101d
HSAIL: disable String.equals() substitutions
Doug Simon <doug.simon@oracle.com>
parents:
13900
diff
changeset
|
144 HSAILHotSpotReplacementsImpl replacements = (HSAILHotSpotReplacementsImpl) providers.getReplacements(); |
bdeadcd7101d
HSAIL: disable String.equals() substitutions
Doug Simon <doug.simon@oracle.com>
parents:
13900
diff
changeset
|
145 replacements.completeInitialization(); |
12797
5341a7fca039
made HSAIL reuse HotSpotLoweringProvider, just with a different set of registers
Doug Simon <doug.simon@oracle.com>
parents:
12664
diff
changeset
|
146 } |
5341a7fca039
made HSAIL reuse HotSpotLoweringProvider, just with a different set of registers
Doug Simon <doug.simon@oracle.com>
parents:
12664
diff
changeset
|
147 |
11739
b8695542d41b
added HSAIL register configuration
Doug Simon <doug.simon@oracle.com>
parents:
10956
diff
changeset
|
148 /** |
13784
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
149 * Compiles and installs a given method to a GPU binary. |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
150 */ |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
151 public HotSpotNmethod compileAndInstallKernel(Method method) { |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
152 ResolvedJavaMethod javaMethod = getProviders().getMetaAccess().lookupJavaMethod(method); |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
153 HotSpotNmethod nm = installKernel(javaMethod, compileKernel(javaMethod, true)); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
154 try (Scope s = Debug.scope("HostCodeGen")) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
155 if (Debug.isLogEnabled()) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
156 DisassemblerProvider dis = getRuntime().getHostBackend().getDisassembler(); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
157 if (dis != null) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
158 String disasm = dis.disassemble(nm); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
159 Debug.log("host code generated for %s%n%s", javaMethod, disasm); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
160 } else { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
161 Debug.log("host code disassembler is null"); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
162 } |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
163 } |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
164 } catch (Throwable e) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
165 throw Debug.handle(e); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
166 } |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
167 return nm; |
13784
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
168 } |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
169 |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
170 /** |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
171 * Compiles a given method to HSAIL code. |
14774
8594b26fc5d8
fixed incorrect uses of Debug.log API
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
172 * |
13784
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
173 * @param makeBinary specifies whether a GPU binary should also be generated for the HSAIL code. |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
174 * If true, the returned value is guaranteed to have a non-zero |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
175 * {@linkplain ExternalCompilationResult#getEntryPoint() entry point}. |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
176 * @return the HSAIL code compiled from {@code method}'s bytecode |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
177 */ |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
178 public ExternalCompilationResult compileKernel(ResolvedJavaMethod method, boolean makeBinary) { |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
179 StructuredGraph graph = new StructuredGraph(method); |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
180 HotSpotProviders providers = getProviders(); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
181 MetaAccessProvider metaAccess = getProviders().getMetaAccess(); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
182 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
183 // changed this from default to help us generate deopts when needed |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
184 OptimisticOptimizations optimisticOpts = OptimisticOptimizations.ALL; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
185 optimisticOpts.remove(OptimisticOptimizations.Optimization.UseExceptionProbabilityForOperations); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
186 new GraphBuilderPhase.Instance(metaAccess, GraphBuilderConfiguration.getSnippetDefault(), optimisticOpts).apply(graph); |
13784
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
187 PhaseSuite<HighTierContext> graphBuilderSuite = providers.getSuites().getDefaultGraphBuilderSuite(); |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
188 CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, graph.method(), false); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
189 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
190 // append special HSAILNonNullParametersPhase |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
191 int numArgs = cc.getArguments().length; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
192 graphBuilderSuite.appendPhase(new HSAILNonNullParametersPhase(numArgs)); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
193 |
13784
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
194 Suites suites = providers.getSuites().getDefaultSuites(); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
195 ExternalCompilationResult hsailCode = compileGraph(graph, null, cc, method, providers, this, this.getTarget(), null, graphBuilderSuite, optimisticOpts, getProfilingInfo(graph), null, suites, |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
196 new ExternalCompilationResult(), CompilationResultBuilderFactory.Default); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
197 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
198 // this code added to dump infopoints |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
199 try (Scope s = Debug.scope("CodeGen")) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
200 if (Debug.isLogEnabled()) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
201 // show infopoints |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
202 List<Infopoint> infoList = hsailCode.getInfopoints(); |
14774
8594b26fc5d8
fixed incorrect uses of Debug.log API
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
203 Debug.log("%d HSAIL infopoints", infoList.size()); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
204 for (Infopoint info : infoList) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
205 Debug.log(info.toString()); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
206 Debug.log(info.debugInfo.frame().toString()); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
207 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
208 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
209 } catch (Throwable e) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
210 throw Debug.handle(e); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
211 } |
13784
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
212 |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
213 if (makeBinary) { |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
214 if (!deviceInitialized) { |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
215 throw new GraalInternalError("Cannot generate GPU kernel if device is not initialized"); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
216 } |
13784
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
217 try (Scope ds = Debug.scope("GeneratingKernelBinary")) { |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
218 long kernel = generateKernel(hsailCode.getTargetCode(), method.getName()); |
13784
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
219 if (kernel == 0) { |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
220 throw new GraalInternalError("Failed to compile HSAIL kernel"); |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
221 } |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
222 hsailCode.setEntryPoint(kernel); |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
223 } catch (Throwable e) { |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
224 throw Debug.handle(e); |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
225 } |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
226 } |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
227 return hsailCode; |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
228 } |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
229 |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
230 private static class HSAILNonNullParametersPhase extends Phase { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
231 // we use this to limit the stamping to exclude the final argument in an obj stream method |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
232 private int numArgs; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
233 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
234 public HSAILNonNullParametersPhase(int numArgs) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
235 this.numArgs = numArgs; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
236 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
237 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
238 @Override |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
239 protected void run(StructuredGraph graph) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
240 int argCount = 0; |
16569
d780f8b87d89
NonNullParametersPhase (and its HSAIL cousin) should join non-null rather than attempt to re-create the paramater stamp.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16242
diff
changeset
|
241 Stamp nonNull = StampFactory.objectNonNull(); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
242 for (ParameterNode param : graph.getNodes(ParameterNode.class)) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
243 argCount++; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
244 if (argCount < numArgs && param.stamp() instanceof ObjectStamp) { |
16569
d780f8b87d89
NonNullParametersPhase (and its HSAIL cousin) should join non-null rather than attempt to re-create the paramater stamp.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16242
diff
changeset
|
245 ObjectStamp paramStamp = (ObjectStamp) param.stamp(); |
d780f8b87d89
NonNullParametersPhase (and its HSAIL cousin) should join non-null rather than attempt to re-create the paramater stamp.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16242
diff
changeset
|
246 param.setStamp(paramStamp.join(nonNull)); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
247 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
248 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
249 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
250 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
251 |
13784
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
252 /** |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
253 * Generates a GPU binary from HSAIL code. |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
254 */ |
16119
310994c667a7
HSAIL: support offloading some IntStream.reduce() operations to HSA
Doug Simon <doug.simon@oracle.com>
parents:
16094
diff
changeset
|
255 static native long generateKernel(byte[] hsailCode, String name); |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
256 |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
257 /** |
13784
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
258 * Installs the {@linkplain ExternalCompilationResult#getEntryPoint() GPU binary} associated |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
259 * with some given HSAIL code in the code cache and returns a {@link HotSpotNmethod} handle to |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
260 * the installed code. |
14774
8594b26fc5d8
fixed incorrect uses of Debug.log API
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
261 * |
13784
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
262 * @param hsailCode HSAIL compilation result for which a GPU binary has been generated |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
263 * @return a handle to the binary as installed in the HotSpot code cache |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
264 */ |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
265 public final HotSpotNmethod installKernel(ResolvedJavaMethod method, ExternalCompilationResult hsailCode) { |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
266 assert hsailCode.getEntryPoint() != 0L; |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
267 // Code here based on HotSpotCodeCacheProvider.addExternalMethod(). |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
268 HotSpotResolvedJavaMethod javaMethod = (HotSpotResolvedJavaMethod) method; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
269 if (hsailCode.getId() == -1) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
270 hsailCode.setId(javaMethod.allocateCompileId(hsailCode.getEntryBCI())); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
271 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
272 CompilationResult compilationResult = hsailCode; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
273 StructuredGraph hostGraph = hsailCode.getHostGraph(); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
274 if (hostGraph != null) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
275 // TODO get rid of the unverified entry point in the host code |
15640
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
276 try (Scope ds = Debug.scope("GeneratingHostGraph", new DebugDumpScope("HostGraph"))) { |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
277 HotSpotBackend hostBackend = getRuntime().getHostBackend(); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
278 JavaType[] parameterTypes = new JavaType[hostGraph.getNodes(ParameterNode.class).count()]; |
14774
8594b26fc5d8
fixed incorrect uses of Debug.log API
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
279 Debug.log("Param count: %d", parameterTypes.length); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
280 for (int i = 0; i < parameterTypes.length; i++) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
281 ParameterNode parameter = hostGraph.getParameter(i); |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
282 Debug.log("Param [%d]=%s", i, parameter); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
283 parameterTypes[i] = parameter.stamp().javaType(hostBackend.getProviders().getMetaAccess()); |
14774
8594b26fc5d8
fixed incorrect uses of Debug.log API
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
284 Debug.log(" %s", parameterTypes[i]); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
285 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
286 CallingConvention cc = hostBackend.getProviders().getCodeCache().getRegisterConfig().getCallingConvention(Type.JavaCallee, method.getSignature().getReturnType(null), parameterTypes, |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
287 hostBackend.getTarget(), false); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
288 CompilationResult hostCode = compileGraph(hostGraph, null, cc, method, hostBackend.getProviders(), hostBackend, this.getTarget(), null, |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
289 hostBackend.getProviders().getSuites().getDefaultGraphBuilderSuite(), OptimisticOptimizations.NONE, null, null, |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
290 hostBackend.getProviders().getSuites().getDefaultSuites(), new CompilationResult(), CompilationResultBuilderFactory.Default); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
291 compilationResult = merge(hostCode, hsailCode); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
292 } catch (Throwable e) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
293 throw Debug.handle(e); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
294 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
295 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
296 |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
297 HSAILHotSpotNmethod code = new HSAILHotSpotNmethod(javaMethod, hsailCode.getName(), false, true); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
298 code.setOopMapArray(hsailCode.getOopMapArray()); |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
299 code.setUsesAllocationFlag(hsailCode.getUsesAllocationFlag()); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
300 HotSpotCompiledNmethod compiled = new HotSpotCompiledNmethod(getTarget(), javaMethod, compilationResult); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
301 CodeInstallResult result = getRuntime().getCompilerToVM().installCode(compiled, code, null); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
302 if (result != CodeInstallResult.OK) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
303 return null; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
304 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
305 return code; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
306 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
307 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
308 private static ExternalCompilationResult merge(CompilationResult hostCode, ExternalCompilationResult hsailCode) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
309 ExternalCompilationResult result = new ExternalCompilationResult(); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
310 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
311 // from hsail code |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
312 result.setEntryPoint(hsailCode.getEntryPoint()); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
313 result.setId(hsailCode.getId()); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
314 result.setEntryBCI(hsailCode.getEntryBCI()); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
315 assert hsailCode.getMarks().isEmpty(); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
316 assert hsailCode.getExceptionHandlers().isEmpty(); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
317 assert hsailCode.getDataReferences().isEmpty(); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
318 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
319 // from host code |
15180
7a9531f50cd8
renamed com.oracle.graal.api.code.CompilationResult.frameSize to totalFrameSize
twisti
parents:
15177
diff
changeset
|
320 result.setTotalFrameSize(hostCode.getTotalFrameSize()); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
321 result.setCustomStackAreaOffset(hostCode.getCustomStackAreaOffset()); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
322 result.setTargetCode(hostCode.getTargetCode(), hostCode.getTargetCodeSize()); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
323 for (CodeAnnotation annotation : hostCode.getAnnotations()) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
324 result.addAnnotation(annotation); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
325 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
326 for (Mark mark : hostCode.getMarks()) { |
15375
1b82cd9e72e9
Remove CompilationResult.Mark.references
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15338
diff
changeset
|
327 result.recordMark(mark.pcOffset, mark.id); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
328 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
329 for (ExceptionHandler handler : hostCode.getExceptionHandlers()) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
330 result.recordExceptionHandler(handler.pcOffset, handler.handlerPos); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
331 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
332 for (DataPatch patch : hostCode.getDataReferences()) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
333 if (patch.data != null) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
334 if (patch.inline) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
335 result.recordInlineData(patch.pcOffset, patch.data); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
336 } else { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
337 result.recordDataReference(patch.pcOffset, patch.data); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
338 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
339 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
340 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
341 for (Infopoint infopoint : hostCode.getInfopoints()) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
342 if (infopoint instanceof Call) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
343 Call call = (Call) infopoint; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
344 result.recordCall(call.pcOffset, call.size, call.target, call.debugInfo, call.direct); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
345 } else { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
346 result.recordInfopoint(infopoint.pcOffset, infopoint.debugInfo, infopoint.reason); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
347 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
348 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
349 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
350 // merged |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
351 Assumptions mergedAssumptions = new Assumptions(true); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
352 if (hostCode.getAssumptions() != null) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
353 for (Assumption assumption : hostCode.getAssumptions().getAssumptions()) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
354 if (assumption != null) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
355 mergedAssumptions.record(assumption); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
356 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
357 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
358 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
359 if (hsailCode.getAssumptions() != null) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
360 for (Assumption assumption : hsailCode.getAssumptions().getAssumptions()) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
361 if (assumption != null) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
362 mergedAssumptions.record(assumption); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
363 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
364 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
365 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
366 if (!mergedAssumptions.isEmpty()) { |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
367 result.setAssumptions(mergedAssumptions); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
368 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
369 return result; |
13784
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
370 } |
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
371 |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
372 private static final ThreadLocal<DonorThreadPool> donorThreadPool = new ThreadLocal<DonorThreadPool>() { |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
373 @Override |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
374 protected DonorThreadPool initialValue() { |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
375 return new DonorThreadPool(); |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
376 } |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
377 }; |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
378 |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
379 public boolean executeKernel(HotSpotInstalledCode kernel, int jobSize, Object[] args) throws InvalidInstalledCodeException { |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
380 if (!deviceInitialized) { |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
381 throw new GraalInternalError("Cannot execute GPU kernel if device is not initialized"); |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
382 } |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
383 int[] oopMapArray = ((HSAILHotSpotNmethod) kernel).getOopMapArray(); |
16242
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16119
diff
changeset
|
384 |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
385 // Pass donorThreadPoolArray if this kernel uses allocation, otherwise null |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
386 Thread[] donorThreadArray = ((HSAILHotSpotNmethod) kernel).getUsesAllocationFlag() ? donorThreadPool.get().getThreads() : null; |
16242
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16119
diff
changeset
|
387 return executeKernel0(kernel, jobSize, args, donorThreadArray, HsailAllocBytesPerWorkitem.getValue(), oopMapArray); |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
388 } |
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
389 |
16242
e9998e2be7f5
use oops_do to modify saved hsail state
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
16119
diff
changeset
|
390 private static native boolean executeKernel0(HotSpotInstalledCode kernel, int jobSize, Object[] args, Thread[] donorThreads, int allocBytesPerWorkitem, int[] oopMapArray) |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
391 throws InvalidInstalledCodeException; |
13819
49db2c1e3bee
added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents:
13784
diff
changeset
|
392 |
13784
219a84093dda
moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents:
13318
diff
changeset
|
393 /** |
11739
b8695542d41b
added HSAIL register configuration
Doug Simon <doug.simon@oracle.com>
parents:
10956
diff
changeset
|
394 * Use the HSAIL register set when the compilation target is HSAIL. |
b8695542d41b
added HSAIL register configuration
Doug Simon <doug.simon@oracle.com>
parents:
10956
diff
changeset
|
395 */ |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
396 @Override |
15011
c8e575742f36
allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14991
diff
changeset
|
397 public FrameMap newFrameMap(RegisterConfig registerConfig) { |
c8e575742f36
allow compilation with custom RegisterConfig
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14991
diff
changeset
|
398 return new HSAILFrameMap(getCodeCache(), registerConfig); |
10956 | 399 } |
400 | |
401 @Override | |
15333
06ecedffb109
Use LIRGeneratorTool in Backend.
Josef Eisl <josef.eisl@jku.at>
parents:
15311
diff
changeset
|
402 public LIRGeneratorTool newLIRGenerator(CallingConvention cc, LIRGenerationResult lirGenRes) { |
14846
43cd57700476
Apply LIRGenerator refactoring to HSAIL backend.
Josef Eisl <josef.eisl@jku.at>
parents:
14809
diff
changeset
|
403 return new HSAILHotSpotLIRGenerator(getProviders(), getRuntime().getConfig(), cc, lirGenRes); |
14809
73774616a6b3
Decoupled LIRGenerator and LIRGenerationResult.
Josef Eisl <josef.eisl@jku.at>
parents:
14804
diff
changeset
|
404 } |
73774616a6b3
Decoupled LIRGenerator and LIRGenerationResult.
Josef Eisl <josef.eisl@jku.at>
parents:
14804
diff
changeset
|
405 |
73774616a6b3
Decoupled LIRGenerator and LIRGenerationResult.
Josef Eisl <josef.eisl@jku.at>
parents:
14804
diff
changeset
|
406 @Override |
15838
15771ff797b4
Pass the compiled method to LIR factory
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15640
diff
changeset
|
407 public LIRGenerationResult newLIRGenerationResult(LIR lir, FrameMap frameMap, ResolvedJavaMethod method, Object stub) { |
14853 | 408 return new HSAILHotSpotLIRGenerationResult(lir, frameMap); |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
409 } |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
410 |
14846
43cd57700476
Apply LIRGenerator refactoring to HSAIL backend.
Josef Eisl <josef.eisl@jku.at>
parents:
14809
diff
changeset
|
411 @Override |
15338
5e544920ad9f
Rename Backend.newNodeLIRGenerator to Backend.newNodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents:
15337
diff
changeset
|
412 public NodeLIRBuilderTool newNodeLIRBuilder(StructuredGraph graph, LIRGeneratorTool lirGen) { |
14921
88dfaf6448e0
Remove LIRGenerationResult from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents:
14888
diff
changeset
|
413 return new HSAILHotSpotNodeLIRBuilder(graph, lirGen); |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
414 } |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
415 |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
416 class HotSpotFrameContext implements FrameContext { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
417 |
13234
7e237378923d
made the frameContext of a CompilationResultBuilder always non-null and added FrameContext.hasFrame() to determine if a frame is actually generated
Doug Simon <doug.simon@oracle.com>
parents:
13229
diff
changeset
|
418 public boolean hasFrame() { |
7e237378923d
made the frameContext of a CompilationResultBuilder always non-null and added FrameContext.hasFrame() to determine if a frame is actually generated
Doug Simon <doug.simon@oracle.com>
parents:
13229
diff
changeset
|
419 return true; |
7e237378923d
made the frameContext of a CompilationResultBuilder always non-null and added FrameContext.hasFrame() to determine if a frame is actually generated
Doug Simon <doug.simon@oracle.com>
parents:
13229
diff
changeset
|
420 } |
7e237378923d
made the frameContext of a CompilationResultBuilder always non-null and added FrameContext.hasFrame() to determine if a frame is actually generated
Doug Simon <doug.simon@oracle.com>
parents:
13229
diff
changeset
|
421 |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
422 @Override |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13105
diff
changeset
|
423 public void enter(CompilationResultBuilder crb) { |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
424 Debug.log("Nothing to do here"); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
425 } |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
426 |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
427 @Override |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13105
diff
changeset
|
428 public void leave(CompilationResultBuilder crb) { |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
429 Debug.log("Nothing to do here"); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
430 } |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
431 } |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
432 |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
433 /** |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
434 * a class to allow us to save lirGen. |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
435 */ |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
436 static class HSAILCompilationResultBuilder extends CompilationResultBuilder { |
14853 | 437 public HSAILHotSpotLIRGenerationResult lirGenRes; |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
438 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
439 public HSAILCompilationResultBuilder(CodeCacheProvider codeCache, ForeignCallsProvider foreignCalls, FrameMap frameMap, Assembler asm, FrameContext frameContext, |
14853 | 440 CompilationResult compilationResult, HSAILHotSpotLIRGenerationResult lirGenRes) { |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
441 super(codeCache, foreignCalls, frameMap, asm, frameContext, compilationResult); |
14853 | 442 this.lirGenRes = lirGenRes; |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
443 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
444 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
445 |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
446 static class HSAILHotSpotNmethod extends HotSpotNmethod { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
447 private int[] oopMapArray; |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
448 private boolean usesAllocation; |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
449 |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
450 HSAILHotSpotNmethod(HotSpotResolvedJavaMethod method, String name, boolean isDefault, boolean isExternal) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
451 super(method, name, isDefault, isExternal); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
452 } |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
453 |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
454 void setOopMapArray(int[] array) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
455 oopMapArray = array; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
456 } |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
457 |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
458 int[] getOopMapArray() { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
459 return oopMapArray; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
460 } |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
461 |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
462 public void setUsesAllocationFlag(boolean val) { |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
463 usesAllocation = val; |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
464 } |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
465 |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
466 public boolean getUsesAllocationFlag() { |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
467 return usesAllocation; |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
468 } |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
469 } |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
470 |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
471 @Override |
14032
d1c1f103d42c
renamed com.oracle.graal.asm.AbstractAssembler to com.oracle.graal.asm.Assembler
twisti
parents:
14031
diff
changeset
|
472 protected Assembler createAssembler(FrameMap frameMap) { |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15011
diff
changeset
|
473 return new HSAILHotSpotAssembler(getTarget()); |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
474 } |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
475 |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
476 @Override |
14809
73774616a6b3
Decoupled LIRGenerator and LIRGenerationResult.
Josef Eisl <josef.eisl@jku.at>
parents:
14804
diff
changeset
|
477 public CompilationResultBuilder newCompilationResultBuilder(LIRGenerationResult lirGenRes, CompilationResult compilationResult, CompilationResultBuilderFactory factory) { |
73774616a6b3
Decoupled LIRGenerator and LIRGenerationResult.
Josef Eisl <josef.eisl@jku.at>
parents:
14804
diff
changeset
|
478 FrameMap frameMap = lirGenRes.getFrameMap(); |
14032
d1c1f103d42c
renamed com.oracle.graal.asm.AbstractAssembler to com.oracle.graal.asm.Assembler
twisti
parents:
14031
diff
changeset
|
479 Assembler masm = createAssembler(frameMap); |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
480 HotSpotFrameContext frameContext = new HotSpotFrameContext(); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
481 // save lirGen for later use by setHostGraph |
14853 | 482 CompilationResultBuilder crb = new HSAILCompilationResultBuilder(getCodeCache(), getForeignCalls(), frameMap, masm, frameContext, compilationResult, |
483 (HSAILHotSpotLIRGenerationResult) lirGenRes); | |
15180
7a9531f50cd8
renamed com.oracle.graal.api.code.CompilationResult.frameSize to totalFrameSize
twisti
parents:
15177
diff
changeset
|
484 crb.setTotalFrameSize(frameMap.totalFrameSize()); |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13105
diff
changeset
|
485 return crb; |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
486 } |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
487 |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
488 @Override |
14065
5dec26f3d4a4
Use LIR instead of LIRGenerator as parameter in emitCode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14032
diff
changeset
|
489 public void emitCode(CompilationResultBuilder crb, LIR lir, ResolvedJavaMethod method) { |
5dec26f3d4a4
Use LIR instead of LIRGenerator as parameter in emitCode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14032
diff
changeset
|
490 assert method != null : lir + " is not associated with a method"; |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
491 Kind wordKind = getProviders().getCodeCache().getTarget().wordKind; |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16077
diff
changeset
|
492 LIRKind wordLIRKind = LIRKind.value(wordKind); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
493 |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
494 HotSpotVMConfig config = getRuntime().getConfig(); |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
495 boolean useHSAILDeoptimization = config.useHSAILDeoptimization; |
15177
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15157
diff
changeset
|
496 boolean useHSAILSafepoints = config.useHSAILSafepoints; |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
497 |
15846 | 498 if ((useHSAILSafepoints == true) && (useHSAILDeoptimization == false)) { |
499 Debug.log("+UseHSAILSafepoints requires +UseHSAILDeoptimization"); | |
500 } | |
501 | |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
502 /* |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
503 * See what graph nodes we have to see if we are using the thread register. If not, we don't |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
504 * have to emit the code that sets it up. Maybe there is a better way to do this? |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
505 */ |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
506 boolean usesAllocation = false; |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
507 search: for (AbstractBlock<?> b : lir.linearScanOrder()) { |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
508 for (LIRInstruction op : lir.getLIRforBlock(b)) { |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
509 if ((op instanceof HSAILMove.LoadOp) && ((HSAILMove.LoadOp) op).usesThreadRegister()) { |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
510 usesAllocation = true; |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
511 assert useHSAILDeoptimization : "cannot use thread register if HSAIL deopt support is disabled"; |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
512 break search; |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
513 } |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
514 } |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
515 } |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
516 // save usesAllocation flag in ExternalCompilationResult |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
517 ((ExternalCompilationResult) crb.compilationResult).setUsesAllocationFlag(usesAllocation); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
518 |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
519 // Emit the prologue. |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
520 HSAILAssembler asm = (HSAILAssembler) crb.asm; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
521 asm.emitString0("version 0:95: $full : $large;\n"); |
13105
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
522 |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
523 Signature signature = method.getSignature(); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
524 int sigParamCount = signature.getParameterCount(false); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
525 // We're subtracting 1 because we're not making the final gid as a parameter. |
13105
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
526 |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
527 int nonConstantParamCount = sigParamCount - 1; |
15311
820c6d353358
added ModifiersProvider as superinterface for ResolvedJava[Method|Field|Type] and implemented all checks against modifiers as default methods
Doug Simon <doug.simon@oracle.com>
parents:
15292
diff
changeset
|
528 boolean isStatic = (method.isStatic()); |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
529 // Determine if this is an object lambda. |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
530 boolean isObjectLambda = true; |
13105
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
531 |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
532 if (signature.getParameterType(nonConstantParamCount, null).getKind() == Kind.Int) { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
533 isObjectLambda = false; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
534 } else { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
535 // Add space for gid int reg. |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
536 nonConstantParamCount++; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
537 } |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
538 |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
539 // If this is an instance method, include the "this" parameter |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
540 if (!isStatic) { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
541 nonConstantParamCount++; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
542 } |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
543 // Add in any "constant" parameters (currently none). |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
544 int totalParamCount = nonConstantParamCount; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
545 JavaType[] paramtypes = new JavaType[totalParamCount]; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
546 String[] paramNames = new String[totalParamCount]; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
547 int pidx = 0; |
13105
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
548 MetaAccessProvider metaAccess = getProviders().getMetaAccess(); |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
549 for (int i = 0; i < totalParamCount; i++) { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
550 if (i == 0 && !isStatic) { |
12363
78e5badf4b8e
moved lookupForeignCall() from CodeCacheProvider to ForeignCallsProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12045
diff
changeset
|
551 paramtypes[i] = metaAccess.lookupJavaType(Object.class); |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
552 paramNames[i] = "%_this"; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
553 } else if (i < nonConstantParamCount) { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
554 if (isObjectLambda && (i == (nonConstantParamCount))) { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
555 // Set up the gid register mapping. |
12363
78e5badf4b8e
moved lookupForeignCall() from CodeCacheProvider to ForeignCallsProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
12045
diff
changeset
|
556 paramtypes[i] = metaAccess.lookupJavaType(int.class); |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
557 paramNames[i] = "%_gid"; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
558 } else { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
559 paramtypes[i] = signature.getParameterType(pidx++, null); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
560 paramNames[i] = "%_arg" + i; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
561 } |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
562 } |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
563 } |
13105
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
564 |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
565 asm.emitString0("// " + (isStatic ? "static" : "instance") + " method " + method + "\n"); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
566 asm.emitString0("kernel &run ( \n"); |
13105
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
567 |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13105
diff
changeset
|
568 FrameMap frameMap = crb.frameMap; |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
569 RegisterConfig regConfig = frameMap.registerConfig; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
570 // Build list of param types which does include the gid (for cc register mapping query). |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
571 JavaType[] ccParamTypes = new JavaType[nonConstantParamCount + 1]; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
572 // Include the gid. |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
573 System.arraycopy(paramtypes, 0, ccParamTypes, 0, nonConstantParamCount); |
13105
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
574 |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
575 /* |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
576 * Last entry is always int (its register gets used in the workitemabsid instruction). This |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
577 * is true even for object stream lambdas. |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
578 */ |
13105
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
579 if (sigParamCount > 0) { |
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
580 ccParamTypes[ccParamTypes.length - 1] = metaAccess.lookupJavaType(int.class); |
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
581 } |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12363
diff
changeset
|
582 CallingConvention cc = regConfig.getCallingConvention(JavaCallee, null, ccParamTypes, getTarget(), false); |
13105
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
583 |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
584 /** |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
585 * Compute the hsail size mappings up to but not including the last non-constant parameter |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
586 * (which is the gid). |
14774
8594b26fc5d8
fixed incorrect uses of Debug.log API
Doug Simon <doug.simon@oracle.com>
parents:
14768
diff
changeset
|
587 * |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
588 */ |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
589 String[] paramHsailSizes = new String[totalParamCount]; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
590 for (int i = 0; i < totalParamCount; i++) { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
591 String paramtypeStr = paramtypes[i].toString(); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
592 String sizeStr = paramTypeMap.get(paramtypeStr); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
593 // Catch all for any unmapped paramtype that is u64 (address of an object). |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
594 paramHsailSizes[i] = (sizeStr != null ? sizeStr : "u64"); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
595 } |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
596 // Emit the kernel function parameters. |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
597 for (int i = 0; i < totalParamCount; i++) { |
13900
d9aad522d355
HSAIL: fixed bug in kernel argument logic
Doug Simon <doug.simon@oracle.com>
parents:
13839
diff
changeset
|
598 String str = "align 8 kernarg_" + paramHsailSizes[i] + " " + paramNames[i]; |
13105
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
599 |
14969
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14945
diff
changeset
|
600 if (useHSAILDeoptimization || (i != totalParamCount - 1)) { |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
601 str += ","; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
602 } |
14031
390c4b742890
made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents:
13902
diff
changeset
|
603 asm.emitString(str); |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
604 } |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
605 |
14969
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14945
diff
changeset
|
606 if (useHSAILDeoptimization) { |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
607 // add in the deoptInfo parameter |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
608 asm.emitString("kernarg_u64 " + asm.getDeoptInfoName()); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
609 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
610 |
14031
390c4b742890
made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents:
13902
diff
changeset
|
611 asm.emitString(") {"); |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
612 |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
613 /* |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
614 * End of parameters start of prolog code. Emit the load instructions for loading of the |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
615 * kernel non-constant parameters into registers. The constant class parameters will not be |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
616 * loaded up front but will be loaded as needed. |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
617 */ |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
618 for (int i = 0; i < nonConstantParamCount; i++) { |
14031
390c4b742890
made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents:
13902
diff
changeset
|
619 asm.emitString("ld_kernarg_" + paramHsailSizes[i] + " " + HSAIL.mapRegister(cc.getArgument(i)) + ", [" + paramNames[i] + "];"); |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
620 } |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
621 |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
622 /* |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
623 * Emit the workitemaid instruction for loading the hidden gid parameter. This is assigned |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
624 * the register as if it were the last of the nonConstant parameters. |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
625 */ |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
626 String workItemReg = "$s" + Integer.toString(asRegister(cc.getArgument(nonConstantParamCount)).encoding()); |
14031
390c4b742890
made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents:
13902
diff
changeset
|
627 asm.emitString("workitemabsid_u32 " + workItemReg + ", 0;"); |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
628 |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
629 final String deoptInProgressLabel = "@LHandleDeoptInProgress"; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
630 |
14969
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14945
diff
changeset
|
631 if (useHSAILDeoptimization) { |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
632 // Aliases for d16 |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16077
diff
changeset
|
633 RegisterValue d16_deoptInfo = HSAIL.d16.asValue(wordLIRKind); |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
634 |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
635 // Aliases for d17 |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16077
diff
changeset
|
636 RegisterValue d17_donorThreadIndex = HSAIL.d17.asValue(wordLIRKind); |
15177
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15157
diff
changeset
|
637 RegisterValue d17_safepointFlagAddrIndex = d17_donorThreadIndex; |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
638 |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
639 // Aliases for s34 |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16077
diff
changeset
|
640 RegisterValue s34_deoptOccurred = HSAIL.s34.asValue(LIRKind.value(Kind.Int)); |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
641 RegisterValue s34_donorThreadIndex = s34_deoptOccurred; |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
642 |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
643 asm.emitLoadKernelArg(d16_deoptInfo, asm.getDeoptInfoName(), "u64"); |
15177
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15157
diff
changeset
|
644 asm.emitComment("// Check if a deopt or safepoint has occurred and abort if true before doing any work"); |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15157
diff
changeset
|
645 |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15157
diff
changeset
|
646 if (useHSAILSafepoints) { |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15157
diff
changeset
|
647 // Load address of _notice_safepoints field |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16077
diff
changeset
|
648 asm.emitLoad(wordKind, d17_safepointFlagAddrIndex, new HSAILAddressValue(wordLIRKind, d16_deoptInfo, config.hsailNoticeSafepointsOffset).toAddress()); |
15177
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15157
diff
changeset
|
649 // Load int value from that field |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16077
diff
changeset
|
650 asm.emitLoadAcquire(s34_deoptOccurred, new HSAILAddressValue(wordLIRKind, d17_safepointFlagAddrIndex, 0).toAddress()); |
15177
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15157
diff
changeset
|
651 asm.emitCompare(Kind.Int, s34_deoptOccurred, Constant.forInt(0), "ne", false, false); |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15157
diff
changeset
|
652 asm.cbr(deoptInProgressLabel); |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15157
diff
changeset
|
653 } |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16077
diff
changeset
|
654 asm.emitLoadAcquire(s34_deoptOccurred, new HSAILAddressValue(wordLIRKind, d16_deoptInfo, config.hsailDeoptOccurredOffset).toAddress()); |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
655 asm.emitCompare(Kind.Int, s34_deoptOccurred, Constant.forInt(0), "ne", false, false); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
656 asm.cbr(deoptInProgressLabel); |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
657 // load thread register if this kernel performs allocation |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
658 if (usesAllocation) { |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16077
diff
changeset
|
659 RegisterValue threadReg = getProviders().getRegisters().getThreadRegister().asValue(wordLIRKind); |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
660 assert HsailDonorThreads.getValue() > 0; |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16077
diff
changeset
|
661 asm.emitLoad(wordKind, threadReg, new HSAILAddressValue(wordLIRKind, d16_deoptInfo, config.hsailCurTlabInfoOffset).toAddress()); |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
662 if (HsailDonorThreads.getValue() != 1) { |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
663 asm.emitComment("// map workitem to a donor thread"); |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
664 asm.emitString(String.format("rem_u32 $%s, %s, %d;", s34_donorThreadIndex.getRegister(), workItemReg, HsailDonorThreads.getValue())); |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
665 asm.emitConvert(d17_donorThreadIndex, s34_donorThreadIndex, wordKind, Kind.Int); |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
666 asm.emit("mad", threadReg, d17_donorThreadIndex, Constant.forInt(8), threadReg); |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
667 } else { |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
668 // workitem is already mapped to solitary donor thread |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
669 } |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
670 asm.emitComment("// $" + getProviders().getRegisters().getThreadRegister() + " will point to holder of tlab thread info for this workitem"); |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
671 } |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
672 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
673 |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
674 /* |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
675 * Note the logic used for this spillseg size is to leave space and then go back and patch |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
676 * in the correct size once we have generated all the instructions. This should probably be |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
677 * done in a more robust way by implementing something like asm.insertString. |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
678 */ |
14031
390c4b742890
made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents:
13902
diff
changeset
|
679 int spillsegDeclarationPosition = asm.position() + 1; |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
680 String spillsegTemplate = "align 4 spill_u8 %spillseg[123456];"; |
14031
390c4b742890
made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents:
13902
diff
changeset
|
681 asm.emitString(spillsegTemplate); |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
682 // Emit object array load prologue here. |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
683 if (isObjectLambda) { |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
684 boolean useCompressedOops = config.useCompressedOops; |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
685 final int arrayElementsOffset = HotSpotGraalRuntime.getArrayBaseOffset(wordKind); |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
686 String iterationObjArgReg = HSAIL.mapRegister(cc.getArgument(nonConstantParamCount - 1)); |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
687 /* |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
688 * iterationObjArgReg will be the highest $d register in use (it is the last parameter) |
16694
a53c26c989d0
HSAIL: miscellaneous HSAIL test tweaks and fixes:
Doug Simon <doug.simon@oracle.com>
parents:
16569
diff
changeset
|
689 * so tempReg can be the next higher $d register. As of 1.0 spec, we cannot use |
a53c26c989d0
HSAIL: miscellaneous HSAIL test tweaks and fixes:
Doug Simon <doug.simon@oracle.com>
parents:
16569
diff
changeset
|
690 * ld_global_u32 $dxx, [addr]; so we need a temporary $s register. We can use |
a53c26c989d0
HSAIL: miscellaneous HSAIL test tweaks and fixes:
Doug Simon <doug.simon@oracle.com>
parents:
16569
diff
changeset
|
691 * workItemReg+1; |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
692 */ |
13105
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
693 String tmpReg = "$d" + (asRegister(cc.getArgument(nonConstantParamCount - 1)).encoding() + 1); |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
694 // Convert gid to long. |
14031
390c4b742890
made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents:
13902
diff
changeset
|
695 asm.emitString("cvt_u64_s32 " + tmpReg + ", " + workItemReg + "; // Convert gid to long"); |
13105
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
696 // Adjust index for sizeof ref. Where to pull this size from? |
14031
390c4b742890
made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents:
13902
diff
changeset
|
697 asm.emitString("mul_u64 " + tmpReg + ", " + tmpReg + ", " + (useCompressedOops ? 4 : 8) + "; // Adjust index for sizeof ref"); |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
698 // Adjust for actual data start. |
14031
390c4b742890
made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents:
13902
diff
changeset
|
699 asm.emitString("add_u64 " + tmpReg + ", " + tmpReg + ", " + arrayElementsOffset + "; // Adjust for actual elements data start"); |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
700 // Add to array ref ptr. |
14031
390c4b742890
made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents:
13902
diff
changeset
|
701 asm.emitString("add_u64 " + tmpReg + ", " + tmpReg + ", " + iterationObjArgReg + "; // Add to array ref ptr"); |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
702 // Load the object into the parameter reg. |
13105
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
703 if (useCompressedOops) { |
16694
a53c26c989d0
HSAIL: miscellaneous HSAIL test tweaks and fixes:
Doug Simon <doug.simon@oracle.com>
parents:
16569
diff
changeset
|
704 int workItemRegEncoding = asRegister(cc.getArgument(nonConstantParamCount)).encoding(); |
a53c26c989d0
HSAIL: miscellaneous HSAIL test tweaks and fixes:
Doug Simon <doug.simon@oracle.com>
parents:
16569
diff
changeset
|
705 String tmpReg32 = "$s" + Integer.toString(workItemRegEncoding + 1); |
13105
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
706 |
16694
a53c26c989d0
HSAIL: miscellaneous HSAIL test tweaks and fixes:
Doug Simon <doug.simon@oracle.com>
parents:
16569
diff
changeset
|
707 // Load u32 into the temporary $s reg since it will become an object address |
a53c26c989d0
HSAIL: miscellaneous HSAIL test tweaks and fixes:
Doug Simon <doug.simon@oracle.com>
parents:
16569
diff
changeset
|
708 |
a53c26c989d0
HSAIL: miscellaneous HSAIL test tweaks and fixes:
Doug Simon <doug.simon@oracle.com>
parents:
16569
diff
changeset
|
709 asm.emitString("ld_global_u32 " + tmpReg32 + ", " + "[" + tmpReg + "]" + "; // Load compressed ptr from array"); |
a53c26c989d0
HSAIL: miscellaneous HSAIL test tweaks and fixes:
Doug Simon <doug.simon@oracle.com>
parents:
16569
diff
changeset
|
710 asm.emitString("cvt_u64_u32 " + tmpReg + ", " + tmpReg32 + "; // cvt to 64 bits"); |
13105
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
711 |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
712 long narrowOopBase = config.narrowOopBase; |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
713 long narrowOopShift = config.narrowOopShift; |
13105
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
714 |
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
715 if (narrowOopBase == 0 && narrowOopShift == 0) { |
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
716 // No more calculation to do, mov to target register |
14031
390c4b742890
made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents:
13902
diff
changeset
|
717 asm.emitString("mov_b64 " + iterationObjArgReg + ", " + tmpReg + "; // no shift or base addition"); |
13105
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
718 } else { |
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
719 if (narrowOopBase == 0) { |
14031
390c4b742890
made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents:
13902
diff
changeset
|
720 asm.emitString("shl_u64 " + iterationObjArgReg + ", " + tmpReg + ", " + narrowOopShift + "; // do narrowOopShift"); |
13105
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
721 } else if (narrowOopShift == 0) { |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
722 // not sure if we ever get add with 0 shift but just in case |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
723 asm.emitString("cmp_eq_b1_u64 $c0, " + tmpReg + ", 0x0; // avoid add if compressed is null"); |
14031
390c4b742890
made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents:
13902
diff
changeset
|
724 asm.emitString("add_u64 " + iterationObjArgReg + ", " + tmpReg + ", " + narrowOopBase + "; // add narrowOopBase"); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
725 asm.emitString("cmov_b64 " + iterationObjArgReg + ", $c0, 0x0, " + iterationObjArgReg + "; // avoid add if compressed is null"); |
13105
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
726 } else { |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
727 asm.emitString("cmp_eq_b1_u64 $c0, " + tmpReg + ", 0x0; // avoid shift-add if compressed is null"); |
14031
390c4b742890
made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents:
13902
diff
changeset
|
728 asm.emitString("mad_u64 " + iterationObjArgReg + ", " + tmpReg + ", " + (1 << narrowOopShift) + ", " + narrowOopBase + "; // shift and add narrowOopBase"); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
729 asm.emitString("cmov_b64 " + iterationObjArgReg + ", $c0, 0x0, " + iterationObjArgReg + "; // avoid shift-add if compressed is null"); |
13105
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
730 } |
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
731 } |
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
732 |
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
733 } else { |
14031
390c4b742890
made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents:
13902
diff
changeset
|
734 asm.emitString("ld_global_u64 " + iterationObjArgReg + ", " + "[" + tmpReg + "]" + "; // Load from array element into parameter reg"); |
13105
d3fc35a43376
HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents:
12797
diff
changeset
|
735 } |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
736 } |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
737 // Prologue done, Emit code for the LIR. |
14065
5dec26f3d4a4
Use LIR instead of LIRGenerator as parameter in emitCode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14032
diff
changeset
|
738 crb.emit(lir); |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
739 // Now that code is emitted go back and figure out what the upper Bound stack size was. |
13227
1a66453f73db
renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents:
13105
diff
changeset
|
740 long maxStackSize = ((HSAILAssembler) crb.asm).upperBoundStackSize(); |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
741 String spillsegStringFinal; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
742 if (maxStackSize == 0) { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
743 // If no spilling, get rid of spillseg declaration. |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
744 char[] array = new char[spillsegTemplate.length()]; |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
745 Arrays.fill(array, ' '); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
746 spillsegStringFinal = new String(array); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
747 } else { |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
748 spillsegStringFinal = spillsegTemplate.replace("123456", String.format("%6d", maxStackSize)); |
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
749 } |
14031
390c4b742890
made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents:
13902
diff
changeset
|
750 asm.emitString(spillsegStringFinal, spillsegDeclarationPosition); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
751 // Emit the epilogue. |
14031
390c4b742890
made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents:
13902
diff
changeset
|
752 |
15640
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
753 HSAILHotSpotLIRGenerationResult lirGenRes = ((HSAILCompilationResultBuilder) crb).lirGenRes; |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
754 |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
755 int numSRegs = 0; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
756 int numDRegs = 0; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
757 int numStackSlotBytes = 0; |
14969
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14945
diff
changeset
|
758 if (useHSAILDeoptimization) { |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
759 /* |
16077
2d296658a24e
HSAIL: enable arraycopy support in backend
Doug Simon <doug.simon@oracle.com>
parents:
16076
diff
changeset
|
760 * Get the union of registers and stack slots needed to be saved at the infopoints. |
2d296658a24e
HSAIL: enable arraycopy support in backend
Doug Simon <doug.simon@oracle.com>
parents:
16076
diff
changeset
|
761 * While doing this compute the highest register in each category. |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
762 */ |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
763 HSAILHotSpotRegisterConfig hsailRegConfig = (HSAILHotSpotRegisterConfig) regConfig; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
764 Set<Register> infoUsedRegs = new TreeSet<>(); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
765 Set<StackSlot> infoUsedStackSlots = new HashSet<>(); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
766 List<Infopoint> infoList = crb.compilationResult.getInfopoints(); |
15640
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
767 Queue<Value[]> workList = new LinkedList<>(); |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
768 for (Infopoint info : infoList) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
769 BytecodeFrame frame = info.debugInfo.frame(); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
770 while (frame != null) { |
15640
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
771 workList.add(frame.values); |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
772 frame = frame.caller(); |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
773 } |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
774 } |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
775 while (!workList.isEmpty()) { |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
776 Value[] values = workList.poll(); |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
777 for (Value val : values) { |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
778 if (isLegal(val)) { |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
779 if (isRegister(val)) { |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
780 Register reg = asRegister(val); |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
781 infoUsedRegs.add(reg); |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
782 if (hsailRegConfig.isAllocatableSReg(reg)) { |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
783 numSRegs = Math.max(numSRegs, reg.encoding + 1); |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
784 } else if (hsailRegConfig.isAllocatableDReg(reg)) { |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
785 numDRegs = Math.max(numDRegs, reg.encoding + 1); |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
786 } |
15640
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
787 } else if (isStackSlot(val)) { |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
788 StackSlot slot = asStackSlot(val); |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
789 Kind slotKind = slot.getKind(); |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
790 int slotSizeBytes = (slotKind.isObject() ? 8 : slotKind.getByteCount()); |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
791 int slotOffsetMax = HSAIL.getStackOffsetStart(slot, slotSizeBytes * 8) + slotSizeBytes; |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
792 numStackSlotBytes = Math.max(numStackSlotBytes, slotOffsetMax); |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
793 infoUsedStackSlots.add(slot); |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
794 } else if (isVirtualObject(val)) { |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
795 workList.add(((VirtualObject) val).getValues()); |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
796 } else { |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
797 assert isConstant(val) : "Unsupported value: " + val; |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
798 } |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
799 } |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
800 } |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
801 } |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
802 |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
803 // round up numSRegs to even number so dregs start on aligned boundary |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
804 numSRegs += (numSRegs & 1); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
805 |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
806 // numStackSlots is the number of 8-byte locations used for stack variables |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
807 int numStackSlots = (numStackSlotBytes + 7) / 8; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
808 |
15609
66d31e70bd79
HSAIL: fixed deopt bug; cleaned up C++ code
Doug Simon <doug.simon@oracle.com>
parents:
15545
diff
changeset
|
809 final int offsetToDeoptSaveStates = config.hsailDeoptimizationInfoHeaderSize; |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
810 final int bytesPerSaveArea = 4 * numSRegs + 8 * numDRegs + 8 * numStackSlots; |
15545
9d456ffc6120
HSAIL: fixed Windows build
Doug Simon <doug.simon@oracle.com>
parents:
15482
diff
changeset
|
811 final int sizeofKernelDeopt = config.hsailKernelDeoptimizationHeaderSize + config.hsailFrameHeaderSize + bytesPerSaveArea; |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
812 final int offsetToNeverRanArray = config.hsailNeverRanArrayOffset; |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
813 final int offsetToDeoptNextIndex = config.hsailDeoptNextIndexOffset; |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
814 final int offsetToDeoptimizationWorkItem = config.hsailDeoptimizationWorkItem; |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
815 final int offsetToDeoptimizationReason = config.hsailDeoptimizationReason; |
15545
9d456ffc6120
HSAIL: fixed Windows build
Doug Simon <doug.simon@oracle.com>
parents:
15482
diff
changeset
|
816 final int offsetToDeoptimizationFrame = config.hsailKernelDeoptimizationHeaderSize; |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
817 final int offsetToFramePc = config.hsailFramePcOffset; |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
818 final int offsetToNumSaves = config.hsailFrameNumSRegOffset; |
15545
9d456ffc6120
HSAIL: fixed Windows build
Doug Simon <doug.simon@oracle.com>
parents:
15482
diff
changeset
|
819 final int offsetToSaveArea = config.hsailFrameHeaderSize; |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
820 |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16077
diff
changeset
|
821 AllocatableValue scratch64 = HSAIL.d16.asValue(wordLIRKind); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16077
diff
changeset
|
822 AllocatableValue cuSaveAreaPtr = HSAIL.d17.asValue(wordLIRKind); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16077
diff
changeset
|
823 AllocatableValue waveMathScratch1 = HSAIL.d18.asValue(wordLIRKind); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16077
diff
changeset
|
824 AllocatableValue waveMathScratch2 = HSAIL.d19.asValue(wordLIRKind); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
825 |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16077
diff
changeset
|
826 AllocatableValue actionAndReasonReg = HSAIL.actionAndReasonReg.asValue(LIRKind.value(Kind.Int)); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16077
diff
changeset
|
827 AllocatableValue codeBufferOffsetReg = HSAIL.codeBufferOffsetReg.asValue(LIRKind.value(Kind.Int)); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16077
diff
changeset
|
828 AllocatableValue scratch32 = HSAIL.s34.asValue(LIRKind.value(Kind.Int)); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16077
diff
changeset
|
829 AllocatableValue workidreg = HSAIL.s35.asValue(LIRKind.value(Kind.Int)); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
830 |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16077
diff
changeset
|
831 HSAILAddress deoptNextIndexAddr = new HSAILAddressValue(wordLIRKind, scratch64, offsetToDeoptNextIndex).toAddress(); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16077
diff
changeset
|
832 HSAILAddress neverRanArrayAddr = new HSAILAddressValue(wordLIRKind, scratch64, offsetToNeverRanArray).toAddress(); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
833 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
834 // The just-started lanes that see the deopt flag will jump here |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
835 asm.emitString0(deoptInProgressLabel + ":\n"); |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
836 asm.emitLoad(wordKind, waveMathScratch1, neverRanArrayAddr); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
837 asm.emitWorkItemAbsId(workidreg); |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
838 asm.emitConvert(waveMathScratch2, workidreg, wordKind, Kind.Int); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
839 asm.emit("add", waveMathScratch1, waveMathScratch1, waveMathScratch2); |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16077
diff
changeset
|
840 HSAILAddress neverRanStoreAddr = new HSAILAddressValue(wordLIRKind, waveMathScratch1, 0).toAddress(); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
841 asm.emitStore(Kind.Byte, Constant.forInt(1), neverRanStoreAddr); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
842 asm.emitString("ret;"); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
843 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
844 // The deoptimizing lanes will jump here |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
845 asm.emitString0(asm.getDeoptLabelName() + ":\n"); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
846 String labelExit = asm.getDeoptLabelName() + "_Exit"; |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
847 |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16077
diff
changeset
|
848 HSAILAddress deoptInfoAddr = new HSAILAddressValue(wordLIRKind, scratch64, config.hsailDeoptOccurredOffset).toAddress(); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
849 asm.emitLoadKernelArg(scratch64, asm.getDeoptInfoName(), "u64"); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
850 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
851 // Set deopt occurred flag |
14945
b14cb2d9253d
Make compression and uncompression explicit in the high level graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
14921
diff
changeset
|
852 asm.emitMov(Kind.Int, scratch32, Constant.forInt(1)); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
853 asm.emitStoreRelease(scratch32, deoptInfoAddr); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
854 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
855 asm.emitComment("// Determine next deopt save slot"); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
856 asm.emitAtomicAdd(scratch32, deoptNextIndexAddr, Constant.forInt(1)); |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
857 /* |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
858 * scratch32 now holds next index to use set error condition if no room in save area |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
859 */ |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
860 asm.emitComment("// assert room to save deopt"); |
15024
2ee777221036
Use high level CompressionNode in lowering of CompareAndSwapNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
861 asm.emitCompare(Kind.Int, scratch32, Constant.forInt(maxDeoptIndex), "lt", false, false); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
862 asm.cbr("@L_StoreDeopt"); |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
863 /* |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
864 * if assert fails, store a guaranteed negative workitemid in top level deopt occurred |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
865 * flag |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
866 */ |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
867 asm.emitWorkItemAbsId(scratch32); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
868 asm.emit("mad", scratch32, scratch32, Constant.forInt(-1), Constant.forInt(-1)); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
869 asm.emitStore(scratch32, deoptInfoAddr); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
870 asm.emitString("ret;"); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
871 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
872 asm.emitString0("@L_StoreDeopt" + ":\n"); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
873 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
874 // Store deopt for this workitem into its slot in the HSAILComputeUnitSaveStates array |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
875 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
876 asm.emitComment("// Convert id's for ptr math"); |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
877 asm.emitConvert(cuSaveAreaPtr, scratch32, wordKind, Kind.Int); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
878 asm.emitComment("// multiply by sizeof KernelDeoptArea"); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
879 asm.emit("mul", cuSaveAreaPtr, cuSaveAreaPtr, Constant.forInt(sizeofKernelDeopt)); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
880 asm.emitComment("// Add computed offset to deoptInfoPtr base"); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
881 asm.emit("add", cuSaveAreaPtr, cuSaveAreaPtr, scratch64); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
882 // Add offset to _deopt_save_states[0] |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
883 asm.emit("add", scratch64, cuSaveAreaPtr, Constant.forInt(offsetToDeoptSaveStates)); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
884 |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16077
diff
changeset
|
885 HSAILAddress workItemAddr = new HSAILAddressValue(wordLIRKind, scratch64, offsetToDeoptimizationWorkItem).toAddress(); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16077
diff
changeset
|
886 HSAILAddress actionReasonStoreAddr = new HSAILAddressValue(wordLIRKind, scratch64, offsetToDeoptimizationReason).toAddress(); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
887 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
888 asm.emitComment("// Get _deopt_info._first_frame"); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
889 asm.emit("add", waveMathScratch1, scratch64, Constant.forInt(offsetToDeoptimizationFrame)); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
890 // Now scratch64 is the _deopt_info._first_frame |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16077
diff
changeset
|
891 HSAILAddress pcStoreAddr = new HSAILAddressValue(wordLIRKind, waveMathScratch1, offsetToFramePc).toAddress(); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16077
diff
changeset
|
892 HSAILAddress regCountsAddr = new HSAILAddressValue(wordLIRKind, waveMathScratch1, offsetToNumSaves).toAddress(); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
893 asm.emitComment("// store deopting workitem"); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
894 asm.emitWorkItemAbsId(scratch32); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
895 asm.emitStore(Kind.Int, scratch32, workItemAddr); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
896 asm.emitComment("// store actionAndReason"); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
897 asm.emitStore(Kind.Int, actionAndReasonReg, actionReasonStoreAddr); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
898 asm.emitComment("// store PC"); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
899 asm.emitStore(Kind.Int, codeBufferOffsetReg, pcStoreAddr); |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
900 |
15609
66d31e70bd79
HSAIL: fixed deopt bug; cleaned up C++ code
Doug Simon <doug.simon@oracle.com>
parents:
15545
diff
changeset
|
901 asm.emitComment("// store regCounts (" + numSRegs + " $s registers, " + numDRegs + " $d registers, " + numStackSlots + " stack slots)"); |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
902 asm.emitStore(Kind.Int, Constant.forInt(numSRegs + (numDRegs << 8) + (numStackSlots << 16)), regCountsAddr); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
903 |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
904 /* |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
905 * Loop thru the usedValues storing each of the registers that are used. We always store |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
906 * in a fixed location, even if some registers are skipped. |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
907 */ |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
908 asm.emitComment("// store used regs"); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
909 for (Register reg : infoUsedRegs) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
910 if (hsailRegConfig.isAllocatableSReg(reg)) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
911 // 32 bit registers |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
912 Kind kind = Kind.Int; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
913 int ofst = offsetToSaveArea + reg.encoding * 4; |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16077
diff
changeset
|
914 HSAILAddress addr = new HSAILAddressValue(wordLIRKind, waveMathScratch1, ofst).toAddress(); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16077
diff
changeset
|
915 AllocatableValue regValue = reg.asValue(LIRKind.value(kind)); |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
916 asm.emitStore(kind, regValue, addr); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
917 } else if (hsailRegConfig.isAllocatableDReg(reg)) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
918 // 64 bit registers |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
919 Kind kind = Kind.Long; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
920 // d reg ofst starts past the 32 sregs |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
921 int ofst = offsetToSaveArea + (numSRegs * 4) + reg.encoding * 8; |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16077
diff
changeset
|
922 HSAILAddress addr = new HSAILAddressValue(wordLIRKind, waveMathScratch1, ofst).toAddress(); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16077
diff
changeset
|
923 AllocatableValue regValue = reg.asValue(LIRKind.value(kind)); |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
924 asm.emitStore(kind, regValue, addr); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
925 } else { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
926 throw GraalInternalError.unimplemented(); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
927 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
928 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
929 |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
930 // loop thru the usedStackSlots creating instructions to save in the save area |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
931 if (numStackSlotBytes > 0) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
932 asm.emitComment("// store stack slots (uses " + numStackSlotBytes + " bytes)"); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
933 for (StackSlot slot : infoUsedStackSlots) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
934 asm.emitComment("// store " + slot); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
935 Kind kind = slot.getKind(); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
936 int sizeInBits = (kind.isObject() || kind.getByteCount() == 8 ? 64 : 32); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
937 int ofst = offsetToSaveArea + (numSRegs * 4) + (numDRegs * 8) + HSAIL.getStackOffsetStart(slot, sizeInBits); |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
16077
diff
changeset
|
938 HSAILAddress addr = new HSAILAddressValue(wordLIRKind, waveMathScratch1, ofst).toAddress(); |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
939 if (sizeInBits == 64) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
940 asm.emitSpillLoad(kind, scratch64, slot); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
941 asm.emitStore(kind, scratch64, addr); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
942 } else { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
943 asm.emitSpillLoad(kind, scratch32, slot); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
944 asm.emitStore(kind, scratch32, addr); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
945 } |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
946 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
947 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
948 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
949 asm.emitString0(labelExit + ":\n"); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
950 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
951 // and emit the return |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
952 crb.frameContext.leave(crb); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
953 asm.exit(); |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
954 // build the oopMap Array |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
955 int[] oopMapArray = new OopMapArrayBuilder().build(infoList, numSRegs, numDRegs, numStackSlots, hsailRegConfig); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
956 ((ExternalCompilationResult) crb.compilationResult).setOopMapArray(oopMapArray); |
14969
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14945
diff
changeset
|
957 } else { |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14945
diff
changeset
|
958 // Deoptimization is explicitly off, so emit simple return |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14945
diff
changeset
|
959 asm.emitString0(asm.getDeoptLabelName() + ":\n"); |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14945
diff
changeset
|
960 asm.emitComment("// No deoptimization"); |
a6c144380ce7
HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14945
diff
changeset
|
961 asm.emitString("ret;"); |
14768
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
962 } |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
963 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
964 asm.emitString0("}; \n"); |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
965 |
3e9a960f0da1
HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents:
14143
diff
changeset
|
966 ExternalCompilationResult compilationResult = (ExternalCompilationResult) crb.compilationResult; |
15640
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
967 if (useHSAILDeoptimization) { |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
968 compilationResult.setHostGraph(prepareHostGraph(method, lirGenRes.getDeopts(), getProviders(), config, numSRegs, numDRegs)); |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
969 } |
14853 | 970 } |
971 | |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
972 private static class OopMapArrayBuilder { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
973 // oopMapArray struct |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
974 // int bytesPerSaveArea; (not strictly part of oopsmap but convenient to put here) |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
975 // int intsPerInfopoint; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
976 static final int SAVEAREACOUNTS_OFST = 0; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
977 static final int INTSPERINFOPOINT_OFST = 1; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
978 static final int HEADERSIZE = 2; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
979 // for each infopoint: |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
980 // int deoptId |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
981 // one or more ints of bits for the oopmap |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
982 |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
983 private int[] array; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
984 private int intsPerInfopoint; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
985 |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
986 int[] build(List<Infopoint> infoList, int numSRegs, int numDRegs, int numStackSlots, HSAILHotSpotRegisterConfig hsailRegConfig) { |
16076
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
987 /* |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
988 * We are told that infoList is always sorted. Each infoPoint can have a different |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
989 * oopMap. Since numStackSlots is the number of 8-byte stack slots used, it is an upper |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
990 * limit on the number of oop stack slots |
06eedda53e14
HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents:
15846
diff
changeset
|
991 */ |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
992 int bitsPerInfopoint = numDRegs + numStackSlots; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
993 int intsForBits = (bitsPerInfopoint + 31) / 32; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
994 int numInfopoints = infoList.size(); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
995 intsPerInfopoint = intsForBits + 1; // +1 for the pcoffset |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
996 int arraySize = HEADERSIZE + (numInfopoints * intsPerInfopoint); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
997 array = new int[arraySize]; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
998 array[INTSPERINFOPOINT_OFST] = intsPerInfopoint; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
999 // compute saveAreaCounts |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1000 int saveAreaCounts = (numSRegs & 0xff) + (numDRegs << 8) + (numStackSlots << 16); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1001 array[SAVEAREACOUNTS_OFST] = saveAreaCounts; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1002 |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1003 // loop thru the infoList |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1004 int infoIndex = 0; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1005 for (Infopoint info : infoList) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1006 setOopMapPcOffset(infoIndex, info.pcOffset); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1007 BytecodeFrame frame = info.debugInfo.frame(); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1008 while (frame != null) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1009 for (int i = 0; i < frame.numLocals + frame.numStack; i++) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1010 Value val = frame.values[i]; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1011 if (isLegal(val)) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1012 if (isRegister(val)) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1013 Register reg = asRegister(val); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1014 if (val.getKind().isObject()) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1015 assert (hsailRegConfig.isAllocatableDReg(reg)); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1016 int bitIndex = reg.encoding(); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1017 setOopMapBit(infoIndex, bitIndex); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1018 } |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1019 } else if (isStackSlot(val)) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1020 StackSlot slot = asStackSlot(val); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1021 if (val.getKind().isObject()) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1022 assert (HSAIL.getStackOffsetStart(slot, 64) % 8 == 0); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1023 int bitIndex = numDRegs + HSAIL.getStackOffsetStart(slot, 64) / 8; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1024 setOopMapBit(infoIndex, bitIndex); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1025 } |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1026 } |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1027 } |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1028 } |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1029 frame = frame.caller(); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1030 } |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1031 infoIndex++; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1032 } |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1033 try (Scope s = Debug.scope("CodeGen")) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1034 if (Debug.isLogEnabled()) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1035 Debug.log("numSRegs=%d, numDRegs=%d, numStackSlots=%d", numSRegs, numDRegs, numStackSlots); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1036 // show infopoint oopmap details |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1037 for (infoIndex = 0; infoIndex < infoList.size(); infoIndex++) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1038 String infoString = "Infopoint " + infoIndex + ", pcOffset=" + getOopMapPcOffset(infoIndex) + ", oopmap="; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1039 for (int i = 0; i < intsForBits; i++) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1040 infoString += (i != 0 ? ", " : "") + Integer.toHexString(getOopMapBitsAsInt(infoIndex, i)); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1041 } |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1042 Debug.log(infoString); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1043 } |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1044 } |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1045 } catch (Throwable e) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1046 throw Debug.handle(e); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1047 } |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1048 |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1049 return array; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1050 } |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1051 |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1052 private void setOopMapPcOffset(int infoIndex, int pcOffset) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1053 int arrIndex = HEADERSIZE + infoIndex * intsPerInfopoint; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1054 array[arrIndex] = pcOffset; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1055 } |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1056 |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1057 private int getOopMapPcOffset(int infoIndex) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1058 int arrIndex = HEADERSIZE + infoIndex * intsPerInfopoint; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1059 return array[arrIndex]; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1060 } |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1061 |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1062 private void setOopMapBit(int infoIndex, int bitIndex) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1063 int arrIndex = HEADERSIZE + infoIndex * intsPerInfopoint + 1 + bitIndex / 32; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1064 array[arrIndex] |= (1 << (bitIndex % 32)); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1065 } |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1066 |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1067 private int getOopMapBitsAsInt(int infoIndex, int intIndex) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1068 int arrIndex = HEADERSIZE + infoIndex * intsPerInfopoint + 1 + intIndex; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1069 return array[arrIndex]; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1070 } |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1071 } |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1072 |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1073 private static StructuredGraph prepareHostGraph(ResolvedJavaMethod method, List<DeoptimizingOp> deopts, HotSpotProviders providers, HotSpotVMConfig config, int numSRegs, int numDRegs) { |
14853 | 1074 if (deopts.isEmpty()) { |
1075 return null; | |
1076 } | |
1077 StructuredGraph hostGraph = new StructuredGraph(method, -2); | |
1078 ParameterNode deoptId = hostGraph.unique(new ParameterNode(0, StampFactory.intValue())); | |
1079 ParameterNode hsailFrame = hostGraph.unique(new ParameterNode(1, StampFactory.forKind(providers.getCodeCache().getTarget().wordKind))); | |
1080 ParameterNode reasonAndAction = hostGraph.unique(new ParameterNode(2, StampFactory.intValue())); | |
1081 ParameterNode speculation = hostGraph.unique(new ParameterNode(3, StampFactory.object())); | |
15145
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15132
diff
changeset
|
1082 BeginNode[] branches = new BeginNode[deopts.size() + 1]; |
14853 | 1083 int[] keys = new int[deopts.size()]; |
1084 int[] keySuccessors = new int[deopts.size() + 1]; | |
1085 double[] keyProbabilities = new double[deopts.size() + 1]; | |
1086 int i = 0; | |
15177
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15157
diff
changeset
|
1087 Collections.sort(deopts, new Comparator<DeoptimizingOp>() { |
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15157
diff
changeset
|
1088 public int compare(DeoptimizingOp o1, DeoptimizingOp o2) { |
14853 | 1089 return o1.getCodeBufferPos() - o2.getCodeBufferPos(); |
1090 } | |
1091 }); | |
15177
66e3af78ea96
HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents:
15157
diff
changeset
|
1092 for (DeoptimizingOp deopt : deopts) { |
14853 | 1093 keySuccessors[i] = i; |
1094 keyProbabilities[i] = 1.0 / deopts.size(); | |
1095 keys[i] = deopt.getCodeBufferPos(); | |
1096 assert keys[i] >= 0; | |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1097 branches[i] = createHostDeoptBranch(deopt, hsailFrame, reasonAndAction, speculation, providers, config, numSRegs, numDRegs); |
14853 | 1098 |
1099 i++; | |
1100 } | |
1101 keyProbabilities[deopts.size()] = 0; // default | |
1102 keySuccessors[deopts.size()] = deopts.size(); | |
1103 branches[deopts.size()] = createHostCrashBranch(hostGraph, deoptId); | |
1104 IntegerSwitchNode switchNode = hostGraph.add(new IntegerSwitchNode(deoptId, branches, keys, keyProbabilities, keySuccessors)); | |
1105 StartNode start = hostGraph.start(); | |
1106 start.setNext(switchNode); | |
1107 /* | |
1108 * printf.setNext(printf2); printf2.setNext(switchNode); | |
1109 */ | |
1110 hostGraph.setGuardsStage(GuardsStage.AFTER_FSA); | |
1111 return hostGraph; | |
1112 } | |
1113 | |
15145
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15132
diff
changeset
|
1114 private static BeginNode createHostCrashBranch(StructuredGraph hostGraph, ValueNode deoptId) { |
14853 | 1115 VMErrorNode vmError = hostGraph.add(new VMErrorNode("Error in HSAIL deopt. DeoptId=%d", deoptId)); |
1116 // ConvertNode.convert(hostGraph, Kind.Long, deoptId))); | |
1117 vmError.setNext(hostGraph.add(new ReturnNode(ConstantNode.defaultForKind(hostGraph.method().getSignature().getReturnKind(), hostGraph)))); | |
1118 return BeginNode.begin(vmError); | |
1119 } | |
1120 | |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1121 private static BeginNode createHostDeoptBranch(DeoptimizingOp deopt, ParameterNode hsailFrame, ValueNode reasonAndAction, ValueNode speculation, HotSpotProviders providers, |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1122 HotSpotVMConfig config, int numSRegs, int numDRegs) { |
14853 | 1123 BeginNode branch = hsailFrame.graph().add(new BeginNode()); |
1124 DynamicDeoptimizeNode deoptimization = hsailFrame.graph().add(new DynamicDeoptimizeNode(reasonAndAction, speculation)); | |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1125 deoptimization.setStateBefore(createFrameState(deopt.getFrameState().topFrame, hsailFrame, providers, config, numSRegs, numDRegs)); |
14853 | 1126 branch.setNext(deoptimization); |
1127 return branch; | |
1128 } | |
1129 | |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1130 private static FrameState createFrameState(BytecodeFrame lowLevelFrame, ParameterNode hsailFrame, HotSpotProviders providers, HotSpotVMConfig config, int numSRegs, int numDRegs) { |
15640
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1131 return createFrameState(lowLevelFrame, hsailFrame, providers, config, numSRegs, numDRegs, new HashMap<VirtualObject, VirtualObjectNode>()); |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1132 } |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1133 |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1134 private static FrameState createFrameState(BytecodeFrame lowLevelFrame, ParameterNode hsailFrame, HotSpotProviders providers, HotSpotVMConfig config, int numSRegs, int numDRegs, |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1135 Map<VirtualObject, VirtualObjectNode> virtualObjects) { |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1136 FrameState outterFrameState = null; |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1137 if (lowLevelFrame.caller() != null) { |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1138 outterFrameState = createFrameState(lowLevelFrame.caller(), hsailFrame, providers, config, numSRegs, numDRegs, virtualObjects); |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1139 } |
14853 | 1140 StructuredGraph hostGraph = hsailFrame.graph(); |
15640
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1141 Function<? super Value, ? extends ValueNode> lirValueToHirNode = v -> getNodeForValueFromFrame(v, hsailFrame, hostGraph, providers, config, numSRegs, numDRegs, virtualObjects); |
14853 | 1142 ValueNode[] locals = new ValueNode[lowLevelFrame.numLocals]; |
1143 for (int i = 0; i < lowLevelFrame.numLocals; i++) { | |
15640
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1144 locals[i] = lirValueToHirNode.apply(lowLevelFrame.getLocalValue(i)); |
14853 | 1145 } |
1146 List<ValueNode> stack = new ArrayList<>(lowLevelFrame.numStack); | |
1147 for (int i = 0; i < lowLevelFrame.numStack; i++) { | |
15640
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1148 stack.add(lirValueToHirNode.apply(lowLevelFrame.getStackValue(i))); |
14853 | 1149 } |
1150 ValueNode[] locks = new ValueNode[lowLevelFrame.numLocks]; | |
1151 MonitorIdNode[] monitorIds = new MonitorIdNode[lowLevelFrame.numLocks]; | |
1152 for (int i = 0; i < lowLevelFrame.numLocks; i++) { | |
1153 HotSpotMonitorValue lockValue = (HotSpotMonitorValue) lowLevelFrame.getLockValue(i); | |
15640
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1154 locks[i] = lirValueToHirNode.apply(lockValue); |
14853 | 1155 monitorIds[i] = getMonitorIdForHotSpotMonitorValueFromFrame(lockValue, hsailFrame, hostGraph); |
1156 } | |
1157 FrameState frameState = hostGraph.add(new FrameState(lowLevelFrame.getMethod(), lowLevelFrame.getBCI(), locals, stack, locks, monitorIds, lowLevelFrame.rethrowException, false)); | |
15640
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1158 if (outterFrameState != null) { |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1159 frameState.setOuterFrameState(outterFrameState); |
14853 | 1160 } |
15640
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1161 Map<VirtualObject, VirtualObjectNode> virtualObjectsCopy; |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1162 // TODO this could be implemented more efficiently with a mark into the map |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1163 // unfortunately LinkedHashMap doesn't seem to provide that. |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1164 List<VirtualObjectState> virtualStates = new ArrayList<>(virtualObjects.size()); |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1165 do { |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1166 virtualObjectsCopy = new HashMap<>(virtualObjects); |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1167 virtualStates.clear(); |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1168 for (Entry<VirtualObject, VirtualObjectNode> entry : virtualObjectsCopy.entrySet()) { |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1169 VirtualObject virtualObject = entry.getKey(); |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1170 VirtualObjectNode virtualObjectNode = entry.getValue(); |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1171 List<ValueNode> fieldValues = Arrays.stream(virtualObject.getValues()).map(lirValueToHirNode).collect(Collectors.toList()); |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1172 virtualStates.add(new VirtualObjectState(virtualObjectNode, fieldValues)); |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1173 } |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1174 // New virtual objects may have been discovered while processing the previous set. |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1175 // Wait until a fixed point is reached |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1176 } while (virtualObjectsCopy.size() < virtualObjects.size()); |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1177 virtualStates.forEach(vos -> frameState.addVirtualObjectMapping(hostGraph.unique(vos))); |
14853 | 1178 return frameState; |
1179 } | |
1180 | |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15024
diff
changeset
|
1181 @SuppressWarnings("unused") |
14853 | 1182 private static MonitorIdNode getMonitorIdForHotSpotMonitorValueFromFrame(HotSpotMonitorValue lockValue, ParameterNode hsailFrame, StructuredGraph hsailGraph) { |
1183 if (lockValue.isEliminated()) { | |
1184 return null; | |
1185 } | |
1186 throw GraalInternalError.unimplemented(); | |
1187 } | |
1188 | |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1189 private static ValueNode getNodeForValueFromFrame(Value localValue, ParameterNode hsailFrame, StructuredGraph hostGraph, HotSpotProviders providers, HotSpotVMConfig config, int numSRegs, |
15640
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1190 int numDRegs, Map<VirtualObject, VirtualObjectNode> virtualObjects) { |
14853 | 1191 ValueNode valueNode; |
1192 if (localValue instanceof Constant) { | |
1193 valueNode = ConstantNode.forConstant((Constant) localValue, providers.getMetaAccess(), hostGraph); | |
1194 } else if (localValue instanceof VirtualObject) { | |
15640
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1195 valueNode = getNodeForVirtualObjectFromFrame((VirtualObject) localValue, virtualObjects, hostGraph); |
14853 | 1196 } else if (localValue instanceof StackSlot) { |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1197 StackSlot slot = (StackSlot) localValue; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1198 valueNode = getNodeForStackSlotFromFrame(slot, localValue.getKind(), hsailFrame, hostGraph, providers, config, numSRegs, numDRegs); |
14853 | 1199 } else if (localValue instanceof HotSpotMonitorValue) { |
1200 HotSpotMonitorValue hotSpotMonitorValue = (HotSpotMonitorValue) localValue; | |
15640
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1201 return getNodeForValueFromFrame(hotSpotMonitorValue.getOwner(), hsailFrame, hostGraph, providers, config, numSRegs, numDRegs, virtualObjects); |
14853 | 1202 } else if (localValue instanceof RegisterValue) { |
1203 RegisterValue registerValue = (RegisterValue) localValue; | |
1204 int regNumber = registerValue.getRegister().number; | |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1205 valueNode = getNodeForRegisterFromFrame(regNumber, localValue.getKind(), hsailFrame, hostGraph, providers, config, numSRegs); |
14853 | 1206 } else if (Value.ILLEGAL.equals(localValue)) { |
1207 valueNode = null; | |
1208 } else { | |
1209 throw GraalInternalError.shouldNotReachHere(); | |
1210 } | |
1211 return valueNode; | |
1212 } | |
1213 | |
15640
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1214 private static ValueNode getNodeForVirtualObjectFromFrame(VirtualObject virtualObject, Map<VirtualObject, VirtualObjectNode> virtualObjects, StructuredGraph hostGraph) { |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1215 return virtualObjects.computeIfAbsent(virtualObject, vo -> { |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1216 if (vo.getType().isArray()) { |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1217 return hostGraph.add(new VirtualArrayNode(vo.getType().getComponentType(), vo.getValues().length)); |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1218 } else { |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1219 return hostGraph.add(new VirtualInstanceNode(vo.getType(), true)); |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1220 } |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1221 }); |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1222 } |
2208a130d636
HSAIL Deopt support for VirtualObjects. Only create the host graph is there are deopts. Add a test provided by Tom Deneau.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15609
diff
changeset
|
1223 |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1224 private static ValueNode getNodeForRegisterFromFrame(int regNumber, Kind valueKind, ParameterNode hsailFrame, StructuredGraph hostGraph, HotSpotProviders providers, HotSpotVMConfig config, |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1225 int numSRegs) { |
14853 | 1226 ValueNode valueNode; |
1227 LocationNode location; | |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1228 int longSize = providers.getCodeCache().getTarget().arch.getSizeInBytes(Kind.Long); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1229 int intSize = providers.getCodeCache().getTarget().arch.getSizeInBytes(Kind.Int); |
14853 | 1230 if (regNumber >= HSAIL.s0.number && regNumber <= HSAIL.s31.number) { |
15545
9d456ffc6120
HSAIL: fixed Windows build
Doug Simon <doug.simon@oracle.com>
parents:
15482
diff
changeset
|
1231 long offset = config.hsailFrameHeaderSize + intSize * (regNumber - HSAIL.s0.number); |
14853 | 1232 location = ConstantLocationNode.create(FINAL_LOCATION, valueKind, offset, hostGraph); |
1233 } else if (regNumber >= HSAIL.d0.number && regNumber <= HSAIL.d15.number) { | |
15545
9d456ffc6120
HSAIL: fixed Windows build
Doug Simon <doug.simon@oracle.com>
parents:
15482
diff
changeset
|
1234 long offset = config.hsailFrameHeaderSize + intSize * numSRegs + longSize * (regNumber - HSAIL.d0.number); |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1235 location = ConstantLocationNode.create(FINAL_LOCATION, valueKind, offset, hostGraph); |
14853 | 1236 } else { |
1237 throw GraalInternalError.shouldNotReachHere("unknown hsail register: " + regNumber); | |
1238 } | |
1239 valueNode = hostGraph.unique(new FloatingReadNode(hsailFrame, location, null, StampFactory.forKind(valueKind))); | |
1240 return valueNode; | |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1241 } |
14809
73774616a6b3
Decoupled LIRGenerator and LIRGenerationResult.
Josef Eisl <josef.eisl@jku.at>
parents:
14804
diff
changeset
|
1242 |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1243 private static ValueNode getNodeForStackSlotFromFrame(StackSlot slot, Kind valueKind, ParameterNode hsailFrame, StructuredGraph hostGraph, HotSpotProviders providers, HotSpotVMConfig config, |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1244 int numSRegs, int numDRegs) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1245 int slotSizeInBits = (valueKind == Kind.Object ? 64 : valueKind.getByteCount() * 8); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1246 if ((slotSizeInBits == 32) || (slotSizeInBits == 64)) { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1247 int longSize = providers.getCodeCache().getTarget().arch.getSizeInBytes(Kind.Long); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1248 int intSize = providers.getCodeCache().getTarget().arch.getSizeInBytes(Kind.Int); |
15545
9d456ffc6120
HSAIL: fixed Windows build
Doug Simon <doug.simon@oracle.com>
parents:
15482
diff
changeset
|
1249 long offset = config.hsailFrameHeaderSize + (intSize * numSRegs) + (longSize * numDRegs) + HSAIL.getStackOffsetStart(slot, slotSizeInBits); |
15482
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1250 LocationNode location = ConstantLocationNode.create(FINAL_LOCATION, valueKind, offset, hostGraph); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1251 ValueNode valueNode = hostGraph.unique(new FloatingReadNode(hsailFrame, location, null, StampFactory.forKind(valueKind))); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1252 return valueNode; |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1253 } else { |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1254 throw GraalInternalError.shouldNotReachHere("unsupported stack slot kind: " + valueKind); |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1255 } |
a250a512434d
HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents:
15375
diff
changeset
|
1256 } |
10662
4ef92b67aeae
added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1257 } |