Mercurial > hg > truffle
annotate graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackendFactory.java @ 15481:09d721bcffe2
Introduce API for lookup of VM-internals of method handles
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Fri, 02 May 2014 11:04:51 -0700 |
parents | 40d0022115ee |
children | 8184c00fefd2 |
rev | line source |
---|---|
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 */ |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.hotspot.hsail; |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
25 import com.oracle.graal.api.code.*; |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
26 import com.oracle.graal.api.meta.*; |
12456
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
27 import com.oracle.graal.api.runtime.*; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
28 import com.oracle.graal.hotspot.*; |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
29 import com.oracle.graal.hotspot.meta.*; |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
30 import com.oracle.graal.hsail.*; |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
31 import com.oracle.graal.nodes.spi.*; |
13638
1dabd01a73bd
PTX backend can alter compilation pipeline to offload selected code to the GPU
Doug Simon <doug.simon@oracle.com>
parents:
13132
diff
changeset
|
32 import com.oracle.graal.phases.tiers.*; |
12469
2a833e0d4e0a
gave HSAIL its own Replacements implementation (HSAILHotSpotReplacementsImpl)
Doug Simon <doug.simon@oracle.com>
parents:
12456
diff
changeset
|
33 import com.oracle.graal.phases.util.*; |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15018
diff
changeset
|
34 import com.oracle.graal.hotspot.hsail.replacements.*; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
35 |
12456
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
36 @ServiceProvider(HotSpotBackendFactory.class) |
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
37 public class HSAILHotSpotBackendFactory implements HotSpotBackendFactory { |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
38 |
15396
73f419a501ac
Make HSAILHotSpotLoweringProvider extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
39 protected HotSpotLoweringProvider createLowerer(HotSpotGraalRuntime runtime, HotSpotMetaAccessProvider metaAccess, HotSpotForeignCallsProvider foreignCalls, HotSpotRegistersProvider registers) { |
73f419a501ac
Make HSAILHotSpotLoweringProvider extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
40 return new HSAILHotSpotLoweringProvider(runtime, metaAccess, foreignCalls, registers); |
73f419a501ac
Make HSAILHotSpotLoweringProvider extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
41 } |
73f419a501ac
Make HSAILHotSpotLoweringProvider extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
42 |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
43 @Override |
12456
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
44 public HSAILHotSpotBackend createBackend(HotSpotGraalRuntime runtime, HotSpotBackend hostBackend) { |
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
45 HotSpotProviders host = hostBackend.getProviders(); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
46 |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15018
diff
changeset
|
47 HotSpotRegisters registers = new HotSpotRegisters(HSAIL.threadRegister, Register.None, Register.None); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
48 HotSpotMetaAccessProvider metaAccess = host.getMetaAccess(); |
12456
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
49 HSAILHotSpotCodeCacheProvider codeCache = new HSAILHotSpotCodeCacheProvider(runtime, createTarget()); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
50 ConstantReflectionProvider constantReflection = host.getConstantReflection(); |
12588
3b178baf3edb
fleshed out HSAIL backend a little to demonstrate changes needed after recent API/infrastructure updates
Doug Simon <doug.simon@oracle.com>
parents:
12469
diff
changeset
|
51 HotSpotForeignCallsProvider foreignCalls = new HSAILHotSpotForeignCallsProvider(runtime, metaAccess, codeCache); |
15396
73f419a501ac
Make HSAILHotSpotLoweringProvider extensible.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
52 HotSpotLoweringProvider lowerer = createLowerer(runtime, metaAccess, foreignCalls, registers); |
12469
2a833e0d4e0a
gave HSAIL its own Replacements implementation (HSAILHotSpotReplacementsImpl)
Doug Simon <doug.simon@oracle.com>
parents:
12456
diff
changeset
|
53 // Replacements cannot have speculative optimizations since they have |
2a833e0d4e0a
gave HSAIL its own Replacements implementation (HSAILHotSpotReplacementsImpl)
Doug Simon <doug.simon@oracle.com>
parents:
12456
diff
changeset
|
54 // to be valid for the entire run of the VM. |
2a833e0d4e0a
gave HSAIL its own Replacements implementation (HSAILHotSpotReplacementsImpl)
Doug Simon <doug.simon@oracle.com>
parents:
12456
diff
changeset
|
55 Assumptions assumptions = new Assumptions(false); |
2a833e0d4e0a
gave HSAIL its own Replacements implementation (HSAILHotSpotReplacementsImpl)
Doug Simon <doug.simon@oracle.com>
parents:
12456
diff
changeset
|
56 Providers p = new Providers(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, null); |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14560
diff
changeset
|
57 Replacements replacements = new HSAILHotSpotReplacementsImpl(p, host.getSnippetReflection(), assumptions, codeCache.getTarget(), host.getReplacements()); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
58 HotSpotDisassemblerProvider disassembler = host.getDisassembler(); |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15018
diff
changeset
|
59 SuitesProvider suites = new HotSpotSuitesProvider(runtime); |
15481
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15399
diff
changeset
|
60 HotSpotProviders providers = new HotSpotProviders(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, replacements, disassembler, suites, registers, host.getSnippetReflection(), |
09d721bcffe2
Introduce API for lookup of VM-internals of method handles
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15399
diff
changeset
|
61 host.getMethodHandleAccess()); |
12456
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
62 |
15066
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15018
diff
changeset
|
63 // pass registers info down to ReplacementsUtil (maybe a better way to do this?) |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15018
diff
changeset
|
64 HSAILHotSpotReplacementsUtil.initialize(providers.getRegisters()); |
2cae21d9f122
HSAIL: initial support for object allocation in HSAIL kernels
Doug Simon <doug.simon@oracle.com>
parents:
15018
diff
changeset
|
65 |
12456
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
66 return new HSAILHotSpotBackend(runtime, providers); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
67 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
68 |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
69 protected TargetDescription createTarget() { |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
70 final int stackFrameAlignment = 8; |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
71 final int implicitNullCheckLimit = 0; |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
72 final boolean inlineObjects = true; |
14560
570910f5412b
Introduce Hotspot-specific NarrowOop kind.
Roland Schatz <roland.schatz@oracle.com>
parents:
13784
diff
changeset
|
73 return new HotSpotTargetDescription(new HSAIL(), true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects, Kind.Int); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
74 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
75 |
12456
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
76 public String getArchitecture() { |
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
77 return "HSAIL"; |
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
78 } |
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
79 |
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
80 public String getGraalRuntimeName() { |
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
81 return "basic"; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
82 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
83 |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
84 @Override |
12456
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
85 public String toString() { |
f87c68d79f07
improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents:
12431
diff
changeset
|
86 return getGraalRuntimeName() + ":" + getArchitecture(); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
87 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
88 } |