made a copy
[strongtalk-kjk.git] / vm / oops / memOop.inline.hpp
blob42ba1d1b965850faa60022d82ca422be67d8d89b
1 /* Copyright 1994, 1995 LongView Technologies L.L.C. $Revision: 1.20 $ */
2 /* Copyright (c) 2006, Sun Microsystems, Inc.
3 All rights reserved.
5 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
6 following conditions are met:
8 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
10 disclaimer in the documentation and/or other materials provided with the distribution.
11 * Neither the name of Sun Microsystems nor the names of its contributors may be used to endorse or promote products derived
12 from this software without specific prior written permission.
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
15 NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
16 THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
17 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
18 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
19 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
24 inline smi memOopDesc::identity_hash() {
25 // don't clean up the addr()->_mark below to mark(),
26 // since hash_markOop can modify its argument
27 return hash_markOop(addr()->_mark);
30 inline void memOopDesc::scavenge_header() {
31 // Not needed since klas is in old space
32 // scavenge_oop(klass_addr());
35 inline void memOopDesc::scavenge_body(int begin, int end) {
36 oop* p = (oop*) addr();
37 oop* q = p + end;
38 p += begin;
39 while (p < q) scavenge_oop(p++);
42 inline void memOopDesc::scavenge_tenured_body(int begin, int end) {
43 oop* p = (oop*) addr();
44 oop* q = p + end;
45 p += begin;
46 while (p < q) scavenge_tenured_oop(p++);
49 inline void memOopDesc::follow_header() {
50 MarkSweep::reverse_and_push(klass_addr());
53 inline void memOopDesc::follow_body(int begin, int end) {
54 oop* p = (oop*) addr();
55 oop* q = p + end;
56 p += begin;
57 while (p < q) MarkSweep::reverse_and_push(p++);
60 inline void memOopDesc::layout_iterate_header(ObjectLayoutClosure* blk) {
61 blk->do_mark(&addr()->_mark);
62 blk->do_oop("klass", (oop*) &addr()->_klass_field);
65 inline void memOopDesc::oop_iterate_header(OopClosure* blk) {
66 blk->do_oop((oop*) &addr()->_klass_field);
69 inline void memOopDesc::oop_iterate_body(OopClosure* blk, int begin, int end) {
70 oop* p = (oop*) addr();
71 oop* q = p + end;
72 p += begin;
73 while (p < q) blk->do_oop(p++);
76 inline void memOopDesc::initialize_header(bool has_untagged_contents, klassOop klass) {
77 set_klass_field(klass);
78 if (has_untagged_contents)
79 init_untagged_contents_mark();
80 else
81 init_mark();
84 inline void memOopDesc::initialize_body(int begin, int end) {
85 oop value = nilObj;
86 oop* p = (oop*) addr();
87 oop* q = p + end;
88 p += begin;
89 while (p < q) Universe::store(p++, value, false);
92 inline void memOopDesc::raw_at_put(int which, oop contents, bool cs) {
93 Universe::store(oops(which), contents, cs); }
95 inline int memOopDesc::size() const {
96 return blueprint()->oop_size(memOop(this));
99 inline int memOopDesc::scavenge_contents() {
100 return blueprint()->oop_scavenge_contents(this);
103 inline int memOopDesc::scavenge_tenured_contents() {
104 return blueprint()->oop_scavenge_tenured_contents(this);
107 // Store object size in age field and remembered set
108 inline void memOopDesc::gc_store_size() {
109 int s = size();
110 if (s < markOopDesc::max_age) {
111 // store size in age field
112 set_mark(mark()->set_age(s));
113 assert(mark()->age() == s, "Check size");
114 } else {
115 // store size in remembered set
116 // first set overflow value in age field
117 set_mark(mark()->set_age(0));
118 assert(mark()->age() == 0, "Check size");
120 Universe::remembered_set->set_size(this, s);
121 assert(Universe::remembered_set->get_size(this) == s, "Check size");
125 // Retrieve object size from age field and remembered set
126 inline int memOopDesc::gc_retrieve_size() {
127 if (mark()->age() == 0)
128 return Universe::remembered_set->get_size(this);
129 return mark()->age();