mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 19:44:41 +02:00
6964498: JSR 292 invokedynamic sites need local bootstrap methods
Add JVM_CONSTANT_InvokeDynamic records to constant pool to determine per-instruction BSMs. Reviewed-by: twisti
This commit is contained in:
parent
ea25541820
commit
a4e4149340
25 changed files with 340 additions and 46 deletions
|
@ -32,14 +32,17 @@
|
|||
void Rewriter::compute_index_maps() {
|
||||
const int length = _pool->length();
|
||||
init_cp_map(length);
|
||||
jint tag_mask = 0;
|
||||
for (int i = 0; i < length; i++) {
|
||||
int tag = _pool->tag_at(i).value();
|
||||
tag_mask |= (1 << tag);
|
||||
switch (tag) {
|
||||
case JVM_CONSTANT_InterfaceMethodref:
|
||||
case JVM_CONSTANT_Fieldref : // fall through
|
||||
case JVM_CONSTANT_Methodref : // fall through
|
||||
case JVM_CONSTANT_MethodHandle : // fall through
|
||||
case JVM_CONSTANT_MethodType : // fall through
|
||||
case JVM_CONSTANT_InvokeDynamic : // fall through
|
||||
add_cp_cache_entry(i);
|
||||
break;
|
||||
}
|
||||
|
@ -47,6 +50,8 @@ void Rewriter::compute_index_maps() {
|
|||
|
||||
guarantee((int)_cp_cache_map.length()-1 <= (int)((u2)-1),
|
||||
"all cp cache indexes fit in a u2");
|
||||
|
||||
_have_invoke_dynamic = ((tag_mask & (1 << JVM_CONSTANT_InvokeDynamic)) != 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -59,6 +64,28 @@ void Rewriter::make_constant_pool_cache(TRAPS) {
|
|||
constantPoolCacheOop cache =
|
||||
oopFactory::new_constantPoolCache(length, methodOopDesc::IsUnsafeConc, CHECK);
|
||||
cache->initialize(_cp_cache_map);
|
||||
|
||||
// Don't bother to the next pass if there is no JVM_CONSTANT_InvokeDynamic.
|
||||
if (_have_invoke_dynamic) {
|
||||
for (int i = 0; i < length; i++) {
|
||||
int pool_index = cp_cache_entry_pool_index(i);
|
||||
if (pool_index >= 0 &&
|
||||
_pool->tag_at(pool_index).is_invoke_dynamic()) {
|
||||
int bsm_index = _pool->invoke_dynamic_bootstrap_method_ref_index_at(pool_index);
|
||||
if (bsm_index != 0) {
|
||||
assert(_pool->tag_at(bsm_index).is_method_handle(), "must be a MH constant");
|
||||
// There is a CP cache entry holding the BSM for these calls.
|
||||
int bsm_cache_index = cp_entry_to_cp_cache(bsm_index);
|
||||
cache->entry_at(i)->initialize_bootstrap_method_index_in_cache(bsm_cache_index);
|
||||
} else {
|
||||
// There is no CP cache entry holding the BSM for these calls.
|
||||
// We will need to look for a class-global BSM, later.
|
||||
guarantee(AllowTransitionalJSR292, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_pool->set_cache(cache);
|
||||
cache->set_constant_pool(_pool());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue