hotspot/src/share/vm/oops/methodOop.cpp
changeset 1894 5c343868d071
parent 670 ddf3e9583f2f
child 2105 347008ce7984
equal deleted inserted replaced
1893:c82e388e17c5 1894:5c343868d071
   790   assert(!m->is_native(), "cannot rewrite native methods");
   790   assert(!m->is_native(), "cannot rewrite native methods");
   791   // Allocate new methodOop
   791   // Allocate new methodOop
   792   AccessFlags flags = m->access_flags();
   792   AccessFlags flags = m->access_flags();
   793   int checked_exceptions_len = m->checked_exceptions_length();
   793   int checked_exceptions_len = m->checked_exceptions_length();
   794   int localvariable_len = m->localvariable_table_length();
   794   int localvariable_len = m->localvariable_table_length();
   795   methodOop newm_oop = oopFactory::new_method(new_code_length, flags, new_compressed_linenumber_size, localvariable_len, checked_exceptions_len, CHECK_(methodHandle()));
   795   // Allocate newm_oop with the is_conc_safe parameter set
       
   796   // to IsUnsafeConc to indicate that newm_oop is not yet
       
   797   // safe for concurrent processing by a GC.
       
   798   methodOop newm_oop = oopFactory::new_method(new_code_length,
       
   799                                               flags,
       
   800                                               new_compressed_linenumber_size,
       
   801                                               localvariable_len,
       
   802                                               checked_exceptions_len,
       
   803                                               IsUnsafeConc,
       
   804                                               CHECK_(methodHandle()));
   796   methodHandle newm (THREAD, newm_oop);
   805   methodHandle newm (THREAD, newm_oop);
   797   int new_method_size = newm->method_size();
   806   int new_method_size = newm->method_size();
   798   // Create a shallow copy of methodOopDesc part, but be careful to preserve the new constMethodOop
   807   // Create a shallow copy of methodOopDesc part, but be careful to preserve the new constMethodOop
   799   constMethodOop newcm = newm->constMethod();
   808   constMethodOop newcm = newm->constMethod();
   800   int new_const_method_size = newm->constMethod()->object_size();
   809   int new_const_method_size = newm->constMethod()->object_size();
       
   810 
   801   memcpy(newm(), m(), sizeof(methodOopDesc));
   811   memcpy(newm(), m(), sizeof(methodOopDesc));
   802   // Create shallow copy of constMethodOopDesc, but be careful to preserve the methodOop
   812   // Create shallow copy of constMethodOopDesc, but be careful to preserve the methodOop
       
   813   // is_conc_safe is set to false because that is the value of
       
   814   // is_conc_safe initialzied into newcm and the copy should
       
   815   // not overwrite that value.  During the window during which it is
       
   816   // tagged as unsafe, some extra work could be needed during precleaning
       
   817   // or concurrent marking but those phases will be correct.  Setting and
       
   818   // resetting is done in preference to a careful copying into newcm to
       
   819   // avoid having to know the precise layout of a constMethodOop.
       
   820   m->constMethod()->set_is_conc_safe(false);
   803   memcpy(newcm, m->constMethod(), sizeof(constMethodOopDesc));
   821   memcpy(newcm, m->constMethod(), sizeof(constMethodOopDesc));
       
   822   m->constMethod()->set_is_conc_safe(true);
   804   // Reset correct method/const method, method size, and parameter info
   823   // Reset correct method/const method, method size, and parameter info
   805   newcm->set_method(newm());
   824   newcm->set_method(newm());
   806   newm->set_constMethod(newcm);
   825   newm->set_constMethod(newcm);
   807   assert(newcm->method() == newm(), "check");
   826   assert(newcm->method() == newm(), "check");
   808   newm->constMethod()->set_code_size(new_code_length);
   827   newm->constMethod()->set_code_size(new_code_length);
   829   if (localvariable_len > 0) {
   848   if (localvariable_len > 0) {
   830     memcpy(newm->localvariable_table_start(),
   849     memcpy(newm->localvariable_table_start(),
   831            m->localvariable_table_start(),
   850            m->localvariable_table_start(),
   832            localvariable_len * sizeof(LocalVariableTableElement));
   851            localvariable_len * sizeof(LocalVariableTableElement));
   833   }
   852   }
       
   853 
       
   854   // Only set is_conc_safe to true when changes to newcm are
       
   855   // complete.
       
   856   newcm->set_is_conc_safe(true);
   834   return newm;
   857   return newm;
   835 }
   858 }
   836 
   859 
   837 vmIntrinsics::ID methodOopDesc::compute_intrinsic_id() const {
   860 vmIntrinsics::ID methodOopDesc::compute_intrinsic_id() const {
   838   assert(vmIntrinsics::_none == 0, "correct coding of default case");
   861   assert(vmIntrinsics::_none == 0, "correct coding of default case");