Mercurial > hg > truffle
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMetaAccessProvider.java @ 16535:ada0a7729b6f
Truffle: introduce debug option to print the stack trace when transferring to the interpreter
author | Andreas Woess <andreas.woess@jku.at> |
---|---|
date | Wed, 16 Jul 2014 15:18:48 +0200 |
parents | e43591136d9f |
children | 2bf5ea10eea7 |
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) 2011, 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.meta; |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
15291
471e28b8f03b
Move UnsafeAccess to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15193
diff
changeset
|
25 import static com.oracle.graal.compiler.common.UnsafeAccess.*; |
13263 | 26 |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
27 import java.lang.reflect.*; |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
28 |
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
|
29 import com.oracle.graal.api.code.*; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
30 import com.oracle.graal.api.meta.*; |
15193
96bb07a5d667
Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents:
15040
diff
changeset
|
31 import com.oracle.graal.compiler.common.*; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
32 import com.oracle.graal.hotspot.*; |
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
|
33 import com.oracle.graal.hotspot.replacements.*; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
34 |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
35 /** |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
36 * HotSpot implementation of {@link MetaAccessProvider}. |
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 public class HotSpotMetaAccessProvider implements MetaAccessProvider { |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
39 |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
40 protected final HotSpotGraalRuntime runtime; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
41 |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
42 public HotSpotMetaAccessProvider(HotSpotGraalRuntime runtime) { |
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
43 this.runtime = runtime; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
44 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
45 |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
46 public ResolvedJavaType lookupJavaType(Class<?> clazz) { |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 if (clazz == null) { |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
48 throw new IllegalArgumentException("Class parameter was null"); |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
49 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
50 return HotSpotResolvedObjectType.fromClass(clazz); |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
51 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
52 |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
53 public ResolvedJavaType lookupJavaType(Constant constant) { |
15909
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
15291
diff
changeset
|
54 if (constant.isNull() || !(constant instanceof HotSpotObjectConstant)) { |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
55 return null; |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
56 } |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14559
diff
changeset
|
57 Object o = HotSpotObjectConstant.asObject(constant); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
58 return HotSpotResolvedObjectType.fromClass(o.getClass()); |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
59 } |
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 public Signature parseMethodDescriptor(String signature) { |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
62 return new HotSpotSignature(signature); |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
63 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
64 |
13264
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
65 /** |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
66 * {@link Field} object of {@link Method#slot}. |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
67 */ |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
68 @SuppressWarnings("javadoc") private Field reflectionMethodSlot = getReflectionSlotField(Method.class); |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
69 |
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 * {@link Field} object of {@link Constructor#slot}. |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
72 */ |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
73 @SuppressWarnings("javadoc") private Field reflectionConstructorSlot = getReflectionSlotField(Constructor.class); |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
74 |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
75 private static Field getReflectionSlotField(Class<?> reflectionClass) { |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
76 try { |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
77 Field field = reflectionClass.getDeclaredField("slot"); |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
78 field.setAccessible(true); |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
79 return field; |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
80 } catch (NoSuchFieldException | SecurityException e) { |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
81 throw new GraalInternalError(e); |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
82 } |
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 |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
85 public ResolvedJavaMethod lookupJavaMethod(Method reflectionMethod) { |
13264
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
86 try { |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
87 Class<?> holder = reflectionMethod.getDeclaringClass(); |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
88 final int slot = reflectionMethodSlot.getInt(reflectionMethod); |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
89 final long metaspaceMethod = runtime.getCompilerToVM().getMetaspaceMethod(holder, slot); |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
90 return HotSpotResolvedJavaMethod.fromMetaspace(metaspaceMethod); |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
91 } catch (IllegalArgumentException | IllegalAccessException e) { |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
92 throw new GraalInternalError(e); |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
93 } |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
94 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
95 |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15018
diff
changeset
|
96 public ResolvedJavaMethod lookupJavaConstructor(Constructor<?> reflectionConstructor) { |
13264
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
97 try { |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
98 Class<?> holder = reflectionConstructor.getDeclaringClass(); |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
99 final int slot = reflectionConstructorSlot.getInt(reflectionConstructor); |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
100 final long metaspaceMethod = runtime.getCompilerToVM().getMetaspaceMethod(holder, slot); |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
101 return HotSpotResolvedJavaMethod.fromMetaspace(metaspaceMethod); |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
102 } catch (IllegalArgumentException | IllegalAccessException e) { |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
103 throw new GraalInternalError(e); |
b23cbfb4366a
merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents:
13263
diff
changeset
|
104 } |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
105 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
106 |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
107 public ResolvedJavaField lookupJavaField(Field reflectionField) { |
13263 | 108 String name = reflectionField.getName(); |
109 Class<?> fieldHolder = reflectionField.getDeclaringClass(); | |
110 Class<?> fieldType = reflectionField.getType(); | |
111 // java.lang.reflect.Field's modifiers should be enough here since VM internal modifier bits | |
112 // are not used (yet). | |
113 final int modifiers = reflectionField.getModifiers(); | |
114 final long offset = Modifier.isStatic(modifiers) ? unsafe.staticFieldOffset(reflectionField) : unsafe.objectFieldOffset(reflectionField); | |
115 | |
116 ResolvedJavaType holder = HotSpotResolvedObjectType.fromClass(fieldHolder); | |
117 ResolvedJavaType type = HotSpotResolvedObjectType.fromClass(fieldType); | |
118 | |
119 if (offset != -1) { | |
120 HotSpotResolvedObjectType resolved = (HotSpotResolvedObjectType) holder; | |
14012 | 121 return resolved.createField(name, type, offset, modifiers); |
13263 | 122 } else { |
14157 | 123 throw GraalInternalError.shouldNotReachHere("unresolved field " + reflectionField); |
13263 | 124 } |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
125 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
126 |
12757
a36839dafe50
Remove some useless short casts, synchronize deoptimization.hpp with HotSpotMetaAccessProvider
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12719
diff
changeset
|
127 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
|
128 assert n <= 32; |
a36839dafe50
Remove some useless short casts, synchronize deoptimization.hpp with HotSpotMetaAccessProvider
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12719
diff
changeset
|
129 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
|
130 } |
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
|
131 |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
132 @Override |
13677
45fcb3ec0d43
Rename more 'speculation id' to 'debug id'. Add decodeDebugId to MetaAccessProvider
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13641
diff
changeset
|
133 public Constant encodeDeoptActionAndReason(DeoptimizationAction action, DeoptimizationReason reason, int debugId) { |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
134 HotSpotVMConfig config = runtime.getConfig(); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
135 int actionValue = convertDeoptAction(action); |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
136 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
|
137 int debugValue = debugId & intMaskRight(config.deoptimizationDebugIdBits); |
45fcb3ec0d43
Rename more 'speculation id' to 'debug id'. Add decodeDebugId to MetaAccessProvider
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13641
diff
changeset
|
138 Constant c = Constant.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
|
139 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
|
140 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
|
141 } |
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
142 |
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 public DeoptimizationReason decodeDeoptReason(Constant constant) { |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
144 HotSpotVMConfig config = runtime.getConfig(); |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
145 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
|
146 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
|
147 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
|
148 } |
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
149 |
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
150 public DeoptimizationAction decodeDeoptAction(Constant constant) { |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
151 HotSpotVMConfig config = runtime.getConfig(); |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
152 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
|
153 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
|
154 return action; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
155 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
156 |
13677
45fcb3ec0d43
Rename more 'speculation id' to 'debug id'. Add decodeDebugId to MetaAccessProvider
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
13641
diff
changeset
|
157 public int decodeDebugId(Constant constant) { |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
158 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
|
159 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
|
160 } |
38b84d5a66fd
Start passing down a 'speculation id' to deoptimizations.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12484
diff
changeset
|
161 |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
162 public int convertDeoptAction(DeoptimizationAction action) { |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
163 HotSpotVMConfig config = runtime.getConfig(); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
164 switch (action) { |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
165 case None: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
166 return config.deoptActionNone; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
167 case RecompileIfTooManyDeopts: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
168 return config.deoptActionMaybeRecompile; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
169 case InvalidateReprofile: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
170 return config.deoptActionReinterpret; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
171 case InvalidateRecompile: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
172 return config.deoptActionMakeNotEntrant; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
173 case InvalidateStopCompiling: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
174 return config.deoptActionMakeNotCompilable; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
175 default: |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
176 throw GraalInternalError.shouldNotReachHere(); |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
177 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
178 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
179 |
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
|
180 public DeoptimizationAction convertDeoptAction(int action) { |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
181 HotSpotVMConfig config = runtime.getConfig(); |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
182 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
|
183 return DeoptimizationAction.None; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
184 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
185 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
|
186 return DeoptimizationAction.RecompileIfTooManyDeopts; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
187 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
188 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
|
189 return DeoptimizationAction.InvalidateReprofile; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
190 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
191 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
|
192 return DeoptimizationAction.InvalidateRecompile; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
193 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
194 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
|
195 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
|
196 } |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
197 throw GraalInternalError.shouldNotReachHere(); |
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
|
198 } |
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
199 |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
200 public int convertDeoptReason(DeoptimizationReason reason) { |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
201 HotSpotVMConfig config = runtime.getConfig(); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
202 switch (reason) { |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
203 case None: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
204 return config.deoptReasonNone; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
205 case NullCheckException: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
206 return config.deoptReasonNullCheck; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
207 case BoundsCheckException: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
208 return config.deoptReasonRangeCheck; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
209 case ClassCastException: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
210 return config.deoptReasonClassCheck; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
211 case ArrayStoreException: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
212 return config.deoptReasonArrayCheck; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
213 case UnreachedCode: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
214 return config.deoptReasonUnreached0; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
215 case TypeCheckedInliningViolated: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
216 return config.deoptReasonTypeCheckInlining; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
217 case OptimizedTypeCheckViolated: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
218 return config.deoptReasonOptimizedTypeCheck; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
219 case NotCompiledExceptionHandler: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
220 return config.deoptReasonNotCompiledExceptionHandler; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
221 case Unresolved: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
222 return config.deoptReasonUnresolved; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
223 case JavaSubroutineMismatch: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
224 return config.deoptReasonJsrMismatch; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
225 case ArithmeticException: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
226 return config.deoptReasonDiv0Check; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
227 case RuntimeConstraint: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
228 return config.deoptReasonConstraint; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
229 case LoopLimitCheck: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
230 return config.deoptReasonLoopLimitCheck; |
13155
1dd9aa5a9ee5
Deoptimization reason for failed aliasing assumptions.
Roland Schatz <roland.schatz@oracle.com>
parents:
12757
diff
changeset
|
231 case Aliasing: |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
232 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
|
233 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
|
234 return config.deoptReasonTransferToInterpreter; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
235 default: |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
236 throw GraalInternalError.shouldNotReachHere(); |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
237 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
238 } |
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 |
2d8a8980eda8
Canonicalize DynamicDeoptimize nodes back to Deoptimize when used with a constant reason&action
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12431
diff
changeset
|
240 public DeoptimizationReason convertDeoptReason(int reason) { |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
241 HotSpotVMConfig config = runtime.getConfig(); |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
242 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
|
243 return DeoptimizationReason.None; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
244 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
245 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
|
246 return DeoptimizationReason.NullCheckException; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
247 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
248 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
|
249 return DeoptimizationReason.BoundsCheckException; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
250 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
251 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
|
252 return DeoptimizationReason.ClassCastException; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
253 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
254 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
|
255 return DeoptimizationReason.ArrayStoreException; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
256 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
257 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
|
258 return DeoptimizationReason.UnreachedCode; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
259 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
260 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
|
261 return DeoptimizationReason.TypeCheckedInliningViolated; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
262 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
263 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
|
264 return DeoptimizationReason.OptimizedTypeCheckViolated; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
265 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
266 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
|
267 return DeoptimizationReason.NotCompiledExceptionHandler; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
268 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
269 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
|
270 return DeoptimizationReason.Unresolved; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
271 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
272 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
|
273 return DeoptimizationReason.JavaSubroutineMismatch; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
274 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
275 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
|
276 return DeoptimizationReason.ArithmeticException; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
277 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
278 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
|
279 return DeoptimizationReason.RuntimeConstraint; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
280 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
281 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
|
282 return DeoptimizationReason.LoopLimitCheck; |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
283 } |
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
284 if (reason == config.deoptReasonAliasing) { |
13155
1dd9aa5a9ee5
Deoptimization reason for failed aliasing assumptions.
Roland Schatz <roland.schatz@oracle.com>
parents:
12757
diff
changeset
|
285 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
|
286 } |
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
|
287 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
|
288 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
|
289 } |
13257
4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
twisti
parents:
13155
diff
changeset
|
290 throw GraalInternalError.shouldNotReachHere(Integer.toHexString(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
|
291 } |
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
|
292 |
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
|
293 @Override |
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 public long getMemorySize(Constant constant) { |
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
|
295 if (constant.getKind() == Kind.Object) { |
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
|
296 HotSpotResolvedObjectType lookupJavaType = (HotSpotResolvedObjectType) this.lookupJavaType(constant); |
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
|
297 |
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
|
298 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
|
299 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
|
300 } 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
|
301 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
|
302 // TODO(tw): Add compressed pointer support. |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
14559
diff
changeset
|
303 int length = Array.getLength(HotSpotObjectConstant.asObject(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
|
304 ResolvedJavaType elementType = lookupJavaType.getComponentType(); |
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 Kind elementKind = elementType.getKind(); |
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
|
306 final int headerSize = HotSpotGraalRuntime.getArrayBaseOffset(elementKind); |
14559
883fbd3e06e0
Make size of PlatformKind overridable by VM specific code.
Roland Schatz <roland.schatz@oracle.com>
parents:
14157
diff
changeset
|
307 int sizeOfElement = HotSpotGraalRuntime.runtime().getTarget().getSizeInBytes(elementKind); |
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
|
308 int alignment = HotSpotGraalRuntime.runtime().getTarget().wordSize; |
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
|
309 int log2ElementSize = CodeUtil.log2(sizeOfElement); |
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
|
310 return NewObjectSnippets.computeArrayAllocationSize(length, alignment, headerSize, log2ElementSize); |
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
|
311 } |
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
|
312 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
|
313 } |
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
|
314 } 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
|
315 return constant.getKind().getByteCount(); |
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
|
316 } |
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
|
317 } |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
318 } |