hotspot/src/share/vm/oops/cpCacheOop.cpp
changeset 2570 ecc7862946d4
parent 670 ddf3e9583f2f
child 3261 c7d5aae8d3f7
equal deleted inserted replaced
2569:9e8daec25638 2570:ecc7862946d4
    27 
    27 
    28 
    28 
    29 // Implememtation of ConstantPoolCacheEntry
    29 // Implememtation of ConstantPoolCacheEntry
    30 
    30 
    31 void ConstantPoolCacheEntry::set_initial_state(int index) {
    31 void ConstantPoolCacheEntry::set_initial_state(int index) {
    32   assert(0 <= index && index < 0x10000, "sanity check");
    32   if (constantPoolCacheOopDesc::is_secondary_index(index)) {
       
    33     // Hack:  The rewriter is trying to say that this entry itself
       
    34     // will be a secondary entry.
       
    35     int main_index = constantPoolCacheOopDesc::decode_secondary_index(index);
       
    36     assert(0 <= main_index && main_index < 0x10000, "sanity check");
       
    37     _indices = (main_index << 16);
       
    38     assert(main_entry_index() == main_index, "");
       
    39     return;
       
    40   }
       
    41   assert(0 < index && index < 0x10000, "sanity check");
    33   _indices = index;
    42   _indices = index;
       
    43   assert(constant_pool_index() == index, "");
    34 }
    44 }
    35 
    45 
    36 
    46 
    37 int ConstantPoolCacheEntry::as_flags(TosState state, bool is_final,
    47 int ConstantPoolCacheEntry::as_flags(TosState state, bool is_final,
    38                     bool is_vfinal, bool is_volatile,
    48                     bool is_vfinal, bool is_volatile,
   134   bool change_to_virtual = (invoke_code == Bytecodes::_invokeinterface);
   144   bool change_to_virtual = (invoke_code == Bytecodes::_invokeinterface);
   135 
   145 
   136   int byte_no = -1;
   146   int byte_no = -1;
   137   bool needs_vfinal_flag = false;
   147   bool needs_vfinal_flag = false;
   138   switch (invoke_code) {
   148   switch (invoke_code) {
       
   149     case Bytecodes::_invokedynamic:
   139     case Bytecodes::_invokevirtual:
   150     case Bytecodes::_invokevirtual:
   140     case Bytecodes::_invokeinterface: {
   151     case Bytecodes::_invokeinterface: {
   141         if (method->can_be_statically_bound()) {
   152         if (method->can_be_statically_bound()) {
   142           set_f2((intptr_t)method());
   153           set_f2((intptr_t)method());
   143           needs_vfinal_flag = true;
   154           needs_vfinal_flag = true;
   209   set_flags(as_flags(as_TosState(method->result_type()), method->is_final_method(), false, false, false, true) | method()->size_of_parameters());
   220   set_flags(as_flags(as_TosState(method->result_type()), method->is_final_method(), false, false, false, true) | method()->size_of_parameters());
   210   set_bytecode_1(Bytecodes::_invokeinterface);
   221   set_bytecode_1(Bytecodes::_invokeinterface);
   211 }
   222 }
   212 
   223 
   213 
   224 
       
   225 void ConstantPoolCacheEntry::set_dynamic_call(Handle call_site, int extra_data) {
       
   226   methodOop method = (methodOop) sun_dyn_CallSiteImpl::vmmethod(call_site());
       
   227   assert(method->is_method(), "must be initialized properly");
       
   228   int param_size = method->size_of_parameters();
       
   229   assert(param_size > 1, "method argument size must include MH.this & initial dynamic receiver");
       
   230   param_size -= 1;              // do not count MH.this; it is not stacked for invokedynamic
       
   231   if (Atomic::cmpxchg_ptr(call_site(), &_f1, NULL) == NULL) {
       
   232     // racing threads might be trying to install their own favorites
       
   233     set_f1(call_site());
       
   234   }
       
   235   set_f2(extra_data);
       
   236   set_flags(as_flags(as_TosState(method->result_type()), method->is_final_method(), false, false, false, true) | param_size);
       
   237   // do not do set_bytecode on a secondary CP cache entry
       
   238   //set_bytecode_1(Bytecodes::_invokedynamic);
       
   239 }
       
   240 
       
   241 
   214 class LocalOopClosure: public OopClosure {
   242 class LocalOopClosure: public OopClosure {
   215  private:
   243  private:
   216   void (*_f)(oop*);
   244   void (*_f)(oop*);
   217 
   245 
   218  public:
   246  public:
   390 
   418 
   391 void ConstantPoolCacheEntry::print(outputStream* st, int index) const {
   419 void ConstantPoolCacheEntry::print(outputStream* st, int index) const {
   392   // print separator
   420   // print separator
   393   if (index == 0) tty->print_cr("                 -------------");
   421   if (index == 0) tty->print_cr("                 -------------");
   394   // print entry
   422   // print entry
   395   tty->print_cr("%3d  (%08x)  [%02x|%02x|%5d]", index, this, bytecode_2(), bytecode_1(), constant_pool_index());
   423   tty->print_cr("%3d  (%08x)  ", index, this);
       
   424   if (is_secondary_entry())
       
   425     tty->print_cr("[%5d|secondary]", main_entry_index());
       
   426   else
       
   427     tty->print_cr("[%02x|%02x|%5d]", bytecode_2(), bytecode_1(), constant_pool_index());
   396   tty->print_cr("                 [   %08x]", (address)(oop)_f1);
   428   tty->print_cr("                 [   %08x]", (address)(oop)_f1);
   397   tty->print_cr("                 [   %08x]", _f2);
   429   tty->print_cr("                 [   %08x]", _f2);
   398   tty->print_cr("                 [   %08x]", _flags);
   430   tty->print_cr("                 [   %08x]", _flags);
   399   tty->print_cr("                 -------------");
   431   tty->print_cr("                 -------------");
   400 }
   432 }