annotate graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackendFactory.java @ 18408:2c3666f44855

Truffle: initial commit of object API implementation
author Andreas Woess <andreas.woess@jku.at>
date Tue, 18 Nov 2014 23:19:43 +0100
parents 0f41072d8bbc
children c538c2c6b7e2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11596
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
1 /*
16094
c0b8d395368b Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents: 16006
diff changeset
2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
11596
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
4 *
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
7 * published by the Free Software Foundation.
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
8 *
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
13 * accompanied this code).
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
14 *
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
18 *
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
21 * questions.
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
22 */
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
23 package com.oracle.graal.hotspot.ptx;
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
24
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15915
diff changeset
25 import static com.oracle.graal.hotspot.InitTimer.*;
15915
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
26
11596
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
27 import com.oracle.graal.api.code.*;
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
28 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
29 import com.oracle.graal.api.runtime.*;
11596
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
30 import com.oracle.graal.hotspot.*;
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
31 import com.oracle.graal.hotspot.meta.*;
13638
1dabd01a73bd PTX backend can alter compilation pipeline to offload selected code to the GPU
Doug Simon <doug.simon@oracle.com>
parents: 12579
diff changeset
32 import com.oracle.graal.java.*;
12456
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
33 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: 12579
diff changeset
34 import com.oracle.graal.phases.tiers.*;
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 11596
diff changeset
35 import com.oracle.graal.ptx.*;
11596
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
36
12456
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
37 @ServiceProvider(HotSpotBackendFactory.class)
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
38 public class PTXHotSpotBackendFactory implements HotSpotBackendFactory {
11596
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
39
12456
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
40 public HotSpotBackend 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
41 HotSpotProviders host = hostBackend.getProviders();
18301
0f41072d8bbc moved use of HotSpotMetaAccessProvider to locations on the "local" side of remote compilation
Doug Simon <doug.simon@oracle.com>
parents: 18258
diff changeset
42 MetaAccessProvider metaAccess;
15915
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
43 PTXHotSpotCodeCacheProvider codeCache;
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
44 ConstantReflectionProvider constantReflection;
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
45 HotSpotForeignCallsProvider foreignCalls;
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
46 LoweringProvider lowerer;
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
47 Replacements replacements;
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
48 HotSpotDisassemblerProvider disassembler;
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
49 SuitesProvider suites;
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
50 HotSpotRegistersProvider registers;
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
51 HotSpotProviders providers;
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
52 try (InitTimer t = timer("create providers")) {
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
53 try (InitTimer rt = timer("create MetaAccess provider")) {
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
54 metaAccess = host.getMetaAccess();
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
55 }
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
56 try (InitTimer rt = timer("create CodeCache provider")) {
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
57 codeCache = new PTXHotSpotCodeCacheProvider(runtime, createTarget());
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
58 }
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
59 try (InitTimer rt = timer("create ConstantReflection provider")) {
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
60 constantReflection = host.getConstantReflection();
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
61 }
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
62 try (InitTimer rt = timer("create ForeignCalls provider")) {
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
63 foreignCalls = new PTXHotSpotForeignCallsProvider();
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
64 }
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
65 try (InitTimer rt = timer("create Lowerer provider")) {
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
66 lowerer = new PTXHotSpotLoweringProvider(host.getLowerer());
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
67 }
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
68 try (InitTimer rt = timer("create Replacements provider")) {
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
69 replacements = host.getReplacements();
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
70 }
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
71 try (InitTimer rt = timer("create Disassembler provider")) {
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
72 disassembler = host.getDisassembler();
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
73 }
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
74 try (InitTimer rt = timer("create Suites provider")) {
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
75 suites = new DefaultSuitesProvider();
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
76 }
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
77 try (InitTimer rt = timer("create HotSpotRegisters provider")) {
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
78 registers = new HotSpotRegisters(PTX.tid, Register.None, Register.None);
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
79 }
18258
6faee2dcebbf moved MethodHandleAccessProvider to graal.api.meta and made it retrievable from MetaAccessProvider so that it does not need to be accessed via a global in MethodHandleNode (which is problematic for remote/replay compilation) (GRAAL-874)
Doug Simon <doug.simon@oracle.com>
parents: 16116
diff changeset
80 providers = new HotSpotProviders(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, replacements, disassembler, suites, registers, host.getSnippetReflection());
15915
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
81 }
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
82 try (InitTimer rt = timer("instantiate backend")) {
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
83 return new PTXHotSpotBackend(runtime, providers);
d1e9a44b14cc added more runtime initialization timers
Doug Simon <doug.simon@oracle.com>
parents: 15481
diff changeset
84 }
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 11596
diff changeset
85 }
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents: 11596
diff changeset
86
11596
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
87 protected Architecture createArchitecture() {
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
88 return new PTX();
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
89 }
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
90
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
91 protected TargetDescription createTarget() {
12456
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
92 final int stackFrameAlignment = 1;
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
93 final int implicitNullCheckLimit = 0;
11596
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
94 final boolean inlineObjects = true;
16116
9e5a323e0a1e Remove hotspot specific NarrowOop kind, use LIRKind.reference(Kind.Int) instead.
Roland Schatz <roland.schatz@oracle.com>
parents: 16104
diff changeset
95 return new HotSpotTargetDescription(createArchitecture(), true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects);
11596
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
96 }
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
97
12456
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
98 public String getArchitecture() {
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
99 return "PTX";
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
100 }
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
101
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
102 public String getGraalRuntimeName() {
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
103 return "basic";
11596
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
104 }
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
105
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
106 @Override
12456
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
107 public String toString() {
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
108 return getGraalRuntimeName() + ":" + getArchitecture();
11596
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
109 }
91e5f927af63 Initial implementation of PTXRuntime (RegisterConfig, PTX description etc); guarded with new flag UseGPU. Specify -XX:+UseGPU to exercise this new implementation.
bharadwaj
parents:
diff changeset
110 }