--- a/hotspot/src/share/vm/interpreter/rewriter.cpp Thu Jul 15 08:54:48 2010 -0700
+++ b/hotspot/src/share/vm/interpreter/rewriter.cpp Thu Jul 15 18:40:45 2010 -0700
@@ -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 @@
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 @@
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());
}