Mercurial > hg > graal-compiler
comparison graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotJVMCIRuntimeProvider.java @ 21551:5324104ac4f3
moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 26 May 2015 17:13:37 +0200 |
parents | |
children | 48c1ebd24120 |
comparison
equal
deleted
inserted
replaced
21550:f48a6cea31eb | 21551:5324104ac4f3 |
---|---|
1 /* | |
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
23 package com.oracle.jvmci.hotspot; | |
24 | |
25 import sun.misc.*; | |
26 | |
27 import com.oracle.graal.api.meta.*; | |
28 import com.oracle.jvmci.common.*; | |
29 import com.oracle.jvmci.runtime.*; | |
30 | |
31 //JaCoCo Exclude | |
32 | |
33 /** | |
34 * Configuration information for the HotSpot Graal runtime. | |
35 */ | |
36 public interface HotSpotJVMCIRuntimeProvider extends JVMCIRuntime { | |
37 | |
38 HotSpotVMConfig getConfig(); | |
39 | |
40 CompilerToVM getCompilerToVM(); | |
41 | |
42 /** | |
43 * Converts a name to a Java type. This method attempts to resolve {@code name} to a | |
44 * {@link ResolvedJavaType}. | |
45 * | |
46 * @param name a well formed Java type in {@linkplain JavaType#getName() internal} format | |
47 * @param accessingType the context of resolution which must be non-null | |
48 * @param resolve specifies whether resolution failure results in an unresolved type being | |
49 * return or a {@link LinkageError} being thrown | |
50 * @return a Java type for {@code name} which is guaranteed to be of type | |
51 * {@link ResolvedJavaType} if {@code resolve == true} | |
52 * @throws LinkageError if {@code resolve == true} and the resolution failed | |
53 * @throws NullPointerException if {@code accessingClass} is {@code null} | |
54 */ | |
55 JavaType lookupType(String name, HotSpotResolvedObjectType accessingType, boolean resolve); | |
56 | |
57 /** | |
58 * Gets the Graal mirror for a {@link Class} object. | |
59 * | |
60 * @return the {@link ResolvedJavaType} corresponding to {@code javaClass} | |
61 */ | |
62 ResolvedJavaType fromClass(Class<?> clazz); | |
63 | |
64 /** | |
65 * The offset from the origin of an array to the first element. | |
66 * | |
67 * @return the offset in bytes | |
68 */ | |
69 default int getArrayBaseOffset(Kind kind) { | |
70 switch (kind) { | |
71 case Boolean: | |
72 return Unsafe.ARRAY_BOOLEAN_BASE_OFFSET; | |
73 case Byte: | |
74 return Unsafe.ARRAY_BYTE_BASE_OFFSET; | |
75 case Char: | |
76 return Unsafe.ARRAY_CHAR_BASE_OFFSET; | |
77 case Short: | |
78 return Unsafe.ARRAY_SHORT_BASE_OFFSET; | |
79 case Int: | |
80 return Unsafe.ARRAY_INT_BASE_OFFSET; | |
81 case Long: | |
82 return Unsafe.ARRAY_LONG_BASE_OFFSET; | |
83 case Float: | |
84 return Unsafe.ARRAY_FLOAT_BASE_OFFSET; | |
85 case Double: | |
86 return Unsafe.ARRAY_DOUBLE_BASE_OFFSET; | |
87 case Object: | |
88 return Unsafe.ARRAY_OBJECT_BASE_OFFSET; | |
89 default: | |
90 throw new JVMCIError("%s", kind); | |
91 } | |
92 } | |
93 | |
94 /** | |
95 * The scale used for the index when accessing elements of an array of this kind. | |
96 * | |
97 * @return the scale in order to convert the index into a byte offset | |
98 */ | |
99 default int getArrayIndexScale(Kind kind) { | |
100 switch (kind) { | |
101 case Boolean: | |
102 return Unsafe.ARRAY_BOOLEAN_INDEX_SCALE; | |
103 case Byte: | |
104 return Unsafe.ARRAY_BYTE_INDEX_SCALE; | |
105 case Char: | |
106 return Unsafe.ARRAY_CHAR_INDEX_SCALE; | |
107 case Short: | |
108 return Unsafe.ARRAY_SHORT_INDEX_SCALE; | |
109 case Int: | |
110 return Unsafe.ARRAY_INT_INDEX_SCALE; | |
111 case Long: | |
112 return Unsafe.ARRAY_LONG_INDEX_SCALE; | |
113 case Float: | |
114 return Unsafe.ARRAY_FLOAT_INDEX_SCALE; | |
115 case Double: | |
116 return Unsafe.ARRAY_DOUBLE_INDEX_SCALE; | |
117 case Object: | |
118 return Unsafe.ARRAY_OBJECT_INDEX_SCALE; | |
119 default: | |
120 throw new JVMCIError("%s", kind); | |
121 } | |
122 } | |
123 } |