1 /* |
1 /* |
2 * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1998, 2019, 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. |
219 if (status == 0) { |
219 if (status == 0) { |
220 if (_pool->klass_ref_at_noresolve(cp_index) == vmSymbols::java_lang_invoke_MethodHandle() && |
220 if (_pool->klass_ref_at_noresolve(cp_index) == vmSymbols::java_lang_invoke_MethodHandle() && |
221 MethodHandles::is_signature_polymorphic_name(SystemDictionary::MethodHandle_klass(), |
221 MethodHandles::is_signature_polymorphic_name(SystemDictionary::MethodHandle_klass(), |
222 _pool->name_ref_at(cp_index))) { |
222 _pool->name_ref_at(cp_index))) { |
223 // we may need a resolved_refs entry for the appendix |
223 // we may need a resolved_refs entry for the appendix |
224 add_invokedynamic_resolved_references_entries(cp_index, cache_index); |
224 add_invokedynamic_resolved_references_entry(cp_index, cache_index); |
225 status = +1; |
225 status = +1; |
226 } else if (_pool->klass_ref_at_noresolve(cp_index) == vmSymbols::java_lang_invoke_VarHandle() && |
226 } else if (_pool->klass_ref_at_noresolve(cp_index) == vmSymbols::java_lang_invoke_VarHandle() && |
227 MethodHandles::is_signature_polymorphic_name(SystemDictionary::VarHandle_klass(), |
227 MethodHandles::is_signature_polymorphic_name(SystemDictionary::VarHandle_klass(), |
228 _pool->name_ref_at(cp_index))) { |
228 _pool->name_ref_at(cp_index))) { |
229 // we may need a resolved_refs entry for the appendix |
229 // we may need a resolved_refs entry for the appendix |
230 add_invokedynamic_resolved_references_entries(cp_index, cache_index); |
230 add_invokedynamic_resolved_references_entry(cp_index, cache_index); |
231 status = +1; |
231 status = +1; |
232 } else { |
232 } else { |
233 status = -1; |
233 status = -1; |
234 } |
234 } |
235 _method_handle_invokers.at(cp_index) = status; |
235 _method_handle_invokers.at(cp_index) = status; |
257 address p = bcp + offset; |
257 address p = bcp + offset; |
258 assert(p[-1] == Bytecodes::_invokedynamic, "not invokedynamic bytecode"); |
258 assert(p[-1] == Bytecodes::_invokedynamic, "not invokedynamic bytecode"); |
259 if (!reverse) { |
259 if (!reverse) { |
260 int cp_index = Bytes::get_Java_u2(p); |
260 int cp_index = Bytes::get_Java_u2(p); |
261 int cache_index = add_invokedynamic_cp_cache_entry(cp_index); |
261 int cache_index = add_invokedynamic_cp_cache_entry(cp_index); |
262 int resolved_index = add_invokedynamic_resolved_references_entries(cp_index, cache_index); |
262 int resolved_index = add_invokedynamic_resolved_references_entry(cp_index, cache_index); |
263 // Replace the trailing four bytes with a CPC index for the dynamic |
263 // Replace the trailing four bytes with a CPC index for the dynamic |
264 // call site. Unlike other CPC entries, there is one per bytecode, |
264 // call site. Unlike other CPC entries, there is one per bytecode, |
265 // not just one per distinct CP entry. In other words, the |
265 // not just one per distinct CP entry. In other words, the |
266 // CPC-to-CP relation is many-to-one for invokedynamic entries. |
266 // CPC-to-CP relation is many-to-one for invokedynamic entries. |
267 // This means we must use a larger index size than u2 to address |
267 // This means we must use a larger index size than u2 to address |
305 Bytes::put_native_u4(p, ConstantPool::encode_invokedynamic_index(cache_index + delta)); |
305 Bytes::put_native_u4(p, ConstantPool::encode_invokedynamic_index(cache_index + delta)); |
306 |
306 |
307 // invokedynamic resolved references map also points to cp cache and must |
307 // invokedynamic resolved references map also points to cp cache and must |
308 // add delta to each. |
308 // add delta to each. |
309 int resolved_index = _patch_invokedynamic_refs->at(i); |
309 int resolved_index = _patch_invokedynamic_refs->at(i); |
310 for (int entry = 0; entry < ConstantPoolCacheEntry::_indy_resolved_references_entries; entry++) { |
310 assert(_invokedynamic_references_map.at(resolved_index) == cache_index, |
311 assert(_invokedynamic_references_map.at(resolved_index + entry) == cache_index, |
|
312 "should be the same index"); |
311 "should be the same index"); |
313 _invokedynamic_references_map.at_put(resolved_index+entry, |
312 _invokedynamic_references_map.at_put(resolved_index, cache_index + delta); |
314 cache_index + delta); |
|
315 } |
|
316 } |
313 } |
317 } |
314 } |
318 } |
315 } |
319 |
316 |
320 |
317 |