Thu, 07 Apr 2011 09:53:20 -0700
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_TYPEARRAYKLASS_HPP
26 #define SHARE_VM_OOPS_TYPEARRAYKLASS_HPP
28 #include "oops/arrayKlass.hpp"
30 // A typeArrayKlass is the klass of a typeArray
31 // It contains the type and size of the elements
33 class typeArrayKlass : public arrayKlass {
34 friend class VMStructs;
35 private:
36 jint _max_length; // maximum number of elements allowed in an array
37 public:
38 // instance variables
39 jint max_length() { return _max_length; }
40 void set_max_length(jint m) { _max_length = m; }
42 // testers
43 bool oop_is_typeArray_slow() const { return true; }
45 // klass allocation
46 DEFINE_ALLOCATE_PERMANENT(typeArrayKlass);
47 static klassOop create_klass(BasicType type, int scale, const char* name_str,
48 TRAPS);
49 static inline klassOop create_klass(BasicType type, int scale, TRAPS) {
50 return create_klass(type, scale, external_name(type), CHECK_NULL);
51 }
53 int oop_size(oop obj) const;
54 int klass_oop_size() const { return object_size(); }
56 bool compute_is_subtype_of(klassOop k);
58 // Allocation
59 typeArrayOop allocate(int length, TRAPS);
60 typeArrayOop allocate_permanent(int length, TRAPS); // used for class file structures
61 oop multi_allocate(int rank, jint* sizes, TRAPS);
63 // Copying
64 void copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS);
66 // Iteration
67 int oop_oop_iterate(oop obj, OopClosure* blk);
68 int oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr);
70 // Garbage collection
71 void oop_follow_contents(oop obj);
72 int oop_adjust_pointers(oop obj);
74 // Parallel Scavenge and Parallel Old
75 PARALLEL_GC_DECLS
77 protected:
78 // Find n'th dimensional array
79 virtual klassOop array_klass_impl(bool or_null, int n, TRAPS);
81 // Returns the array class with this class as element type
82 virtual klassOop array_klass_impl(bool or_null, TRAPS);
84 public:
85 // Casting from klassOop
86 static typeArrayKlass* cast(klassOop k) {
87 assert(k->klass_part()->oop_is_typeArray_slow(), "cast to typeArrayKlass");
88 return (typeArrayKlass*) k->klass_part();
89 }
91 // Naming
92 static const char* external_name(BasicType type);
94 // Sizing
95 static int header_size() { return oopDesc::header_size() + sizeof(typeArrayKlass)/HeapWordSize; }
96 int object_size() const { return arrayKlass::object_size(header_size()); }
98 // Initialization (virtual from Klass)
99 void initialize(TRAPS);
101 private:
102 // Helpers
103 static klassOop array_klass_impl(typeArrayKlassHandle h_this, bool or_null, int n, TRAPS);
105 #ifndef PRODUCT
106 public:
107 // Printing
108 void oop_print_on(oop obj, outputStream* st);
109 #endif
110 public:
111 const char* internal_name() const;
112 };
114 #endif // SHARE_VM_OOPS_TYPEARRAYKLASS_HPP