Mercurial > hg > graal-jvmci-8
annotate jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfigVerifier.java @ 22672:1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Thu, 08 Oct 2015 17:28:41 -0700 |
parents | jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotVMConfigVerifier.java@ec96f33a101d |
children | d6cbb275d6ce |
rev | line source |
---|---|
18652
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
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:
22569
diff
changeset
|
23 package jdk.vm.ci.hotspot; |
18652
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
25 import static java.lang.String.format; |
18652
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
26 |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
27 import java.io.IOException; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
28 import java.io.InputStream; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
29 import java.lang.reflect.Constructor; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
30 import java.lang.reflect.Executable; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
31 import java.lang.reflect.Method; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
32 import java.lang.reflect.Modifier; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
33 import java.util.Arrays; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
34 import java.util.Objects; |
18652
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
35 |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22569
diff
changeset
|
36 import jdk.vm.ci.common.JVMCIError; |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
37 import jdk.internal.org.objectweb.asm.ClassReader; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
38 import jdk.internal.org.objectweb.asm.ClassVisitor; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
39 import jdk.internal.org.objectweb.asm.Label; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
40 import jdk.internal.org.objectweb.asm.MethodVisitor; |
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
41 import jdk.internal.org.objectweb.asm.Opcodes; |
18652
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
42 import jdk.internal.org.objectweb.asm.Type; |
22569
ec96f33a101d
updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents:
22054
diff
changeset
|
43 import sun.misc.Unsafe; |
18652
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
44 |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
45 /** |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
46 * A {@link ClassVisitor} that verifies {@link HotSpotVMConfig} does not access {@link Unsafe} from |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 * any of its non-static, non-constructor methods. This ensures that a deserialized |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
48 * {@link HotSpotVMConfig} object does not perform any unsafe reads on addresses that are only valid |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
49 * in the context in which the object was serialized. Note that this does not catch cases where a |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
50 * client uses an address stored in a {@link HotSpotVMConfig} field. |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
51 */ |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
52 final class HotSpotVMConfigVerifier extends ClassVisitor { |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
53 |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
54 public static boolean check() { |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
55 Class<?> cls = HotSpotVMConfig.class; |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
56 String classFilePath = "/" + cls.getName().replace('.', '/') + ".class"; |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
57 try { |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
58 InputStream classfile = cls.getResourceAsStream(classFilePath); |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
59 ClassReader cr = new ClassReader(Objects.requireNonNull(classfile, "Could not find class file for " + cls.getName())); |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
60 ClassVisitor cv = new HotSpotVMConfigVerifier(); |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
61 cr.accept(cv, 0); |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
62 return true; |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
63 } catch (IOException e) { |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18656
diff
changeset
|
64 throw new JVMCIError(e); |
18652
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
65 } |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
66 } |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
67 |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
68 /** |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
69 * Source file context for error reporting. |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
70 */ |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
71 String sourceFile = null; |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
72 |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
73 /** |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
74 * Line number for error reporting. |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
75 */ |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
76 int lineNo = -1; |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
77 |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
78 private static Class<?> resolve(String name) { |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
79 try { |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
80 return Class.forName(name.replace('/', '.')); |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
81 } catch (ClassNotFoundException e) { |
21552
9579a3c62a9e
use skeleton findbugs jar containing only SuppresFBWarnings to avoid external dependency for JVMCI classes (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18656
diff
changeset
|
82 throw new JVMCIError(e); |
18652
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
83 } |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
84 } |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
85 |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
86 HotSpotVMConfigVerifier() { |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
87 super(Opcodes.ASM5); |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
88 } |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
89 |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
90 @Override |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
91 public void visitSource(String source, String debug) { |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
92 this.sourceFile = source; |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
93 } |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
94 |
18656 | 95 void verify(boolean condition, String message) { |
18652
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
96 if (!condition) { |
18656 | 97 error(message); |
18652
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
98 } |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
99 } |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
100 |
18656 | 101 void error(String message) { |
102 String errorMessage = format("%s:%d: %s is not allowed in the context of compilation replay. The unsafe access should be moved into the %s constructor and the result cached in a field", | |
103 sourceFile, lineNo, message, HotSpotVMConfig.class.getSimpleName()); | |
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:
18656
diff
changeset
|
104 throw new JVMCIError(errorMessage); |
18652
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
105 |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
106 } |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
107 |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
108 @Override |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
109 public MethodVisitor visitMethod(int access, String name, String d, String signature, String[] exceptions) { |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
110 if (!Modifier.isStatic(access) && Modifier.isPublic(access) && !name.equals("<init>")) { |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
111 return new MethodVisitor(Opcodes.ASM5) { |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
112 |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
113 @Override |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
114 public void visitLineNumber(int line, Label start) { |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
115 lineNo = line; |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
116 } |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
117 |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
118 private Executable resolveMethod(String owner, String methodName, String methodDesc) { |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
119 Class<?> declaringClass = resolve(owner); |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
120 while (declaringClass != null) { |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
121 if (methodName.equals("<init>")) { |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
122 for (Constructor<?> c : declaringClass.getDeclaredConstructors()) { |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
123 if (methodDesc.equals(Type.getConstructorDescriptor(c))) { |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
124 return c; |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
125 } |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
126 } |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
127 } else { |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
128 Type[] argumentTypes = Type.getArgumentTypes(methodDesc); |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
129 for (Method m : declaringClass.getDeclaredMethods()) { |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
130 if (m.getName().equals(methodName)) { |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
131 if (Arrays.equals(argumentTypes, Type.getArgumentTypes(m))) { |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
132 if (Type.getReturnType(methodDesc).equals(Type.getReturnType(m))) { |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
133 return m; |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
134 } |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
135 } |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
136 } |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
137 } |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
138 } |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
139 declaringClass = declaringClass.getSuperclass(); |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
140 } |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
141 throw new NoSuchMethodError(owner + "." + methodName + methodDesc); |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
142 } |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
143 |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
144 /** |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
145 * Checks whether a given method is allowed to be called. |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
146 */ |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
147 private boolean checkInvokeTarget(Executable method) { |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
148 if (method.getDeclaringClass().equals(Unsafe.class)) { |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
149 return false; |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
150 } |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
151 return true; |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
152 } |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
153 |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
154 @Override |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
155 public void visitMethodInsn(int opcode, String owner, String methodName, String methodDesc, boolean itf) { |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
156 Executable callee = resolveMethod(owner, methodName, methodDesc); |
18656 | 157 verify(checkInvokeTarget(callee), "invocation of " + callee); |
18652
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
158 } |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
159 }; |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
160 } else { |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
161 return null; |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
162 } |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
163 } |
dfacef5b7958
remove uses of Unsafe in HotSpotVMConfig methods that may be executed on a deserialized HotSpotVMConfig object
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
164 } |