Mercurial > hg > graal-jvmci-8
annotate jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java @ 23703:9ac04c6047c8
sync with jdk9 changes for JDK-8159613
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 21 Jun 2016 09:48:02 +0200 |
parents | b5557b757040 |
children | 66059526b021 |
rev | line source |
---|---|
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
23322
f8178417d018
Expose SharedRuntime::throw_and_post_jvmti_exception to JVMCI compilers.
Roland Schatz <roland.schatz@oracle.com>
parents:
23297
diff
changeset
|
2 * Copyright (c) 2011, 2016, 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 */ |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22598
diff
changeset
|
23 package jdk.vm.ci.hotspot; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22598
diff
changeset
|
25 import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22598
diff
changeset
|
26 import jdk.vm.ci.meta.Constant; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22598
diff
changeset
|
27 import jdk.vm.ci.meta.JavaConstant; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22598
diff
changeset
|
28 import jdk.vm.ci.meta.JavaKind; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22598
diff
changeset
|
29 import jdk.vm.ci.meta.MemoryAccessProvider; |
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22598
diff
changeset
|
30 import jdk.vm.ci.meta.PrimitiveConstant; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
31 |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
32 /** |
18482
b8a622c3e99f
Move raw memory access operations to a separate interface.
Roland Schatz <roland.schatz@oracle.com>
parents:
18472
diff
changeset
|
33 * HotSpot implementation of {@link MemoryAccessProvider}. |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
34 */ |
23393
1d4ce2d19e52
clean up and minimize JVMCI (JDK-8156835)
Doug Simon <doug.simon@oracle.com>
parents:
23390
diff
changeset
|
35 class HotSpotMemoryAccessProviderImpl implements HotSpotMemoryAccessProvider { |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
36 |
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:
20176
diff
changeset
|
37 protected final HotSpotJVMCIRuntimeProvider runtime; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
38 |
23297
4b58c92e939b
remove redundant modifiers
Manuel Rigger <rigger.manuel@gmail.com>
parents:
22672
diff
changeset
|
39 HotSpotMemoryAccessProviderImpl(HotSpotJVMCIRuntimeProvider runtime) { |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
40 this.runtime = runtime; |
18472
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
41 } |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
42 |
18719
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
43 private static Object asObject(Constant base) { |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
44 if (base instanceof HotSpotObjectConstantImpl) { |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
45 return ((HotSpotObjectConstantImpl) base).object(); |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
46 } else { |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
47 return null; |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
48 } |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
49 } |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
50 |
19772
94d87f6324a3
ensure an offset into a HotSpot metaspace object is valid before reading it
Doug Simon <doug.simon@oracle.com>
parents:
19412
diff
changeset
|
51 private boolean isValidObjectFieldDisplacement(Constant base, long displacement) { |
94d87f6324a3
ensure an offset into a HotSpot metaspace object is valid before reading it
Doug Simon <doug.simon@oracle.com>
parents:
19412
diff
changeset
|
52 if (base instanceof HotSpotMetaspaceConstant) { |
22590
3f6488b29c1a
Remove rawValue from HotSpotMetaspaceConstantImpl, patch raw pointer at code installation time.
Roland Schatz <roland.schatz@oracle.com>
parents:
22556
diff
changeset
|
53 MetaspaceWrapperObject metaspaceObject = HotSpotMetaspaceConstantImpl.getMetaspaceObject(base); |
19772
94d87f6324a3
ensure an offset into a HotSpot metaspace object is valid before reading it
Doug Simon <doug.simon@oracle.com>
parents:
19412
diff
changeset
|
54 if (metaspaceObject instanceof HotSpotResolvedObjectTypeImpl) { |
94d87f6324a3
ensure an offset into a HotSpot metaspace object is valid before reading it
Doug Simon <doug.simon@oracle.com>
parents:
19412
diff
changeset
|
55 if (displacement == runtime.getConfig().classMirrorOffset) { |
94d87f6324a3
ensure an offset into a HotSpot metaspace object is valid before reading it
Doug Simon <doug.simon@oracle.com>
parents:
19412
diff
changeset
|
56 // Klass::_java_mirror is valid for all Klass* values |
94d87f6324a3
ensure an offset into a HotSpot metaspace object is valid before reading it
Doug Simon <doug.simon@oracle.com>
parents:
19412
diff
changeset
|
57 return true; |
94d87f6324a3
ensure an offset into a HotSpot metaspace object is valid before reading it
Doug Simon <doug.simon@oracle.com>
parents:
19412
diff
changeset
|
58 } else if (displacement == runtime.getConfig().arrayKlassComponentMirrorOffset) { |
94d87f6324a3
ensure an offset into a HotSpot metaspace object is valid before reading it
Doug Simon <doug.simon@oracle.com>
parents:
19412
diff
changeset
|
59 // ArrayKlass::_component_mirror is only valid for all ArrayKlass* values |
94d87f6324a3
ensure an offset into a HotSpot metaspace object is valid before reading it
Doug Simon <doug.simon@oracle.com>
parents:
19412
diff
changeset
|
60 return ((HotSpotResolvedObjectTypeImpl) metaspaceObject).mirror().isArray(); |
94d87f6324a3
ensure an offset into a HotSpot metaspace object is valid before reading it
Doug Simon <doug.simon@oracle.com>
parents:
19412
diff
changeset
|
61 } |
94d87f6324a3
ensure an offset into a HotSpot metaspace object is valid before reading it
Doug Simon <doug.simon@oracle.com>
parents:
19412
diff
changeset
|
62 } else { |
23341
67c84a8b19cc
fixed javadoc and implementation of MemoryAccessProvider methods to only throw IllegalArgumentException (JDK-8152024)
Doug Simon <doug.simon@oracle.com>
parents:
23322
diff
changeset
|
63 throw new IllegalArgumentException(String.valueOf(metaspaceObject)); |
19772
94d87f6324a3
ensure an offset into a HotSpot metaspace object is valid before reading it
Doug Simon <doug.simon@oracle.com>
parents:
19412
diff
changeset
|
64 } |
94d87f6324a3
ensure an offset into a HotSpot metaspace object is valid before reading it
Doug Simon <doug.simon@oracle.com>
parents:
19412
diff
changeset
|
65 } |
94d87f6324a3
ensure an offset into a HotSpot metaspace object is valid before reading it
Doug Simon <doug.simon@oracle.com>
parents:
19412
diff
changeset
|
66 return false; |
94d87f6324a3
ensure an offset into a HotSpot metaspace object is valid before reading it
Doug Simon <doug.simon@oracle.com>
parents:
19412
diff
changeset
|
67 } |
94d87f6324a3
ensure an offset into a HotSpot metaspace object is valid before reading it
Doug Simon <doug.simon@oracle.com>
parents:
19412
diff
changeset
|
68 |
18719
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
69 private static long asRawPointer(Constant base) { |
22590
3f6488b29c1a
Remove rawValue from HotSpotMetaspaceConstantImpl, patch raw pointer at code installation time.
Roland Schatz <roland.schatz@oracle.com>
parents:
22556
diff
changeset
|
70 if (base instanceof HotSpotMetaspaceConstantImpl) { |
3f6488b29c1a
Remove rawValue from HotSpotMetaspaceConstantImpl, patch raw pointer at code installation time.
Roland Schatz <roland.schatz@oracle.com>
parents:
22556
diff
changeset
|
71 MetaspaceWrapperObject meta = HotSpotMetaspaceConstantImpl.getMetaspaceObject(base); |
3f6488b29c1a
Remove rawValue from HotSpotMetaspaceConstantImpl, patch raw pointer at code installation time.
Roland Schatz <roland.schatz@oracle.com>
parents:
22556
diff
changeset
|
72 return meta.getMetaspacePointer(); |
18719
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
73 } else if (base instanceof PrimitiveConstant) { |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
74 PrimitiveConstant prim = (PrimitiveConstant) base; |
22536
dc1aeef79e7e
Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22454
diff
changeset
|
75 if (prim.getJavaKind().isNumericInteger()) { |
18719
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
76 return prim.asLong(); |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
77 } |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
78 } |
23341
67c84a8b19cc
fixed javadoc and implementation of MemoryAccessProvider methods to only throw IllegalArgumentException (JDK-8152024)
Doug Simon <doug.simon@oracle.com>
parents:
23322
diff
changeset
|
79 throw new IllegalArgumentException(String.valueOf(base)); |
18719
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
80 } |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
81 |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
82 private static long readRawValue(Constant baseConstant, long displacement, int bits) { |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
83 Object base = asObject(baseConstant); |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
84 if (base != null) { |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
85 switch (bits) { |
23322
f8178417d018
Expose SharedRuntime::throw_and_post_jvmti_exception to JVMCI compilers.
Roland Schatz <roland.schatz@oracle.com>
parents:
23297
diff
changeset
|
86 case Byte.SIZE: |
22542
15579668ec3a
renamed constant field to UNSAFE
Doug Simon <doug.simon@oracle.com>
parents:
22541
diff
changeset
|
87 return UNSAFE.getByte(base, displacement); |
23322
f8178417d018
Expose SharedRuntime::throw_and_post_jvmti_exception to JVMCI compilers.
Roland Schatz <roland.schatz@oracle.com>
parents:
23297
diff
changeset
|
88 case Short.SIZE: |
22542
15579668ec3a
renamed constant field to UNSAFE
Doug Simon <doug.simon@oracle.com>
parents:
22541
diff
changeset
|
89 return UNSAFE.getShort(base, displacement); |
23322
f8178417d018
Expose SharedRuntime::throw_and_post_jvmti_exception to JVMCI compilers.
Roland Schatz <roland.schatz@oracle.com>
parents:
23297
diff
changeset
|
90 case Integer.SIZE: |
22542
15579668ec3a
renamed constant field to UNSAFE
Doug Simon <doug.simon@oracle.com>
parents:
22541
diff
changeset
|
91 return UNSAFE.getInt(base, displacement); |
23322
f8178417d018
Expose SharedRuntime::throw_and_post_jvmti_exception to JVMCI compilers.
Roland Schatz <roland.schatz@oracle.com>
parents:
23297
diff
changeset
|
92 case Long.SIZE: |
22542
15579668ec3a
renamed constant field to UNSAFE
Doug Simon <doug.simon@oracle.com>
parents:
22541
diff
changeset
|
93 return UNSAFE.getLong(base, displacement); |
18719
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
94 default: |
23341
67c84a8b19cc
fixed javadoc and implementation of MemoryAccessProvider methods to only throw IllegalArgumentException (JDK-8152024)
Doug Simon <doug.simon@oracle.com>
parents:
23322
diff
changeset
|
95 throw new IllegalArgumentException(String.valueOf(bits)); |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13488
diff
changeset
|
96 } |
15023
652564fe42d5
Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
97 } else { |
18719
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
98 long pointer = asRawPointer(baseConstant); |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
99 switch (bits) { |
23322
f8178417d018
Expose SharedRuntime::throw_and_post_jvmti_exception to JVMCI compilers.
Roland Schatz <roland.schatz@oracle.com>
parents:
23297
diff
changeset
|
100 case Byte.SIZE: |
22542
15579668ec3a
renamed constant field to UNSAFE
Doug Simon <doug.simon@oracle.com>
parents:
22541
diff
changeset
|
101 return UNSAFE.getByte(pointer + displacement); |
23322
f8178417d018
Expose SharedRuntime::throw_and_post_jvmti_exception to JVMCI compilers.
Roland Schatz <roland.schatz@oracle.com>
parents:
23297
diff
changeset
|
102 case Short.SIZE: |
22542
15579668ec3a
renamed constant field to UNSAFE
Doug Simon <doug.simon@oracle.com>
parents:
22541
diff
changeset
|
103 return UNSAFE.getShort(pointer + displacement); |
23322
f8178417d018
Expose SharedRuntime::throw_and_post_jvmti_exception to JVMCI compilers.
Roland Schatz <roland.schatz@oracle.com>
parents:
23297
diff
changeset
|
104 case Integer.SIZE: |
22542
15579668ec3a
renamed constant field to UNSAFE
Doug Simon <doug.simon@oracle.com>
parents:
22541
diff
changeset
|
105 return UNSAFE.getInt(pointer + displacement); |
23322
f8178417d018
Expose SharedRuntime::throw_and_post_jvmti_exception to JVMCI compilers.
Roland Schatz <roland.schatz@oracle.com>
parents:
23297
diff
changeset
|
106 case Long.SIZE: |
22542
15579668ec3a
renamed constant field to UNSAFE
Doug Simon <doug.simon@oracle.com>
parents:
22541
diff
changeset
|
107 return UNSAFE.getLong(pointer + displacement); |
18719
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
108 default: |
23341
67c84a8b19cc
fixed javadoc and implementation of MemoryAccessProvider methods to only throw IllegalArgumentException (JDK-8152024)
Doug Simon <doug.simon@oracle.com>
parents:
23322
diff
changeset
|
109 throw new IllegalArgumentException(String.valueOf(bits)); |
18719
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
110 } |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
111 } |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
112 } |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
113 |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
114 private boolean verifyReadRawObject(Object expected, Constant base, long displacement, boolean compressed) { |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
115 if (compressed == runtime.getConfig().useCompressedOops) { |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
116 Object obj = asObject(base); |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
117 if (obj != null) { |
22542
15579668ec3a
renamed constant field to UNSAFE
Doug Simon <doug.simon@oracle.com>
parents:
22541
diff
changeset
|
118 assert expected == UNSAFE.getObject(obj, displacement) : "readUnsafeOop doesn't agree with unsafe.getObject"; |
18719
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
119 } |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
120 } |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
121 if (base instanceof HotSpotMetaspaceConstant) { |
22590
3f6488b29c1a
Remove rawValue from HotSpotMetaspaceConstantImpl, patch raw pointer at code installation time.
Roland Schatz <roland.schatz@oracle.com>
parents:
22556
diff
changeset
|
122 MetaspaceWrapperObject metaspaceObject = HotSpotMetaspaceConstantImpl.getMetaspaceObject(base); |
18719
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
123 if (metaspaceObject instanceof HotSpotResolvedObjectTypeImpl) { |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
124 if (displacement == runtime.getConfig().classMirrorOffset) { |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
125 assert expected == ((HotSpotResolvedObjectTypeImpl) metaspaceObject).mirror(); |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
126 } else if (displacement == runtime.getConfig().arrayKlassComponentMirrorOffset) { |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
127 assert expected == ((HotSpotResolvedObjectTypeImpl) metaspaceObject).mirror().getComponentType(); |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
128 } |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
129 } |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
130 } |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
131 return true; |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
132 } |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
133 |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
134 private Object readRawObject(Constant baseConstant, long initialDisplacement, boolean compressed) { |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
135 long displacement = initialDisplacement; |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
136 |
20176
03b4fa99eff8
rename CompilerToVM.readUnsafeOop to readUncompressedOop and only use it for reading oops in VM data structures since Unsafe.getObject() can be used for other cases
Doug Simon <doug.simon@oracle.com>
parents:
19772
diff
changeset
|
137 Object ret; |
18719
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
138 Object base = asObject(baseConstant); |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
139 if (base == null) { |
20176
03b4fa99eff8
rename CompilerToVM.readUnsafeOop to readUncompressedOop and only use it for reading oops in VM data structures since Unsafe.getObject() can be used for other cases
Doug Simon <doug.simon@oracle.com>
parents:
19772
diff
changeset
|
140 assert !compressed; |
18719
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
141 displacement += asRawPointer(baseConstant); |
20176
03b4fa99eff8
rename CompilerToVM.readUnsafeOop to readUncompressedOop and only use it for reading oops in VM data structures since Unsafe.getObject() can be used for other cases
Doug Simon <doug.simon@oracle.com>
parents:
19772
diff
changeset
|
142 ret = runtime.getCompilerToVM().readUncompressedOop(displacement); |
03b4fa99eff8
rename CompilerToVM.readUnsafeOop to readUncompressedOop and only use it for reading oops in VM data structures since Unsafe.getObject() can be used for other cases
Doug Simon <doug.simon@oracle.com>
parents:
19772
diff
changeset
|
143 } else { |
03b4fa99eff8
rename CompilerToVM.readUnsafeOop to readUncompressedOop and only use it for reading oops in VM data structures since Unsafe.getObject() can be used for other cases
Doug Simon <doug.simon@oracle.com>
parents:
19772
diff
changeset
|
144 assert runtime.getConfig().useCompressedOops == compressed; |
22542
15579668ec3a
renamed constant field to UNSAFE
Doug Simon <doug.simon@oracle.com>
parents:
22541
diff
changeset
|
145 ret = UNSAFE.getObject(base, displacement); |
15023
652564fe42d5
Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
146 } |
18719
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
147 assert verifyReadRawObject(ret, baseConstant, initialDisplacement, compressed); |
6484e5c068c7
Generalize object reading in HotSpotMemoryAccessProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18530
diff
changeset
|
148 return ret; |
18359
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18340
diff
changeset
|
149 } |
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18340
diff
changeset
|
150 |
23401
c9993da505a0
Remove unused method MemoryAccessProvider.readUnsafeConstant (JDK-8157428).
Roland Schatz <roland.schatz@oracle.com>
parents:
23400
diff
changeset
|
151 /** |
c9993da505a0
Remove unused method MemoryAccessProvider.readUnsafeConstant (JDK-8157428).
Roland Schatz <roland.schatz@oracle.com>
parents:
23400
diff
changeset
|
152 * Reads a value of this kind using a base address and a displacement. No bounds checking or |
c9993da505a0
Remove unused method MemoryAccessProvider.readUnsafeConstant (JDK-8157428).
Roland Schatz <roland.schatz@oracle.com>
parents:
23400
diff
changeset
|
153 * type checking is performed. Returns {@code null} if the value is not available at this point. |
c9993da505a0
Remove unused method MemoryAccessProvider.readUnsafeConstant (JDK-8157428).
Roland Schatz <roland.schatz@oracle.com>
parents:
23400
diff
changeset
|
154 * |
c9993da505a0
Remove unused method MemoryAccessProvider.readUnsafeConstant (JDK-8157428).
Roland Schatz <roland.schatz@oracle.com>
parents:
23400
diff
changeset
|
155 * @param baseConstant the base address from which the value is read. |
c9993da505a0
Remove unused method MemoryAccessProvider.readUnsafeConstant (JDK-8157428).
Roland Schatz <roland.schatz@oracle.com>
parents:
23400
diff
changeset
|
156 * @param displacement the displacement within the object in bytes |
c9993da505a0
Remove unused method MemoryAccessProvider.readUnsafeConstant (JDK-8157428).
Roland Schatz <roland.schatz@oracle.com>
parents:
23400
diff
changeset
|
157 * @return the read value encapsulated in a {@link JavaConstant} object, or {@code null} if the |
c9993da505a0
Remove unused method MemoryAccessProvider.readUnsafeConstant (JDK-8157428).
Roland Schatz <roland.schatz@oracle.com>
parents:
23400
diff
changeset
|
158 * value cannot be read. |
c9993da505a0
Remove unused method MemoryAccessProvider.readUnsafeConstant (JDK-8157428).
Roland Schatz <roland.schatz@oracle.com>
parents:
23400
diff
changeset
|
159 * @throws IllegalArgumentException if {@code kind} is {@code null}, {@link JavaKind#Void}, not |
c9993da505a0
Remove unused method MemoryAccessProvider.readUnsafeConstant (JDK-8157428).
Roland Schatz <roland.schatz@oracle.com>
parents:
23400
diff
changeset
|
160 * {@link JavaKind#Object} or not {@linkplain JavaKind#isPrimitive() primitive} kind |
c9993da505a0
Remove unused method MemoryAccessProvider.readUnsafeConstant (JDK-8157428).
Roland Schatz <roland.schatz@oracle.com>
parents:
23400
diff
changeset
|
161 */ |
c9993da505a0
Remove unused method MemoryAccessProvider.readUnsafeConstant (JDK-8157428).
Roland Schatz <roland.schatz@oracle.com>
parents:
23400
diff
changeset
|
162 JavaConstant readUnsafeConstant(JavaKind kind, JavaConstant baseConstant, long displacement) { |
23360
73ceb487b9ca
MemoryAccessProvider.readUnsafeConstant javadoc should be updated for null JavaKind case (JDK-8155244)
Doug Simon <doug.simon@oracle.com>
parents:
23341
diff
changeset
|
163 if (kind == null) { |
23398
3e8ce13f4e12
minimize diff to jvmci-9
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
164 throw new IllegalArgumentException("null JavaKind"); |
23360
73ceb487b9ca
MemoryAccessProvider.readUnsafeConstant javadoc should be updated for null JavaKind case (JDK-8155244)
Doug Simon <doug.simon@oracle.com>
parents:
23341
diff
changeset
|
165 } |
22536
dc1aeef79e7e
Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22454
diff
changeset
|
166 if (kind == JavaKind.Object) { |
18359
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18340
diff
changeset
|
167 Object o = readRawObject(baseConstant, displacement, runtime.getConfig().useCompressedOops); |
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18340
diff
changeset
|
168 return HotSpotObjectConstantImpl.forObject(o); |
15023
652564fe42d5
Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
169 } else { |
23322
f8178417d018
Expose SharedRuntime::throw_and_post_jvmti_exception to JVMCI compilers.
Roland Schatz <roland.schatz@oracle.com>
parents:
23297
diff
changeset
|
170 int bits = kind.getByteCount() * Byte.SIZE; |
f8178417d018
Expose SharedRuntime::throw_and_post_jvmti_exception to JVMCI compilers.
Roland Schatz <roland.schatz@oracle.com>
parents:
23297
diff
changeset
|
171 return readPrimitiveConstant(kind, baseConstant, displacement, bits); |
18359
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18340
diff
changeset
|
172 } |
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18340
diff
changeset
|
173 } |
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18340
diff
changeset
|
174 |
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18340
diff
changeset
|
175 @Override |
22536
dc1aeef79e7e
Refactoring: Rename Kind to JavaKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
22454
diff
changeset
|
176 public JavaConstant readPrimitiveConstant(JavaKind kind, Constant baseConstant, long initialDisplacement, int bits) { |
18359
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18340
diff
changeset
|
177 try { |
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18340
diff
changeset
|
178 long rawValue = readRawValue(baseConstant, initialDisplacement, bits); |
15023
652564fe42d5
Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
179 switch (kind) { |
18359
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18340
diff
changeset
|
180 case Boolean: |
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18340
diff
changeset
|
181 return JavaConstant.forBoolean(rawValue != 0); |
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18340
diff
changeset
|
182 case Byte: |
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18340
diff
changeset
|
183 return JavaConstant.forByte((byte) rawValue); |
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18340
diff
changeset
|
184 case Char: |
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18340
diff
changeset
|
185 return JavaConstant.forChar((char) rawValue); |
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18340
diff
changeset
|
186 case Short: |
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18340
diff
changeset
|
187 return JavaConstant.forShort((short) rawValue); |
15023
652564fe42d5
Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
188 case Int: |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
189 return JavaConstant.forInt((int) rawValue); |
15023
652564fe42d5
Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
190 case Long: |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
191 return JavaConstant.forLong(rawValue); |
15023
652564fe42d5
Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
192 case Float: |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
193 return JavaConstant.forFloat(Float.intBitsToFloat((int) rawValue)); |
15023
652564fe42d5
Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
194 case Double: |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
195 return JavaConstant.forDouble(Double.longBitsToDouble(rawValue)); |
15023
652564fe42d5
Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
196 default: |
23341
67c84a8b19cc
fixed javadoc and implementation of MemoryAccessProvider methods to only throw IllegalArgumentException (JDK-8152024)
Doug Simon <doug.simon@oracle.com>
parents:
23322
diff
changeset
|
197 throw new IllegalArgumentException("Unsupported kind: " + kind); |
15023
652564fe42d5
Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
198 } |
18359
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18340
diff
changeset
|
199 } catch (NullPointerException e) { |
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18340
diff
changeset
|
200 return null; |
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18340
diff
changeset
|
201 } |
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18340
diff
changeset
|
202 } |
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18340
diff
changeset
|
203 |
18483
d7cc487d1325
Move HotSpot specific functionality to new subinterface of ConstantReflectionProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18482
diff
changeset
|
204 @Override |
d7cc487d1325
Move HotSpot specific functionality to new subinterface of ConstantReflectionProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18482
diff
changeset
|
205 public JavaConstant readObjectConstant(Constant base, long displacement) { |
23361
dafcbf1bb9cd
HotSpotMemoryAccessProviderImpl.readObjectConstant should support reading fields in objects (JDK-8155626)
Doug Simon <doug.simon@oracle.com>
parents:
23360
diff
changeset
|
206 if (base instanceof HotSpotObjectConstantImpl) { |
dafcbf1bb9cd
HotSpotMemoryAccessProviderImpl.readObjectConstant should support reading fields in objects (JDK-8155626)
Doug Simon <doug.simon@oracle.com>
parents:
23360
diff
changeset
|
207 Object o = readRawObject(base, displacement, runtime.getConfig().useCompressedOops); |
dafcbf1bb9cd
HotSpotMemoryAccessProviderImpl.readObjectConstant should support reading fields in objects (JDK-8155626)
Doug Simon <doug.simon@oracle.com>
parents:
23360
diff
changeset
|
208 return HotSpotObjectConstantImpl.forObject(o); |
dafcbf1bb9cd
HotSpotMemoryAccessProviderImpl.readObjectConstant should support reading fields in objects (JDK-8155626)
Doug Simon <doug.simon@oracle.com>
parents:
23360
diff
changeset
|
209 } |
23400
0cbc2bd101c3
revert incorrect assertion and correct javadoc around MemoryAccessProvider.readObjectConstant
Doug Simon <doug.simon@oracle.com>
parents:
23398
diff
changeset
|
210 if (!isValidObjectFieldDisplacement(base, displacement)) { |
0cbc2bd101c3
revert incorrect assertion and correct javadoc around MemoryAccessProvider.readObjectConstant
Doug Simon <doug.simon@oracle.com>
parents:
23398
diff
changeset
|
211 return null; |
0cbc2bd101c3
revert incorrect assertion and correct javadoc around MemoryAccessProvider.readObjectConstant
Doug Simon <doug.simon@oracle.com>
parents:
23398
diff
changeset
|
212 } |
18483
d7cc487d1325
Move HotSpot specific functionality to new subinterface of ConstantReflectionProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18482
diff
changeset
|
213 return HotSpotObjectConstantImpl.forObject(readRawObject(base, displacement, false)); |
d7cc487d1325
Move HotSpot specific functionality to new subinterface of ConstantReflectionProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18482
diff
changeset
|
214 } |
d7cc487d1325
Move HotSpot specific functionality to new subinterface of ConstantReflectionProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18482
diff
changeset
|
215 |
d7cc487d1325
Move HotSpot specific functionality to new subinterface of ConstantReflectionProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18482
diff
changeset
|
216 @Override |
23679
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
23401
diff
changeset
|
217 public JavaConstant readNarrowOopConstant(Constant base, long displacement) { |
18483
d7cc487d1325
Move HotSpot specific functionality to new subinterface of ConstantReflectionProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18482
diff
changeset
|
218 return HotSpotObjectConstantImpl.forObject(readRawObject(base, displacement, true), true); |
18359
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18340
diff
changeset
|
219 } |
a3a2359ac88e
Support constant folding of pointer reads.
Roland Schatz <roland.schatz@oracle.com>
parents:
18340
diff
changeset
|
220 |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
221 private HotSpotResolvedObjectTypeImpl readKlass(Constant base, long displacement, boolean compressed) { |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
222 assert (base instanceof HotSpotMetaspaceConstantImpl) || (base instanceof HotSpotObjectConstantImpl) : base.getClass(); |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
223 Object baseObject = (base instanceof HotSpotMetaspaceConstantImpl) ? ((HotSpotMetaspaceConstantImpl) base).asResolvedJavaType() : ((HotSpotObjectConstantImpl) base).object(); |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
224 return runtime.getCompilerToVM().getResolvedJavaType(baseObject, displacement, compressed); |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
225 } |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
226 |
18483
d7cc487d1325
Move HotSpot specific functionality to new subinterface of ConstantReflectionProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18482
diff
changeset
|
227 @Override |
d7cc487d1325
Move HotSpot specific functionality to new subinterface of ConstantReflectionProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18482
diff
changeset
|
228 public Constant readKlassPointerConstant(Constant base, long displacement) { |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
229 HotSpotResolvedObjectTypeImpl klass = readKlass(base, displacement, false); |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
230 if (klass == null) { |
18735
e04e41c3cb6e
Handle null in readKlassPointer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18719
diff
changeset
|
231 return JavaConstant.NULL_POINTER; |
e04e41c3cb6e
Handle null in readKlassPointer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18719
diff
changeset
|
232 } |
22590
3f6488b29c1a
Remove rawValue from HotSpotMetaspaceConstantImpl, patch raw pointer at code installation time.
Roland Schatz <roland.schatz@oracle.com>
parents:
22556
diff
changeset
|
233 return HotSpotMetaspaceConstantImpl.forMetaspaceObject(klass, false); |
18483
d7cc487d1325
Move HotSpot specific functionality to new subinterface of ConstantReflectionProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18482
diff
changeset
|
234 } |
d7cc487d1325
Move HotSpot specific functionality to new subinterface of ConstantReflectionProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18482
diff
changeset
|
235 |
d7cc487d1325
Move HotSpot specific functionality to new subinterface of ConstantReflectionProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18482
diff
changeset
|
236 @Override |
23679
b5557b757040
fix HotSpotVMConfig startup performance (JDK-8159167)
Doug Simon <doug.simon@oracle.com>
parents:
23401
diff
changeset
|
237 public Constant readNarrowKlassPointerConstant(Constant base, long displacement) { |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
238 HotSpotResolvedObjectTypeImpl klass = readKlass(base, displacement, true); |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
239 if (klass == null) { |
18779
7ea9a39bd7cc
return proper kind of NULL
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18735
diff
changeset
|
240 return HotSpotCompressedNullConstant.COMPRESSED_NULL; |
18735
e04e41c3cb6e
Handle null in readKlassPointer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18719
diff
changeset
|
241 } |
22590
3f6488b29c1a
Remove rawValue from HotSpotMetaspaceConstantImpl, patch raw pointer at code installation time.
Roland Schatz <roland.schatz@oracle.com>
parents:
22556
diff
changeset
|
242 return HotSpotMetaspaceConstantImpl.forMetaspaceObject(klass, true); |
18483
d7cc487d1325
Move HotSpot specific functionality to new subinterface of ConstantReflectionProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18482
diff
changeset
|
243 } |
d7cc487d1325
Move HotSpot specific functionality to new subinterface of ConstantReflectionProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18482
diff
changeset
|
244 |
d7cc487d1325
Move HotSpot specific functionality to new subinterface of ConstantReflectionProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18482
diff
changeset
|
245 @Override |
d7cc487d1325
Move HotSpot specific functionality to new subinterface of ConstantReflectionProvider.
Roland Schatz <roland.schatz@oracle.com>
parents:
18482
diff
changeset
|
246 public Constant readMethodPointerConstant(Constant base, long displacement) { |
22454
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
247 assert (base instanceof HotSpotObjectConstantImpl); |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
248 Object baseObject = ((HotSpotObjectConstantImpl) base).object(); |
76af33d4d504
Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
249 HotSpotResolvedJavaMethodImpl method = runtime.getCompilerToVM().getResolvedJavaMethod(baseObject, displacement); |
22590
3f6488b29c1a
Remove rawValue from HotSpotMetaspaceConstantImpl, patch raw pointer at code installation time.
Roland Schatz <roland.schatz@oracle.com>
parents:
22556
diff
changeset
|
250 return HotSpotMetaspaceConstantImpl.forMetaspaceObject(method, false); |
15023
652564fe42d5
Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
251 } |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
252 } |