Mon, 09 Jun 2008 11:51:19 -0400
6687581: Make CMS work with compressed oops
Summary: Make FreeChunk read markword instead of LSB in _klass pointer to indicate that it's a FreeChunk for compressed oops.
Reviewed-by: ysr, jmasa
1 /*
2 * Copyright 1997-2003 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 *
23 */
25 // An objArrayOop is an array containing oops.
26 // Evaluating "String arg[10]" will create an objArrayOop.
28 class objArrayOopDesc : public arrayOopDesc {
29 friend class objArrayKlass;
30 friend class Runtime1;
31 friend class psPromotionManager;
33 template <class T> T* obj_at_addr(int index) const {
34 assert(is_within_bounds(index), "index out of bounds");
35 return &((T*)base())[index];
36 }
38 public:
39 // base is the address following the header.
40 HeapWord* base() const { return (HeapWord*) arrayOopDesc::base(T_OBJECT); }
42 // Accessing
43 oop obj_at(int index) const {
44 // With UseCompressedOops decode the narrow oop in the objArray to an
45 // uncompressed oop. Otherwise this is simply a "*" operator.
46 if (UseCompressedOops) {
47 return load_decode_heap_oop(obj_at_addr<narrowOop>(index));
48 } else {
49 return load_decode_heap_oop(obj_at_addr<oop>(index));
50 }
51 }
53 void obj_at_put(int index, oop value) {
54 if (UseCompressedOops) {
55 oop_store(obj_at_addr<narrowOop>(index), value);
56 } else {
57 oop_store(obj_at_addr<oop>(index), value);
58 }
59 }
60 // Sizing
61 static int header_size() { return arrayOopDesc::header_size(T_OBJECT); }
62 int object_size() { return object_size(length()); }
63 int array_size() { return array_size(length()); }
65 static int object_size(int length) {
66 // This returns the object size in HeapWords.
67 return align_object_size(header_size() + array_size(length));
68 }
70 // Give size of objArrayOop in HeapWords minus the header
71 static int array_size(int length) {
72 // Without UseCompressedOops, this is simply:
73 // oop->length() * HeapWordsPerOop;
74 // With narrowOops, HeapWordsPerOop is 1/2 or equal 0 as an integer.
75 // The oop elements are aligned up to wordSize
76 const int HeapWordsPerOop = heapOopSize/HeapWordSize;
77 if (HeapWordsPerOop > 0) {
78 return length * HeapWordsPerOop;
79 } else {
80 const int OopsPerHeapWord = HeapWordSize/heapOopSize;
81 int word_len = align_size_up(length, OopsPerHeapWord)/OopsPerHeapWord;
82 return word_len;
83 }
84 }
86 // special iterators for index ranges, returns size of object
87 #define ObjArrayOop_OOP_ITERATE_DECL(OopClosureType, nv_suffix) \
88 int oop_iterate_range(OopClosureType* blk, int start, int end);
90 ALL_OOP_OOP_ITERATE_CLOSURES_1(ObjArrayOop_OOP_ITERATE_DECL)
91 ALL_OOP_OOP_ITERATE_CLOSURES_3(ObjArrayOop_OOP_ITERATE_DECL)
92 };