Mercurial > hg > truffle
annotate src/share/vm/interpreter/linkResolver.hpp @ 6273:4c8f2a12e757 hs24-b20
Merge
author | twisti |
---|---|
date | Fri, 10 Aug 2012 17:50:24 -0700 |
parents | 1d7922586cf6 |
children | da91efe96a93 |
rev | line source |
---|---|
0 | 1 /* |
2426
1d1603768966
7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
trims
parents:
2177
diff
changeset
|
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1508
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1508
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1508
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_INTERPRETER_LINKRESOLVER_HPP |
26 #define SHARE_VM_INTERPRETER_LINKRESOLVER_HPP | |
27 | |
28 #include "oops/methodOop.hpp" | |
29 #include "utilities/top.hpp" | |
30 | |
0 | 31 // All the necessary definitions for run-time link resolution. |
32 | |
33 // LinkInfo & its subclasses provide all the information gathered | |
34 // for a particular link after resolving it. A link is any reference | |
35 // made from within the bytecodes of a method to an object outside of | |
36 // that method. If the info is invalid, the link has not been resolved | |
37 // successfully. | |
38 | |
39 class LinkInfo VALUE_OBJ_CLASS_SPEC { | |
40 }; | |
41 | |
42 | |
43 // Link information for getfield/putfield & getstatic/putstatic bytecodes. | |
44 | |
45 class FieldAccessInfo: public LinkInfo { | |
46 protected: | |
47 KlassHandle _klass; | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
48 Symbol* _name; |
0 | 49 AccessFlags _access_flags; |
50 int _field_index; // original index in the klass | |
51 int _field_offset; | |
52 BasicType _field_type; | |
53 | |
54 public: | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
55 void set(KlassHandle klass, Symbol* name, int field_index, int field_offset, |
0 | 56 BasicType field_type, AccessFlags access_flags); |
57 KlassHandle klass() const { return _klass; } | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
58 Symbol* name() const { return _name; } |
0 | 59 int field_index() const { return _field_index; } |
60 int field_offset() const { return _field_offset; } | |
61 BasicType field_type() const { return _field_type; } | |
62 AccessFlags access_flags() const { return _access_flags; } | |
63 | |
64 // debugging | |
65 void print() PRODUCT_RETURN; | |
66 }; | |
67 | |
68 | |
69 // Link information for all calls. | |
70 | |
71 class CallInfo: public LinkInfo { | |
72 private: | |
73 KlassHandle _resolved_klass; // static receiver klass | |
74 KlassHandle _selected_klass; // dynamic receiver class (same as static, or subklass) | |
75 methodHandle _resolved_method; // static target method | |
76 methodHandle _selected_method; // dynamic (actual) target method | |
77 int _vtable_index; // vtable index of selected method | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
2426
diff
changeset
|
78 Handle _resolved_appendix; // extra argument in constant pool (if CPCE::has_appendix) |
0 | 79 |
80 void set_static( KlassHandle resolved_klass, methodHandle resolved_method , TRAPS); | |
81 void set_interface(KlassHandle resolved_klass, KlassHandle selected_klass, methodHandle resolved_method, methodHandle selected_method , TRAPS); | |
82 void set_virtual( KlassHandle resolved_klass, KlassHandle selected_klass, methodHandle resolved_method, methodHandle selected_method, int vtable_index, TRAPS); | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
2426
diff
changeset
|
83 void set_handle( methodHandle resolved_method, Handle resolved_appendix, TRAPS); |
0 | 84 void set_common( KlassHandle resolved_klass, KlassHandle selected_klass, methodHandle resolved_method, methodHandle selected_method, int vtable_index, TRAPS); |
85 | |
86 friend class LinkResolver; | |
87 | |
88 public: | |
89 KlassHandle resolved_klass() const { return _resolved_klass; } | |
90 KlassHandle selected_klass() const { return _selected_klass; } | |
91 methodHandle resolved_method() const { return _resolved_method; } | |
92 methodHandle selected_method() const { return _selected_method; } | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
2426
diff
changeset
|
93 Handle resolved_appendix() const { return _resolved_appendix; } |
0 | 94 |
95 BasicType result_type() const { return selected_method()->result_type(); } | |
96 bool has_vtable_index() const { return _vtable_index >= 0; } | |
97 bool is_statically_bound() const { return _vtable_index == methodOopDesc::nonvirtual_vtable_index; } | |
98 int vtable_index() const { | |
99 // Even for interface calls the vtable index could be non-negative. | |
100 // See CallInfo::set_interface. | |
101 assert(has_vtable_index() || is_statically_bound(), ""); | |
102 return _vtable_index; | |
103 } | |
104 }; | |
105 | |
106 | |
107 // The LinkResolver is used to resolve constant-pool references at run-time. | |
108 // It does all necessary link-time checks & throws exceptions if necessary. | |
109 | |
110 class LinkResolver: AllStatic { | |
111 private: | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
112 static void lookup_method_in_klasses (methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
113 static void lookup_instance_method_in_klasses (methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
114 static void lookup_method_in_interfaces (methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
2426
diff
changeset
|
115 static void lookup_polymorphic_method (methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
2426
diff
changeset
|
116 KlassHandle current_klass, Handle* appendix_result_or_null, TRAPS); |
0 | 117 |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
118 static int vtable_index_of_miranda_method(KlassHandle klass, Symbol* name, Symbol* signature, TRAPS); |
0 | 119 |
120 static void resolve_klass (KlassHandle& result, constantPoolHandle pool, int index, TRAPS); | |
121 static void resolve_klass_no_update (KlassHandle& result, constantPoolHandle pool, int index, TRAPS); // no update of constantPool entry | |
122 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
123 static void resolve_pool (KlassHandle& resolved_klass, Symbol*& method_name, Symbol*& method_signature, KlassHandle& current_klass, constantPoolHandle pool, int index, TRAPS); |
0 | 124 |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
125 static void resolve_interface_method(methodHandle& resolved_method, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access, TRAPS); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
126 static void resolve_method (methodHandle& resolved_method, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access, TRAPS); |
0 | 127 |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
128 static void linktime_resolve_static_method (methodHandle& resolved_method, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access, TRAPS); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
129 static void linktime_resolve_special_method (methodHandle& resolved_method, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access, TRAPS); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
130 static void linktime_resolve_virtual_method (methodHandle &resolved_method, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature,KlassHandle current_klass, bool check_access, TRAPS); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
131 static void linktime_resolve_interface_method (methodHandle& resolved_method, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access, TRAPS); |
0 | 132 |
133 static void runtime_resolve_special_method (CallInfo& result, methodHandle resolved_method, KlassHandle resolved_klass, KlassHandle current_klass, bool check_access, TRAPS); | |
134 static void runtime_resolve_virtual_method (CallInfo& result, methodHandle resolved_method, KlassHandle resolved_klass, Handle recv, KlassHandle recv_klass, bool check_null_and_abstract, TRAPS); | |
135 static void runtime_resolve_interface_method (CallInfo& result, methodHandle resolved_method, KlassHandle resolved_klass, Handle recv, KlassHandle recv_klass, bool check_null_and_abstract, TRAPS); | |
136 | |
137 static void check_field_accessability (KlassHandle ref_klass, KlassHandle resolved_klass, KlassHandle sel_klass, fieldDescriptor& fd, TRAPS); | |
138 static void check_method_accessability (KlassHandle ref_klass, KlassHandle resolved_klass, KlassHandle sel_klass, methodHandle sel_method, TRAPS); | |
139 | |
140 public: | |
141 // constant pool resolving | |
142 static void check_klass_accessability(KlassHandle ref_klass, KlassHandle sel_klass, TRAPS); | |
143 | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
2426
diff
changeset
|
144 // static resolving calls (will not run any Java code); used only from Bytecode_invoke::static_target |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
2426
diff
changeset
|
145 static void resolve_method_statically(methodHandle& method_result, KlassHandle& klass_result, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
2426
diff
changeset
|
146 Bytecodes::Code code, constantPoolHandle pool, int index, TRAPS); |
0 | 147 |
148 // runtime/static resolving for fields | |
149 static void resolve_field(FieldAccessInfo& result, constantPoolHandle pool, int index, Bytecodes::Code byte, bool check_only, TRAPS); | |
150 // takes an extra bool argument "update_pool" to decide whether to update the constantPool during klass resolution. | |
151 static void resolve_field(FieldAccessInfo& result, constantPoolHandle pool, int index, Bytecodes::Code byte, bool check_only, bool update_pool, TRAPS); | |
152 | |
153 // runtime resolving: | |
154 // resolved_klass = specified class (i.e., static receiver class) | |
155 // current_klass = sending method holder (i.e., class containing the method containing the call being resolved) | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
156 static void resolve_static_call (CallInfo& result, KlassHandle& resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access, bool initialize_klass, TRAPS); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
157 static void resolve_special_call (CallInfo& result, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access, TRAPS); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
158 static void resolve_virtual_call (CallInfo& result, Handle recv, KlassHandle recv_klass, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access, bool check_null_and_abstract, TRAPS); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
159 static void resolve_interface_call(CallInfo& result, Handle recv, KlassHandle recv_klass, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access, bool check_null_and_abstract, TRAPS); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
2426
diff
changeset
|
160 static void resolve_handle_call (CallInfo& result, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, TRAPS); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
2426
diff
changeset
|
161 static void resolve_dynamic_call (CallInfo& result, Handle bootstrap_specifier, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, TRAPS); |
0 | 162 |
163 // same as above for compile-time resolution; but returns null handle instead of throwing an exception on error | |
164 // also, does not initialize klass (i.e., no side effects) | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
165 static methodHandle resolve_virtual_call_or_null (KlassHandle receiver_klass, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
166 static methodHandle resolve_interface_call_or_null(KlassHandle receiver_klass, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
167 static methodHandle resolve_static_call_or_null (KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
168 static methodHandle resolve_special_call_or_null (KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass); |
0 | 169 |
170 // same as above for compile-time resolution; returns vtable_index if current_klass if linked | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
171 static int resolve_virtual_vtable_index (KlassHandle receiver_klass, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass); |
0 | 172 |
173 // static resolving for compiler (does not throw exceptions, returns null handle if unsuccessful) | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
174 static methodHandle linktime_resolve_virtual_method_or_null (KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
175 static methodHandle linktime_resolve_interface_method_or_null(KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access); |
0 | 176 |
177 // runtime resolving from constant pool | |
178 static void resolve_invokestatic (CallInfo& result, constantPoolHandle pool, int index, TRAPS); | |
179 static void resolve_invokespecial (CallInfo& result, constantPoolHandle pool, int index, TRAPS); | |
180 static void resolve_invokevirtual (CallInfo& result, Handle recv, constantPoolHandle pool, int index, TRAPS); | |
181 static void resolve_invokeinterface(CallInfo& result, Handle recv, constantPoolHandle pool, int index, TRAPS); | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
182 static void resolve_invokedynamic (CallInfo& result, constantPoolHandle pool, int index, TRAPS); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
2426
diff
changeset
|
183 static void resolve_invokehandle (CallInfo& result, constantPoolHandle pool, int index, TRAPS); |
0 | 184 |
185 static void resolve_invoke (CallInfo& result, Handle recv, constantPoolHandle pool, int index, Bytecodes::Code byte, TRAPS); | |
186 }; | |
1972 | 187 |
188 #endif // SHARE_VM_INTERPRETER_LINKRESOLVER_HPP |