src/share/vm/oops/objArrayKlass.hpp

Thu, 07 Apr 2011 09:53:20 -0700

author
johnc
date
Thu, 07 Apr 2011 09:53:20 -0700
changeset 2781
e1162778c1c8
parent 2314
f95d63e2154a
child 3391
069ab3f976d3
permissions
-rw-r--r--

7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
Summary: A referent object that is only weakly reachable at the start of concurrent marking but is re-attached to the strongly reachable object graph during marking may not be marked as live. This can cause the reference object to be processed prematurely and leave dangling pointers to the referent object. Implement a read barrier for the java.lang.ref.Reference::referent field by intrinsifying the Reference.get() method, and intercepting accesses though JNI, reflection, and Unsafe, so that when a non-null referent object is read it is also logged in an SATB buffer.
Reviewed-by: kvn, iveresov, never, tonyp, dholmes

     1 /*
     2  * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 #ifndef SHARE_VM_OOPS_OBJARRAYKLASS_HPP
    26 #define SHARE_VM_OOPS_OBJARRAYKLASS_HPP
    28 #include "memory/specialized_oop_closures.hpp"
    29 #include "oops/arrayKlass.hpp"
    30 #include "oops/instanceKlass.hpp"
    32 // objArrayKlass is the klass for objArrays
    34 class objArrayKlass : public arrayKlass {
    35   friend class VMStructs;
    36  private:
    37   klassOop _element_klass;            // The klass of the elements of this array type
    38   klassOop _bottom_klass;             // The one-dimensional type (instanceKlass or typeArrayKlass)
    39  public:
    40   // Instance variables
    41   klassOop element_klass() const      { return _element_klass; }
    42   void set_element_klass(klassOop k)  { oop_store_without_check((oop*) &_element_klass, (oop) k); }
    43   oop* element_klass_addr()           { return (oop*)&_element_klass; }
    45   klassOop bottom_klass() const       { return _bottom_klass; }
    46   void set_bottom_klass(klassOop k)   { oop_store_without_check((oop*) &_bottom_klass, (oop) k); }
    47   oop* bottom_klass_addr()            { return (oop*)&_bottom_klass; }
    49   // Compiler/Interpreter offset
    50   static int element_klass_offset_in_bytes() { return offset_of(objArrayKlass, _element_klass); }
    52   // Dispatched operation
    53   bool can_be_primary_super_slow() const;
    54   objArrayOop compute_secondary_supers(int num_extra_slots, TRAPS);
    55   bool compute_is_subtype_of(klassOop k);
    56   bool oop_is_objArray_slow()  const  { return true; }
    57   int oop_size(oop obj) const;
    58   int klass_oop_size() const          { return object_size(); }
    60   // Allocation
    61   DEFINE_ALLOCATE_PERMANENT(objArrayKlass);
    62   objArrayOop allocate(int length, TRAPS);
    63   oop multi_allocate(int rank, jint* sizes, TRAPS);
    65   // Copying
    66   void  copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS);
    68   // Compute protection domain
    69   oop protection_domain() { return Klass::cast(bottom_klass())->protection_domain(); }
    70   // Compute class loader
    71   oop class_loader() const { return Klass::cast(bottom_klass())->class_loader(); }
    73  private:
    74   // Either oop or narrowOop depending on UseCompressedOops.
    75   // must be called from within objArrayKlass.cpp
    76   template <class T> void do_copy(arrayOop s, T* src, arrayOop d,
    77                                   T* dst, int length, TRAPS);
    78  protected:
    79   // Returns the objArrayKlass for n'th dimension.
    80   virtual klassOop array_klass_impl(bool or_null, int n, TRAPS);
    82   // Returns the array class with this class as element type.
    83   virtual klassOop array_klass_impl(bool or_null, TRAPS);
    85  public:
    86   // Casting from klassOop
    87   static objArrayKlass* cast(klassOop k) {
    88     assert(k->klass_part()->oop_is_objArray_slow(), "cast to objArrayKlass");
    89     return (objArrayKlass*) k->klass_part();
    90   }
    92   // Sizing
    93   static int header_size()                { return oopDesc::header_size() + sizeof(objArrayKlass)/HeapWordSize; }
    94   int object_size() const                 { return arrayKlass::object_size(header_size()); }
    96   // Initialization (virtual from Klass)
    97   void initialize(TRAPS);
    99   // Garbage collection
   100   void oop_follow_contents(oop obj);
   101   inline void oop_follow_contents(oop obj, int index);
   102   template <class T> inline void objarray_follow_contents(oop obj, int index);
   104   int  oop_adjust_pointers(oop obj);
   106   // Parallel Scavenge and Parallel Old
   107   PARALLEL_GC_DECLS
   108 #ifndef SERIALGC
   109   inline void oop_follow_contents(ParCompactionManager* cm, oop obj, int index);
   110   template <class T> inline void
   111     objarray_follow_contents(ParCompactionManager* cm, oop obj, int index);
   112 #endif // !SERIALGC
   114   // Iterators
   115   int oop_oop_iterate(oop obj, OopClosure* blk) {
   116     return oop_oop_iterate_v(obj, blk);
   117   }
   118   int oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
   119     return oop_oop_iterate_v_m(obj, blk, mr);
   120   }
   121 #define ObjArrayKlass_OOP_OOP_ITERATE_DECL(OopClosureType, nv_suffix)   \
   122   int oop_oop_iterate##nv_suffix(oop obj, OopClosureType* blk);         \
   123   int oop_oop_iterate##nv_suffix##_m(oop obj, OopClosureType* blk,      \
   124                                      MemRegion mr);                     \
   125   int oop_oop_iterate_range##nv_suffix(oop obj, OopClosureType* blk,    \
   126                                      int start, int end);
   128   ALL_OOP_OOP_ITERATE_CLOSURES_1(ObjArrayKlass_OOP_OOP_ITERATE_DECL)
   129   ALL_OOP_OOP_ITERATE_CLOSURES_2(ObjArrayKlass_OOP_OOP_ITERATE_DECL)
   131   // JVM support
   132   jint compute_modifier_flags(TRAPS) const;
   134  private:
   135    static klassOop array_klass_impl   (objArrayKlassHandle this_oop, bool or_null, int n, TRAPS);
   137  public:
   138   // Printing
   139   void oop_print_value_on(oop obj, outputStream* st);
   140 #ifndef PRODUCT
   141   void oop_print_on      (oop obj, outputStream* st);
   142 #endif //PRODUCT
   144   // Verification
   145   const char* internal_name() const;
   146   void oop_verify_on(oop obj, outputStream* st);
   147   void oop_verify_old_oop(oop obj, oop* p, bool allow_dirty);
   148   void oop_verify_old_oop(oop obj, narrowOop* p, bool allow_dirty);
   149 };
   151 #endif // SHARE_VM_OOPS_OBJARRAYKLASS_HPP

mercurial