8029381: assert(is_method_type()) failed: bad cast
authordrchase
Mon, 02 Jun 2014 14:32:29 -0400
changeset 24926 5ea835dfafaa
parent 24924 f4f18b588249
child 24927 1449552c239c
8029381: assert(is_method_type()) failed: bad cast Summary: Access to method_type and appendix from constant pool (cpcache) needs to be guarded by is_f1_null() because of racy update/initialization. Reviewed-by: kvn, coleenp, jrose
hotspot/src/share/vm/oops/cpCache.cpp
hotspot/src/share/vm/oops/cpCache.hpp
--- a/hotspot/src/share/vm/oops/cpCache.cpp	Mon Jun 02 10:01:15 2014 +0200
+++ b/hotspot/src/share/vm/oops/cpCache.cpp	Mon Jun 02 14:32:29 2014 -0400
@@ -407,7 +407,7 @@
 
 
 oop ConstantPoolCacheEntry::appendix_if_resolved(constantPoolHandle cpool) {
-  if (is_f1_null() || !has_appendix())
+  if (!has_appendix())
     return NULL;
   const int ref_index = f2_as_index() + _indy_resolved_references_appendix_offset;
   objArrayOop resolved_references = cpool->resolved_references();
@@ -416,7 +416,7 @@
 
 
 oop ConstantPoolCacheEntry::method_type_if_resolved(constantPoolHandle cpool) {
-  if (is_f1_null() || !has_method_type())
+  if (!has_method_type())
     return NULL;
   const int ref_index = f2_as_index() + _indy_resolved_references_method_type_offset;
   objArrayOop resolved_references = cpool->resolved_references();
--- a/hotspot/src/share/vm/oops/cpCache.hpp	Mon Jun 02 10:01:15 2014 +0200
+++ b/hotspot/src/share/vm/oops/cpCache.hpp	Mon Jun 02 14:32:29 2014 -0400
@@ -348,8 +348,8 @@
   bool is_final() const                          { return (_flags & (1 << is_final_shift))          != 0; }
   bool is_forced_virtual() const                 { return (_flags & (1 << is_forced_virtual_shift)) != 0; }
   bool is_vfinal() const                         { return (_flags & (1 << is_vfinal_shift))         != 0; }
-  bool has_appendix() const                      { return (_flags & (1 << has_appendix_shift))      != 0; }
-  bool has_method_type() const                   { return (_flags & (1 << has_method_type_shift))   != 0; }
+  bool has_appendix() const                      { return (!is_f1_null()) && (_flags & (1 << has_appendix_shift))      != 0; }
+  bool has_method_type() const                   { return (!is_f1_null()) && (_flags & (1 << has_method_type_shift))   != 0; }
   bool is_method_entry() const                   { return (_flags & (1 << is_field_entry_shift))    == 0; }
   bool is_field_entry() const                    { return (_flags & (1 << is_field_entry_shift))    != 0; }
   bool is_byte() const                           { return flag_state() == btos; }