Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotConstantReflectionProvider.java @ 21789:5b9adb645217
fixed remnants of "graal" names in JVMCI code
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 08 Jun 2015 20:24:51 +0200 |
parents | 2081f8f294fe |
children |
rev | line source |
---|---|
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21459
diff
changeset
|
2 * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 */ |
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:
21459
diff
changeset
|
23 package com.oracle.jvmci.hotspot; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
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:
21459
diff
changeset
|
25 import static com.oracle.jvmci.hotspot.HotSpotConstantReflectionProvider.Options.*; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
26 |
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 |
21556
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21554
diff
changeset
|
29 import com.oracle.jvmci.meta.*; |
21554
b1530a6cce8c
renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21552
diff
changeset
|
30 import com.oracle.jvmci.options.*; |
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 /** |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
33 * HotSpot implementation of {@link ConstantReflectionProvider}. |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
34 */ |
18867
7f4cb7587f4c
localized replay compilation marker interface to HotSpot specific code
Doug Simon <doug.simon@oracle.com>
parents:
18801
diff
changeset
|
35 public class HotSpotConstantReflectionProvider implements ConstantReflectionProvider, HotSpotProxified { |
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:
21459
diff
changeset
|
37 static class Options { |
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:
21459
diff
changeset
|
38 //@formatter:off |
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:
21459
diff
changeset
|
39 @Option(help = "Constant fold final fields with default values.", type = OptionType.Debug) |
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:
21459
diff
changeset
|
40 public static final OptionValue<Boolean> TrustFinalDefaultFields = new OptionValue<>(true); |
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:
21459
diff
changeset
|
41 //@formatter:on |
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:
21459
diff
changeset
|
42 } |
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:
21459
diff
changeset
|
43 |
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:
21459
diff
changeset
|
44 protected final HotSpotJVMCIRuntimeProvider runtime; |
18465
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
45 protected final HotSpotMethodHandleAccessProvider methodHandleAccess; |
18482
b8a622c3e99f
Move raw memory access operations to a separate interface.
Roland Schatz <roland.schatz@oracle.com>
parents:
18472
diff
changeset
|
46 protected final HotSpotMemoryAccessProviderImpl memoryAccess; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 |
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:
21459
diff
changeset
|
48 public HotSpotConstantReflectionProvider(HotSpotJVMCIRuntimeProvider runtime) { |
12431
7080a96be216
rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
49 this.runtime = runtime; |
18465
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
50 this.methodHandleAccess = new HotSpotMethodHandleAccessProvider(this); |
18482
b8a622c3e99f
Move raw memory access operations to a separate interface.
Roland Schatz <roland.schatz@oracle.com>
parents:
18472
diff
changeset
|
51 this.memoryAccess = new HotSpotMemoryAccessProviderImpl(runtime); |
18465
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
52 } |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
53 |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
54 public MethodHandleAccessProvider getMethodHandleAccess() { |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
55 return methodHandleAccess; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
56 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
57 |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
58 @Override |
18482
b8a622c3e99f
Move raw memory access operations to a separate interface.
Roland Schatz <roland.schatz@oracle.com>
parents:
18472
diff
changeset
|
59 public MemoryAccessProvider getMemoryAccessProvider() { |
b8a622c3e99f
Move raw memory access operations to a separate interface.
Roland Schatz <roland.schatz@oracle.com>
parents:
18472
diff
changeset
|
60 return memoryAccess; |
b8a622c3e99f
Move raw memory access operations to a separate interface.
Roland Schatz <roland.schatz@oracle.com>
parents:
18472
diff
changeset
|
61 } |
b8a622c3e99f
Move raw memory access operations to a separate interface.
Roland Schatz <roland.schatz@oracle.com>
parents:
18472
diff
changeset
|
62 |
b8a622c3e99f
Move raw memory access operations to a separate interface.
Roland Schatz <roland.schatz@oracle.com>
parents:
18472
diff
changeset
|
63 @Override |
18188
8652481a1110
Introduce new Constant interface for use in high-level graph.
Roland Schatz <roland.schatz@oracle.com>
parents:
18187
diff
changeset
|
64 public Boolean constantEquals(Constant x, Constant y) { |
18471
7b60f8334af0
Compare compressed flag in HotSpotObjectConstantImpl#equals and reference equality in HotSpotConstantReflectionProvider#constantEquals
Andreas Woess <andreas.woess@jku.at>
parents:
18465
diff
changeset
|
65 if (x == y) { |
7b60f8334af0
Compare compressed flag in HotSpotObjectConstantImpl#equals and reference equality in HotSpotConstantReflectionProvider#constantEquals
Andreas Woess <andreas.woess@jku.at>
parents:
18465
diff
changeset
|
66 return true; |
7b60f8334af0
Compare compressed flag in HotSpotObjectConstantImpl#equals and reference equality in HotSpotConstantReflectionProvider#constantEquals
Andreas Woess <andreas.woess@jku.at>
parents:
18465
diff
changeset
|
67 } else if (x instanceof HotSpotObjectConstantImpl) { |
7b60f8334af0
Compare compressed flag in HotSpotObjectConstantImpl#equals and reference equality in HotSpotConstantReflectionProvider#constantEquals
Andreas Woess <andreas.woess@jku.at>
parents:
18465
diff
changeset
|
68 return y instanceof HotSpotObjectConstantImpl && ((HotSpotObjectConstantImpl) x).object() == ((HotSpotObjectConstantImpl) y).object(); |
7b60f8334af0
Compare compressed flag in HotSpotObjectConstantImpl#equals and reference equality in HotSpotConstantReflectionProvider#constantEquals
Andreas Woess <andreas.woess@jku.at>
parents:
18465
diff
changeset
|
69 } else { |
7b60f8334af0
Compare compressed flag in HotSpotObjectConstantImpl#equals and reference equality in HotSpotConstantReflectionProvider#constantEquals
Andreas Woess <andreas.woess@jku.at>
parents:
18465
diff
changeset
|
70 return x.equals(y); |
7b60f8334af0
Compare compressed flag in HotSpotObjectConstantImpl#equals and reference equality in HotSpotConstantReflectionProvider#constantEquals
Andreas Woess <andreas.woess@jku.at>
parents:
18465
diff
changeset
|
71 } |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
72 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
73 |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
74 @Override |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
75 public Integer readArrayLength(JavaConstant array) { |
18262
f7d45e2426d4
converted HotSpotObjectConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18223
diff
changeset
|
76 if (array.getKind() != Kind.Object || array.isNull()) { |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
77 return null; |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
78 } |
18262
f7d45e2426d4
converted HotSpotObjectConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18223
diff
changeset
|
79 |
18290
e7d219e9d01f
removed HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18266
diff
changeset
|
80 Object arrayObject = ((HotSpotObjectConstantImpl) array).object(); |
18262
f7d45e2426d4
converted HotSpotObjectConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18223
diff
changeset
|
81 if (!arrayObject.getClass().isArray()) { |
f7d45e2426d4
converted HotSpotObjectConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18223
diff
changeset
|
82 return null; |
f7d45e2426d4
converted HotSpotObjectConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18223
diff
changeset
|
83 } |
f7d45e2426d4
converted HotSpotObjectConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18223
diff
changeset
|
84 return Array.getLength(arrayObject); |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
85 } |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
86 |
18472
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
87 public JavaConstant readConstantArrayElement(JavaConstant array, int index) { |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
88 if (array instanceof HotSpotObjectConstantImpl && ((HotSpotObjectConstantImpl) array).getStableDimension() > 0) { |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
89 JavaConstant element = readArrayElement(array, index); |
18505
3356ea593672
Add missing null check in readConstantArrayElement
Andreas Woess <andreas.woess@jku.at>
parents:
18487
diff
changeset
|
90 if (element != null && (((HotSpotObjectConstantImpl) array).isDefaultStable() || !element.isDefaultForKind())) { |
18472
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
91 return element; |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
92 } |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
93 } |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
94 return null; |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
95 } |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
96 |
21459
f5c2bc68205e
support later folding of constant array reads
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21377
diff
changeset
|
97 /** |
f5c2bc68205e
support later folding of constant array reads
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21377
diff
changeset
|
98 * Try to convert {@code offset} into an an index into {@code array}. |
f5c2bc68205e
support later folding of constant array reads
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21377
diff
changeset
|
99 * |
21643
2081f8f294fe
Fixed some javadoc
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21556
diff
changeset
|
100 * @return the computed index or -1 if the offset isn't within the array |
21459
f5c2bc68205e
support later folding of constant array reads
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21377
diff
changeset
|
101 */ |
f5c2bc68205e
support later folding of constant array reads
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21377
diff
changeset
|
102 private int indexForOffset(JavaConstant array, long offset) { |
f5c2bc68205e
support later folding of constant array reads
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21377
diff
changeset
|
103 if (array.getKind() != Kind.Object || array.isNull()) { |
f5c2bc68205e
support later folding of constant array reads
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21377
diff
changeset
|
104 return -1; |
f5c2bc68205e
support later folding of constant array reads
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21377
diff
changeset
|
105 } |
f5c2bc68205e
support later folding of constant array reads
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21377
diff
changeset
|
106 Class<?> componentType = ((HotSpotObjectConstantImpl) array).object().getClass().getComponentType(); |
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:
21459
diff
changeset
|
107 Kind kind = runtime.getHostJVMCIBackend().getMetaAccess().lookupJavaType(componentType).getKind(); |
21459
f5c2bc68205e
support later folding of constant array reads
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21377
diff
changeset
|
108 int arraybase = runtime.getArrayBaseOffset(kind); |
f5c2bc68205e
support later folding of constant array reads
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21377
diff
changeset
|
109 int scale = runtime.getArrayIndexScale(kind); |
f5c2bc68205e
support later folding of constant array reads
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21377
diff
changeset
|
110 if (offset < arraybase) { |
f5c2bc68205e
support later folding of constant array reads
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21377
diff
changeset
|
111 return -1; |
f5c2bc68205e
support later folding of constant array reads
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21377
diff
changeset
|
112 } |
f5c2bc68205e
support later folding of constant array reads
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21377
diff
changeset
|
113 long index = offset - arraybase; |
f5c2bc68205e
support later folding of constant array reads
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21377
diff
changeset
|
114 if (index % scale != 0) { |
f5c2bc68205e
support later folding of constant array reads
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21377
diff
changeset
|
115 return -1; |
f5c2bc68205e
support later folding of constant array reads
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21377
diff
changeset
|
116 } |
f5c2bc68205e
support later folding of constant array reads
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21377
diff
changeset
|
117 long result = index / scale; |
f5c2bc68205e
support later folding of constant array reads
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21377
diff
changeset
|
118 if (result >= Integer.MAX_VALUE) { |
f5c2bc68205e
support later folding of constant array reads
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21377
diff
changeset
|
119 return -1; |
f5c2bc68205e
support later folding of constant array reads
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21377
diff
changeset
|
120 } |
f5c2bc68205e
support later folding of constant array reads
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21377
diff
changeset
|
121 return (int) result; |
f5c2bc68205e
support later folding of constant array reads
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21377
diff
changeset
|
122 } |
f5c2bc68205e
support later folding of constant array reads
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21377
diff
changeset
|
123 |
f5c2bc68205e
support later folding of constant array reads
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21377
diff
changeset
|
124 public JavaConstant readConstantArrayElementForOffset(JavaConstant array, long offset) { |
f5c2bc68205e
support later folding of constant array reads
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21377
diff
changeset
|
125 if (array instanceof HotSpotObjectConstantImpl && ((HotSpotObjectConstantImpl) array).getStableDimension() > 0) { |
f5c2bc68205e
support later folding of constant array reads
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21377
diff
changeset
|
126 return readConstantArrayElement(array, indexForOffset(array, offset)); |
f5c2bc68205e
support later folding of constant array reads
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21377
diff
changeset
|
127 } |
f5c2bc68205e
support later folding of constant array reads
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21377
diff
changeset
|
128 return null; |
f5c2bc68205e
support later folding of constant array reads
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21377
diff
changeset
|
129 } |
f5c2bc68205e
support later folding of constant array reads
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21377
diff
changeset
|
130 |
15023
652564fe42d5
Use CompressionNode for accessing compressed Klass pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
15018
diff
changeset
|
131 @Override |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
132 public JavaConstant readArrayElement(JavaConstant array, int index) { |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13488
diff
changeset
|
133 if (array.getKind() != Kind.Object || array.isNull()) { |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13488
diff
changeset
|
134 return null; |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13488
diff
changeset
|
135 } |
18290
e7d219e9d01f
removed HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18266
diff
changeset
|
136 Object a = ((HotSpotObjectConstantImpl) array).object(); |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13488
diff
changeset
|
137 |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13488
diff
changeset
|
138 if (index < 0 || index >= Array.getLength(a)) { |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13488
diff
changeset
|
139 return null; |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13488
diff
changeset
|
140 } |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13488
diff
changeset
|
141 |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13488
diff
changeset
|
142 if (a instanceof Object[]) { |
18472
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
143 Object element = ((Object[]) a)[index]; |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
144 if (((HotSpotObjectConstantImpl) array).getStableDimension() > 1) { |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
145 return HotSpotObjectConstantImpl.forStableArray(element, ((HotSpotObjectConstantImpl) array).getStableDimension() - 1, ((HotSpotObjectConstantImpl) array).isDefaultStable()); |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
146 } else { |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
147 return HotSpotObjectConstantImpl.forObject(element); |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
148 } |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13488
diff
changeset
|
149 } else { |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
150 return JavaConstant.forBoxedPrimitive(Array.get(a, index)); |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13488
diff
changeset
|
151 } |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13488
diff
changeset
|
152 } |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13488
diff
changeset
|
153 |
18801
95249d5e794f
Only embed boxed primitives when the box is cached by the JDK
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18686
diff
changeset
|
154 /** |
95249d5e794f
Only embed boxed primitives when the box is cached by the JDK
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18686
diff
changeset
|
155 * Check if the constant is a boxed value that is guaranteed to be cached by the platform. |
95249d5e794f
Only embed boxed primitives when the box is cached by the JDK
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18686
diff
changeset
|
156 * Otherwise the generated code might be the only reference to the boxed value and since object |
95249d5e794f
Only embed boxed primitives when the box is cached by the JDK
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18686
diff
changeset
|
157 * references from nmethods are weak this can cause GC problems. |
95249d5e794f
Only embed boxed primitives when the box is cached by the JDK
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18686
diff
changeset
|
158 * |
95249d5e794f
Only embed boxed primitives when the box is cached by the JDK
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18686
diff
changeset
|
159 * @param source |
95249d5e794f
Only embed boxed primitives when the box is cached by the JDK
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18686
diff
changeset
|
160 * @return true if the box is cached |
95249d5e794f
Only embed boxed primitives when the box is cached by the JDK
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18686
diff
changeset
|
161 */ |
95249d5e794f
Only embed boxed primitives when the box is cached by the JDK
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18686
diff
changeset
|
162 private static boolean isBoxCached(JavaConstant source) { |
95249d5e794f
Only embed boxed primitives when the box is cached by the JDK
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18686
diff
changeset
|
163 switch (source.getKind()) { |
95249d5e794f
Only embed boxed primitives when the box is cached by the JDK
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18686
diff
changeset
|
164 case Boolean: |
95249d5e794f
Only embed boxed primitives when the box is cached by the JDK
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18686
diff
changeset
|
165 return true; |
95249d5e794f
Only embed boxed primitives when the box is cached by the JDK
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18686
diff
changeset
|
166 case Char: |
95249d5e794f
Only embed boxed primitives when the box is cached by the JDK
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18686
diff
changeset
|
167 return source.asInt() <= 127; |
95249d5e794f
Only embed boxed primitives when the box is cached by the JDK
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18686
diff
changeset
|
168 case Byte: |
95249d5e794f
Only embed boxed primitives when the box is cached by the JDK
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18686
diff
changeset
|
169 case Short: |
95249d5e794f
Only embed boxed primitives when the box is cached by the JDK
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18686
diff
changeset
|
170 case Int: |
95249d5e794f
Only embed boxed primitives when the box is cached by the JDK
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18686
diff
changeset
|
171 return source.asInt() >= -128 && source.asInt() <= 127; |
95249d5e794f
Only embed boxed primitives when the box is cached by the JDK
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18686
diff
changeset
|
172 case Long: |
95249d5e794f
Only embed boxed primitives when the box is cached by the JDK
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18686
diff
changeset
|
173 return source.asLong() >= -128 && source.asLong() <= 127; |
95249d5e794f
Only embed boxed primitives when the box is cached by the JDK
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18686
diff
changeset
|
174 case Float: |
95249d5e794f
Only embed boxed primitives when the box is cached by the JDK
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18686
diff
changeset
|
175 case Double: |
95249d5e794f
Only embed boxed primitives when the box is cached by the JDK
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18686
diff
changeset
|
176 return false; |
95249d5e794f
Only embed boxed primitives when the box is cached by the JDK
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18686
diff
changeset
|
177 default: |
95249d5e794f
Only embed boxed primitives when the box is cached by the JDK
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18686
diff
changeset
|
178 throw new IllegalArgumentException("unexpected kind " + source.getKind()); |
95249d5e794f
Only embed boxed primitives when the box is cached by the JDK
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18686
diff
changeset
|
179 } |
95249d5e794f
Only embed boxed primitives when the box is cached by the JDK
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18686
diff
changeset
|
180 } |
95249d5e794f
Only embed boxed primitives when the box is cached by the JDK
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18686
diff
changeset
|
181 |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13488
diff
changeset
|
182 @Override |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
183 public JavaConstant boxPrimitive(JavaConstant source) { |
18801
95249d5e794f
Only embed boxed primitives when the box is cached by the JDK
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18686
diff
changeset
|
184 if (!source.getKind().isPrimitive() || !isBoxCached(source)) { |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13488
diff
changeset
|
185 return null; |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13488
diff
changeset
|
186 } |
18262
f7d45e2426d4
converted HotSpotObjectConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18223
diff
changeset
|
187 return HotSpotObjectConstantImpl.forObject(source.asBoxedPrimitive()); |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13488
diff
changeset
|
188 } |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13488
diff
changeset
|
189 |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13488
diff
changeset
|
190 @Override |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
18176
diff
changeset
|
191 public JavaConstant unboxPrimitive(JavaConstant source) { |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13488
diff
changeset
|
192 if (!source.getKind().isObject()) { |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13488
diff
changeset
|
193 return null; |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13488
diff
changeset
|
194 } |
18293
ab8fbaa5e72f
fixed minor regressions after removing HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18290
diff
changeset
|
195 if (source.isNull()) { |
ab8fbaa5e72f
fixed minor regressions after removing HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18290
diff
changeset
|
196 return null; |
ab8fbaa5e72f
fixed minor regressions after removing HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18290
diff
changeset
|
197 } |
18290
e7d219e9d01f
removed HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18266
diff
changeset
|
198 return JavaConstant.forBoxedPrimitive(((HotSpotObjectConstantImpl) source).object()); |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13488
diff
changeset
|
199 } |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13488
diff
changeset
|
200 |
18295
17bf458cf86e
reduced use of HotSpotObjectConstantImpl.forObject
Doug Simon <doug.simon@oracle.com>
parents:
18293
diff
changeset
|
201 public JavaConstant forString(String value) { |
17bf458cf86e
reduced use of HotSpotObjectConstantImpl.forObject
Doug Simon <doug.simon@oracle.com>
parents:
18293
diff
changeset
|
202 return HotSpotObjectConstantImpl.forObject(value); |
17bf458cf86e
reduced use of HotSpotObjectConstantImpl.forObject
Doug Simon <doug.simon@oracle.com>
parents:
18293
diff
changeset
|
203 } |
17bf458cf86e
reduced use of HotSpotObjectConstantImpl.forObject
Doug Simon <doug.simon@oracle.com>
parents:
18293
diff
changeset
|
204 |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13488
diff
changeset
|
205 @Override |
18487
0f4813e0b4a9
Use asConstant() instead of asJavaConstant() where possible.
Roland Schatz <roland.schatz@oracle.com>
parents:
18482
diff
changeset
|
206 public ResolvedJavaType asJavaType(Constant constant) { |
15909
e43591136d9f
Support for compressed constants.
Roland Schatz <roland.schatz@oracle.com>
parents:
15291
diff
changeset
|
207 if (constant instanceof HotSpotObjectConstant) { |
18290
e7d219e9d01f
removed HotSpotObjectConstantImpl.asObject()
Doug Simon <doug.simon@oracle.com>
parents:
18266
diff
changeset
|
208 Object obj = ((HotSpotObjectConstantImpl) constant).object(); |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13488
diff
changeset
|
209 if (obj instanceof Class) { |
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:
21459
diff
changeset
|
210 return runtime.getHostJVMCIBackend().getMetaAccess().lookupJavaType((Class<?>) obj); |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13488
diff
changeset
|
211 } |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13488
diff
changeset
|
212 } |
16183
b1be2a46cc5c
canonicalize LoadMethodNodes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15909
diff
changeset
|
213 if (constant instanceof HotSpotMetaspaceConstant) { |
18266
ae181ec869c5
converted HotSpotMetaspaceConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18262
diff
changeset
|
214 Object obj = HotSpotMetaspaceConstantImpl.getMetaspaceObject(constant); |
18223
17c98fad6980
converted HotSpotResolvedObjectType to an interface
Doug Simon <doug.simon@oracle.com>
parents:
18188
diff
changeset
|
215 if (obj instanceof HotSpotResolvedObjectTypeImpl) { |
16183
b1be2a46cc5c
canonicalize LoadMethodNodes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15909
diff
changeset
|
216 return (ResolvedJavaType) obj; |
b1be2a46cc5c
canonicalize LoadMethodNodes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15909
diff
changeset
|
217 } |
b1be2a46cc5c
canonicalize LoadMethodNodes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15909
diff
changeset
|
218 } |
15018
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13488
diff
changeset
|
219 return null; |
db4254246f9a
Remove Constant.forObject and Constant.asObject to improve compiler/VM separation
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13488
diff
changeset
|
220 } |
18465
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
221 |
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:
21459
diff
changeset
|
222 private static final String SystemClassName = "Ljava/lang/System;"; |
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:
21459
diff
changeset
|
223 |
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:
21459
diff
changeset
|
224 /** |
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:
21459
diff
changeset
|
225 * Determines if a static field is constant for the purpose of |
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:
21459
diff
changeset
|
226 * {@link #readConstantFieldValue(JavaField, JavaConstant)}. |
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:
21459
diff
changeset
|
227 */ |
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:
21459
diff
changeset
|
228 protected boolean isStaticFieldConstant(HotSpotResolvedJavaField staticField) { |
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:
21459
diff
changeset
|
229 if (staticField.isFinal() || staticField.isStable()) { |
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:
21459
diff
changeset
|
230 ResolvedJavaType holder = staticField.getDeclaringClass(); |
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:
21459
diff
changeset
|
231 if (holder.isInitialized() && !holder.getName().equals(SystemClassName)) { |
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:
21459
diff
changeset
|
232 return true; |
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:
21459
diff
changeset
|
233 } |
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:
21459
diff
changeset
|
234 } |
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:
21459
diff
changeset
|
235 return false; |
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:
21459
diff
changeset
|
236 } |
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:
21459
diff
changeset
|
237 |
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:
21459
diff
changeset
|
238 /** |
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:
21459
diff
changeset
|
239 * Determines if a value read from a {@code final} instance field is considered constant. The |
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21459
diff
changeset
|
240 * implementation in {@link HotSpotConstantReflectionProvider} returns true if {@code value} is |
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:
21459
diff
changeset
|
241 * not the {@link JavaConstant#isDefaultForKind default value} for its kind or if |
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:
21459
diff
changeset
|
242 * {@link Options#TrustFinalDefaultFields} is true. |
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:
21459
diff
changeset
|
243 * |
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:
21459
diff
changeset
|
244 * @param value a value read from a {@code final} instance field |
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:
21459
diff
changeset
|
245 * @param receiverClass the {@link Object#getClass() class} of object from which the |
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21459
diff
changeset
|
246 * {@code value} was read |
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:
21459
diff
changeset
|
247 */ |
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:
21459
diff
changeset
|
248 protected boolean isFinalInstanceFieldValueConstant(JavaConstant value, Class<?> receiverClass) { |
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:
21459
diff
changeset
|
249 return !value.isDefaultForKind() || TrustFinalDefaultFields.getValue(); |
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:
21459
diff
changeset
|
250 } |
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:
21459
diff
changeset
|
251 |
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:
21459
diff
changeset
|
252 /** |
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:
21459
diff
changeset
|
253 * Determines if a value read from a {@link Stable} instance field is considered constant. The |
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21459
diff
changeset
|
254 * implementation in {@link HotSpotConstantReflectionProvider} returns true if {@code value} is |
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:
21459
diff
changeset
|
255 * not the {@link JavaConstant#isDefaultForKind default value} for its kind. |
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:
21459
diff
changeset
|
256 * |
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:
21459
diff
changeset
|
257 * @param value a value read from a {@link Stable} field |
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:
21459
diff
changeset
|
258 * @param receiverClass the {@link Object#getClass() class} of object from which the |
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21459
diff
changeset
|
259 * {@code value} was read |
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:
21459
diff
changeset
|
260 */ |
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:
21459
diff
changeset
|
261 protected boolean isStableInstanceFieldValueConstant(JavaConstant value, Class<?> receiverClass) { |
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:
21459
diff
changeset
|
262 return !value.isDefaultForKind(); |
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:
21459
diff
changeset
|
263 } |
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:
21459
diff
changeset
|
264 |
18465
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
265 /** |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
266 * {@inheritDoc} |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
267 * <p> |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
268 * The {@code value} field in {@link OptionValue} is considered constant if the type of |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
269 * {@code receiver} is (assignable to) {@link StableOptionValue}. |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
270 */ |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
271 public JavaConstant readConstantFieldValue(JavaField field, JavaConstant receiver) { |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
272 HotSpotResolvedJavaField hotspotField = (HotSpotResolvedJavaField) field; |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
273 |
21377
6f2ff1bccbf1
Adhere to specification described in JavaDoc of interface
Christian Wimmer <christian.wimmer@oracle.com>
parents:
21290
diff
changeset
|
274 if (hotspotField.isStatic()) { |
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:
21459
diff
changeset
|
275 if (isStaticFieldConstant(hotspotField)) { |
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:
21459
diff
changeset
|
276 JavaConstant value = readFieldValue(field, receiver); |
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:
21459
diff
changeset
|
277 if (hotspotField.isFinal() || !value.isDefaultForKind()) { |
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:
21459
diff
changeset
|
278 return value; |
18465
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
279 } |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
280 } |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
281 } else { |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
282 /* |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
283 * for non-static final fields, we must assume that they are only initialized if they |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
284 * have a non-default value. |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
285 */ |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
286 Object object = receiver.isNull() ? null : ((HotSpotObjectConstantImpl) receiver).object(); |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
287 |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
288 // Canonicalization may attempt to process an unsafe read before |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
289 // processing a guard (e.g. a null check or a type check) for this read |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
290 // so we need to check the object being read |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
291 if (object != null) { |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
292 if (hotspotField.isFinal()) { |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
293 if (hotspotField.isInObject(object)) { |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
294 JavaConstant value = readFieldValue(field, receiver); |
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:
21459
diff
changeset
|
295 if (isFinalInstanceFieldValueConstant(value, object.getClass())) { |
18465
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
296 return value; |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
297 } |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
298 } |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
299 } else if (hotspotField.isStable()) { |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
300 if (hotspotField.isInObject(object)) { |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
301 JavaConstant value = readFieldValue(field, receiver); |
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:
21459
diff
changeset
|
302 if (isStableInstanceFieldValueConstant(value, object.getClass())) { |
18465
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
303 return value; |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
304 } |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
305 } |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
306 } else { |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
307 Class<?> clazz = object.getClass(); |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
308 if (StableOptionValue.class.isAssignableFrom(clazz)) { |
18686
3f15de59df5e
Support multiple fields in StableOptionValue
Christian Wimmer <christian.wimmer@oracle.com>
parents:
18564
diff
changeset
|
309 if (hotspotField.isInObject(object) && hotspotField.getName().equals("value")) { |
18465
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
310 StableOptionValue<?> option = (StableOptionValue<?>) object; |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
311 return HotSpotObjectConstantImpl.forObject(option.getValue()); |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
312 } |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
313 } |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
314 } |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
315 } |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
316 } |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
317 return null; |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
318 } |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
319 |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
320 public JavaConstant readFieldValue(JavaField field, JavaConstant receiver) { |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
321 HotSpotResolvedJavaField hotspotField = (HotSpotResolvedJavaField) field; |
18472
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
322 if (!hotspotField.isStable()) { |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
323 return readNonStableFieldValue(field, receiver); |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
324 } else { |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
325 return readStableFieldValue(field, receiver, false); |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
326 } |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
327 } |
18465
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
328 |
18472
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
329 private JavaConstant readNonStableFieldValue(JavaField field, JavaConstant receiver) { |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
330 HotSpotResolvedJavaField hotspotField = (HotSpotResolvedJavaField) field; |
21377
6f2ff1bccbf1
Adhere to specification described in JavaDoc of interface
Christian Wimmer <christian.wimmer@oracle.com>
parents:
21290
diff
changeset
|
331 if (hotspotField.isStatic()) { |
18465
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
332 HotSpotResolvedJavaType holder = (HotSpotResolvedJavaType) hotspotField.getDeclaringClass(); |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
333 if (holder.isInitialized()) { |
18482
b8a622c3e99f
Move raw memory access operations to a separate interface.
Roland Schatz <roland.schatz@oracle.com>
parents:
18472
diff
changeset
|
334 return memoryAccess.readUnsafeConstant(hotspotField.getKind(), HotSpotObjectConstantImpl.forObject(holder.mirror()), hotspotField.offset()); |
18465
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
335 } |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
336 } else { |
21377
6f2ff1bccbf1
Adhere to specification described in JavaDoc of interface
Christian Wimmer <christian.wimmer@oracle.com>
parents:
21290
diff
changeset
|
337 if (receiver.isNonNull() && hotspotField.isInObject(((HotSpotObjectConstantImpl) receiver).object())) { |
6f2ff1bccbf1
Adhere to specification described in JavaDoc of interface
Christian Wimmer <christian.wimmer@oracle.com>
parents:
21290
diff
changeset
|
338 return memoryAccess.readUnsafeConstant(hotspotField.getKind(), receiver, hotspotField.offset()); |
6f2ff1bccbf1
Adhere to specification described in JavaDoc of interface
Christian Wimmer <christian.wimmer@oracle.com>
parents:
21290
diff
changeset
|
339 } |
18465
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
340 } |
21377
6f2ff1bccbf1
Adhere to specification described in JavaDoc of interface
Christian Wimmer <christian.wimmer@oracle.com>
parents:
21290
diff
changeset
|
341 return null; |
18465
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
342 } |
f0a8b72315c1
Move ResolvedJavaField#read[Constant]Value and getMethodHandleAccess() to ConstantReflectionProvider
Andreas Woess <andreas.woess@jku.at>
parents:
18362
diff
changeset
|
343 |
18472
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
344 public JavaConstant readStableFieldValue(JavaField field, JavaConstant receiver, boolean isDefaultStable) { |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
345 JavaConstant fieldValue = readNonStableFieldValue(field, receiver); |
18564
966081b8e830
guard against null element in HotSpotConstantReflectionProvider.readStableFieldValue
Doug Simon <doug.simon@oracle.com>
parents:
18530
diff
changeset
|
346 if (fieldValue.isNonNull()) { |
966081b8e830
guard against null element in HotSpotConstantReflectionProvider.readStableFieldValue
Doug Simon <doug.simon@oracle.com>
parents:
18530
diff
changeset
|
347 JavaType declaredType = field.getType(); |
966081b8e830
guard against null element in HotSpotConstantReflectionProvider.readStableFieldValue
Doug Simon <doug.simon@oracle.com>
parents:
18530
diff
changeset
|
348 if (declaredType.getComponentType() != null) { |
966081b8e830
guard against null element in HotSpotConstantReflectionProvider.readStableFieldValue
Doug Simon <doug.simon@oracle.com>
parents:
18530
diff
changeset
|
349 int stableDimension = getArrayDimension(declaredType); |
966081b8e830
guard against null element in HotSpotConstantReflectionProvider.readStableFieldValue
Doug Simon <doug.simon@oracle.com>
parents:
18530
diff
changeset
|
350 return HotSpotObjectConstantImpl.forStableArray(((HotSpotObjectConstantImpl) fieldValue).object(), stableDimension, isDefaultStable); |
966081b8e830
guard against null element in HotSpotConstantReflectionProvider.readStableFieldValue
Doug Simon <doug.simon@oracle.com>
parents:
18530
diff
changeset
|
351 } |
18472
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
352 } |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
353 return fieldValue; |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
354 } |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
355 |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
356 private static int getArrayDimension(JavaType type) { |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
357 int dimensions = 0; |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
358 JavaType componentType = type; |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
359 while ((componentType = componentType.getComponentType()) != null) { |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
360 dimensions++; |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
361 } |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
362 return dimensions; |
de179c27cad3
Add support for stable array constants
Andreas Woess <andreas.woess@jku.at>
parents:
18471
diff
changeset
|
363 } |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
364 } |