src/share/vm/oops/constantPoolOop.hpp

changeset 1957
136b78722a08
parent 1934
e9ff18c4ace7
child 2015
083fde3b838e
     1.1 --- a/src/share/vm/oops/constantPoolOop.hpp	Mon Jun 07 14:17:01 2010 -0700
     1.2 +++ b/src/share/vm/oops/constantPoolOop.hpp	Wed Jun 09 18:50:45 2010 -0700
     1.3 @@ -146,6 +146,16 @@
     1.4      oop_store_without_check(obj_at_addr(which), oop(s));
     1.5    }
     1.6  
     1.7 +  void method_handle_index_at_put(int which, int ref_kind, int ref_index) {
     1.8 +    tag_at_put(which, JVM_CONSTANT_MethodHandle);
     1.9 +    *int_at_addr(which) = ((jint) ref_index<<16) | ref_kind;
    1.10 +  }
    1.11 +
    1.12 +  void method_type_index_at_put(int which, int ref_index) {
    1.13 +    tag_at_put(which, JVM_CONSTANT_MethodType);
    1.14 +    *int_at_addr(which) = ref_index;
    1.15 +  }
    1.16 +
    1.17    // Temporary until actual use
    1.18    void unresolved_string_at_put(int which, symbolOop s) {
    1.19      *obj_at_addr(which) = NULL;
    1.20 @@ -357,6 +367,36 @@
    1.21      return *int_at_addr(which);
    1.22    }
    1.23  
    1.24 +  int method_handle_ref_kind_at(int which) {
    1.25 +    assert(tag_at(which).is_method_handle(), "Corrupted constant pool");
    1.26 +    return extract_low_short_from_int(*int_at_addr(which));  // mask out unwanted ref_index bits
    1.27 +  }
    1.28 +  int method_handle_index_at(int which) {
    1.29 +    assert(tag_at(which).is_method_handle(), "Corrupted constant pool");
    1.30 +    return extract_high_short_from_int(*int_at_addr(which));  // shift out unwanted ref_kind bits
    1.31 +  }
    1.32 +  int method_type_index_at(int which) {
    1.33 +    assert(tag_at(which).is_method_type(), "Corrupted constant pool");
    1.34 +    return *int_at_addr(which);
    1.35 +  }
    1.36 +  // Derived queries:
    1.37 +  symbolOop method_handle_name_ref_at(int which) {
    1.38 +    int member = method_handle_index_at(which);
    1.39 +    return impl_name_ref_at(member, true);
    1.40 +  }
    1.41 +  symbolOop method_handle_signature_ref_at(int which) {
    1.42 +    int member = method_handle_index_at(which);
    1.43 +    return impl_signature_ref_at(member, true);
    1.44 +  }
    1.45 +  int method_handle_klass_index_at(int which) {
    1.46 +    int member = method_handle_index_at(which);
    1.47 +    return impl_klass_ref_index_at(member, true);
    1.48 +  }
    1.49 +  symbolOop method_type_signature_at(int which) {
    1.50 +    int sym = method_type_index_at(which);
    1.51 +    return symbol_at(sym);
    1.52 +  }
    1.53 +
    1.54    // The following methods (name/signature/klass_ref_at, klass_ref_at_noresolve,
    1.55    // name_and_type_ref_index_at) all expect to be passed indices obtained
    1.56    // directly from the bytecode, and extracted according to java byte order.
    1.57 @@ -388,6 +428,17 @@
    1.58      resolve_string_constants_impl(h_this, CHECK);
    1.59    }
    1.60  
    1.61 +  // Resolve late bound constants.
    1.62 +  oop resolve_constant_at(int index, TRAPS) {
    1.63 +    constantPoolHandle h_this(THREAD, this);
    1.64 +    return resolve_constant_at_impl(h_this, index, -1, THREAD);
    1.65 +  }
    1.66 +
    1.67 +  oop resolve_cached_constant_at(int cache_index, TRAPS) {
    1.68 +    constantPoolHandle h_this(THREAD, this);
    1.69 +    return resolve_constant_at_impl(h_this, -1, cache_index, THREAD);
    1.70 +  }
    1.71 +
    1.72    // Klass name matches name at offset
    1.73    bool klass_name_at_matches(instanceKlassHandle k, int which);
    1.74  
    1.75 @@ -420,6 +471,7 @@
    1.76    // Routines currently used for annotations (only called by jvm.cpp) but which might be used in the
    1.77    // future by other Java code. These take constant pool indices rather than possibly-byte-swapped
    1.78    // constant pool cache indices as do the peer methods above.
    1.79 +  symbolOop uncached_klass_ref_at_noresolve(int which);
    1.80    symbolOop uncached_name_ref_at(int which)                 { return impl_name_ref_at(which, true); }
    1.81    symbolOop uncached_signature_ref_at(int which)            { return impl_signature_ref_at(which, true); }
    1.82    int       uncached_klass_ref_index_at(int which)          { return impl_klass_ref_index_at(which, true); }
    1.83 @@ -436,6 +488,8 @@
    1.84  
    1.85  #ifdef ASSERT
    1.86    enum { CPCACHE_INDEX_TAG = 0x10000 };  // helps keep CP cache indices distinct from CP indices
    1.87 +#else
    1.88 +  enum { CPCACHE_INDEX_TAG = 0 };        // in product mode, this zero value is a no-op
    1.89  #endif //ASSERT
    1.90  
    1.91   private:
    1.92 @@ -469,6 +523,8 @@
    1.93    // Resolve string constants (to prevent allocation during compilation)
    1.94    static void resolve_string_constants_impl(constantPoolHandle this_oop, TRAPS);
    1.95  
    1.96 +  static oop resolve_constant_at_impl(constantPoolHandle this_oop, int index, int cache_index, TRAPS);
    1.97 +
    1.98   public:
    1.99    // Merging constantPoolOop support:
   1.100    bool compare_entry_to(int index1, constantPoolHandle cp2, int index2, TRAPS);

mercurial