1 /* |
1 /* |
2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
22 */ |
22 */ |
23 |
23 |
24 #include "precompiled.hpp" |
24 #include "precompiled.hpp" |
25 #include "classfile/stringTable.hpp" |
25 #include "classfile/stringTable.hpp" |
26 #include "classfile/symbolTable.hpp" |
26 #include "classfile/symbolTable.hpp" |
|
27 #include "interpreter/linkResolver.hpp" |
27 #include "jvmci/compilerRuntime.hpp" |
28 #include "jvmci/compilerRuntime.hpp" |
|
29 #include "oops/oop.inline.hpp" |
28 #include "runtime/compilationPolicy.hpp" |
30 #include "runtime/compilationPolicy.hpp" |
29 #include "runtime/deoptimization.hpp" |
31 #include "runtime/deoptimization.hpp" |
30 #include "runtime/interfaceSupport.hpp" |
32 #include "runtime/interfaceSupport.hpp" |
|
33 #include "runtime/vframe.hpp" |
|
34 #include "aot/aotLoader.hpp" |
31 |
35 |
32 // Resolve and allocate String |
36 // Resolve and allocate String |
33 JRT_BLOCK_ENTRY(void, CompilerRuntime::resolve_string_by_symbol(JavaThread *thread, void* string_result, const char* name)) |
37 JRT_BLOCK_ENTRY(void, CompilerRuntime::resolve_string_by_symbol(JavaThread *thread, void* string_result, const char* name)) |
34 JRT_BLOCK |
38 JRT_BLOCK |
35 oop str = *(oop*)string_result; // Is it resolved already? |
39 oop str = *(oop*)string_result; // Is it resolved already? |
117 } |
121 } |
118 } |
122 } |
119 return m; |
123 return m; |
120 } |
124 } |
121 |
125 |
|
126 JRT_BLOCK_ENTRY(void, CompilerRuntime::resolve_dynamic_invoke(JavaThread *thread, oop* appendix_result)) |
|
127 JRT_BLOCK |
|
128 { |
|
129 ResourceMark rm(THREAD); |
|
130 vframeStream vfst(thread, true); // Do not skip and javaCalls |
|
131 assert(!vfst.at_end(), "Java frame must exist"); |
|
132 methodHandle caller(THREAD, vfst.method()); |
|
133 InstanceKlass* holder = caller->method_holder(); |
|
134 int bci = vfst.bci(); |
|
135 Bytecode_invoke bytecode(caller, bci); |
|
136 int index = bytecode.index(); |
|
137 |
|
138 // Make sure it's resolved first |
|
139 CallInfo callInfo; |
|
140 constantPoolHandle cp(holder->constants()); |
|
141 ConstantPoolCacheEntry* cp_cache_entry = cp->cache()->entry_at(cp->decode_cpcache_index(index, true)); |
|
142 Bytecodes::Code invoke_code = bytecode.invoke_code(); |
|
143 if (!cp_cache_entry->is_resolved(invoke_code)) { |
|
144 LinkResolver::resolve_invoke(callInfo, Handle(), cp, index, invoke_code, CHECK); |
|
145 if (bytecode.is_invokedynamic()) { |
|
146 cp_cache_entry->set_dynamic_call(cp, callInfo); |
|
147 } else { |
|
148 cp_cache_entry->set_method_handle(cp, callInfo); |
|
149 } |
|
150 vmassert(cp_cache_entry->is_resolved(invoke_code), "sanity"); |
|
151 } |
|
152 |
|
153 Handle appendix(THREAD, cp_cache_entry->appendix_if_resolved(cp)); |
|
154 Klass *appendix_klass = appendix.is_null() ? NULL : appendix->klass(); |
|
155 |
|
156 methodHandle adapter_method(cp_cache_entry->f1_as_method()); |
|
157 InstanceKlass *adapter_klass = adapter_method->method_holder(); |
|
158 |
|
159 if (appendix_klass != NULL && appendix_klass->is_instance_klass()) { |
|
160 vmassert(InstanceKlass::cast(appendix_klass)->is_initialized(), "sanity"); |
|
161 } |
|
162 if (!adapter_klass->is_initialized()) { |
|
163 // Force initialization of adapter class |
|
164 adapter_klass->initialize(CHECK); |
|
165 // Double-check that it was really initialized, |
|
166 // because we could be doing a recursive call |
|
167 // from inside <clinit>. |
|
168 } |
|
169 |
|
170 int cpi = cp_cache_entry->constant_pool_index(); |
|
171 if (!AOTLoader::reconcile_dynamic_invoke(holder, cpi, adapter_method(), |
|
172 appendix_klass)) { |
|
173 return; |
|
174 } |
|
175 |
|
176 *appendix_result = appendix(); |
|
177 thread->set_vm_result(appendix()); |
|
178 } |
|
179 JRT_BLOCK_END |
|
180 JRT_END |
|
181 |
122 JRT_BLOCK_ENTRY(MethodCounters*, CompilerRuntime::resolve_method_by_symbol_and_load_counters(JavaThread *thread, MethodCounters** counters_result, Klass* klass, const char* data)) |
182 JRT_BLOCK_ENTRY(MethodCounters*, CompilerRuntime::resolve_method_by_symbol_and_load_counters(JavaThread *thread, MethodCounters** counters_result, Klass* klass, const char* data)) |
123 MethodCounters* c = *counters_result; // Is it resolved already? |
183 MethodCounters* c = *counters_result; // Is it resolved already? |
124 JRT_BLOCK |
184 JRT_BLOCK |
125 if (c == NULL) { // Do resolution |
185 if (c == NULL) { // Do resolution |
126 // Get method name and its length |
186 // Get method name and its length |