src/share/vm/interpreter/rewriter.cpp

changeset 2015
083fde3b838e
parent 1957
136b78722a08
child 2314
f95d63e2154a
     1.1 --- a/src/share/vm/interpreter/rewriter.cpp	Thu Jul 15 08:54:48 2010 -0700
     1.2 +++ b/src/share/vm/interpreter/rewriter.cpp	Thu Jul 15 18:40:45 2010 -0700
     1.3 @@ -32,14 +32,17 @@
     1.4  void Rewriter::compute_index_maps() {
     1.5    const int length  = _pool->length();
     1.6    init_cp_map(length);
     1.7 +  jint tag_mask = 0;
     1.8    for (int i = 0; i < length; i++) {
     1.9      int tag = _pool->tag_at(i).value();
    1.10 +    tag_mask |= (1 << tag);
    1.11      switch (tag) {
    1.12        case JVM_CONSTANT_InterfaceMethodref:
    1.13        case JVM_CONSTANT_Fieldref          : // fall through
    1.14        case JVM_CONSTANT_Methodref         : // fall through
    1.15        case JVM_CONSTANT_MethodHandle      : // fall through
    1.16        case JVM_CONSTANT_MethodType        : // fall through
    1.17 +      case JVM_CONSTANT_InvokeDynamic     : // fall through
    1.18          add_cp_cache_entry(i);
    1.19          break;
    1.20      }
    1.21 @@ -47,6 +50,8 @@
    1.22  
    1.23    guarantee((int)_cp_cache_map.length()-1 <= (int)((u2)-1),
    1.24              "all cp cache indexes fit in a u2");
    1.25 +
    1.26 +  _have_invoke_dynamic = ((tag_mask & (1 << JVM_CONSTANT_InvokeDynamic)) != 0);
    1.27  }
    1.28  
    1.29  
    1.30 @@ -59,6 +64,28 @@
    1.31    constantPoolCacheOop cache =
    1.32        oopFactory::new_constantPoolCache(length, methodOopDesc::IsUnsafeConc, CHECK);
    1.33    cache->initialize(_cp_cache_map);
    1.34 +
    1.35 +  // Don't bother to the next pass if there is no JVM_CONSTANT_InvokeDynamic.
    1.36 +  if (_have_invoke_dynamic) {
    1.37 +    for (int i = 0; i < length; i++) {
    1.38 +      int pool_index = cp_cache_entry_pool_index(i);
    1.39 +      if (pool_index >= 0 &&
    1.40 +          _pool->tag_at(pool_index).is_invoke_dynamic()) {
    1.41 +        int bsm_index = _pool->invoke_dynamic_bootstrap_method_ref_index_at(pool_index);
    1.42 +        if (bsm_index != 0) {
    1.43 +          assert(_pool->tag_at(bsm_index).is_method_handle(), "must be a MH constant");
    1.44 +          // There is a CP cache entry holding the BSM for these calls.
    1.45 +          int bsm_cache_index = cp_entry_to_cp_cache(bsm_index);
    1.46 +          cache->entry_at(i)->initialize_bootstrap_method_index_in_cache(bsm_cache_index);
    1.47 +        } else {
    1.48 +          // There is no CP cache entry holding the BSM for these calls.
    1.49 +          // We will need to look for a class-global BSM, later.
    1.50 +          guarantee(AllowTransitionalJSR292, "");
    1.51 +        }
    1.52 +      }
    1.53 +    }
    1.54 +  }
    1.55 +
    1.56    _pool->set_cache(cache);
    1.57    cache->set_constant_pool(_pool());
    1.58  }

mercurial