Mercurial > hg > graal-jvmci-8
annotate jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotMetaAccessProvider.java @ 22555:2fe06375f2d3
made HotSpotJVMCIRuntimeProvider.getArrayBaseOffset and HotSpotJVMCIRuntimeProvider.getArrayIndexScale static
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 14 Sep 2015 16:25:07 +0200 |
parents | 15579668ec3a |
children | ec96f33a101d |
rev | line source |
---|---|
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
2 * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. |
12429
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 */ |
22054 | 23 package jdk.internal.jvmci.hotspot; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
22555
2fe06375f2d3
made HotSpotJVMCIRuntimeProvider.getArrayBaseOffset and HotSpotJVMCIRuntimeProvider.getArrayIndexScale static
Doug Simon <doug.simon@oracle.com>
parents:
22542
diff
changeset
|
25 import static jdk.internal.jvmci.hotspot.HotSpotJVMCIRuntimeProvider.getArrayBaseOffset; |
22054 | 26 import static jdk.internal.jvmci.hotspot.HotSpotResolvedObjectTypeImpl.*; |
22542
15579668ec3a
renamed constant field to UNSAFE
Doug Simon <doug.simon@oracle.com>
parents:
22541
diff
changeset
|
27 import static jdk.internal.jvmci.hotspot.UnsafeAccess.UNSAFE; |
13263 | 28 |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
29 import java.lang.reflect.*; |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
30 |
22054 | 31 import jdk.internal.jvmci.code.*; |
32 import jdk.internal.jvmci.common.*; | |
33 import jdk.internal.jvmci.meta.*; | |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
34 |
21665
6166968c6359
Add missing JaCoCo excludes
Josef Eisl <josef.eisl@jku.at>
parents:
21556
diff
changeset
|
35 // JaCoCo Exclude |
6166968c6359
Add missing JaCoCo excludes
Josef Eisl <josef.eisl@jku.at>
parents:
21556
diff
changeset
|
36 |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
37 /** |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
38 * HotSpot implementation of {@link MetaAccessProvider}. |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
39 */ |
18867
7f4cb7587f4c
localized replay compilation marker interface to HotSpot specific code
Doug Simon <doug.simon@oracle.com>
parents:
18544
diff
changeset
|
40 public class HotSpotMetaAccessProvider implements MetaAccessProvider, HotSpotProxified { |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
41 |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
42 protected final HotSpotJVMCIRuntimeProvider runtime; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
43 |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
44 public HotSpotMetaAccessProvider(HotSpotJVMCIRuntimeProvider runtime) { |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
45 this.runtime = runtime; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
46 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 |
18544
17b5e453ab41
replaced concrete types with interface types to support replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18540
diff
changeset
|
48 public ResolvedJavaType lookupJavaType(Class<?> clazz) { |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
49 if (clazz == null) { |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
50 throw new IllegalArgumentException("Class parameter was null"); |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
51 } |
18544
17b5e453ab41
replaced concrete types with interface types to support replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18540
diff
changeset
|
52 return runtime.fromClass(clazz); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
53 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
54 |
18544
17b5e453ab41
replaced concrete types with interface types to support replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18540
diff
changeset
|
55 public HotSpotResolvedObjectType lookupJavaType(JavaConstant constant) { |
15909
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
15291
diff
changeset
|
56 if (constant.isNull() || !(constant instanceof HotSpotObjectConstant)) { |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
57 return null; |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
58 } |
18544
17b5e453ab41
replaced concrete types with interface types to support replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18540
diff
changeset
|
59 return ((HotSpotObjectConstant) constant).getType(); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
60 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
61 |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
62 public Signature parseMethodDescriptor(String signature) { |
18540
21384a8fbb64
removed static accesses to HotSpotGraalRuntime from some HotSpot meta API classes
Doug Simon <doug.simon@oracle.com>
parents:
18530
diff
changeset
|
63 return new HotSpotSignature(runtime, signature); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
64 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
65 |
13264
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
66 /** |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
67 * {@link Field} object of {@link Method#slot}. |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
68 */ |
22531
99dc98466321
removed no longer necessary applications of @SuppressWarnings("javadoc")
Doug Simon <doug.simon@oracle.com>
parents:
22454
diff
changeset
|
69 private Field reflectionMethodSlot = getReflectionSlotField(Method.class); |
13264
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
70 |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
71 /** |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
72 * {@link Field} object of {@link Constructor#slot}. |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
73 */ |
22531
99dc98466321
removed no longer necessary applications of @SuppressWarnings("javadoc")
Doug Simon <doug.simon@oracle.com>
parents:
22454
diff
changeset
|
74 private Field reflectionConstructorSlot = getReflectionSlotField(Constructor.class); |
13264
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
75 |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
76 private static Field getReflectionSlotField(Class<?> reflectionClass) { |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
77 try { |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
78 Field field = reflectionClass.getDeclaredField("slot"); |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
79 field.setAccessible(true); |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
80 return field; |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
81 } catch (NoSuchFieldException | SecurityException e) { |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
82 throw new JVMCIError(e); |
13264
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
83 } |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
84 } |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
85 |
18373
91283d4a1218
Use the base class Executable (introduced in Java 8) to unify the handling of Method and Constructor in MetaAccessProvider
Christian Wimmer <christian.wimmer@oracle.com>
parents:
18290
diff
changeset
|
86 public ResolvedJavaMethod lookupJavaMethod(Executable reflectionMethod) { |
13264
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
87 try { |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
88 Class<?> holder = reflectionMethod.getDeclaringClass(); |
18373
91283d4a1218
Use the base class Executable (introduced in Java 8) to unify the handling of Method and Constructor in MetaAccessProvider
Christian Wimmer <christian.wimmer@oracle.com>
parents:
18290
diff
changeset
|
89 Field slotField = reflectionMethod instanceof Constructor ? reflectionConstructorSlot : reflectionMethodSlot; |
91283d4a1218
Use the base class Executable (introduced in Java 8) to unify the handling of Method and Constructor in MetaAccessProvider
Christian Wimmer <christian.wimmer@oracle.com>
parents:
18290
diff
changeset
|
90 final int slot = slotField.getInt(reflectionMethod); |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22422
diff
changeset
|
91 return runtime.getCompilerToVM().getResolvedJavaMethodAtSlot(holder, slot); |
13264
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
92 } catch (IllegalArgumentException | IllegalAccessException e) { |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
93 throw new JVMCIError(e); |
13264
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
94 } |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
95 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
96 |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
97 public ResolvedJavaField lookupJavaField(Field reflectionField) { |
13263 | 98 String name = reflectionField.getName(); |
99 Class<?> fieldHolder = reflectionField.getDeclaringClass(); | |
100 Class<?> fieldType = reflectionField.getType(); | |
101 // java.lang.reflect.Field's modifiers should be enough here since VM internal modifier bits | |
102 // are not used (yet). | |
103 final int modifiers = reflectionField.getModifiers(); | |
22542
15579668ec3a
renamed constant field to UNSAFE
Doug Simon <doug.simon@oracle.com>
parents:
22541
diff
changeset
|
104 final long offset = Modifier.isStatic(modifiers) ? UNSAFE.staticFieldOffset(reflectionField) : UNSAFE.objectFieldOffset(reflectionField); |
13263 | 105 |
18544
17b5e453ab41
replaced concrete types with interface types to support replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18540
diff
changeset
|
106 HotSpotResolvedObjectType holder = fromObjectClass(fieldHolder); |
22422
a98a02bad801
Add simple interface to control caching policy for ResolvedJavaTypes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
107 JavaType type = runtime.fromClass(fieldType); |
13263 | 108 |
109 if (offset != -1) { | |
18544
17b5e453ab41
replaced concrete types with interface types to support replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18540
diff
changeset
|
110 HotSpotResolvedObjectType resolved = holder; |
14012 | 111 return resolved.createField(name, type, offset, modifiers); |
13263 | 112 } else { |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
113 throw new JVMCIError("unresolved field %s", reflectionField); |
13263 | 114 } |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
115 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
116 |
12757
a36839dafe50
Remove some useless short casts, synchronize deoptimization.hpp with HotSpotMetaAccessProvider
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12719
diff
changeset
|
117 private static int intMaskRight(int n) { |
a36839dafe50
Remove some useless short casts, synchronize deoptimization.hpp with HotSpotMetaAccessProvider
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12719
diff
changeset
|
118 assert n <= 32; |
a36839dafe50
Remove some useless short casts, synchronize deoptimization.hpp with HotSpotMetaAccessProvider
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12719
diff
changeset
|
119 return n == 32 ? -1 : (1 << n) - 1; |
a36839dafe50
Remove some useless short casts, synchronize deoptimization.hpp with HotSpotMetaAccessProvider
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12719
diff
changeset
|
120 } |
12484
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
121 |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
122 @Override |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18167
diff
changeset
|
123 public JavaConstant encodeDeoptActionAndReason(DeoptimizationAction action, DeoptimizationReason reason, int debugId) { |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
124 HotSpotVMConfig config = runtime.getConfig(); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
125 int actionValue = convertDeoptAction(action); |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
126 int reasonValue = convertDeoptReason(reason); |
13677
45fcb3ec0d43
Rename more 'speculation id' to 'debug id'. Add decodeDebugId to MetaAccessProvider
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13641
diff
changeset
|
127 int debugValue = debugId & intMaskRight(config.deoptimizationDebugIdBits); |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18167
diff
changeset
|
128 JavaConstant c = JavaConstant.forInt(~((debugValue << config.deoptimizationDebugIdShift) | (reasonValue << config.deoptimizationReasonShift) | (actionValue << config.deoptimizationActionShift))); |
12717
dd856c84a75c
Mask the speculation id correctly in HotSpotMetaAccessProvider.encodeDeoptActionAndReason
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12699
diff
changeset
|
129 assert c.asInt() < 0; |
12484
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
130 return c; |
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
131 } |
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
132 |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18167
diff
changeset
|
133 public DeoptimizationReason decodeDeoptReason(JavaConstant constant) { |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
134 HotSpotVMConfig config = runtime.getConfig(); |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
135 int reasonValue = ((~constant.asInt()) >> config.deoptimizationReasonShift) & intMaskRight(config.deoptimizationReasonBits); |
12484
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
136 DeoptimizationReason reason = convertDeoptReason(reasonValue); |
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
137 return reason; |
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
138 } |
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
139 |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18167
diff
changeset
|
140 public DeoptimizationAction decodeDeoptAction(JavaConstant constant) { |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
141 HotSpotVMConfig config = runtime.getConfig(); |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
142 int actionValue = ((~constant.asInt()) >> config.deoptimizationActionShift) & intMaskRight(config.deoptimizationActionBits); |
12484
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
143 DeoptimizationAction action = convertDeoptAction(actionValue); |
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
144 return action; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
145 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
146 |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18167
diff
changeset
|
147 public int decodeDebugId(JavaConstant constant) { |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
148 HotSpotVMConfig config = runtime.getConfig(); |
13677
45fcb3ec0d43
Rename more 'speculation id' to 'debug id'. Add decodeDebugId to MetaAccessProvider
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13641
diff
changeset
|
149 return ((~constant.asInt()) >> config.deoptimizationDebugIdShift) & intMaskRight(config.deoptimizationDebugIdBits); |
12699
38b84d5a66fd
Start passing down a 'speculation id' to deoptimizations.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12484
diff
changeset
|
150 } |
38b84d5a66fd
Start passing down a 'speculation id' to deoptimizations.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12484
diff
changeset
|
151 |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
152 public int convertDeoptAction(DeoptimizationAction action) { |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
153 HotSpotVMConfig config = runtime.getConfig(); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
154 switch (action) { |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
155 case None: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
156 return config.deoptActionNone; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
157 case RecompileIfTooManyDeopts: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
158 return config.deoptActionMaybeRecompile; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
159 case InvalidateReprofile: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
160 return config.deoptActionReinterpret; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
161 case InvalidateRecompile: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
162 return config.deoptActionMakeNotEntrant; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
163 case InvalidateStopCompiling: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
164 return config.deoptActionMakeNotCompilable; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
165 default: |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
166 throw new JVMCIError("%s", action); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
167 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
168 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
169 |
12484
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
170 public DeoptimizationAction convertDeoptAction(int action) { |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
171 HotSpotVMConfig config = runtime.getConfig(); |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
172 if (action == config.deoptActionNone) { |
12484
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
173 return DeoptimizationAction.None; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
174 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
175 if (action == config.deoptActionMaybeRecompile) { |
12484
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
176 return DeoptimizationAction.RecompileIfTooManyDeopts; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
177 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
178 if (action == config.deoptActionReinterpret) { |
12484
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
179 return DeoptimizationAction.InvalidateReprofile; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
180 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
181 if (action == config.deoptActionMakeNotEntrant) { |
12484
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
182 return DeoptimizationAction.InvalidateRecompile; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
183 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
184 if (action == config.deoptActionMakeNotCompilable) { |
12484
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
185 return DeoptimizationAction.InvalidateStopCompiling; |
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
186 } |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
187 throw new JVMCIError("%d", action); |
12484
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
188 } |
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
189 |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
190 public int convertDeoptReason(DeoptimizationReason reason) { |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
191 HotSpotVMConfig config = runtime.getConfig(); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
192 switch (reason) { |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
193 case None: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
194 return config.deoptReasonNone; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
195 case NullCheckException: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
196 return config.deoptReasonNullCheck; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
197 case BoundsCheckException: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
198 return config.deoptReasonRangeCheck; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
199 case ClassCastException: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
200 return config.deoptReasonClassCheck; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
201 case ArrayStoreException: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
202 return config.deoptReasonArrayCheck; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
203 case UnreachedCode: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
204 return config.deoptReasonUnreached0; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
205 case TypeCheckedInliningViolated: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
206 return config.deoptReasonTypeCheckInlining; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
207 case OptimizedTypeCheckViolated: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
208 return config.deoptReasonOptimizedTypeCheck; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
209 case NotCompiledExceptionHandler: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
210 return config.deoptReasonNotCompiledExceptionHandler; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
211 case Unresolved: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
212 return config.deoptReasonUnresolved; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
213 case JavaSubroutineMismatch: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
214 return config.deoptReasonJsrMismatch; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
215 case ArithmeticException: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
216 return config.deoptReasonDiv0Check; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
217 case RuntimeConstraint: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
218 return config.deoptReasonConstraint; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
219 case LoopLimitCheck: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
220 return config.deoptReasonLoopLimitCheck; |
13155
1dd9aa5a9ee5
Deoptimization reason for failed aliasing assumptions.
Roland Schatz <roland.schatz@oracle.com>
parents:
12757
diff
changeset
|
221 case Aliasing: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
222 return config.deoptReasonAliasing; |
16535
ada0a7729b6f
Truffle: introduce debug option to print the stack trace when transferring to the interpreter
Andreas Woess <andreas.woess@jku.at>
parents:
15909
diff
changeset
|
223 case TransferToInterpreter: |
ada0a7729b6f
Truffle: introduce debug option to print the stack trace when transferring to the interpreter
Andreas Woess <andreas.woess@jku.at>
parents:
15909
diff
changeset
|
224 return config.deoptReasonTransferToInterpreter; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
225 default: |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
226 throw new JVMCIError("%s", reason); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
227 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
228 } |
12484
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
229 |
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
230 public DeoptimizationReason convertDeoptReason(int reason) { |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
231 HotSpotVMConfig config = runtime.getConfig(); |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
232 if (reason == config.deoptReasonNone) { |
12484
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
233 return DeoptimizationReason.None; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
234 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
235 if (reason == config.deoptReasonNullCheck) { |
12484
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
236 return DeoptimizationReason.NullCheckException; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
237 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
238 if (reason == config.deoptReasonRangeCheck) { |
12484
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
239 return DeoptimizationReason.BoundsCheckException; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
240 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
241 if (reason == config.deoptReasonClassCheck) { |
12484
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
242 return DeoptimizationReason.ClassCastException; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
243 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
244 if (reason == config.deoptReasonArrayCheck) { |
12484
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
245 return DeoptimizationReason.ArrayStoreException; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
246 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
247 if (reason == config.deoptReasonUnreached0) { |
12484
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
248 return DeoptimizationReason.UnreachedCode; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
249 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
250 if (reason == config.deoptReasonTypeCheckInlining) { |
12484
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
251 return DeoptimizationReason.TypeCheckedInliningViolated; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
252 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
253 if (reason == config.deoptReasonOptimizedTypeCheck) { |
12484
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
254 return DeoptimizationReason.OptimizedTypeCheckViolated; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
255 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
256 if (reason == config.deoptReasonNotCompiledExceptionHandler) { |
12484
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
257 return DeoptimizationReason.NotCompiledExceptionHandler; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
258 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
259 if (reason == config.deoptReasonUnresolved) { |
12484
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
260 return DeoptimizationReason.Unresolved; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
261 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
262 if (reason == config.deoptReasonJsrMismatch) { |
12484
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
263 return DeoptimizationReason.JavaSubroutineMismatch; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
264 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
265 if (reason == config.deoptReasonDiv0Check) { |
12484
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
266 return DeoptimizationReason.ArithmeticException; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
267 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
268 if (reason == config.deoptReasonConstraint) { |
12484
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
269 return DeoptimizationReason.RuntimeConstraint; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
270 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
271 if (reason == config.deoptReasonLoopLimitCheck) { |
12484
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
272 return DeoptimizationReason.LoopLimitCheck; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
273 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
274 if (reason == config.deoptReasonAliasing) { |
13155
1dd9aa5a9ee5
Deoptimization reason for failed aliasing assumptions.
Roland Schatz <roland.schatz@oracle.com>
parents:
12757
diff
changeset
|
275 return DeoptimizationReason.Aliasing; |
12484
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
276 } |
16535
ada0a7729b6f
Truffle: introduce debug option to print the stack trace when transferring to the interpreter
Andreas Woess <andreas.woess@jku.at>
parents:
15909
diff
changeset
|
277 if (reason == config.deoptReasonTransferToInterpreter) { |
ada0a7729b6f
Truffle: introduce debug option to print the stack trace when transferring to the interpreter
Andreas Woess <andreas.woess@jku.at>
parents:
15909
diff
changeset
|
278 return DeoptimizationReason.TransferToInterpreter; |
ada0a7729b6f
Truffle: introduce debug option to print the stack trace when transferring to the interpreter
Andreas Woess <andreas.woess@jku.at>
parents:
15909
diff
changeset
|
279 } |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
280 throw new JVMCIError("%x", reason); |
12484
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
281 } |
13966
be0d961e3a88
New methods for querying memory usage of individual objects and object graphs in Graal API (MetaAccessProvider#getMemorySize, MetaUtil#getMemorySizeRecursive).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13677
diff
changeset
|
282 |
be0d961e3a88
New methods for querying memory usage of individual objects and object graphs in Graal API (MetaAccessProvider#getMemorySize, MetaUtil#getMemorySizeRecursive).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13677
diff
changeset
|
283 @Override |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18167
diff
changeset
|
284 public long getMemorySize(JavaConstant constant) { |
22536
dc1aeef79e7e
Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22531
diff
changeset
|
285 if (constant.getJavaKind() == JavaKind.Object) { |
18544
17b5e453ab41
replaced concrete types with interface types to support replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18540
diff
changeset
|
286 HotSpotResolvedObjectType lookupJavaType = lookupJavaType(constant); |
13966
be0d961e3a88
New methods for querying memory usage of individual objects and object graphs in Graal API (MetaAccessProvider#getMemorySize, MetaUtil#getMemorySizeRecursive).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13677
diff
changeset
|
287 |
be0d961e3a88
New methods for querying memory usage of individual objects and object graphs in Graal API (MetaAccessProvider#getMemorySize, MetaUtil#getMemorySizeRecursive).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13677
diff
changeset
|
288 if (lookupJavaType == null) { |
be0d961e3a88
New methods for querying memory usage of individual objects and object graphs in Graal API (MetaAccessProvider#getMemorySize, MetaUtil#getMemorySizeRecursive).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13677
diff
changeset
|
289 return 0; |
be0d961e3a88
New methods for querying memory usage of individual objects and object graphs in Graal API (MetaAccessProvider#getMemorySize, MetaUtil#getMemorySizeRecursive).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13677
diff
changeset
|
290 } else { |
be0d961e3a88
New methods for querying memory usage of individual objects and object graphs in Graal API (MetaAccessProvider#getMemorySize, MetaUtil#getMemorySizeRecursive).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13677
diff
changeset
|
291 if (lookupJavaType.isArray()) { |
be0d961e3a88
New methods for querying memory usage of individual objects and object graphs in Graal API (MetaAccessProvider#getMemorySize, MetaUtil#getMemorySizeRecursive).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13677
diff
changeset
|
292 // TODO(tw): Add compressed pointer support. |
18290
e7d219e9d01f
removed HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18262
diff
changeset
|
293 int length = Array.getLength(((HotSpotObjectConstantImpl) constant).object()); |
13966
be0d961e3a88
New methods for querying memory usage of individual objects and object graphs in Graal API (MetaAccessProvider#getMemorySize, MetaUtil#getMemorySizeRecursive).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13677
diff
changeset
|
294 ResolvedJavaType elementType = lookupJavaType.getComponentType(); |
22536
dc1aeef79e7e
Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22531
diff
changeset
|
295 JavaKind elementKind = elementType.getJavaKind(); |
22555
2fe06375f2d3
made HotSpotJVMCIRuntimeProvider.getArrayBaseOffset and HotSpotJVMCIRuntimeProvider.getArrayIndexScale static
Doug Simon <doug.simon@oracle.com>
parents:
22542
diff
changeset
|
296 final int headerSize = getArrayBaseOffset(elementKind); |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
297 TargetDescription target = runtime.getHostJVMCIBackend().getTarget(); |
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
298 int sizeOfElement = target.getSizeInBytes(elementKind); |
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
299 int alignment = target.wordSize; |
13966
be0d961e3a88
New methods for querying memory usage of individual objects and object graphs in Graal API (MetaAccessProvider#getMemorySize, MetaUtil#getMemorySizeRecursive).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13677
diff
changeset
|
300 int log2ElementSize = CodeUtil.log2(sizeOfElement); |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
301 return computeArrayAllocationSize(length, alignment, headerSize, log2ElementSize); |
13966
be0d961e3a88
New methods for querying memory usage of individual objects and object graphs in Graal API (MetaAccessProvider#getMemorySize, MetaUtil#getMemorySizeRecursive).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13677
diff
changeset
|
302 } |
be0d961e3a88
New methods for querying memory usage of individual objects and object graphs in Graal API (MetaAccessProvider#getMemorySize, MetaUtil#getMemorySizeRecursive).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13677
diff
changeset
|
303 return lookupJavaType.instanceSize(); |
be0d961e3a88
New methods for querying memory usage of individual objects and object graphs in Graal API (MetaAccessProvider#getMemorySize, MetaUtil#getMemorySizeRecursive).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13677
diff
changeset
|
304 } |
be0d961e3a88
New methods for querying memory usage of individual objects and object graphs in Graal API (MetaAccessProvider#getMemorySize, MetaUtil#getMemorySizeRecursive).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13677
diff
changeset
|
305 } else { |
22536
dc1aeef79e7e
Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22531
diff
changeset
|
306 return constant.getJavaKind().getByteCount(); |
13966
be0d961e3a88
New methods for querying memory usage of individual objects and object graphs in Graal API (MetaAccessProvider#getMemorySize, MetaUtil#getMemorySizeRecursive).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13677
diff
changeset
|
307 } |
be0d961e3a88
New methods for querying memory usage of individual objects and object graphs in Graal API (MetaAccessProvider#getMemorySize, MetaUtil#getMemorySizeRecursive).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13677
diff
changeset
|
308 } |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
309 |
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
310 /** |
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
311 * Computes the size of the memory chunk allocated for an array. This size accounts for the |
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
312 * array header size, body size and any padding after the last element to satisfy object |
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
313 * alignment requirements. |
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
314 * |
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
315 * @param length the number of elements in the array |
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
316 * @param alignment the object alignment requirement |
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
317 * @param headerSize the size of the array header |
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
318 * @param log2ElementSize log2 of the size of an element in the array |
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
319 */ |
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
320 public static int computeArrayAllocationSize(int length, int alignment, int headerSize, int log2ElementSize) { |
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
321 int size = (length << log2ElementSize) + headerSize + (alignment - 1); |
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
322 int mask = ~(alignment - 1); |
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
323 return size & mask; |
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18867
diff
changeset
|
324 } |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
325 } |