src/share/vm/oops/cpCacheOop.hpp

changeset 1161
be93aad57795
parent 1014
0fbdb4381b99
child 1494
389049f3f393
     1.1 --- a/src/share/vm/oops/cpCacheOop.hpp	Mon Apr 20 14:48:03 2009 -0700
     1.2 +++ b/src/share/vm/oops/cpCacheOop.hpp	Tue Apr 21 23:21:04 2009 -0700
     1.3 @@ -89,6 +89,7 @@
     1.4  // _f1      = method for all but virtual calls, unused by virtual calls
     1.5  //            (note: for interface calls, which are essentially virtual,
     1.6  //             contains klassOop for the corresponding interface.
     1.7 +//            for invokedynamic, f1 contains the CallSite object for the invocation
     1.8  // _f2      = method/vtable index for virtual calls only, unused by all other
     1.9  //            calls.  The vf flag indicates this is a method pointer not an
    1.10  //            index.
    1.11 @@ -108,6 +109,8 @@
    1.12  
    1.13  class ConstantPoolCacheEntry VALUE_OBJ_CLASS_SPEC {
    1.14    friend class VMStructs;
    1.15 +  friend class constantPoolCacheKlass;
    1.16 +
    1.17   private:
    1.18    volatile intx     _indices;  // constant pool index & rewrite bytecodes
    1.19    volatile oop      _f1;       // entry specific oop field
    1.20 @@ -175,6 +178,11 @@
    1.21      int index                                    // Method index into interface
    1.22    );
    1.23  
    1.24 +  void set_dynamic_call(
    1.25 +    Handle call_site,                            // Resolved java.dyn.CallSite (f1)
    1.26 +    int extra_data                               // (f2)
    1.27 +  );
    1.28 +
    1.29    void set_parameter_size(int value) {
    1.30      assert(parameter_size() == 0 || parameter_size() == value,
    1.31             "size must not change");
    1.32 @@ -216,7 +224,11 @@
    1.33    }
    1.34  
    1.35    // Accessors
    1.36 -  int constant_pool_index() const                { return _indices & 0xFFFF; }
    1.37 +  bool is_secondary_entry() const                { return (_indices & 0xFFFF) == 0; }
    1.38 +  int constant_pool_index() const                { assert((_indices & 0xFFFF) != 0, "must be main entry");
    1.39 +                                                   return (_indices & 0xFFFF); }
    1.40 +  int main_entry_index() const                   { assert((_indices & 0xFFFF) == 0, "must be secondary entry");
    1.41 +                                                   return ((uintx)_indices >> 16); }
    1.42    Bytecodes::Code bytecode_1() const             { return Bytecodes::cast((_indices >> 16) & 0xFF); }
    1.43    Bytecodes::Code bytecode_2() const             { return Bytecodes::cast((_indices >> 24) & 0xFF); }
    1.44    volatile oop  f1() const                       { return _f1; }
    1.45 @@ -314,10 +326,30 @@
    1.46    // Initialization
    1.47    void initialize(intArray& inverse_index_map);
    1.48  
    1.49 +  // Secondary indexes.
    1.50 +  // They must look completely different from normal indexes.
    1.51 +  // The main reason is that byte swapping is sometimes done on normal indexes.
    1.52 +  // Also, it is helpful for debugging to tell the two apart.
    1.53 +  static bool is_secondary_index(int i) { return (i < 0); }
    1.54 +  static int  decode_secondary_index(int i) { assert(is_secondary_index(i),  ""); return ~i; }
    1.55 +  static int  encode_secondary_index(int i) { assert(!is_secondary_index(i), ""); return ~i; }
    1.56 +
    1.57    // Accessors
    1.58    void set_constant_pool(constantPoolOop pool)   { oop_store_without_check((oop*)&_constant_pool, (oop)pool); }
    1.59    constantPoolOop constant_pool() const          { return _constant_pool; }
    1.60    ConstantPoolCacheEntry* entry_at(int i) const  { assert(0 <= i && i < length(), "index out of bounds"); return base() + i; }
    1.61 +  ConstantPoolCacheEntry* main_entry_at(int i) const {
    1.62 +    ConstantPoolCacheEntry* e;
    1.63 +    if (is_secondary_index(i)) {
    1.64 +      // run through an extra level of indirection:
    1.65 +      i = decode_secondary_index(i);
    1.66 +      e = entry_at(i);
    1.67 +      i = e->main_entry_index();
    1.68 +    }
    1.69 +    e = entry_at(i);
    1.70 +    assert(!e->is_secondary_entry(), "only one level of indirection");
    1.71 +    return e;
    1.72 +  }
    1.73  
    1.74    // GC support
    1.75    // If the _length field has not been set, the size of the

mercurial