annotate graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java @ 18193:0a17944b7baf

Throw an exception if ResolvedJavaType.getImplementor() is called with a non-interface type.
author Josef Eisl <josef.eisl@jku.at>
date Thu, 30 Oct 2014 16:43:16 +0100
parents e75eb4720d4e
children d90c0904ff56
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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;
18176
c2270ad35f57 Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents: 18163
diff changeset
46 import com.oracle.graal.api.code.CompilationResult.DataSectionReference;
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
47 import com.oracle.graal.api.code.CompilationResult.ExceptionHandler;
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
48 import com.oracle.graal.api.code.CompilationResult.Infopoint;
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
49 import com.oracle.graal.api.code.CompilationResult.Mark;
18176
c2270ad35f57 Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents: 18163
diff changeset
50 import com.oracle.graal.api.code.DataSection.Data;
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
51 import com.oracle.graal.api.meta.*;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
52 import com.oracle.graal.asm.*;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
53 import com.oracle.graal.asm.hsail.*;
15193
96bb07a5d667 Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents: 15192
diff changeset
54 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
55 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
56 import com.oracle.graal.compiler.common.type.*;
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
57 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
58 import com.oracle.graal.debug.Debug.Scope;
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
59 import com.oracle.graal.gpu.*;
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
60 import com.oracle.graal.hotspot.*;
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
61 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
62 import com.oracle.graal.hotspot.meta.*;
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
63 import com.oracle.graal.hotspot.nodes.*;
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
64 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
65 import com.oracle.graal.java.*;
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
66 import com.oracle.graal.lir.*;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
67 import com.oracle.graal.lir.asm.*;
15292
a38d791982e1 Move LIRGenerationResult* to graal.lir.
Josef Eisl <josef.eisl@jku.at>
parents: 15261
diff changeset
68 import com.oracle.graal.lir.gen.*;
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents: 10662
diff changeset
69 import com.oracle.graal.lir.hsail.*;
15177
66e3af78ea96 HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents: 15157
diff changeset
70 import com.oracle.graal.lir.hsail.HSAILControlFlow.DeoptimizingOp;
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
71 import com.oracle.graal.nodes.*;
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
72 import com.oracle.graal.nodes.StructuredGraph.GuardsStage;
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
73 import com.oracle.graal.nodes.extended.*;
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
74 import com.oracle.graal.nodes.java.*;
15337
c4be3c1b2d6d Use NodeLIRBuilderTool instead of NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 15333
diff changeset
75 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
76 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
77 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
78 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
79 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
80 import com.oracle.graal.virtual.nodes.*;
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
81
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
82 /**
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
83 * HSAIL specific backend.
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
84 */
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
85 public class HSAILHotSpotBackend extends HotSpotBackend {
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
86
15066
2cae21d9f122 HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents: 15024
diff changeset
87 public static class Options {
2cae21d9f122 HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents: 15024
diff changeset
88
2cae21d9f122 HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents: 15024
diff changeset
89 // @formatter:off
16795
a29e6e7b7a86 Replace hsail donor threads with hsail tlabs
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16694
diff changeset
90 @Option(help = "Number of TLABs used for HSAIL kernels which allocate")
18163
c88ab4f1f04a re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents: 18155
diff changeset
91 public static final OptionValue<Integer> HsailKernelTlabs = new OptionValue<>(4);
15066
2cae21d9f122 HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents: 15024
diff changeset
92 // @formatter:on
2cae21d9f122 HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents: 15024
diff changeset
93 }
2cae21d9f122 HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents: 15024
diff changeset
94
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
95 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
96 private final boolean deviceInitialized;
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
97 // TODO: get maximum Concurrency from okra
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
98 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
99
12431
7080a96be216 rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents: 12429
diff changeset
100 public HSAILHotSpotBackend(HotSpotGraalRuntime runtime, HotSpotProviders providers) {
7080a96be216 rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents: 12429
diff changeset
101 super(runtime, providers);
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
102 paramTypeMap.put("HotSpotResolvedPrimitiveType<int>", "s32");
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
103 paramTypeMap.put("HotSpotResolvedPrimitiveType<float>", "f32");
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
104 paramTypeMap.put("HotSpotResolvedPrimitiveType<double>", "f64");
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
105 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
106
16076
06eedda53e14 HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents: 15846
diff changeset
107 /*
06eedda53e14 HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents: 15846
diff changeset
108 * 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
109 * 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
110 */
13819
49db2c1e3bee added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents: 13784
diff changeset
111 deviceInitialized = OkraUtil.okraLibExists() && initialize();
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
112 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
113
11775
b04b94b71649 Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents: 11739
diff changeset
114 @Override
b04b94b71649 Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents: 11739
diff changeset
115 public boolean shouldAllocateRegisters() {
b04b94b71649 Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents: 11739
diff changeset
116 return true;
b04b94b71649 Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents: 11739
diff changeset
117 }
b04b94b71649 Finished PTX assembler and Register -> Variable conversion
Morris Meyer <morris.meyer@oracle.com>
parents: 11739
diff changeset
118
13308
d3b3c6e17d40 HSAIL: added Math intrinsifications
Doug Simon <doug.simon@oracle.com>
parents: 13234
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 * Initializes the GPU device.
14774
8594b26fc5d8 fixed incorrect uses of Debug.log API
Doug Simon <doug.simon@oracle.com>
parents: 14768
diff changeset
121 *
13819
49db2c1e3bee added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents: 13784
diff changeset
122 * @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
123 */
49db2c1e3bee added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents: 13784
diff changeset
124 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
125
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 * 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
128 */
49db2c1e3bee added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents: 13784
diff changeset
129 public boolean isDeviceInitialized() {
49db2c1e3bee added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents: 13784
diff changeset
130 return deviceInitialized;
49db2c1e3bee added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents: 13784
diff changeset
131 }
49db2c1e3bee added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents: 13784
diff changeset
132
49db2c1e3bee added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents: 13784
diff changeset
133 /**
13308
d3b3c6e17d40 HSAIL: added Math intrinsifications
Doug Simon <doug.simon@oracle.com>
parents: 13234
diff changeset
134 * 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
135 * 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
136 */
12797
5341a7fca039 made HSAIL reuse HotSpotLoweringProvider, just with a different set of registers
Doug Simon <doug.simon@oracle.com>
parents: 12664
diff changeset
137 @Override
5341a7fca039 made HSAIL reuse HotSpotLoweringProvider, just with a different set of registers
Doug Simon <doug.simon@oracle.com>
parents: 12664
diff changeset
138 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
139 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
140 HotSpotVMConfig config = getRuntime().getConfig();
13308
d3b3c6e17d40 HSAIL: added Math intrinsifications
Doug Simon <doug.simon@oracle.com>
parents: 13234
diff changeset
141 // 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
142 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
143 lowerer.initialize(providers, config);
13308
d3b3c6e17d40 HSAIL: added Math intrinsifications
Doug Simon <doug.simon@oracle.com>
parents: 13234
diff changeset
144
d3b3c6e17d40 HSAIL: added Math intrinsifications
Doug Simon <doug.simon@oracle.com>
parents: 13234
diff changeset
145 // 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
146 HSAILHotSpotReplacementsImpl replacements = (HSAILHotSpotReplacementsImpl) providers.getReplacements();
bdeadcd7101d HSAIL: disable String.equals() substitutions
Doug Simon <doug.simon@oracle.com>
parents: 13900
diff changeset
147 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
148 }
5341a7fca039 made HSAIL reuse HotSpotLoweringProvider, just with a different set of registers
Doug Simon <doug.simon@oracle.com>
parents: 12664
diff changeset
149
11739
b8695542d41b added HSAIL register configuration
Doug Simon <doug.simon@oracle.com>
parents: 10956
diff changeset
150 /**
13784
219a84093dda moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents: 13318
diff changeset
151 * 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
152 */
219a84093dda moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents: 13318
diff changeset
153 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
154 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
155 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
156 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
157 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
158 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
159 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
160 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
161 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
162 } else {
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
163 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
164 }
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
165 }
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
166 } 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
167 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
168 }
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
169 return nm;
13784
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
219a84093dda moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents: 13318
diff changeset
172 /**
219a84093dda moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents: 13318
diff changeset
173 * 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
174 *
13784
219a84093dda moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents: 13318
diff changeset
175 * @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
176 * 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
177 * {@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
178 * @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
179 */
219a84093dda moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents: 13318
diff changeset
180 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
181 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
182 HotSpotProviders providers = getProviders();
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
183 MetaAccessProvider metaAccess = getProviders().getMetaAccess();
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
184
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
185 // 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
186 OptimisticOptimizations optimisticOpts = OptimisticOptimizations.ALL;
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
187 optimisticOpts.remove(OptimisticOptimizations.Optimization.UseExceptionProbabilityForOperations);
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
188 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
189 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
190 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
191
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
192 // append special HSAILNonNullParametersPhase
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
193 int numArgs = cc.getArguments().length;
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
194 graphBuilderSuite.appendPhase(new HSAILNonNullParametersPhase(numArgs));
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
195
13784
219a84093dda moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents: 13318
diff changeset
196 Suites suites = providers.getSuites().getDefaultSuites();
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
197 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
198 new ExternalCompilationResult(), CompilationResultBuilderFactory.Default);
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
199
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
200 // this code added to dump infopoints
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
201 try (Scope s = Debug.scope("CodeGen")) {
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
202 if (Debug.isLogEnabled()) {
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
203 // show infopoints
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
204 List<Infopoint> infoList = hsailCode.getInfopoints();
14774
8594b26fc5d8 fixed incorrect uses of Debug.log API
Doug Simon <doug.simon@oracle.com>
parents: 14768
diff changeset
205 Debug.log("%d HSAIL infopoints", infoList.size());
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
206 for (Infopoint info : infoList) {
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
207 Debug.log(info.toString());
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
208 Debug.log(info.debugInfo.frame().toString());
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
209 }
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
210 }
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
211 } catch (Throwable e) {
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
212 throw Debug.handle(e);
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
213 }
13784
219a84093dda moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents: 13318
diff changeset
214
219a84093dda moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents: 13318
diff changeset
215 if (makeBinary) {
13819
49db2c1e3bee added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents: 13784
diff changeset
216 if (!deviceInitialized) {
49db2c1e3bee added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents: 13784
diff changeset
217 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
218 }
13784
219a84093dda moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents: 13318
diff changeset
219 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
220 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
221 if (kernel == 0) {
219a84093dda moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents: 13318
diff changeset
222 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
223 }
219a84093dda moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents: 13318
diff changeset
224 hsailCode.setEntryPoint(kernel);
219a84093dda moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents: 13318
diff changeset
225 } catch (Throwable e) {
219a84093dda moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents: 13318
diff changeset
226 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
227 }
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 return hsailCode;
219a84093dda moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents: 13318
diff changeset
230 }
219a84093dda moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents: 13318
diff changeset
231
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
232 private static class HSAILNonNullParametersPhase extends Phase {
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
233 // 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
234 private int numArgs;
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
235
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
236 public HSAILNonNullParametersPhase(int numArgs) {
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
237 this.numArgs = numArgs;
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
238 }
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
239
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
240 @Override
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
241 protected void run(StructuredGraph graph) {
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
242 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
243 Stamp nonNull = StampFactory.objectNonNull();
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
244 for (ParameterNode param : graph.getNodes(ParameterNode.class)) {
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
245 argCount++;
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
246 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
247 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
248 param.setStamp(paramStamp.join(nonNull));
14768
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 }
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
252 }
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
253
13784
219a84093dda moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents: 13318
diff changeset
254 /**
13819
49db2c1e3bee added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents: 13784
diff changeset
255 * 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
256 */
16119
310994c667a7 HSAIL: support offloading some IntStream.reduce() operations to HSA
Doug Simon <doug.simon@oracle.com>
parents: 16094
diff changeset
257 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
258
49db2c1e3bee added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents: 13784
diff changeset
259 /**
13784
219a84093dda moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents: 13318
diff changeset
260 * 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
261 * 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
262 * the installed code.
14774
8594b26fc5d8 fixed incorrect uses of Debug.log API
Doug Simon <doug.simon@oracle.com>
parents: 14768
diff changeset
263 *
13784
219a84093dda moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents: 13318
diff changeset
264 * @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
265 * @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
266 */
219a84093dda moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents: 13318
diff changeset
267 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
268 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
269 // Code here based on HotSpotCodeCacheProvider.addExternalMethod().
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
270 HotSpotResolvedJavaMethod javaMethod = (HotSpotResolvedJavaMethod) method;
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
271 if (hsailCode.getId() == -1) {
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
272 hsailCode.setId(javaMethod.allocateCompileId(hsailCode.getEntryBCI()));
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
273 }
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
274 CompilationResult compilationResult = hsailCode;
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
275 StructuredGraph hostGraph = hsailCode.getHostGraph();
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
276 if (hostGraph != null) {
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
277 // 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
278 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
279 HotSpotBackend hostBackend = getRuntime().getHostBackend();
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
280 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
281 Debug.log("Param count: %d", parameterTypes.length);
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
282 for (int i = 0; i < parameterTypes.length; i++) {
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
283 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
284 Debug.log("Param [%d]=%s", i, parameter);
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
285 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
286 Debug.log(" %s", parameterTypes[i]);
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
287 }
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
288 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
289 hostBackend.getTarget(), false);
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
290 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
291 hostBackend.getProviders().getSuites().getDefaultGraphBuilderSuite(), OptimisticOptimizations.NONE, null, null,
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
292 hostBackend.getProviders().getSuites().getDefaultSuites(), new CompilationResult(), CompilationResultBuilderFactory.Default);
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
293 compilationResult = merge(hostCode, hsailCode);
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
294 } catch (Throwable e) {
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
295 throw Debug.handle(e);
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
296 }
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
297 }
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
298
15482
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
299 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
300 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
301 code.setUsesAllocationFlag(hsailCode.getUsesAllocationFlag());
18176
c2270ad35f57 Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents: 18163
diff changeset
302 HotSpotCompiledNmethod compiled = new HotSpotCompiledNmethod(javaMethod, compilationResult);
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
303 CodeInstallResult result = getRuntime().getCompilerToVM().installCode(compiled, code, null);
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
304 if (result != CodeInstallResult.OK) {
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
305 return null;
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 return code;
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
308 }
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
309
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
310 private static ExternalCompilationResult merge(CompilationResult hostCode, ExternalCompilationResult hsailCode) {
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
311 ExternalCompilationResult result = new ExternalCompilationResult();
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
312
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
313 // from hsail code
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
314 result.setEntryPoint(hsailCode.getEntryPoint());
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
315 result.setId(hsailCode.getId());
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
316 result.setEntryBCI(hsailCode.getEntryBCI());
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
317 assert hsailCode.getMarks().isEmpty();
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
318 assert hsailCode.getExceptionHandlers().isEmpty();
18176
c2270ad35f57 Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents: 18163
diff changeset
319 assert hsailCode.getDataPatches().isEmpty();
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
320
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
321 // from host code
15180
7a9531f50cd8 renamed com.oracle.graal.api.code.CompilationResult.frameSize to totalFrameSize
twisti
parents: 15177
diff changeset
322 result.setTotalFrameSize(hostCode.getTotalFrameSize());
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
323 result.setCustomStackAreaOffset(hostCode.getCustomStackAreaOffset());
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
324 result.setTargetCode(hostCode.getTargetCode(), hostCode.getTargetCodeSize());
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
325 for (CodeAnnotation annotation : hostCode.getAnnotations()) {
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
326 result.addAnnotation(annotation);
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
327 }
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
328 for (Mark mark : hostCode.getMarks()) {
15375
1b82cd9e72e9 Remove CompilationResult.Mark.references
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15338
diff changeset
329 result.recordMark(mark.pcOffset, mark.id);
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
330 }
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
331 for (ExceptionHandler handler : hostCode.getExceptionHandlers()) {
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
332 result.recordExceptionHandler(handler.pcOffset, handler.handlerPos);
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
333 }
18176
c2270ad35f57 Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents: 18163
diff changeset
334 for (DataPatch patch : hostCode.getDataPatches()) {
c2270ad35f57 Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents: 18163
diff changeset
335 if (patch.reference instanceof DataSectionReference) {
c2270ad35f57 Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents: 18163
diff changeset
336 Data hostData = hostCode.getDataSection().findData((DataSectionReference) patch.reference);
c2270ad35f57 Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents: 18163
diff changeset
337 Data resultData = new Data(hostData.getAlignment(), hostData.getSize(), hostData.getBuilder());
c2270ad35f57 Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents: 18163
diff changeset
338 patch.reference = result.getDataSection().insertData(resultData);
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
339 }
18176
c2270ad35f57 Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents: 18163
diff changeset
340 result.recordDataPatch(patch.pcOffset, patch.reference);
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
341 }
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
342 for (Infopoint infopoint : hostCode.getInfopoints()) {
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
343 if (infopoint instanceof Call) {
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
344 Call call = (Call) infopoint;
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
345 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
346 } else {
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
347 result.recordInfopoint(infopoint.pcOffset, infopoint.debugInfo, infopoint.reason);
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
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
351 // merged
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
352 Assumptions mergedAssumptions = new Assumptions(true);
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
353 if (hostCode.getAssumptions() != null) {
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
354 for (Assumption assumption : hostCode.getAssumptions().getAssumptions()) {
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
355 if (assumption != null) {
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
356 mergedAssumptions.record(assumption);
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 }
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
360 if (hsailCode.getAssumptions() != null) {
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
361 for (Assumption assumption : hsailCode.getAssumptions().getAssumptions()) {
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
362 if (assumption != null) {
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
363 mergedAssumptions.record(assumption);
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 }
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
367 if (!mergedAssumptions.isEmpty()) {
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
368 result.setAssumptions(mergedAssumptions);
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
369 }
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
370 return result;
13784
219a84093dda moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents: 13318
diff changeset
371 }
219a84093dda moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents: 13318
diff changeset
372
13819
49db2c1e3bee added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents: 13784
diff changeset
373 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
374 if (!deviceInitialized) {
49db2c1e3bee added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents: 13784
diff changeset
375 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
376 }
15482
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
377 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
378
16795
a29e6e7b7a86 Replace hsail donor threads with hsail tlabs
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16694
diff changeset
379 // Pass HsailKernelTlabs number if this kernel uses allocation, otherwise 0
a29e6e7b7a86 Replace hsail donor threads with hsail tlabs
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16694
diff changeset
380 int numTlabs = ((HSAILHotSpotNmethod) kernel).getUsesAllocationFlag() ? HsailKernelTlabs.getValue() : 0;
a29e6e7b7a86 Replace hsail donor threads with hsail tlabs
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16694
diff changeset
381 return executeKernel0(kernel, jobSize, args, numTlabs, 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
382 }
49db2c1e3bee added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents: 13784
diff changeset
383
16795
a29e6e7b7a86 Replace hsail donor threads with hsail tlabs
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16694
diff changeset
384 private static native boolean executeKernel0(HotSpotInstalledCode kernel, int jobSize, Object[] args, int numTlabs, 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
385 throws InvalidInstalledCodeException;
13819
49db2c1e3bee added support for co-existing GPU backends (JBS:GRAAL-1)
Doug Simon <doug.simon@oracle.com>
parents: 13784
diff changeset
386
18154
448be95baef8 Add Backend.newFrameMapBuilder().
Josef Eisl <josef.eisl@jku.at>
parents: 18151
diff changeset
387 @Override
448be95baef8 Add Backend.newFrameMapBuilder().
Josef Eisl <josef.eisl@jku.at>
parents: 18151
diff changeset
388 public FrameMapBuilder newFrameMapBuilder(RegisterConfig registerConfig) {
18155
115c9fac7542 Move FrameMapBuilderImpl to com.oracle.graal.lir.
Josef Eisl <josef.eisl@jku.at>
parents: 18154
diff changeset
389 return new FrameMapBuilderImpl(this::newFrameMap, getCodeCache(), registerConfig);
18154
448be95baef8 Add Backend.newFrameMapBuilder().
Josef Eisl <josef.eisl@jku.at>
parents: 18151
diff changeset
390 }
448be95baef8 Add Backend.newFrameMapBuilder().
Josef Eisl <josef.eisl@jku.at>
parents: 18151
diff changeset
391
13784
219a84093dda moved HSAIL compilation harness logic into HSAILHotSpotBackend and deleted HSAILCompilationResult
Doug Simon <doug.simon@oracle.com>
parents: 13318
diff changeset
392 /**
11739
b8695542d41b added HSAIL register configuration
Doug Simon <doug.simon@oracle.com>
parents: 10956
diff changeset
393 * 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
394 */
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
395 @Override
18154
448be95baef8 Add Backend.newFrameMapBuilder().
Josef Eisl <josef.eisl@jku.at>
parents: 18151
diff changeset
396 public FrameMap newFrameMap(FrameMapBuilder frameMapBuilder) {
448be95baef8 Add Backend.newFrameMapBuilder().
Josef Eisl <josef.eisl@jku.at>
parents: 18151
diff changeset
397 return new HSAILFrameMap(getCodeCache(), frameMapBuilder.getRegisterConfig());
10956
563c6d1994c0 added architecture specific frame maps
twisti
parents: 10662
diff changeset
398 }
563c6d1994c0 added architecture specific frame maps
twisti
parents: 10662
diff changeset
399
563c6d1994c0 added architecture specific frame maps
twisti
parents: 10662
diff changeset
400 @Override
15333
06ecedffb109 Use LIRGeneratorTool in Backend.
Josef Eisl <josef.eisl@jku.at>
parents: 15311
diff changeset
401 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
402 return new HSAILHotSpotLIRGenerator(getProviders(), getRuntime().getConfig(), cc, lirGenRes);
14809
73774616a6b3 Decoupled LIRGenerator and LIRGenerationResult.
Josef Eisl <josef.eisl@jku.at>
parents: 14804
diff changeset
403 }
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 @Override
18151
04b54406c292 Use FrameMapBuilder in Backend.newLIRGenerationResult().
Josef Eisl <josef.eisl@jku.at>
parents: 18148
diff changeset
406 public LIRGenerationResult newLIRGenerationResult(LIR lir, FrameMapBuilder frameMapBuilder, ResolvedJavaMethod method, Object stub) {
04b54406c292 Use FrameMapBuilder in Backend.newLIRGenerationResult().
Josef Eisl <josef.eisl@jku.at>
parents: 18148
diff changeset
407 return new HSAILHotSpotLIRGenerationResult(lir, frameMapBuilder);
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
408 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
409
14846
43cd57700476 Apply LIRGenerator refactoring to HSAIL backend.
Josef Eisl <josef.eisl@jku.at>
parents: 14809
diff changeset
410 @Override
15338
5e544920ad9f Rename Backend.newNodeLIRGenerator to Backend.newNodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 15337
diff changeset
411 public NodeLIRBuilderTool newNodeLIRBuilder(StructuredGraph graph, LIRGeneratorTool lirGen) {
14921
88dfaf6448e0 Remove LIRGenerationResult from NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 14888
diff changeset
412 return new HSAILHotSpotNodeLIRBuilder(graph, lirGen);
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
413 }
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 class HotSpotFrameContext implements FrameContext {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
416
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
417 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
418 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
419 }
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
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
421 @Override
13227
1a66453f73db renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents: 13105
diff changeset
422 public void enter(CompilationResultBuilder crb) {
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
423 Debug.log("Nothing to do here");
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
424 }
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 @Override
13227
1a66453f73db renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents: 13105
diff changeset
427 public void leave(CompilationResultBuilder crb) {
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
428 Debug.log("Nothing to do here");
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
429 }
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
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
432 /**
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
433 * a class to allow us to save lirGen.
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
434 */
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
435 static class HSAILCompilationResultBuilder extends CompilationResultBuilder {
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
436 public HSAILHotSpotLIRGenerationResult lirGenRes;
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
437
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
438 public HSAILCompilationResultBuilder(CodeCacheProvider codeCache, ForeignCallsProvider foreignCalls, FrameMap frameMap, Assembler asm, FrameContext frameContext,
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
439 CompilationResult compilationResult, HSAILHotSpotLIRGenerationResult lirGenRes) {
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
440 super(codeCache, foreignCalls, frameMap, asm, frameContext, compilationResult);
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
441 this.lirGenRes = lirGenRes;
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
442 }
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
15482
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
445 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
446 private int[] oopMapArray;
16076
06eedda53e14 HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents: 15846
diff changeset
447 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
448
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
449 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
450 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
451 }
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 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
454 oopMapArray = array;
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
455 }
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 int[] getOopMapArray() {
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
458 return oopMapArray;
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
459 }
16076
06eedda53e14 HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents: 15846
diff changeset
460
06eedda53e14 HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents: 15846
diff changeset
461 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
462 usesAllocation = val;
06eedda53e14 HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents: 15846
diff changeset
463 }
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 public boolean getUsesAllocationFlag() {
06eedda53e14 HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents: 15846
diff changeset
466 return usesAllocation;
06eedda53e14 HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents: 15846
diff changeset
467 }
15482
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
468 }
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
469
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
470 @Override
14032
d1c1f103d42c renamed com.oracle.graal.asm.AbstractAssembler to com.oracle.graal.asm.Assembler
twisti
parents: 14031
diff changeset
471 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
472 return new HSAILHotSpotAssembler(getTarget());
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
473 }
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 @Override
18148
aed00dc20923 Pass FrameMap to Backend.newCompilationResultBuilder().
Josef Eisl <josef.eisl@jku.at>
parents: 18147
diff changeset
476 public CompilationResultBuilder newCompilationResultBuilder(LIRGenerationResult lirGenRes, FrameMap frameMap, CompilationResult compilationResult, CompilationResultBuilderFactory factory) {
14032
d1c1f103d42c renamed com.oracle.graal.asm.AbstractAssembler to com.oracle.graal.asm.Assembler
twisti
parents: 14031
diff changeset
477 Assembler masm = createAssembler(frameMap);
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
478 HotSpotFrameContext frameContext = new HotSpotFrameContext();
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
479 // save lirGen for later use by setHostGraph
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
480 CompilationResultBuilder crb = new HSAILCompilationResultBuilder(getCodeCache(), getForeignCalls(), frameMap, masm, frameContext, compilationResult,
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
481 (HSAILHotSpotLIRGenerationResult) lirGenRes);
15180
7a9531f50cd8 renamed com.oracle.graal.api.code.CompilationResult.frameSize to totalFrameSize
twisti
parents: 15177
diff changeset
482 crb.setTotalFrameSize(frameMap.totalFrameSize());
13227
1a66453f73db renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents: 13105
diff changeset
483 return crb;
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
484 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
485
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
486 @Override
14065
5dec26f3d4a4 Use LIR instead of LIRGenerator as parameter in emitCode.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14032
diff changeset
487 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
488 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
489 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
490 LIRKind wordLIRKind = LIRKind.value(wordKind);
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
491
15066
2cae21d9f122 HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents: 15024
diff changeset
492 HotSpotVMConfig config = getRuntime().getConfig();
2cae21d9f122 HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents: 15024
diff changeset
493 boolean useHSAILDeoptimization = config.useHSAILDeoptimization;
15177
66e3af78ea96 HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents: 15157
diff changeset
494 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
495
15846
399aa56c6366 HSAIL: fix for -UseHSAILDeoptimization
twisti
parents: 15838
diff changeset
496 if ((useHSAILSafepoints == true) && (useHSAILDeoptimization == false)) {
399aa56c6366 HSAIL: fix for -UseHSAILDeoptimization
twisti
parents: 15838
diff changeset
497 Debug.log("+UseHSAILSafepoints requires +UseHSAILDeoptimization");
399aa56c6366 HSAIL: fix for -UseHSAILDeoptimization
twisti
parents: 15838
diff changeset
498 }
399aa56c6366 HSAIL: fix for -UseHSAILDeoptimization
twisti
parents: 15838
diff changeset
499
16076
06eedda53e14 HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents: 15846
diff changeset
500 /*
06eedda53e14 HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents: 15846
diff changeset
501 * 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
502 * 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
503 */
06eedda53e14 HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents: 15846
diff changeset
504 boolean usesAllocation = false;
15066
2cae21d9f122 HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents: 15024
diff changeset
505 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
506 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
507 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
508 usesAllocation = true;
15066
2cae21d9f122 HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents: 15024
diff changeset
509 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
510 break search;
2cae21d9f122 HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents: 15024
diff changeset
511 }
2cae21d9f122 HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents: 15024
diff changeset
512 }
2cae21d9f122 HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents: 15024
diff changeset
513 }
16076
06eedda53e14 HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents: 15846
diff changeset
514 // 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
515 ((ExternalCompilationResult) crb.compilationResult).setUsesAllocationFlag(usesAllocation);
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
516
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
517 // Emit the prologue.
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
518 HSAILAssembler asm = (HSAILAssembler) crb.asm;
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
519 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
520
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
521 Signature signature = method.getSignature();
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
522 int sigParamCount = signature.getParameterCount(false);
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
523 // 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
524
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
525 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
526 boolean isStatic = (method.isStatic());
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
527 // Determine if this is an object lambda.
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
528 boolean isObjectLambda = true;
13105
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
529
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
530 if (signature.getParameterType(nonConstantParamCount, null).getKind() == Kind.Int) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
531 isObjectLambda = false;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
532 } else {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
533 // Add space for gid int reg.
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
534 nonConstantParamCount++;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
535 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
536
16076
06eedda53e14 HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents: 15846
diff changeset
537 // 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
538 if (!isStatic) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
539 nonConstantParamCount++;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
540 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
541 // Add in any "constant" parameters (currently none).
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
542 int totalParamCount = nonConstantParamCount;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
543 JavaType[] paramtypes = new JavaType[totalParamCount];
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
544 String[] paramNames = new String[totalParamCount];
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
545 int pidx = 0;
13105
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
546 MetaAccessProvider metaAccess = getProviders().getMetaAccess();
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
547 for (int i = 0; i < totalParamCount; i++) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
548 if (i == 0 && !isStatic) {
12363
78e5badf4b8e moved lookupForeignCall() from CodeCacheProvider to ForeignCallsProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 12045
diff changeset
549 paramtypes[i] = metaAccess.lookupJavaType(Object.class);
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
550 paramNames[i] = "%_this";
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
551 } else if (i < nonConstantParamCount) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
552 if (isObjectLambda && (i == (nonConstantParamCount))) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
553 // 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
554 paramtypes[i] = metaAccess.lookupJavaType(int.class);
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
555 paramNames[i] = "%_gid";
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
556 } else {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
557 paramtypes[i] = signature.getParameterType(pidx++, null);
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
558 paramNames[i] = "%_arg" + i;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
559 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
560 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
561 }
13105
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
562
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
563 asm.emitString0("// " + (isStatic ? "static" : "instance") + " method " + method + "\n");
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
564 asm.emitString0("kernel &run ( \n");
13105
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
565
13227
1a66453f73db renamed TargetMethodAssembler to CompilationResultBuilder
Doug Simon <doug.simon@oracle.com>
parents: 13105
diff changeset
566 FrameMap frameMap = crb.frameMap;
18123
3c7e73362d6a Encapsulate FrameMap.registerConfig & FrameMap.target.
Josef Eisl <josef.eisl@jku.at>
parents: 16895
diff changeset
567 RegisterConfig regConfig = frameMap.getRegisterConfig();
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
568 // 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
569 JavaType[] ccParamTypes = new JavaType[nonConstantParamCount + 1];
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
570 // Include the gid.
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
571 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
572
16076
06eedda53e14 HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents: 15846
diff changeset
573 /*
06eedda53e14 HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents: 15846
diff changeset
574 * 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
575 * 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
576 */
13105
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
577 if (sigParamCount > 0) {
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
578 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
579 }
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 12363
diff changeset
580 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
581
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
582 /**
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
583 * 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
584 * (which is the gid).
14774
8594b26fc5d8 fixed incorrect uses of Debug.log API
Doug Simon <doug.simon@oracle.com>
parents: 14768
diff changeset
585 *
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
586 */
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
587 String[] paramHsailSizes = new String[totalParamCount];
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
588 for (int i = 0; i < totalParamCount; i++) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
589 String paramtypeStr = paramtypes[i].toString();
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
590 String sizeStr = paramTypeMap.get(paramtypeStr);
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
591 // 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
592 paramHsailSizes[i] = (sizeStr != null ? sizeStr : "u64");
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
593 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
594 // Emit the kernel function parameters.
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
595 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
596 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
597
14969
a6c144380ce7 HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14945
diff changeset
598 if (useHSAILDeoptimization || (i != totalParamCount - 1)) {
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
599 str += ",";
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
600 }
14031
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13902
diff changeset
601 asm.emitString(str);
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
602 }
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
603
14969
a6c144380ce7 HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14945
diff changeset
604 if (useHSAILDeoptimization) {
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
605 // add in the deoptInfo parameter
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
606 asm.emitString("kernarg_u64 " + asm.getDeoptInfoName());
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
607 }
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
608
14031
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13902
diff changeset
609 asm.emitString(") {");
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
610
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
611 /*
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
612 * 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
613 * 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
614 * loaded up front but will be loaded as needed.
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
615 */
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
616 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
617 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
618 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
619
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 * 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
622 * 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
623 */
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
624 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
625 asm.emitString("workitemabsid_u32 " + workItemReg + ", 0;");
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
626
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
627 final String deoptInProgressLabel = "@LHandleDeoptInProgress";
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
628
14969
a6c144380ce7 HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14945
diff changeset
629 if (useHSAILDeoptimization) {
15066
2cae21d9f122 HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents: 15024
diff changeset
630 // Aliases for d16
18163
c88ab4f1f04a re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents: 18155
diff changeset
631 RegisterValue d16DeoptInfo = 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
632
2cae21d9f122 HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents: 15024
diff changeset
633 // Aliases for d17
18163
c88ab4f1f04a re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents: 18155
diff changeset
634 RegisterValue d17TlabIndex = HSAIL.d17.asValue(wordLIRKind);
c88ab4f1f04a re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents: 18155
diff changeset
635 RegisterValue d17SafepointFlagAddrIndex = d17TlabIndex;
15066
2cae21d9f122 HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents: 15024
diff changeset
636
2cae21d9f122 HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents: 15024
diff changeset
637 // Aliases for s34
18163
c88ab4f1f04a re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents: 18155
diff changeset
638 RegisterValue s34DeoptOccurred = HSAIL.s34.asValue(LIRKind.value(Kind.Int));
c88ab4f1f04a re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents: 18155
diff changeset
639 RegisterValue s34TlabIndex = s34DeoptOccurred;
15066
2cae21d9f122 HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents: 15024
diff changeset
640
18163
c88ab4f1f04a re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents: 18155
diff changeset
641 asm.emitLoadKernelArg(d16DeoptInfo, asm.getDeoptInfoName(), "u64");
15177
66e3af78ea96 HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents: 15157
diff changeset
642 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
643
66e3af78ea96 HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents: 15157
diff changeset
644 if (useHSAILSafepoints) {
66e3af78ea96 HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents: 15157
diff changeset
645 // Load address of _notice_safepoints field
18163
c88ab4f1f04a re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents: 18155
diff changeset
646 asm.emitLoad(wordKind, d17SafepointFlagAddrIndex, new HSAILAddressValue(wordLIRKind, d16DeoptInfo, config.hsailNoticeSafepointsOffset).toAddress());
15177
66e3af78ea96 HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents: 15157
diff changeset
647 // Load int value from that field
18163
c88ab4f1f04a re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents: 18155
diff changeset
648 asm.emitLoadAcquire(s34DeoptOccurred, new HSAILAddressValue(wordLIRKind, d17SafepointFlagAddrIndex, 0).toAddress());
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18176
diff changeset
649 asm.emitCompare(Kind.Int, s34DeoptOccurred, JavaConstant.forInt(0), "ne", false, false);
15177
66e3af78ea96 HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents: 15157
diff changeset
650 asm.cbr(deoptInProgressLabel);
66e3af78ea96 HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents: 15157
diff changeset
651 }
18163
c88ab4f1f04a re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents: 18155
diff changeset
652 asm.emitLoadAcquire(s34DeoptOccurred, new HSAILAddressValue(wordLIRKind, d16DeoptInfo, config.hsailDeoptOccurredOffset).toAddress());
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18176
diff changeset
653 asm.emitCompare(Kind.Int, s34DeoptOccurred, JavaConstant.forInt(0), "ne", false, false);
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
654 asm.cbr(deoptInProgressLabel);
16076
06eedda53e14 HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents: 15846
diff changeset
655 // 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
656 if (usesAllocation) {
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16077
diff changeset
657 RegisterValue threadReg = getProviders().getRegisters().getThreadRegister().asValue(wordLIRKind);
16795
a29e6e7b7a86 Replace hsail donor threads with hsail tlabs
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16694
diff changeset
658 assert HsailKernelTlabs.getValue() > 0;
18163
c88ab4f1f04a re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents: 18155
diff changeset
659 asm.emitLoad(wordKind, threadReg, new HSAILAddressValue(wordLIRKind, d16DeoptInfo, config.hsailCurTlabInfoOffset).toAddress());
16795
a29e6e7b7a86 Replace hsail donor threads with hsail tlabs
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16694
diff changeset
660 if (HsailKernelTlabs.getValue() != 1) {
a29e6e7b7a86 Replace hsail donor threads with hsail tlabs
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16694
diff changeset
661 asm.emitComment("// map workitem to a tlab");
18163
c88ab4f1f04a re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents: 18155
diff changeset
662 asm.emitString(String.format("rem_u32 $%s, %s, %d;", s34TlabIndex.getRegister(), workItemReg, HsailKernelTlabs.getValue()));
c88ab4f1f04a re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents: 18155
diff changeset
663 asm.emitConvert(d17TlabIndex, s34TlabIndex, wordKind, Kind.Int);
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18176
diff changeset
664 asm.emit("mad", threadReg, d17TlabIndex, JavaConstant.forInt(8), threadReg);
15066
2cae21d9f122 HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents: 15024
diff changeset
665 } else {
16795
a29e6e7b7a86 Replace hsail donor threads with hsail tlabs
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16694
diff changeset
666 // workitem is already mapped to solitary tlab
15066
2cae21d9f122 HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents: 15024
diff changeset
667 }
16076
06eedda53e14 HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents: 15846
diff changeset
668 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
669 }
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
670 }
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
671
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
672 /*
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
673 * 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
674 * 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
675 * 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
676 */
14031
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13902
diff changeset
677 int spillsegDeclarationPosition = asm.position() + 1;
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
678 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
679 asm.emitString(spillsegTemplate);
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
680 // Emit object array load prologue here.
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
681 if (isObjectLambda) {
15066
2cae21d9f122 HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents: 15024
diff changeset
682 boolean useCompressedOops = config.useCompressedOops;
2cae21d9f122 HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents: 15024
diff changeset
683 final int arrayElementsOffset = HotSpotGraalRuntime.getArrayBaseOffset(wordKind);
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
684 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
685 /*
06eedda53e14 HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents: 15846
diff changeset
686 * 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
687 * 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
688 * 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
689 * workItemReg+1;
16076
06eedda53e14 HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents: 15846
diff changeset
690 */
13105
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
691 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
692 // 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
693 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
694 // 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
695 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
696 // 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
697 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
698 // 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
699 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
700 // 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
701 if (useCompressedOops) {
16694
a53c26c989d0 HSAIL: miscellaneous HSAIL test tweaks and fixes:
Doug Simon <doug.simon@oracle.com>
parents: 16569
diff changeset
702 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
703 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
704
16694
a53c26c989d0 HSAIL: miscellaneous HSAIL test tweaks and fixes:
Doug Simon <doug.simon@oracle.com>
parents: 16569
diff changeset
705 // 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
706
a53c26c989d0 HSAIL: miscellaneous HSAIL test tweaks and fixes:
Doug Simon <doug.simon@oracle.com>
parents: 16569
diff changeset
707 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
708 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
709
15066
2cae21d9f122 HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents: 15024
diff changeset
710 long narrowOopBase = config.narrowOopBase;
2cae21d9f122 HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents: 15024
diff changeset
711 long narrowOopShift = config.narrowOopShift;
13105
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
712
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
713 if (narrowOopBase == 0 && narrowOopShift == 0) {
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
714 // 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
715 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
716 } else {
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
717 if (narrowOopBase == 0) {
14031
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13902
diff changeset
718 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
719 } else if (narrowOopShift == 0) {
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
720 // 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
721 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
722 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
723 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
724 } else {
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
725 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
726 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
727 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
728 }
d3fc35a43376 HSAIL: addressed issues in JUnit tests
Doug Simon <doug.simon@oracle.com>
parents: 12797
diff changeset
729 }
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 } else {
14031
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13902
diff changeset
732 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
733 }
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
734 }
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
735 // 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
736 crb.emit(lir);
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
737 // 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
738 long maxStackSize = ((HSAILAssembler) crb.asm).upperBoundStackSize();
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
739 String spillsegStringFinal;
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
740 if (maxStackSize == 0) {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
741 // If no spilling, get rid of spillseg declaration.
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
742 char[] array = new char[spillsegTemplate.length()];
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
743 Arrays.fill(array, ' ');
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
744 spillsegStringFinal = new String(array);
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
745 } else {
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
746 spillsegStringFinal = spillsegTemplate.replace("123456", String.format("%6d", maxStackSize));
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
747 }
14031
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13902
diff changeset
748 asm.emitString(spillsegStringFinal, spillsegDeclarationPosition);
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
749 // Emit the epilogue.
14031
390c4b742890 made com.oracle.graal.asm.Buffer non-public and a private field in AbstractAssembler
twisti
parents: 13902
diff changeset
750
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
751 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
752
15482
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
753 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
754 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
755 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
756 if (useHSAILDeoptimization) {
16076
06eedda53e14 HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents: 15846
diff changeset
757 /*
16077
2d296658a24e HSAIL: enable arraycopy support in backend
Doug Simon <doug.simon@oracle.com>
parents: 16076
diff changeset
758 * 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
759 * 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
760 */
15482
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
761 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
762 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
763 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
764 List<Infopoint> infoList = crb.compilationResult.getInfopoints();
18189
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
765 Queue<JavaValue[]> 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
766 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
767 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
768 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
769 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
770 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
771 }
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 }
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 while (!workList.isEmpty()) {
18189
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
774 JavaValue[] values = workList.poll();
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
775 for (JavaValue val : values) {
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
776 if (!Value.ILLEGAL.equals(val)) {
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
777 if (val instanceof RegisterValue) {
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
778 Register reg = ((RegisterValue) val).getRegister();
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
779 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
780 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
781 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
782 } 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
783 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
784 }
18189
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
785 } else if (val instanceof StackSlot) {
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
786 StackSlot slot = (StackSlot) val;
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 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
788 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
789 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
790 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
791 infoUsedStackSlots.add(slot);
18189
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
792 } else if (val 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
793 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
794 } else {
18189
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
795 assert val instanceof JavaConstant : "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
796 }
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
797 }
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 // 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
802 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
803
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
804 // 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
805 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
806
15609
66d31e70bd79 HSAIL: fixed deopt bug; cleaned up C++ code
Doug Simon <doug.simon@oracle.com>
parents: 15545
diff changeset
807 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
808 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
809 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
810 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
811 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
812 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
813 final int offsetToDeoptimizationReason = config.hsailDeoptimizationReason;
15545
9d456ffc6120 HSAIL: fixed Windows build
Doug Simon <doug.simon@oracle.com>
parents: 15482
diff changeset
814 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
815 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
816 final int offsetToNumSaves = config.hsailFrameNumSRegOffset;
15545
9d456ffc6120 HSAIL: fixed Windows build
Doug Simon <doug.simon@oracle.com>
parents: 15482
diff changeset
817 final int offsetToSaveArea = config.hsailFrameHeaderSize;
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
818
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16077
diff changeset
819 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
820 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
821 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
822 AllocatableValue waveMathScratch2 = HSAIL.d19.asValue(wordLIRKind);
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
823
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16077
diff changeset
824 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
825 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
826 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
827 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
828
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16077
diff changeset
829 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
830 HSAILAddress neverRanArrayAddr = new HSAILAddressValue(wordLIRKind, scratch64, offsetToNeverRanArray).toAddress();
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
831
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
832 // 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
833 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
834 asm.emitLoad(wordKind, waveMathScratch1, neverRanArrayAddr);
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
835 asm.emitWorkItemAbsId(workidreg);
15066
2cae21d9f122 HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents: 15024
diff changeset
836 asm.emitConvert(waveMathScratch2, workidreg, wordKind, Kind.Int);
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
837 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
838 HSAILAddress neverRanStoreAddr = new HSAILAddressValue(wordLIRKind, waveMathScratch1, 0).toAddress();
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18176
diff changeset
839 asm.emitStore(Kind.Byte, JavaConstant.forInt(1), neverRanStoreAddr);
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
840 asm.emitString("ret;");
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
841
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
842 // The deoptimizing lanes will jump here
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
843 asm.emitString0(asm.getDeoptLabelName() + ":\n");
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
844 String labelExit = asm.getDeoptLabelName() + "_Exit";
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
845
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16077
diff changeset
846 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
847 asm.emitLoadKernelArg(scratch64, asm.getDeoptInfoName(), "u64");
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
848
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
849 // Set deopt occurred flag
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18176
diff changeset
850 asm.emitMov(Kind.Int, scratch32, JavaConstant.forInt(1));
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
851 asm.emitStoreRelease(scratch32, deoptInfoAddr);
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
852
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
853 asm.emitComment("// Determine next deopt save slot");
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18176
diff changeset
854 asm.emitAtomicAdd(scratch32, deoptNextIndexAddr, JavaConstant.forInt(1));
16076
06eedda53e14 HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents: 15846
diff changeset
855 /*
06eedda53e14 HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents: 15846
diff changeset
856 * 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
857 */
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
858 asm.emitComment("// assert room to save deopt");
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18176
diff changeset
859 asm.emitCompare(Kind.Int, scratch32, JavaConstant.forInt(maxDeoptIndex), "lt", false, false);
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
860 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
861 /*
06eedda53e14 HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents: 15846
diff changeset
862 * 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
863 * flag
06eedda53e14 HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents: 15846
diff changeset
864 */
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
865 asm.emitWorkItemAbsId(scratch32);
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18176
diff changeset
866 asm.emit("mad", scratch32, scratch32, JavaConstant.forInt(-1), JavaConstant.forInt(-1));
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
867 asm.emitStore(scratch32, deoptInfoAddr);
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
868 asm.emitString("ret;");
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
869
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
870 asm.emitString0("@L_StoreDeopt" + ":\n");
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 // 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
873
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
874 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
875 asm.emitConvert(cuSaveAreaPtr, scratch32, wordKind, Kind.Int);
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
876 asm.emitComment("// multiply by sizeof KernelDeoptArea");
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18176
diff changeset
877 asm.emit("mul", cuSaveAreaPtr, cuSaveAreaPtr, JavaConstant.forInt(sizeofKernelDeopt));
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
878 asm.emitComment("// Add computed offset to deoptInfoPtr base");
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
879 asm.emit("add", cuSaveAreaPtr, cuSaveAreaPtr, scratch64);
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
880 // Add offset to _deopt_save_states[0]
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18176
diff changeset
881 asm.emit("add", scratch64, cuSaveAreaPtr, JavaConstant.forInt(offsetToDeoptSaveStates));
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
882
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16077
diff changeset
883 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
884 HSAILAddress actionReasonStoreAddr = new HSAILAddressValue(wordLIRKind, scratch64, offsetToDeoptimizationReason).toAddress();
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
885
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
886 asm.emitComment("// Get _deopt_info._first_frame");
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18176
diff changeset
887 asm.emit("add", waveMathScratch1, scratch64, JavaConstant.forInt(offsetToDeoptimizationFrame));
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
888 // 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
889 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
890 HSAILAddress regCountsAddr = new HSAILAddressValue(wordLIRKind, waveMathScratch1, offsetToNumSaves).toAddress();
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
891 asm.emitComment("// store deopting workitem");
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
892 asm.emitWorkItemAbsId(scratch32);
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
893 asm.emitStore(Kind.Int, scratch32, workItemAddr);
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
894 asm.emitComment("// store actionAndReason");
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
895 asm.emitStore(Kind.Int, actionAndReasonReg, actionReasonStoreAddr);
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
896 asm.emitComment("// store PC");
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
897 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
898
15609
66d31e70bd79 HSAIL: fixed deopt bug; cleaned up C++ code
Doug Simon <doug.simon@oracle.com>
parents: 15545
diff changeset
899 asm.emitComment("// store regCounts (" + numSRegs + " $s registers, " + numDRegs + " $d registers, " + numStackSlots + " stack slots)");
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18176
diff changeset
900 asm.emitStore(Kind.Int, JavaConstant.forInt(numSRegs + (numDRegs << 8) + (numStackSlots << 16)), regCountsAddr);
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
901
16076
06eedda53e14 HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents: 15846
diff changeset
902 /*
06eedda53e14 HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents: 15846
diff changeset
903 * 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
904 * 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
905 */
15482
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
906 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
907 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
908 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
909 // 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
910 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
911 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
912 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
913 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
914 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
915 } 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
916 // 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
917 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
918 // 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
919 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
920 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
921 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
922 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
923 } else {
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
924 throw GraalInternalError.unimplemented();
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
925 }
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
926 }
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
927
15482
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
928 // 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
929 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
930 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
931 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
932 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
933 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
934 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
935 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
936 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
937 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
938 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
939 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
940 } else {
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
941 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
942 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
943 }
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
944 }
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
945 }
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 asm.emitString0(labelExit + ":\n");
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 // and emit the return
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
950 crb.frameContext.leave(crb);
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
951 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
952 // 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
953 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
954 ((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
955 } else {
a6c144380ce7 HSAIL: added UseHSAILDeoptimization VM option for disabling HSAIL deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14945
diff changeset
956 // 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
957 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
958 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
959 asm.emitString("ret;");
14768
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
960 }
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
961
3e9a960f0da1 HSAIL: preliminary deopt support
Doug Simon <doug.simon@oracle.com>
parents: 14143
diff changeset
962 asm.emitString0("}; \n");
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 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
965 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
966 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
967 }
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
968 }
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
969
15482
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
970 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
971 // oopMapArray struct
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
972 // 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
973 // int intsPerInfopoint;
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
974 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
975 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
976 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
977 // 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
978 // int deoptId
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
979 // 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
980
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
981 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
982 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
983
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
984 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
985 /*
06eedda53e14 HSAIL: add support to allocate new TLAB from GPU
Doug Simon <doug.simon@oracle.com>
parents: 15846
diff changeset
986 * 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
987 * 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
988 * 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
989 */
15482
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
990 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
991 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
992 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
993 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
994 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
995 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
996 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
997 // compute saveAreaCounts
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
998 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
999 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
1000
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
1001 // 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
1002 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
1003 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
1004 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
1005 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
1006 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
1007 for (int i = 0; i < frame.numLocals + frame.numStack; i++) {
18189
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
1008 JavaValue val = frame.values[i];
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
1009 if (val instanceof RegisterValue) {
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
1010 Register reg = ((RegisterValue) val).getRegister();
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
1011 if (val.getKind().isObject()) {
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
1012 assert (hsailRegConfig.isAllocatableDReg(reg));
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
1013 int bitIndex = reg.encoding();
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
1014 setOopMapBit(infoIndex, bitIndex);
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
1015 }
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
1016 } else if (val instanceof StackSlot) {
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
1017 StackSlot slot = (StackSlot) val;
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
1018 if (val.getKind().isObject()) {
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
1019 assert (HSAIL.getStackOffsetStart(slot, 64) % 8 == 0);
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
1020 int bitIndex = numDRegs + HSAIL.getStackOffsetStart(slot, 64) / 8;
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
1021 setOopMapBit(infoIndex, bitIndex);
15482
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
1022 }
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
1023 }
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
1024 }
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
1025 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
1026 }
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
1027 infoIndex++;
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 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
1030 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
1031 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
1032 // 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
1033 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
1034 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
1035 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
1036 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
1037 }
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
1038 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
1039 }
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
1040 }
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
1041 } 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
1042 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
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 return array;
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
1046 }
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 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
1049 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
1050 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
1051 }
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
1052
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
1053 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
1054 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
1055 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
1056 }
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
1057
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
1058 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
1059 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
1060 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
1061 }
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
1062
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
1063 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
1064 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
1065 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
1066 }
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
1067 }
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
1068
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
1069 private static StructuredGraph prepareHostGraph(ResolvedJavaMethod method, List<DeoptimizingOp> deopts, HotSpotProviders providers, HotSpotVMConfig config, int numSRegs, int numDRegs) {
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1070 if (deopts.isEmpty()) {
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1071 return null;
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1072 }
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1073 StructuredGraph hostGraph = new StructuredGraph(method, -2);
16895
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16795
diff changeset
1074 ParameterNode deoptId = hostGraph.unique(ParameterNode.create(0, StampFactory.intValue()));
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16795
diff changeset
1075 ParameterNode hsailFrame = hostGraph.unique(ParameterNode.create(1, StampFactory.forKind(providers.getCodeCache().getTarget().wordKind)));
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16795
diff changeset
1076 ParameterNode reasonAndAction = hostGraph.unique(ParameterNode.create(2, StampFactory.intValue()));
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16795
diff changeset
1077 ParameterNode speculation = hostGraph.unique(ParameterNode.create(3, StampFactory.object()));
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15132
diff changeset
1078 BeginNode[] branches = new BeginNode[deopts.size() + 1];
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1079 int[] keys = new int[deopts.size()];
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1080 int[] keySuccessors = new int[deopts.size() + 1];
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1081 double[] keyProbabilities = new double[deopts.size() + 1];
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1082 int i = 0;
15177
66e3af78ea96 HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents: 15157
diff changeset
1083 Collections.sort(deopts, new Comparator<DeoptimizingOp>() {
66e3af78ea96 HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents: 15157
diff changeset
1084 public int compare(DeoptimizingOp o1, DeoptimizingOp o2) {
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1085 return o1.getCodeBufferPos() - o2.getCodeBufferPos();
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1086 }
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1087 });
15177
66e3af78ea96 HSAIL: added safepoint support
Doug Simon <doug.simon@oracle.com>
parents: 15157
diff changeset
1088 for (DeoptimizingOp deopt : deopts) {
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1089 keySuccessors[i] = i;
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1090 keyProbabilities[i] = 1.0 / deopts.size();
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1091 keys[i] = deopt.getCodeBufferPos();
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1092 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
1093 branches[i] = createHostDeoptBranch(deopt, hsailFrame, reasonAndAction, speculation, providers, config, numSRegs, numDRegs);
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1094
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1095 i++;
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1096 }
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1097 keyProbabilities[deopts.size()] = 0; // default
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1098 keySuccessors[deopts.size()] = deopts.size();
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1099 branches[deopts.size()] = createHostCrashBranch(hostGraph, deoptId);
16895
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16795
diff changeset
1100 IntegerSwitchNode switchNode = hostGraph.add(IntegerSwitchNode.create(deoptId, branches, keys, keyProbabilities, keySuccessors));
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1101 StartNode start = hostGraph.start();
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1102 start.setNext(switchNode);
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1103 /*
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1104 * printf.setNext(printf2); printf2.setNext(switchNode);
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1105 */
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1106 hostGraph.setGuardsStage(GuardsStage.AFTER_FSA);
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1107 return hostGraph;
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1108 }
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1109
15145
df2ef5204f2b Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15132
diff changeset
1110 private static BeginNode createHostCrashBranch(StructuredGraph hostGraph, ValueNode deoptId) {
16895
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16795
diff changeset
1111 VMErrorNode vmError = hostGraph.add(VMErrorNode.create("Error in HSAIL deopt. DeoptId=%d", deoptId));
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1112 // ConvertNode.convert(hostGraph, Kind.Long, deoptId)));
16895
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16795
diff changeset
1113 vmError.setNext(hostGraph.add(ReturnNode.create(ConstantNode.defaultForKind(hostGraph.method().getSignature().getReturnKind(), hostGraph))));
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1114 return BeginNode.begin(vmError);
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1115 }
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1116
15482
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
1117 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
1118 HotSpotVMConfig config, int numSRegs, int numDRegs) {
16895
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16795
diff changeset
1119 BeginNode branch = hsailFrame.graph().add(BeginNode.create());
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16795
diff changeset
1120 DynamicDeoptimizeNode deoptimization = hsailFrame.graph().add(DynamicDeoptimizeNode.create(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
1121 deoptimization.setStateBefore(createFrameState(deopt.getFrameState().topFrame, hsailFrame, providers, config, numSRegs, numDRegs));
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1122 branch.setNext(deoptimization);
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1123 return branch;
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1124 }
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1125
15482
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
1126 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
1127 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
1128 }
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
1129
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
1130 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
1131 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
1132 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
1133 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
1134 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
1135 }
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1136 StructuredGraph hostGraph = hsailFrame.graph();
18189
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
1137 Function<? super JavaValue, ? extends ValueNode> lirValueToHirNode = v -> getNodeForValueFromFrame(v, hsailFrame, hostGraph, providers, config, numSRegs, numDRegs, virtualObjects);
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1138 ValueNode[] locals = new ValueNode[lowLevelFrame.numLocals];
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1139 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
1140 locals[i] = lirValueToHirNode.apply(lowLevelFrame.getLocalValue(i));
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1141 }
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1142 List<ValueNode> stack = new ArrayList<>(lowLevelFrame.numStack);
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1143 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
1144 stack.add(lirValueToHirNode.apply(lowLevelFrame.getStackValue(i)));
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1145 }
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1146 ValueNode[] locks = new ValueNode[lowLevelFrame.numLocks];
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1147 MonitorIdNode[] monitorIds = new MonitorIdNode[lowLevelFrame.numLocks];
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1148 for (int i = 0; i < lowLevelFrame.numLocks; i++) {
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1149 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
1150 locks[i] = lirValueToHirNode.apply(lockValue);
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1151 monitorIds[i] = getMonitorIdForHotSpotMonitorValueFromFrame(lockValue, hsailFrame, hostGraph);
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1152 }
16895
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16795
diff changeset
1153 FrameState frameState = hostGraph.add(FrameState.create(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
1154 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
1155 frameState.setOuterFrameState(outterFrameState);
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1156 }
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
1157 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
1158 // 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
1159 // 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
1160 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
1161 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
1162 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
1163 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
1164 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
1165 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
1166 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
1167 List<ValueNode> fieldValues = Arrays.stream(virtualObject.getValues()).map(lirValueToHirNode).collect(Collectors.toList());
16895
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16795
diff changeset
1168 virtualStates.add(VirtualObjectState.create(virtualObjectNode, fieldValues));
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
1169 }
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 // 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
1171 // 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
1172 } 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
1173 virtualStates.forEach(vos -> frameState.addVirtualObjectMapping(hostGraph.unique(vos)));
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1174 return frameState;
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1175 }
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1176
15066
2cae21d9f122 HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents: 15024
diff changeset
1177 @SuppressWarnings("unused")
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1178 private static MonitorIdNode getMonitorIdForHotSpotMonitorValueFromFrame(HotSpotMonitorValue lockValue, ParameterNode hsailFrame, StructuredGraph hsailGraph) {
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1179 if (lockValue.isEliminated()) {
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1180 return null;
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1181 }
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1182 throw GraalInternalError.unimplemented();
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1183 }
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1184
18189
e75eb4720d4e Introduce new JavaValue interface for use in debug info.
Roland Schatz <roland.schatz@oracle.com>
parents: 18187
diff changeset
1185 private static ValueNode getNodeForValueFromFrame(JavaValue 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
1186 int numDRegs, Map<VirtualObject, VirtualObjectNode> virtualObjects) {
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1187 ValueNode valueNode;
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18176
diff changeset
1188 if (localValue instanceof JavaConstant) {
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18176
diff changeset
1189 valueNode = ConstantNode.forConstant((JavaConstant) localValue, providers.getMetaAccess(), hostGraph);
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1190 } 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
1191 valueNode = getNodeForVirtualObjectFromFrame((VirtualObject) localValue, virtualObjects, hostGraph);
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1192 } 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
1193 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
1194 valueNode = getNodeForStackSlotFromFrame(slot, localValue.getKind(), hsailFrame, hostGraph, providers, config, numSRegs, numDRegs);
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1195 } else if (localValue instanceof HotSpotMonitorValue) {
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1196 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
1197 return getNodeForValueFromFrame(hotSpotMonitorValue.getOwner(), hsailFrame, hostGraph, providers, config, numSRegs, numDRegs, virtualObjects);
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1198 } else if (localValue instanceof RegisterValue) {
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1199 RegisterValue registerValue = (RegisterValue) localValue;
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1200 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
1201 valueNode = getNodeForRegisterFromFrame(regNumber, localValue.getKind(), hsailFrame, hostGraph, providers, config, numSRegs);
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1202 } else if (Value.ILLEGAL.equals(localValue)) {
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1203 valueNode = null;
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1204 } else {
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1205 throw GraalInternalError.shouldNotReachHere();
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1206 }
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1207 return valueNode;
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1208 }
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1209
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
1210 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
1211 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
1212 if (vo.getType().isArray()) {
16895
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16795
diff changeset
1213 return hostGraph.add(VirtualArrayNode.create(vo.getType().getComponentType(), vo.getValues().length));
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 } else {
16895
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16795
diff changeset
1215 return hostGraph.add(VirtualInstanceNode.create(vo.getType(), true));
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
1216 }
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 });
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 }
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
15482
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
1220 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
1221 int numSRegs) {
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1222 ValueNode valueNode;
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1223 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
1224 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
1225 int intSize = providers.getCodeCache().getTarget().arch.getSizeInBytes(Kind.Int);
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1226 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
1227 long offset = config.hsailFrameHeaderSize + intSize * (regNumber - HSAIL.s0.number);
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1228 location = ConstantLocationNode.create(FINAL_LOCATION, valueKind, offset, hostGraph);
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1229 } 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
1230 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
1231 location = ConstantLocationNode.create(FINAL_LOCATION, valueKind, offset, hostGraph);
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1232 } else {
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1233 throw GraalInternalError.shouldNotReachHere("unknown hsail register: " + regNumber);
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1234 }
16895
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16795
diff changeset
1235 valueNode = hostGraph.unique(FloatingReadNode.create(hsailFrame, location, null, StampFactory.forKind(valueKind)));
14853
6bde7deb5be1 Adopt HSAILLIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14852
diff changeset
1236 return valueNode;
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1237 }
14809
73774616a6b3 Decoupled LIRGenerator and LIRGenerationResult.
Josef Eisl <josef.eisl@jku.at>
parents: 14804
diff changeset
1238
15482
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
1239 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
1240 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
1241 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
1242 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
1243 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
1244 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
1245 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
1246 LocationNode location = ConstantLocationNode.create(FINAL_LOCATION, valueKind, offset, hostGraph);
16895
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16795
diff changeset
1247 ValueNode valueNode = hostGraph.unique(FloatingReadNode.create(hsailFrame, location, null, StampFactory.forKind(valueKind)));
15482
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
1248 return valueNode;
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
1249 } else {
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
1250 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
1251 }
a250a512434d HSAIL: support for object values in stack slots at deoptimization points
Doug Simon <doug.simon@oracle.com>
parents: 15375
diff changeset
1252 }
10662
4ef92b67aeae added HSAIL backend and tests
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1253 }