annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java @ 14105:f62c770c22be

make HotSpotResolvedJavaMethod leaner
author twisti
date Thu, 06 Mar 2014 22:40:48 -0800
parents a38a54030ea2
children 800057208a2c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
5548
8872bc0eebdf Renaming hotspot.ri => hotspot.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5547
diff changeset
23 package com.oracle.graal.hotspot.meta;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
9338
0266549ff6e0 added support from compiled stubs to be installed as RuntimeStubs and to be able to directly call C/C++ runtime functions (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9289
diff changeset
25 import static com.oracle.graal.graph.UnsafeAccess.*;
7037
dd81042f4eb1 added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents: 7014
diff changeset
26 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9760
diff changeset
27 import static com.oracle.graal.phases.GraalOptions.*;
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6588
diff changeset
28
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
29 import java.lang.annotation.*;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
30 import java.lang.reflect.*;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
31 import java.util.*;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
32 import java.util.concurrent.*;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
33
8217
dce9cefed571 Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7930
diff changeset
34 import com.oracle.graal.api.code.*;
5507
dc71b06d09f8 Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5346
diff changeset
35 import com.oracle.graal.api.meta.*;
8610
5407d1dd6450 API to access nullness profiling information for instanceof, checkcast, and aastore
Christian Haeubl <haeubl@ssw.jku.at>
parents: 8217
diff changeset
36 import com.oracle.graal.api.meta.ProfilingInfo.TriState;
13164
70e6bb85d802 cleaned up HotSpotMethodData tracing a little and enabled it when -Dgraal.traceMethodDataFilter=true
Doug Simon <doug.simon@oracle.com>
parents: 12654
diff changeset
37 import com.oracle.graal.debug.*;
9636
ff4e8218d3dd Remove hasVtableEntry, use isInVirtualMethodTable instead
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9610
diff changeset
38 import com.oracle.graal.graph.*;
5176
af59b4dfc9e4 compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5115
diff changeset
39 import com.oracle.graal.hotspot.*;
7310
79a7b761755c Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7212
diff changeset
40 import com.oracle.graal.hotspot.debug.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
41
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
42 /**
5775
2c088af17e59 Removed left over Ri* prefixed identifiers
Doug Simon <doug.simon@oracle.com>
parents: 5722
diff changeset
43 * Implementation of {@link JavaMethod} for resolved HotSpot methods.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
44 */
5554
70f715dfbb41 Bring Java renamings and restructurings to the C++ part.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5548
diff changeset
45 public final class HotSpotResolvedJavaMethod extends HotSpotMethod implements ResolvedJavaMethod {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
46
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
47 private static final long serialVersionUID = -5486975070147586588L;
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
48
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6588
diff changeset
49 /**
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6588
diff changeset
50 * Reference to metaspace Method object.
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6588
diff changeset
51 */
13259
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
52 private final long metaspaceMethod;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
53
7084
9ba90252ce08 HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7083
diff changeset
54 private final HotSpotResolvedObjectType holder;
13259
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
55 private final HotSpotConstantPool constantPool;
13254
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 13217
diff changeset
56 private final HotSpotSignature signature;
9416
16c354398d09 intrinsify Reflection.getCallerClass
twisti
parents: 9380
diff changeset
57 private boolean callerSensitive;
16c354398d09 intrinsify Reflection.getCallerClass
twisti
parents: 9380
diff changeset
58 private boolean forceInline;
16c354398d09 intrinsify Reflection.getCallerClass
twisti
parents: 9380
diff changeset
59 private boolean dontInline;
16c354398d09 intrinsify Reflection.getCallerClass
twisti
parents: 9380
diff changeset
60 private boolean ignoredBySecurityStackWalk;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
61 private Map<Object, Object> compilerStorage;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4220
diff changeset
62 private HotSpotMethodData methodData;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
63 private byte[] code;
5176
af59b4dfc9e4 compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5115
diff changeset
64 private CompilationTask currentTask;
8217
dce9cefed571 Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7930
diff changeset
65 private SpeculationLog speculationLog;
5176
af59b4dfc9e4 compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5115
diff changeset
66
9760
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9714
diff changeset
67 /**
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9714
diff changeset
68 * Gets the holder of a HotSpot metaspace method native object.
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9714
diff changeset
69 *
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9714
diff changeset
70 * @param metaspaceMethod a metaspace Method object
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9714
diff changeset
71 * @return the {@link ResolvedJavaType} corresponding to the holder of the
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9714
diff changeset
72 * {@code metaspaceMethod}
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9714
diff changeset
73 */
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9714
diff changeset
74 public static HotSpotResolvedObjectType getHolder(long metaspaceMethod) {
12431
7080a96be216 rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents: 12429
diff changeset
75 HotSpotVMConfig config = runtime().getConfig();
13264
b23cbfb4366a merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents: 13259
diff changeset
76 final long metaspaceConstMethod = unsafe.getAddress(metaspaceMethod + config.methodConstMethodOffset);
b23cbfb4366a merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents: 13259
diff changeset
77 final long metaspaceConstantPool = unsafe.getAddress(metaspaceConstMethod + config.constMethodConstantsOffset);
b23cbfb4366a merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents: 13259
diff changeset
78 final long metaspaceKlass = unsafe.getAddress(metaspaceConstantPool + config.constantPoolHolderOffset);
b23cbfb4366a merged CompilerToVM.getMetaspaceConstructor into CompilerToVM.getMetaspaceMethod
twisti
parents: 13259
diff changeset
79 return (HotSpotResolvedObjectType) HotSpotResolvedObjectType.fromMetaspaceKlass(metaspaceKlass);
9760
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9714
diff changeset
80 }
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9714
diff changeset
81
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9714
diff changeset
82 /**
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9714
diff changeset
83 * Gets the {@link ResolvedJavaMethod} for a HotSpot metaspace method native object.
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9714
diff changeset
84 *
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9714
diff changeset
85 * @param metaspaceMethod a metaspace Method object
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9714
diff changeset
86 * @return the {@link ResolvedJavaMethod} corresponding to {@code metaspaceMethod}
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9714
diff changeset
87 */
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9714
diff changeset
88 public static HotSpotResolvedJavaMethod fromMetaspace(long metaspaceMethod) {
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9714
diff changeset
89 HotSpotResolvedObjectType holder = getHolder(metaspaceMethod);
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9714
diff changeset
90 return holder.createMethod(metaspaceMethod);
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9714
diff changeset
91 }
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9714
diff changeset
92
7084
9ba90252ce08 HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7083
diff changeset
93 HotSpotResolvedJavaMethod(HotSpotResolvedObjectType holder, long metaspaceMethod) {
13259
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
94 // It would be too much work to get the method name here so we fill it in later.
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
95 super(null);
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6588
diff changeset
96 this.metaspaceMethod = metaspaceMethod;
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6588
diff changeset
97 this.holder = holder;
13254
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 13217
diff changeset
98
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 13217
diff changeset
99 HotSpotVMConfig config = runtime().getConfig();
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 13217
diff changeset
100 final long constMethod = getConstMethod();
13259
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
101
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
102 /*
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
103 * Get the constant pool from the metaspace method. Some methods (e.g. intrinsics for
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
104 * signature-polymorphic method handle methods) have their own constant pool instead of the
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
105 * one from their holder.
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
106 */
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
107 final long metaspaceConstantPool = unsafe.getAddress(constMethod + config.constMethodConstantsOffset);
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
108 this.constantPool = new HotSpotConstantPool(metaspaceConstantPool);
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
109
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
110 final int nameIndex = unsafe.getChar(constMethod + config.constMethodNameIndexOffset);
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
111 this.name = constantPool.lookupUtf8(nameIndex);
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
112
13254
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 13217
diff changeset
113 final int signatureIndex = unsafe.getChar(constMethod + config.constMethodSignatureIndexOffset);
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 13217
diff changeset
114 this.signature = (HotSpotSignature) constantPool.lookupSignature(signatureIndex);
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 13217
diff changeset
115
12431
7080a96be216 rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents: 12429
diff changeset
116 runtime().getCompilerToVM().initializeMethod(metaspaceMethod, this);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
117 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
118
13254
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 13217
diff changeset
119 /**
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 13217
diff changeset
120 * Returns a pointer to this method's constant method data structure (
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 13217
diff changeset
121 * {@code Method::_constMethod}).
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 13217
diff changeset
122 *
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 13217
diff changeset
123 * @return pointer to this method's ConstMethod
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 13217
diff changeset
124 */
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 13217
diff changeset
125 private long getConstMethod() {
13259
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
126 assert metaspaceMethod != 0;
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
127 return unsafe.getAddress(metaspaceMethod + runtime().getConfig().methodConstMethodOffset);
13254
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 13217
diff changeset
128 }
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 13217
diff changeset
129
13306
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
130 /**
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
131 * Returns this method's constant method flags ({@code ConstMethod::_flags}).
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
132 *
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
133 * @return flags of this method's ConstMethod
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
134 */
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
135 private long getConstMethodFlags() {
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
136 return unsafe.getChar(getConstMethod() + runtime().getConfig().constMethodFlagsOffset);
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
137 }
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
138
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
139 @Override
14089
280332c0180e removed unnecessary explicit cast by tightening return type of overloaded method
Doug Simon <doug.simon@oracle.com>
parents: 13953
diff changeset
140 public HotSpotResolvedObjectType getDeclaringClass() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
141 return holder;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
142 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
143
7930
fe64b5da8229 Create direct call for Static and Special to avoid out-of-line patching stub.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7912
diff changeset
144 /**
fe64b5da8229 Create direct call for Static and Special to avoid out-of-line patching stub.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7912
diff changeset
145 * Gets the address of the C++ Method object for this method.
fe64b5da8229 Create direct call for Static and Special to avoid out-of-line patching stub.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7912
diff changeset
146 */
fe64b5da8229 Create direct call for Static and Special to avoid out-of-line patching stub.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7912
diff changeset
147 public Constant getMetaspaceMethodConstant() {
12464
59ce8d220e11 replaced HotSpotGraalRuntime.wordKind with an access via the host backend (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12463
diff changeset
148 return Constant.forIntegerKind(getHostWordKind(), metaspaceMethod, this);
7930
fe64b5da8229 Create direct call for Static and Special to avoid out-of-line patching stub.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7912
diff changeset
149 }
fe64b5da8229 Create direct call for Static and Special to avoid out-of-line patching stub.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7912
diff changeset
150
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
151 @Override
9380
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9338
diff changeset
152 public Constant getEncoding() {
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9338
diff changeset
153 return getMetaspaceMethodConstant();
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9338
diff changeset
154 }
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9338
diff changeset
155
13787
eec9f21a40b7 added documentation
Doug Simon <doug.simon@oracle.com>
parents: 13777
diff changeset
156 /**
eec9f21a40b7 added documentation
Doug Simon <doug.simon@oracle.com>
parents: 13777
diff changeset
157 * Gets the complete set of modifiers for this method which includes the JVM specification
eec9f21a40b7 added documentation
Doug Simon <doug.simon@oracle.com>
parents: 13777
diff changeset
158 * modifiers as well as the HotSpot internal modifiers.
eec9f21a40b7 added documentation
Doug Simon <doug.simon@oracle.com>
parents: 13777
diff changeset
159 */
eec9f21a40b7 added documentation
Doug Simon <doug.simon@oracle.com>
parents: 13777
diff changeset
160 public int getAllModifiers() {
13777
b6cecbcfa503 fixed HotSpotResolvedJavaMethod.isSynthetic so that it doesn't do any class loading (JBS:GRAAL-5)
Doug Simon <doug.simon@oracle.com>
parents: 13373
diff changeset
161 HotSpotVMConfig config = runtime().getConfig();
b6cecbcfa503 fixed HotSpotResolvedJavaMethod.isSynthetic so that it doesn't do any class loading (JBS:GRAAL-5)
Doug Simon <doug.simon@oracle.com>
parents: 13373
diff changeset
162 return unsafe.getInt(metaspaceMethod + config.methodAccessFlagsOffset);
b6cecbcfa503 fixed HotSpotResolvedJavaMethod.isSynthetic so that it doesn't do any class loading (JBS:GRAAL-5)
Doug Simon <doug.simon@oracle.com>
parents: 13373
diff changeset
163 }
b6cecbcfa503 fixed HotSpotResolvedJavaMethod.isSynthetic so that it doesn't do any class loading (JBS:GRAAL-5)
Doug Simon <doug.simon@oracle.com>
parents: 13373
diff changeset
164
9380
ee8cd087a731 Dispatch based on method instead of type if it seems more beneficial.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9338
diff changeset
165 @Override
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6525
diff changeset
166 public int getModifiers() {
13787
eec9f21a40b7 added documentation
Doug Simon <doug.simon@oracle.com>
parents: 13777
diff changeset
167 return getAllModifiers() & Modifier.methodModifiers();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
168 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
169
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
170 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
171 public boolean canBeStaticallyBound() {
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6588
diff changeset
172 int modifiers = getModifiers();
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6588
diff changeset
173 return (Modifier.isFinal(modifiers) || Modifier.isPrivate(modifiers) || Modifier.isStatic(modifiers)) && !Modifier.isAbstract(modifiers);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
174 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
175
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
176 @Override
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6525
diff changeset
177 public byte[] getCode() {
14105
f62c770c22be make HotSpotResolvedJavaMethod leaner
twisti
parents: 14104
diff changeset
178 if (getCodeSize() == 0) {
7912
06ecee106195 added unit tests for bytecode and machine code disassembly
Doug Simon <doug.simon@oracle.com>
parents: 7786
diff changeset
179 return null;
06ecee106195 added unit tests for bytecode and machine code disassembly
Doug Simon <doug.simon@oracle.com>
parents: 7786
diff changeset
180 }
13214
3f34b8f91cc5 moved CompilerToVM.isTypeInitialized and isTypeLinked to Java
twisti
parents: 13183
diff changeset
181 if (code == null && holder.isLinked()) {
14105
f62c770c22be make HotSpotResolvedJavaMethod leaner
twisti
parents: 14104
diff changeset
182 code = runtime().getCompilerToVM().initializeBytecode(metaspaceMethod, new byte[getCodeSize()]);
f62c770c22be make HotSpotResolvedJavaMethod leaner
twisti
parents: 14104
diff changeset
183 assert code.length == getCodeSize() : "expected: " + getCodeSize() + ", actual: " + code.length;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
184 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
185 return code;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
186 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
187
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
188 @Override
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6525
diff changeset
189 public int getCodeSize() {
14105
f62c770c22be make HotSpotResolvedJavaMethod leaner
twisti
parents: 14104
diff changeset
190 return unsafe.getChar(getConstMethod() + runtime().getConfig().constMethodCodeSizeOffset);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
191 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
192
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
193 @Override
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6525
diff changeset
194 public ExceptionHandler[] getExceptionHandlers() {
14105
f62c770c22be make HotSpotResolvedJavaMethod leaner
twisti
parents: 14104
diff changeset
195 final boolean hasExceptionTable = (getConstMethodFlags() & runtime().getConfig().constMethodHasExceptionTable) != 0;
f62c770c22be make HotSpotResolvedJavaMethod leaner
twisti
parents: 14104
diff changeset
196 if (!hasExceptionTable) {
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6588
diff changeset
197 return new ExceptionHandler[0];
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6588
diff changeset
198 }
13305
a63d65b682a8 moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents: 13264
diff changeset
199
a63d65b682a8 moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents: 13264
diff changeset
200 HotSpotVMConfig config = runtime().getConfig();
14105
f62c770c22be make HotSpotResolvedJavaMethod leaner
twisti
parents: 14104
diff changeset
201 final int exceptionTableLength = runtime().getCompilerToVM().exceptionTableLength(metaspaceMethod);
f62c770c22be make HotSpotResolvedJavaMethod leaner
twisti
parents: 14104
diff changeset
202 ExceptionHandler[] handlers = new ExceptionHandler[exceptionTableLength];
13305
a63d65b682a8 moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents: 13264
diff changeset
203 long exceptionTableElement = runtime().getCompilerToVM().exceptionTableStart(metaspaceMethod);
a63d65b682a8 moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents: 13264
diff changeset
204
14105
f62c770c22be make HotSpotResolvedJavaMethod leaner
twisti
parents: 14104
diff changeset
205 for (int i = 0; i < exceptionTableLength; i++) {
13305
a63d65b682a8 moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents: 13264
diff changeset
206 final int startPc = unsafe.getChar(exceptionTableElement + config.exceptionTableElementStartPcOffset);
a63d65b682a8 moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents: 13264
diff changeset
207 final int endPc = unsafe.getChar(exceptionTableElement + config.exceptionTableElementEndPcOffset);
a63d65b682a8 moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents: 13264
diff changeset
208 final int handlerPc = unsafe.getChar(exceptionTableElement + config.exceptionTableElementHandlerPcOffset);
a63d65b682a8 moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents: 13264
diff changeset
209 int catchTypeIndex = unsafe.getChar(exceptionTableElement + config.exceptionTableElementCatchTypeIndexOffset);
a63d65b682a8 moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents: 13264
diff changeset
210
a63d65b682a8 moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents: 13264
diff changeset
211 JavaType catchType;
a63d65b682a8 moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents: 13264
diff changeset
212 if (catchTypeIndex == 0) {
a63d65b682a8 moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents: 13264
diff changeset
213 catchType = null;
a63d65b682a8 moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents: 13264
diff changeset
214 } else {
a63d65b682a8 moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents: 13264
diff changeset
215 final int opcode = -1; // opcode is not used
a63d65b682a8 moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents: 13264
diff changeset
216 catchType = constantPool.lookupType(catchTypeIndex, opcode);
a63d65b682a8 moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents: 13264
diff changeset
217
a63d65b682a8 moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents: 13264
diff changeset
218 // Check for Throwable which catches everything.
a63d65b682a8 moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents: 13264
diff changeset
219 if (catchType instanceof HotSpotResolvedObjectType) {
a63d65b682a8 moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents: 13264
diff changeset
220 HotSpotResolvedObjectType resolvedType = (HotSpotResolvedObjectType) catchType;
a63d65b682a8 moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents: 13264
diff changeset
221 if (resolvedType.mirror() == Throwable.class) {
a63d65b682a8 moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents: 13264
diff changeset
222 catchTypeIndex = 0;
a63d65b682a8 moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents: 13264
diff changeset
223 catchType = null;
a63d65b682a8 moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents: 13264
diff changeset
224 }
a63d65b682a8 moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents: 13264
diff changeset
225 }
a63d65b682a8 moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents: 13264
diff changeset
226 }
a63d65b682a8 moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents: 13264
diff changeset
227 handlers[i] = new ExceptionHandler(startPc, endPc, handlerPc, catchTypeIndex, catchType);
a63d65b682a8 moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents: 13264
diff changeset
228
a63d65b682a8 moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents: 13264
diff changeset
229 // Go to the next ExceptionTableElement
a63d65b682a8 moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents: 13264
diff changeset
230 exceptionTableElement += config.exceptionTableElementSize;
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6588
diff changeset
231 }
13305
a63d65b682a8 moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents: 13264
diff changeset
232
a63d65b682a8 moved most HotSpotResolvedJavaMethod.getExceptionHandlers logic to Java
twisti
parents: 13264
diff changeset
233 return handlers;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
234 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
235
9416
16c354398d09 intrinsify Reflection.getCallerClass
twisti
parents: 9380
diff changeset
236 /**
16c354398d09 intrinsify Reflection.getCallerClass
twisti
parents: 9380
diff changeset
237 * Returns true if this method has a CallerSensitive annotation.
16c354398d09 intrinsify Reflection.getCallerClass
twisti
parents: 9380
diff changeset
238 *
16c354398d09 intrinsify Reflection.getCallerClass
twisti
parents: 9380
diff changeset
239 * @return true if CallerSensitive annotation present, false otherwise
16c354398d09 intrinsify Reflection.getCallerClass
twisti
parents: 9380
diff changeset
240 */
16c354398d09 intrinsify Reflection.getCallerClass
twisti
parents: 9380
diff changeset
241 public boolean isCallerSensitive() {
16c354398d09 intrinsify Reflection.getCallerClass
twisti
parents: 9380
diff changeset
242 return callerSensitive;
16c354398d09 intrinsify Reflection.getCallerClass
twisti
parents: 9380
diff changeset
243 }
16c354398d09 intrinsify Reflection.getCallerClass
twisti
parents: 9380
diff changeset
244
16c354398d09 intrinsify Reflection.getCallerClass
twisti
parents: 9380
diff changeset
245 /**
12532
9b1cc2628961 Extend the CompilerToVM interface to explicitly avoid compilation and inlining of methods
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 12464
diff changeset
246 * Manually adds a DontInline annotation to this method.
9b1cc2628961 Extend the CompilerToVM interface to explicitly avoid compilation and inlining of methods
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 12464
diff changeset
247 */
13953
d587baa55dd7 Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13818
diff changeset
248 public void setNotInlineable() {
12532
9b1cc2628961 Extend the CompilerToVM interface to explicitly avoid compilation and inlining of methods
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 12464
diff changeset
249 dontInline = true;
12535
cee7f686c470 rename CompilerToVm.dontInline to doNotInlineOrCompile
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 12533
diff changeset
250 runtime().getCompilerToVM().doNotInlineOrCompile(metaspaceMethod);
12532
9b1cc2628961 Extend the CompilerToVM interface to explicitly avoid compilation and inlining of methods
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 12464
diff changeset
251 }
9b1cc2628961 Extend the CompilerToVM interface to explicitly avoid compilation and inlining of methods
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 12464
diff changeset
252
9b1cc2628961 Extend the CompilerToVM interface to explicitly avoid compilation and inlining of methods
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 12464
diff changeset
253 /**
9416
16c354398d09 intrinsify Reflection.getCallerClass
twisti
parents: 9380
diff changeset
254 * Returns true if this method is one of the special methods that is ignored by security stack
16c354398d09 intrinsify Reflection.getCallerClass
twisti
parents: 9380
diff changeset
255 * walks.
16c354398d09 intrinsify Reflection.getCallerClass
twisti
parents: 9380
diff changeset
256 *
16c354398d09 intrinsify Reflection.getCallerClass
twisti
parents: 9380
diff changeset
257 * @return true if special method ignored by security stack walks, false otherwise
16c354398d09 intrinsify Reflection.getCallerClass
twisti
parents: 9380
diff changeset
258 */
16c354398d09 intrinsify Reflection.getCallerClass
twisti
parents: 9380
diff changeset
259 public boolean ignoredBySecurityStackWalk() {
16c354398d09 intrinsify Reflection.getCallerClass
twisti
parents: 9380
diff changeset
260 return ignoredBySecurityStackWalk;
16c354398d09 intrinsify Reflection.getCallerClass
twisti
parents: 9380
diff changeset
261 }
16c354398d09 intrinsify Reflection.getCallerClass
twisti
parents: 9380
diff changeset
262
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
263 public boolean hasBalancedMonitors() {
14105
f62c770c22be make HotSpotResolvedJavaMethod leaner
twisti
parents: 14104
diff changeset
264 HotSpotVMConfig config = runtime().getConfig();
f62c770c22be make HotSpotResolvedJavaMethod leaner
twisti
parents: 14104
diff changeset
265 final int modifiers = getAllModifiers();
f62c770c22be make HotSpotResolvedJavaMethod leaner
twisti
parents: 14104
diff changeset
266
f62c770c22be make HotSpotResolvedJavaMethod leaner
twisti
parents: 14104
diff changeset
267 // Method has no monitorenter/exit bytecodes.
f62c770c22be make HotSpotResolvedJavaMethod leaner
twisti
parents: 14104
diff changeset
268 if ((modifiers & config.jvmAccHasMonitorBytecodes) == 0) {
f62c770c22be make HotSpotResolvedJavaMethod leaner
twisti
parents: 14104
diff changeset
269 return false;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
270 }
14105
f62c770c22be make HotSpotResolvedJavaMethod leaner
twisti
parents: 14104
diff changeset
271
f62c770c22be make HotSpotResolvedJavaMethod leaner
twisti
parents: 14104
diff changeset
272 // Check to see if a previous compilation computed the monitor-matching analysis.
f62c770c22be make HotSpotResolvedJavaMethod leaner
twisti
parents: 14104
diff changeset
273 if ((modifiers & config.jvmAccMonitorMatch) != 0) {
f62c770c22be make HotSpotResolvedJavaMethod leaner
twisti
parents: 14104
diff changeset
274 return true;
f62c770c22be make HotSpotResolvedJavaMethod leaner
twisti
parents: 14104
diff changeset
275 }
f62c770c22be make HotSpotResolvedJavaMethod leaner
twisti
parents: 14104
diff changeset
276
f62c770c22be make HotSpotResolvedJavaMethod leaner
twisti
parents: 14104
diff changeset
277 // This either happens only once if monitors are balanced or very rarely multiple-times.
f62c770c22be make HotSpotResolvedJavaMethod leaner
twisti
parents: 14104
diff changeset
278 return runtime().getCompilerToVM().hasBalancedMonitors(metaspaceMethod);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
279 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
280
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
281 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
282 public boolean isClassInitializer() {
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6525
diff changeset
283 return "<clinit>".equals(name) && Modifier.isStatic(getModifiers());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
284 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
285
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
286 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
287 public boolean isConstructor() {
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6525
diff changeset
288 return "<init>".equals(name) && !Modifier.isStatic(getModifiers());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
289 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
290
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
291 @Override
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6525
diff changeset
292 public int getMaxLocals() {
11718
f679f5411fd7 Better handling of methods which have no line number or variable name tables.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11521
diff changeset
293 int modifiers = getModifiers();
f679f5411fd7 Better handling of methods which have no line number or variable name tables.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11521
diff changeset
294 if (Modifier.isAbstract(modifiers) || Modifier.isNative(modifiers)) {
f679f5411fd7 Better handling of methods which have no line number or variable name tables.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11521
diff changeset
295 return 0;
f679f5411fd7 Better handling of methods which have no line number or variable name tables.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11521
diff changeset
296 }
12431
7080a96be216 rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents: 12429
diff changeset
297 HotSpotVMConfig config = runtime().getConfig();
13254
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 13217
diff changeset
298 return unsafe.getChar(getConstMethod() + config.methodMaxLocalsOffset);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
299 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
300
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
301 @Override
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6525
diff changeset
302 public int getMaxStackSize() {
11718
f679f5411fd7 Better handling of methods which have no line number or variable name tables.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11521
diff changeset
303 int modifiers = getModifiers();
f679f5411fd7 Better handling of methods which have no line number or variable name tables.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11521
diff changeset
304 if (Modifier.isAbstract(modifiers) || Modifier.isNative(modifiers)) {
f679f5411fd7 Better handling of methods which have no line number or variable name tables.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11521
diff changeset
305 return 0;
f679f5411fd7 Better handling of methods which have no line number or variable name tables.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11521
diff changeset
306 }
12431
7080a96be216 rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents: 12429
diff changeset
307 HotSpotVMConfig config = runtime().getConfig();
13254
42aaf7306707 Teach Graal about Symbol and ConstantPool so we can move more logic into Java. We'll see how that ends...
twisti
parents: 13217
diff changeset
308 return config.extraStackEntries + unsafe.getChar(getConstMethod() + config.constMethodMaxStackOffset);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
309 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
310
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
311 @Override
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6525
diff changeset
312 public StackTraceElement asStackTraceElement(int bci) {
14105
f62c770c22be make HotSpotResolvedJavaMethod leaner
twisti
parents: 14104
diff changeset
313 if (bci < 0 || bci >= getCodeSize()) {
5250
0f6f647e8a96 bug fix: can only use HotSpot code for constructing a StackTraceElement when the bci is valid
Doug Simon <doug.simon@oracle.com>
parents: 5247
diff changeset
314 // HotSpot code can only construct stack trace elements for valid bcis
12431
7080a96be216 rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents: 12429
diff changeset
315 StackTraceElement ste = runtime().getCompilerToVM().getStackTraceElement(metaspaceMethod, 0);
5250
0f6f647e8a96 bug fix: can only use HotSpot code for constructing a StackTraceElement when the bci is valid
Doug Simon <doug.simon@oracle.com>
parents: 5247
diff changeset
316 return new StackTraceElement(ste.getClassName(), ste.getMethodName(), ste.getFileName(), -1);
0f6f647e8a96 bug fix: can only use HotSpot code for constructing a StackTraceElement when the bci is valid
Doug Simon <doug.simon@oracle.com>
parents: 5247
diff changeset
317 }
12431
7080a96be216 rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents: 12429
diff changeset
318 return runtime().getCompilerToVM().getStackTraceElement(metaspaceMethod, bci);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
319 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
320
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
321 public ResolvedJavaMethod uniqueConcreteMethod() {
13373
430c9f08728d moved most CompilerToVM.getUniqueConcreteMethod logic up to Java and replace getUniqueConcreteMethod with findUniqueConcreteMethod
twisti
parents: 13306
diff changeset
322 if (holder.isInterface()) {
430c9f08728d moved most CompilerToVM.getUniqueConcreteMethod logic up to Java and replace getUniqueConcreteMethod with findUniqueConcreteMethod
twisti
parents: 13306
diff changeset
323 // Cannot trust interfaces. Because of:
430c9f08728d moved most CompilerToVM.getUniqueConcreteMethod logic up to Java and replace getUniqueConcreteMethod with findUniqueConcreteMethod
twisti
parents: 13306
diff changeset
324 // interface I { void foo(); }
430c9f08728d moved most CompilerToVM.getUniqueConcreteMethod logic up to Java and replace getUniqueConcreteMethod with findUniqueConcreteMethod
twisti
parents: 13306
diff changeset
325 // class A { public void foo() {} }
430c9f08728d moved most CompilerToVM.getUniqueConcreteMethod logic up to Java and replace getUniqueConcreteMethod with findUniqueConcreteMethod
twisti
parents: 13306
diff changeset
326 // class B extends A implements I { }
430c9f08728d moved most CompilerToVM.getUniqueConcreteMethod logic up to Java and replace getUniqueConcreteMethod with findUniqueConcreteMethod
twisti
parents: 13306
diff changeset
327 // class C extends B { public void foo() { } }
430c9f08728d moved most CompilerToVM.getUniqueConcreteMethod logic up to Java and replace getUniqueConcreteMethod with findUniqueConcreteMethod
twisti
parents: 13306
diff changeset
328 // class D extends B { }
430c9f08728d moved most CompilerToVM.getUniqueConcreteMethod logic up to Java and replace getUniqueConcreteMethod with findUniqueConcreteMethod
twisti
parents: 13306
diff changeset
329 // Would lead to identify C.foo() as the unique concrete method for I.foo() without
430c9f08728d moved most CompilerToVM.getUniqueConcreteMethod logic up to Java and replace getUniqueConcreteMethod with findUniqueConcreteMethod
twisti
parents: 13306
diff changeset
330 // seeing A.foo().
430c9f08728d moved most CompilerToVM.getUniqueConcreteMethod logic up to Java and replace getUniqueConcreteMethod with findUniqueConcreteMethod
twisti
parents: 13306
diff changeset
331 return null;
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6588
diff changeset
332 }
13373
430c9f08728d moved most CompilerToVM.getUniqueConcreteMethod logic up to Java and replace getUniqueConcreteMethod with findUniqueConcreteMethod
twisti
parents: 13306
diff changeset
333 final long uniqueConcreteMethod = runtime().getCompilerToVM().findUniqueConcreteMethod(metaspaceMethod);
430c9f08728d moved most CompilerToVM.getUniqueConcreteMethod logic up to Java and replace getUniqueConcreteMethod with findUniqueConcreteMethod
twisti
parents: 13306
diff changeset
334 if (uniqueConcreteMethod == 0) {
430c9f08728d moved most CompilerToVM.getUniqueConcreteMethod logic up to Java and replace getUniqueConcreteMethod with findUniqueConcreteMethod
twisti
parents: 13306
diff changeset
335 return null;
430c9f08728d moved most CompilerToVM.getUniqueConcreteMethod logic up to Java and replace getUniqueConcreteMethod with findUniqueConcreteMethod
twisti
parents: 13306
diff changeset
336 }
430c9f08728d moved most CompilerToVM.getUniqueConcreteMethod logic up to Java and replace getUniqueConcreteMethod with findUniqueConcreteMethod
twisti
parents: 13306
diff changeset
337 return fromMetaspace(uniqueConcreteMethod);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
338 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
339
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
340 @Override
7676
ca9061b6694c getMethodDescriptor does not need to be in the Signature interface
Christian Wimmer <christian.wimmer@oracle.com>
parents: 7530
diff changeset
341 public HotSpotSignature getSignature() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
342 return signature;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
343 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
344
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6525
diff changeset
345 public int getCompiledCodeSize() {
12431
7080a96be216 rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents: 12429
diff changeset
346 return runtime().getCompilerToVM().getCompiledCodeSize(metaspaceMethod);
4528
e6e14d25e608 added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4527
diff changeset
347 }
e6e14d25e608 added two inlining policies for comparison
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4527
diff changeset
348
10639
08e06d4a9e73 Removed API to access method invocation count from Graal.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10056
diff changeset
349 public boolean hasCompiledCode() {
08e06d4a9e73 Removed API to access method invocation count from Graal.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10056
diff changeset
350 return getCompiledCodeSize() > 0;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
351 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
352
13164
70e6bb85d802 cleaned up HotSpotMethodData tracing a little and enabled it when -Dgraal.traceMethodDataFilter=true
Doug Simon <doug.simon@oracle.com>
parents: 12654
diff changeset
353 private static final String TraceMethodDataFilter = System.getProperty("graal.traceMethodDataFilter");
70e6bb85d802 cleaned up HotSpotMethodData tracing a little and enabled it when -Dgraal.traceMethodDataFilter=true
Doug Simon <doug.simon@oracle.com>
parents: 12654
diff changeset
354
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4220
diff changeset
355 @Override
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6525
diff changeset
356 public ProfilingInfo getProfilingInfo() {
13217
210f58e992a1 Use separate method profile for OSR compilations.
Roland Schatz <roland.schatz@oracle.com>
parents: 13214
diff changeset
357 return getProfilingInfo(true, true);
210f58e992a1 Use separate method profile for OSR compilations.
Roland Schatz <roland.schatz@oracle.com>
parents: 13214
diff changeset
358 }
210f58e992a1 Use separate method profile for OSR compilations.
Roland Schatz <roland.schatz@oracle.com>
parents: 13214
diff changeset
359
210f58e992a1 Use separate method profile for OSR compilations.
Roland Schatz <roland.schatz@oracle.com>
parents: 13214
diff changeset
360 public ProfilingInfo getCompilationProfilingInfo(boolean isOSR) {
210f58e992a1 Use separate method profile for OSR compilations.
Roland Schatz <roland.schatz@oracle.com>
parents: 13214
diff changeset
361 return getProfilingInfo(!isOSR, isOSR);
210f58e992a1 Use separate method profile for OSR compilations.
Roland Schatz <roland.schatz@oracle.com>
parents: 13214
diff changeset
362 }
210f58e992a1 Use separate method profile for OSR compilations.
Roland Schatz <roland.schatz@oracle.com>
parents: 13214
diff changeset
363
210f58e992a1 Use separate method profile for OSR compilations.
Roland Schatz <roland.schatz@oracle.com>
parents: 13214
diff changeset
364 private ProfilingInfo getProfilingInfo(boolean includeNormal, boolean includeOSR) {
5722
cdc3c0776f9f removed mechanism for persisting profile information
Doug Simon <doug.simon@oracle.com>
parents: 5721
diff changeset
365 ProfilingInfo info;
5346
4c3d953f8131 added mechanism (enabled by -G:PICache and -G:PiFilter) for saving/loading method profiling info to/from disk
Doug Simon <doug.simon@oracle.com>
parents: 5344
diff changeset
366
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9760
diff changeset
367 if (UseProfilingInformation.getValue() && methodData == null) {
12431
7080a96be216 rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents: 12429
diff changeset
368 long metaspaceMethodData = unsafeReadWord(metaspaceMethod + runtime().getConfig().methodDataOffset);
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6588
diff changeset
369 if (metaspaceMethodData != 0) {
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6588
diff changeset
370 methodData = new HotSpotMethodData(metaspaceMethodData);
13164
70e6bb85d802 cleaned up HotSpotMethodData tracing a little and enabled it when -Dgraal.traceMethodDataFilter=true
Doug Simon <doug.simon@oracle.com>
parents: 12654
diff changeset
371 if (TraceMethodDataFilter != null && MetaUtil.format("%H.%n", this).contains(TraceMethodDataFilter)) {
70e6bb85d802 cleaned up HotSpotMethodData tracing a little and enabled it when -Dgraal.traceMethodDataFilter=true
Doug Simon <doug.simon@oracle.com>
parents: 12654
diff changeset
372 TTY.println("Raw method data for " + MetaUtil.format("%H.%n(%p)", this) + ":");
70e6bb85d802 cleaned up HotSpotMethodData tracing a little and enabled it when -Dgraal.traceMethodDataFilter=true
Doug Simon <doug.simon@oracle.com>
parents: 12654
diff changeset
373 TTY.println(methodData.toString());
70e6bb85d802 cleaned up HotSpotMethodData tracing a little and enabled it when -Dgraal.traceMethodDataFilter=true
Doug Simon <doug.simon@oracle.com>
parents: 12654
diff changeset
374 }
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6588
diff changeset
375 }
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4220
diff changeset
376 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
377
5346
4c3d953f8131 added mechanism (enabled by -G:PICache and -G:PiFilter) for saving/loading method profiling info to/from disk
Doug Simon <doug.simon@oracle.com>
parents: 5344
diff changeset
378 if (methodData == null || (!methodData.hasNormalData() && !methodData.hasExtraData())) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7483
diff changeset
379 // Be optimistic and return false for exceptionSeen. A methodDataOop is allocated in
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7483
diff changeset
380 // case of a deoptimization.
8610
5407d1dd6450 API to access nullness profiling information for instanceof, checkcast, and aastore
Christian Haeubl <haeubl@ssw.jku.at>
parents: 8217
diff changeset
381 info = DefaultProfilingInfo.get(TriState.FALSE);
4446
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4444
diff changeset
382 } else {
13217
210f58e992a1 Use separate method profile for OSR compilations.
Roland Schatz <roland.schatz@oracle.com>
parents: 13214
diff changeset
383 info = new HotSpotProfilingInfo(methodData, this, includeNormal, includeOSR);
4446
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4444
diff changeset
384 }
5346
4c3d953f8131 added mechanism (enabled by -G:PICache and -G:PiFilter) for saving/loading method profiling info to/from disk
Doug Simon <doug.simon@oracle.com>
parents: 5344
diff changeset
385 return info;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
386 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
387
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
388 @Override
8611
6c4db417385a added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents: 8610
diff changeset
389 public void reprofile() {
12431
7080a96be216 rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents: 12429
diff changeset
390 runtime().getCompilerToVM().reprofile(metaspaceMethod);
8611
6c4db417385a added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents: 8610
diff changeset
391 }
6c4db417385a added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents: 8610
diff changeset
392
6c4db417385a added API to reset the profiling information for a method
Christian Haeubl <haeubl@ssw.jku.at>
parents: 8610
diff changeset
393 @Override
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6525
diff changeset
394 public Map<Object, Object> getCompilerStorage() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
395 if (compilerStorage == null) {
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
396 compilerStorage = new ConcurrentHashMap<>();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
397 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
398 return compilerStorage;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
399 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
400
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
401 @Override
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5536
diff changeset
402 public ConstantPool getConstantPool() {
13259
b16fb0b7479b every HotSpotResolvedJavaMethod needs its own constant pool
twisti
parents: 13254
diff changeset
403 return constantPool;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
404 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
405
5039
f3d2447db2d9 added detection for endless recompilation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5003
diff changeset
406 @Override
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
407 public Annotation[][] getParameterAnnotations() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
408 if (isConstructor()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
409 Constructor javaConstructor = toJavaConstructor();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
410 return javaConstructor == null ? null : javaConstructor.getParameterAnnotations();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
411 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
412 Method javaMethod = toJava();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
413 return javaMethod == null ? null : javaMethod.getParameterAnnotations();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
414 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
415
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
416 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
417 public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
418 if (isConstructor()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
419 Constructor<?> javaConstructor = toJavaConstructor();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
420 return javaConstructor == null ? null : javaConstructor.getAnnotation(annotationClass);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
421 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
422 Method javaMethod = toJava();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
423 return javaMethod == null ? null : javaMethod.getAnnotation(annotationClass);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
424 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
425
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
426 @Override
9984
f3330a4487eb added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents: 9928
diff changeset
427 public boolean isSynthetic() {
13787
eec9f21a40b7 added documentation
Doug Simon <doug.simon@oracle.com>
parents: 13777
diff changeset
428 int modifiers = getAllModifiers();
13818
d2f520f46180 added more unit tests for meta.api, discovering and fixing an issue with HotSpotResolvedJavaField.getModifiers() in the process
Doug Simon <doug.simon@oracle.com>
parents: 13787
diff changeset
429 return (runtime().getConfig().syntheticFlag & modifiers) != 0;
9984
f3330a4487eb added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents: 9928
diff changeset
430 }
f3330a4487eb added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents: 9928
diff changeset
431
13183
0266ac3b26c0 JDK8: added support for default methods as well as interfaces containing static and private methods
Doug Simon <doug.simon@oracle.com>
parents: 13164
diff changeset
432 public boolean isDefault() {
0266ac3b26c0 JDK8: added support for default methods as well as interfaces containing static and private methods
Doug Simon <doug.simon@oracle.com>
parents: 13164
diff changeset
433 if (isConstructor()) {
0266ac3b26c0 JDK8: added support for default methods as well as interfaces containing static and private methods
Doug Simon <doug.simon@oracle.com>
parents: 13164
diff changeset
434 return false;
0266ac3b26c0 JDK8: added support for default methods as well as interfaces containing static and private methods
Doug Simon <doug.simon@oracle.com>
parents: 13164
diff changeset
435 }
0266ac3b26c0 JDK8: added support for default methods as well as interfaces containing static and private methods
Doug Simon <doug.simon@oracle.com>
parents: 13164
diff changeset
436 // Copied from java.lang.Method.isDefault()
0266ac3b26c0 JDK8: added support for default methods as well as interfaces containing static and private methods
Doug Simon <doug.simon@oracle.com>
parents: 13164
diff changeset
437 int mask = Modifier.ABSTRACT | Modifier.PUBLIC | Modifier.STATIC;
0266ac3b26c0 JDK8: added support for default methods as well as interfaces containing static and private methods
Doug Simon <doug.simon@oracle.com>
parents: 13164
diff changeset
438 return ((getModifiers() & mask) == Modifier.PUBLIC) && getDeclaringClass().isInterface();
0266ac3b26c0 JDK8: added support for default methods as well as interfaces containing static and private methods
Doug Simon <doug.simon@oracle.com>
parents: 13164
diff changeset
439 }
0266ac3b26c0 JDK8: added support for default methods as well as interfaces containing static and private methods
Doug Simon <doug.simon@oracle.com>
parents: 13164
diff changeset
440
9984
f3330a4487eb added ResolvedJava[Field|Method].isSynthetic()
Doug Simon <doug.simon@oracle.com>
parents: 9928
diff changeset
441 @Override
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
442 public Type[] getGenericParameterTypes() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
443 if (isConstructor()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
444 Constructor javaConstructor = toJavaConstructor();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
445 return javaConstructor == null ? null : javaConstructor.getGenericParameterTypes();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
446 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
447 Method javaMethod = toJava();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
448 return javaMethod == null ? null : javaMethod.getGenericParameterTypes();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
449 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
450
7053
014727292ae0 removed more usages of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents: 7037
diff changeset
451 public Class<?>[] signatureToTypes() {
014727292ae0 removed more usages of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents: 7037
diff changeset
452 Signature sig = getSignature();
014727292ae0 removed more usages of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents: 7037
diff changeset
453 int count = sig.getParameterCount(false);
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7483
diff changeset
454 Class<?>[] result = new Class<?>[count];
7053
014727292ae0 removed more usages of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents: 7037
diff changeset
455 for (int i = 0; i < result.length; ++i) {
7084
9ba90252ce08 HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7083
diff changeset
456 result[i] = ((HotSpotResolvedJavaType) sig.getParameterType(i, holder).resolve(holder)).mirror();
7053
014727292ae0 removed more usages of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents: 7037
diff changeset
457 }
014727292ae0 removed more usages of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents: 7037
diff changeset
458 return result;
014727292ae0 removed more usages of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents: 7037
diff changeset
459 }
014727292ae0 removed more usages of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents: 7037
diff changeset
460
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
461 private Method toJava() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
462 try {
7053
014727292ae0 removed more usages of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents: 7037
diff changeset
463 return holder.mirror().getDeclaredMethod(name, signatureToTypes());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
464 } catch (NoSuchMethodException e) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
465 return null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
466 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
467 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
468
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
469 private Constructor toJavaConstructor() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
470 try {
7053
014727292ae0 removed more usages of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents: 7037
diff changeset
471 return holder.mirror().getDeclaredConstructor(signatureToTypes());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
472 } catch (NoSuchMethodException e) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
473 return null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
474 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
475 }
4296
d089b71a5237 Add possibility to disable inlining for specific methods.
Andreas Woess <andreas.woess@jku.at>
parents: 4220
diff changeset
476
d089b71a5237 Add possibility to disable inlining for specific methods.
Andreas Woess <andreas.woess@jku.at>
parents: 4220
diff changeset
477 @Override
d089b71a5237 Add possibility to disable inlining for specific methods.
Andreas Woess <andreas.woess@jku.at>
parents: 4220
diff changeset
478 public boolean canBeInlined() {
9691
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents: 9636
diff changeset
479 if (dontInline) {
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents: 9636
diff changeset
480 return false;
bd5c6b3dedc5 implement inlining support for JSR 292
twisti
parents: 9636
diff changeset
481 }
13953
d587baa55dd7 Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13818
diff changeset
482 return runtime().getCompilerToVM().canInlineMethod(metaspaceMethod);
d587baa55dd7 Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13818
diff changeset
483 }
d587baa55dd7 Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13818
diff changeset
484
d587baa55dd7 Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13818
diff changeset
485 @Override
d587baa55dd7 Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13818
diff changeset
486 public boolean shouldBeInlined() {
d587baa55dd7 Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13818
diff changeset
487 if (forceInline) {
d587baa55dd7 Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13818
diff changeset
488 return true;
d587baa55dd7 Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13818
diff changeset
489 }
d587baa55dd7 Add shouldBeInlined method to ResolvedJavaMethod, implement it for HotSpot and use it in the inlining phase
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13818
diff changeset
490 return runtime().getCompilerToVM().shouldInlineMethod(metaspaceMethod);
4319
3c21eee8ab4d Add installMethodCallback() to HotSpotRuntime.
Andreas Woess <andreas.woess@jku.at>
parents: 4296
diff changeset
491 }
4296
d089b71a5237 Add possibility to disable inlining for specific methods.
Andreas Woess <andreas.woess@jku.at>
parents: 4220
diff changeset
492
7310
79a7b761755c Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7212
diff changeset
493 @Override
79a7b761755c Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7212
diff changeset
494 public LineNumberTable getLineNumberTable() {
14105
f62c770c22be make HotSpotResolvedJavaMethod leaner
twisti
parents: 14104
diff changeset
495 final boolean hasLineNumberTable = (getConstMethodFlags() & runtime().getConfig().constMethodHasLineNumberTable) != 0;
f62c770c22be make HotSpotResolvedJavaMethod leaner
twisti
parents: 14104
diff changeset
496 if (!hasLineNumberTable) {
11718
f679f5411fd7 Better handling of methods which have no line number or variable name tables.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11521
diff changeset
497 return null;
f679f5411fd7 Better handling of methods which have no line number or variable name tables.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11521
diff changeset
498 }
14105
f62c770c22be make HotSpotResolvedJavaMethod leaner
twisti
parents: 14104
diff changeset
499
f62c770c22be make HotSpotResolvedJavaMethod leaner
twisti
parents: 14104
diff changeset
500 long[] values = runtime().getCompilerToVM().getLineNumberTable(metaspaceMethod);
7310
79a7b761755c Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7212
diff changeset
501 assert values.length % 2 == 0;
79a7b761755c Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7212
diff changeset
502 int[] bci = new int[values.length / 2];
79a7b761755c Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7212
diff changeset
503 int[] line = new int[values.length / 2];
79a7b761755c Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7212
diff changeset
504
79a7b761755c Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7212
diff changeset
505 for (int i = 0; i < values.length / 2; i++) {
79a7b761755c Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7212
diff changeset
506 bci[i] = (int) values[i * 2];
79a7b761755c Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7212
diff changeset
507 line[i] = (int) values[i * 2 + 1];
79a7b761755c Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7212
diff changeset
508 }
79a7b761755c Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7212
diff changeset
509
79a7b761755c Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7212
diff changeset
510 return new LineNumberTableImpl(line, bci);
79a7b761755c Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7212
diff changeset
511 }
79a7b761755c Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7212
diff changeset
512
7786
8bbbde9d0a52 extended ResolvedJavaMethod API by getLocalVariableTable
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 7676
diff changeset
513 @Override
8bbbde9d0a52 extended ResolvedJavaMethod API by getLocalVariableTable
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 7676
diff changeset
514 public LocalVariableTable getLocalVariableTable() {
14105
f62c770c22be make HotSpotResolvedJavaMethod leaner
twisti
parents: 14104
diff changeset
515 final boolean hasLocalVariableTable = (getConstMethodFlags() & runtime().getConfig().constMethodHasLocalVariableTable) != 0;
f62c770c22be make HotSpotResolvedJavaMethod leaner
twisti
parents: 14104
diff changeset
516 if (!hasLocalVariableTable) {
11718
f679f5411fd7 Better handling of methods which have no line number or variable name tables.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11521
diff changeset
517 return null;
f679f5411fd7 Better handling of methods which have no line number or variable name tables.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11521
diff changeset
518 }
13306
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
519
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
520 HotSpotVMConfig config = runtime().getConfig();
14104
a38a54030ea2 pass metaspace pointers instead of object to VM
twisti
parents: 14089
diff changeset
521 long localVariableTableElement = runtime().getCompilerToVM().getLocalVariableTableStart(metaspaceMethod);
a38a54030ea2 pass metaspace pointers instead of object to VM
twisti
parents: 14089
diff changeset
522 final int localVariableTableLength = runtime().getCompilerToVM().getLocalVariableTableLength(metaspaceMethod);
13306
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
523 Local[] locals = new Local[localVariableTableLength];
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
524
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
525 for (int i = 0; i < localVariableTableLength; i++) {
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
526 final int startBci = unsafe.getChar(localVariableTableElement + config.localVariableTableElementStartBciOffset);
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
527 final int endBci = startBci + unsafe.getChar(localVariableTableElement + config.localVariableTableElementLengthOffset);
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
528 final int nameCpIndex = unsafe.getChar(localVariableTableElement + config.localVariableTableElementNameCpIndexOffset);
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
529 final int typeCpIndex = unsafe.getChar(localVariableTableElement + config.localVariableTableElementDescriptorCpIndexOffset);
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
530 final int slot = unsafe.getChar(localVariableTableElement + config.localVariableTableElementSlotOffset);
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
531
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
532 String localName = getConstantPool().lookupUtf8(nameCpIndex);
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
533 String localType = getConstantPool().lookupUtf8(typeCpIndex);
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
534
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
535 locals[i] = new LocalImpl(localName, localType, holder, startBci, endBci, slot);
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
536
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
537 // Go to the next LocalVariableTableElement
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
538 localVariableTableElement += config.localVariableTableElementSize;
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
539 }
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
540
7786
8bbbde9d0a52 extended ResolvedJavaMethod API by getLocalVariableTable
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 7676
diff changeset
541 return new LocalVariableTableImpl(locals);
8bbbde9d0a52 extended ResolvedJavaMethod API by getLocalVariableTable
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 7676
diff changeset
542 }
8bbbde9d0a52 extended ResolvedJavaMethod API by getLocalVariableTable
Matthias Grimmer <grimmer@ssw.jku.at>
parents: 7676
diff changeset
543
6379
ad97777056ec Checks on vtableEntryOffset to avoid calling to the VM if the holder is not initialized
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5775
diff changeset
544 /**
12559
ae412befde21 read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents: 12535
diff changeset
545 * Returns the offset of this method into the v-table. The method must have a v-table entry as
9636
ff4e8218d3dd Remove hasVtableEntry, use isInVirtualMethodTable instead
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9610
diff changeset
546 * indicated by {@link #isInVirtualMethodTable()}, otherwise an exception is thrown.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7483
diff changeset
547 *
6379
ad97777056ec Checks on vtableEntryOffset to avoid calling to the VM if the holder is not initialized
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5775
diff changeset
548 * @return the offset of this method into the v-table
ad97777056ec Checks on vtableEntryOffset to avoid calling to the VM if the holder is not initialized
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5775
diff changeset
549 */
5000
b5dc2403c1e7 add option to inline VTable stubs
Lukas Stadler <lukas.stadler@jku.at>
parents: 4600
diff changeset
550 public int vtableEntryOffset() {
9636
ff4e8218d3dd Remove hasVtableEntry, use isInVirtualMethodTable instead
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9610
diff changeset
551 if (!isInVirtualMethodTable() || !holder.isInitialized()) {
ff4e8218d3dd Remove hasVtableEntry, use isInVirtualMethodTable instead
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9610
diff changeset
552 throw new GraalInternalError("%s does not have a vtable entry", this);
6379
ad97777056ec Checks on vtableEntryOffset to avoid calling to the VM if the holder is not initialized
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5775
diff changeset
553 }
12559
ae412befde21 read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents: 12535
diff changeset
554 HotSpotVMConfig config = runtime().getConfig();
ae412befde21 read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents: 12535
diff changeset
555 final int vtableIndex = getVtableIndex();
ae412befde21 read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents: 12535
diff changeset
556 return config.instanceKlassVtableStartOffset + vtableIndex * config.vtableEntrySize + config.vtableEntryMethodOffset;
5000
b5dc2403c1e7 add option to inline VTable stubs
Lukas Stadler <lukas.stadler@jku.at>
parents: 4600
diff changeset
557 }
5176
af59b4dfc9e4 compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5115
diff changeset
558
9636
ff4e8218d3dd Remove hasVtableEntry, use isInVirtualMethodTable instead
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9610
diff changeset
559 @Override
ff4e8218d3dd Remove hasVtableEntry, use isInVirtualMethodTable instead
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9610
diff changeset
560 public boolean isInVirtualMethodTable() {
12559
ae412befde21 read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents: 12535
diff changeset
561 return getVtableIndex() >= 0;
ae412befde21 read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents: 12535
diff changeset
562 }
ae412befde21 read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents: 12535
diff changeset
563
13306
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
564 /**
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
565 * Returns this method's virtual table index.
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
566 *
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
567 * @return virtual table index
dfb780080923 moved most CompilerToVM.getLocalVariableTable to Java
twisti
parents: 13305
diff changeset
568 */
12559
ae412befde21 read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents: 12535
diff changeset
569 private int getVtableIndex() {
ae412befde21 read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents: 12535
diff changeset
570 HotSpotVMConfig config = runtime().getConfig();
ae412befde21 read HotSpotVMConfig fields from HotSpot's vmStructs via annotations
twisti
parents: 12535
diff changeset
571 return unsafe.getInt(metaspaceMethod + config.methodVtableIndexOffset);
9610
ae17e540c5d2 More asserts while getting vtable offsets
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9416
diff changeset
572 }
ae17e540c5d2 More asserts while getting vtable offsets
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 9416
diff changeset
573
5176
af59b4dfc9e4 compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5115
diff changeset
574 public void setCurrentTask(CompilationTask task) {
af59b4dfc9e4 compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5115
diff changeset
575 currentTask = task;
af59b4dfc9e4 compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5115
diff changeset
576 }
af59b4dfc9e4 compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5115
diff changeset
577
af59b4dfc9e4 compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5115
diff changeset
578 public CompilationTask currentTask() {
af59b4dfc9e4 compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5115
diff changeset
579 return currentTask;
af59b4dfc9e4 compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 5115
diff changeset
580 }
7310
79a7b761755c Added getLineNumberTable and getFileName capabilities.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7212
diff changeset
581
8217
dce9cefed571 Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7930
diff changeset
582 public SpeculationLog getSpeculationLog() {
dce9cefed571 Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7930
diff changeset
583 if (speculationLog == null) {
dce9cefed571 Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7930
diff changeset
584 speculationLog = new SpeculationLog();
dce9cefed571 Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7930
diff changeset
585 }
dce9cefed571 Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7930
diff changeset
586 return speculationLog;
dce9cefed571 Draft speculation log.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7930
diff changeset
587 }
9013
3b0ec709827c added macro substitutions for the @PolymorphicSignature methods in MethodHandle
Doug Simon <doug.simon@oracle.com>
parents: 8949
diff changeset
588
3b0ec709827c added macro substitutions for the @PolymorphicSignature methods in MethodHandle
Doug Simon <doug.simon@oracle.com>
parents: 8949
diff changeset
589 public int intrinsicId() {
12431
7080a96be216 rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents: 12429
diff changeset
590 HotSpotVMConfig config = runtime().getConfig();
9013
3b0ec709827c added macro substitutions for the @PolymorphicSignature methods in MethodHandle
Doug Simon <doug.simon@oracle.com>
parents: 8949
diff changeset
591 return unsafe.getByte(metaspaceMethod + config.methodIntrinsicIdOffset) & 0xff;
3b0ec709827c added macro substitutions for the @PolymorphicSignature methods in MethodHandle
Doug Simon <doug.simon@oracle.com>
parents: 8949
diff changeset
592 }
9100
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
593
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
594 @Override
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
595 public Constant invoke(Constant receiver, Constant[] arguments) {
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
596 assert !isConstructor();
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
597 Method javaMethod = toJava();
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
598 javaMethod.setAccessible(true);
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
599
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
600 Object[] objArguments = new Object[arguments.length];
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
601 for (int i = 0; i < arguments.length; i++) {
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
602 objArguments[i] = arguments[i].asBoxedValue();
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
603 }
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
604 Object objReceiver = receiver != null ? receiver.asObject() : null;
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
605
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
606 try {
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
607 Object objResult = javaMethod.invoke(objReceiver, objArguments);
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
608 return javaMethod.getReturnType() == void.class ? null : Constant.forBoxed(getSignature().getReturnKind(), objResult);
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
609
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
610 } catch (IllegalAccessException | InvocationTargetException ex) {
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
611 throw new IllegalArgumentException(ex);
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
612 }
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
613 }
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
614
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
615 @Override
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
616 public Constant newInstance(Constant[] arguments) {
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
617 assert isConstructor();
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
618 Constructor javaConstructor = toJavaConstructor();
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
619 javaConstructor.setAccessible(true);
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
620
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
621 Object[] objArguments = new Object[arguments.length];
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
622 for (int i = 0; i < arguments.length; i++) {
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
623 objArguments[i] = arguments[i].asBoxedValue();
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
624 }
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
625
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
626 try {
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
627 Object objResult = javaConstructor.newInstance(objArguments);
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
628 assert objResult != null;
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
629 return Constant.forObject(objResult);
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
630
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
631 } catch (IllegalAccessException | InvocationTargetException | InstantiationException ex) {
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
632 throw new IllegalArgumentException(ex);
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
633 }
d24955427b0b Remove MetaUtil.getMirrorOrFail; Add necessary functionality to the Graal API so that all previous usages of java.lang.Class can now use ResolvedJavaType
Christian Wimmer <christian.wimmer@oracle.com>
parents: 9013
diff changeset
634 }
10056
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
635
14104
a38a54030ea2 pass metaspace pointers instead of object to VM
twisti
parents: 14089
diff changeset
636 /**
a38a54030ea2 pass metaspace pointers instead of object to VM
twisti
parents: 14089
diff changeset
637 * Allocates a compile id for this method by asking the VM for one.
a38a54030ea2 pass metaspace pointers instead of object to VM
twisti
parents: 14089
diff changeset
638 *
a38a54030ea2 pass metaspace pointers instead of object to VM
twisti
parents: 14089
diff changeset
639 * @param entryBCI entry bci
a38a54030ea2 pass metaspace pointers instead of object to VM
twisti
parents: 14089
diff changeset
640 * @return compile id
a38a54030ea2 pass metaspace pointers instead of object to VM
twisti
parents: 14089
diff changeset
641 */
a38a54030ea2 pass metaspace pointers instead of object to VM
twisti
parents: 14089
diff changeset
642 public int allocateCompileId(int entryBCI) {
a38a54030ea2 pass metaspace pointers instead of object to VM
twisti
parents: 14089
diff changeset
643 return runtime().getCompilerToVM().allocateCompileId(metaspaceMethod, entryBCI);
a38a54030ea2 pass metaspace pointers instead of object to VM
twisti
parents: 14089
diff changeset
644 }
a38a54030ea2 pass metaspace pointers instead of object to VM
twisti
parents: 14089
diff changeset
645
10056
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
646 public boolean tryToQueueForCompilation() {
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
647 // other threads may update certain bits of the access flags field concurrently. So, the
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
648 // loop ensures that this method only returns false when another thread has set the
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
649 // queuedForCompilation bit.
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
650 do {
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
651 long address = getAccessFlagsAddress();
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
652 int actualValue = unsafe.getInt(address);
12431
7080a96be216 rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents: 12429
diff changeset
653 int expectedValue = actualValue & ~runtime().getConfig().methodQueuedForCompilationBit;
10056
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
654 if (actualValue != expectedValue) {
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
655 return false;
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
656 } else {
12431
7080a96be216 rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents: 12429
diff changeset
657 int newValue = expectedValue | runtime().getConfig().methodQueuedForCompilationBit;
10056
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
658 boolean success = unsafe.compareAndSwapInt(null, address, expectedValue, newValue);
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
659 if (success) {
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
660 return true;
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
661 }
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
662 }
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
663 } while (true);
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
664 }
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
665
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
666 public void clearQueuedForCompilation() {
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
667 long address = getAccessFlagsAddress();
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
668 boolean success;
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
669 do {
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
670 int actualValue = unsafe.getInt(address);
12431
7080a96be216 rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents: 12429
diff changeset
671 int newValue = actualValue & ~runtime().getConfig().methodQueuedForCompilationBit;
10056
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
672 assert isQueuedForCompilation() : "queued for compilation must be set";
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
673 success = unsafe.compareAndSwapInt(null, address, actualValue, newValue);
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
674 } while (!success);
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
675 }
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
676
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
677 public boolean isQueuedForCompilation() {
12431
7080a96be216 rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents: 12429
diff changeset
678 return (unsafe.getInt(getAccessFlagsAddress()) & runtime().getConfig().methodQueuedForCompilationBit) != 0;
10056
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
679 }
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
680
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
681 private long getAccessFlagsAddress() {
12431
7080a96be216 rename: graalRuntime -> runtime, getGraalRuntime -> getRuntime
Doug Simon <doug.simon@oracle.com>
parents: 12429
diff changeset
682 return metaspaceMethod + runtime().getConfig().methodAccessFlagsOffset;
10056
a323a9e20f9d Fixed a few race conditions in the compilation queue.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 10000
diff changeset
683 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
684 }