memOop.cpp

Go to the documentation of this file.
00001 /* Copyright 1994, 1995 LongView Technologies L.L.C. $Revision: 1.34 $ */
00002 /* Copyright (c) 2006, Sun Microsystems, Inc.
00003 All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 
00006 following conditions are met:
00007 
00008     * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
00009     * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following 
00010           disclaimer in the documentation and/or other materials provided with the distribution.
00011     * Neither the name of Sun Microsystems nor the names of its contributors may be used to endorse or promote products derived 
00012           from this software without specific prior written permission.
00013 
00014 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT 
00015 NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 
00016 THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
00017 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
00018 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
00019 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
00020 
00021 
00022 */
00023 
00024 # include "incls/_precompiled.incl"
00025 # include "incls/_memOop.cpp.incl"
00026 
00027 void memOopDesc::layout_iterate_body(ObjectLayoutClosure* blk, int begin, int end) {
00028   oop* p = (oop*) addr();
00029   oop* q = p + end;
00030   p     += begin;
00031   while (p < q) {
00032     int offset = p - (oop*) addr();
00033     // Compute the instance variable name at the current offset
00034     symbolOop name = blueprint()->inst_var_name_at(offset);
00035     char* n = "instVar?";
00036     if (name) {
00037       stringStream st(50);
00038       name->print_symbol_on(&st);
00039       n = st.as_string();
00040     }
00041     blk->do_oop(n, p++);
00042   }
00043 }
00044 
00045 oop memOopDesc::scavenge() {
00046   assert((!Universe::should_scavenge(this)) == 
00047          (((char*) this > Universe::old_gen.low_boundary) || Universe::new_gen.to()->contains(this)),
00048          "just checking");
00049 
00050   if (((char*) this > Universe::old_gen.low_boundary) || Universe::new_gen.to()->contains(this)) {
00051     return this;
00052   } else if (this->is_forwarded()) {
00053     return oop(this->forwardee());
00054   } else {
00055     return copy_to_survivor_space();
00056   }
00057 }
00058 
00059 void memOopDesc::follow_contents() {
00060   assert(is_gc_marked(), "pointer reversal should have taken place");
00061   // lprintf("[%s, 0x%lx, 0x%lx]", blueprint()->name(), this, klass());
00062   blueprint()->oop_follow_contents(this);
00063 }
00064 
00065 oop memOopDesc::copy_to_survivor_space() {
00066   int s = size();
00067   assert(Universe::should_scavenge(this) && !is_forwarded(), 
00068          "shouldn't be scavenging"); 
00069   bool is_new;
00070   oop* x = Universe::allocate_in_survivor_space(this, s, is_new);
00071 
00072 # ifdef VERBOSE_SCAVENGING
00073   lprintf("{copy %s %#lx -> %#lx (%d)}\n",
00074           blueprint()->name(), oops(), x, s);
00075 # endif
00076 
00077   memOop p= as_memOop(x);
00078   copy_oops(oops(), x, s);
00079 
00080   if (is_new) { 
00081     p->set_mark(p->mark()->incr_age()); 
00082     Universe::age_table->add(p, s); 
00083   } else {
00084   # ifdef VERBOSE_SCAVENGING
00085     lprintf("{tenuring %s %#lx -> %#lx (%d)}\n",
00086             blueprint()->name(), oops(), x, s);
00087   # endif
00088   }
00089   forward_to(p); 
00090   return p;
00091 }
00092 
00093 void memOopDesc::oop_iterate(OopClosure* blk) {
00094   blueprint()->oop_oop_iterate(this, blk);
00095 }
00096 
00097 void memOopDesc::layout_iterate(ObjectLayoutClosure* blk) {
00098   blueprint()->oop_layout_iterate(this, blk);
00099 }
00100 
00101 bool memOopDesc::verify() {
00102   bool flag = true;
00103   if (flag) {
00104     markOop m = mark();
00105     if (! oop(m)->is_mark()) {
00106       error("mark of memOop %#lx isn't a markOop", this);
00107       if (! m->verify())
00108         error(" mark of memOop %#lx isn't even a legal oop", this);
00109       flag = false;
00110     }
00111     klassOop p = klass();
00112     if (! p->is_klass()) {
00113       error("map of memOop %#lx isn't a klassOop", this);
00114       flag = false;
00115     }
00116   }
00117   return flag;
00118 }
00119 
00120 void memOopDesc::set_identity_hash(smi h) {
00121   set_mark(mark()->set_hash(h));
00122 }
00123 
00124 void memOopDesc::bootstrap_header(bootstrap* st) {
00125   if (st->new_format()) {
00126     st->read_oop((oop*)&addr()->_klass_field);
00127     set_mark(blueprint()->has_untagged_contents() 
00128            ? markOopDesc::untagged_prototype()
00129            : markOopDesc::tagged_prototype());
00130   } else {
00131     st->read_mark(&addr()->_mark);
00132     st->read_oop((oop*)&addr()->_klass_field);
00133   }
00134 }
00135 
00136 void memOopDesc::bootstrap_object(bootstrap* st) {
00137   bootstrap_header(st);
00138   bootstrap_body(st, header_size());
00139 }
00140 
00141 void memOopDesc::bootstrap_body(bootstrap* st, int h_size) {
00142   int offset = h_size;
00143   int s      = blueprint()->non_indexable_size();
00144   while (offset < s) {
00145     st->read_oop((oop*)addr() + offset);
00146     offset++;
00147   }
00148 }
00149 
00150 bool memOopDesc::is_within_instVar_bounds(int index) {
00151   return index >= blueprint()->oop_header_size()
00152       && index <  blueprint()->non_indexable_size();
00153 }
00154 
00155 oop memOopDesc::instVarAt(int index) {
00156   return raw_at(index );
00157 }
00158 
00159 
00160 oop memOopDesc::instVarAtPut(int index, oop value) {
00161   raw_at_put(index, value);
00162   return this;
00163 }
00164 
00165 void memOopDesc::print_on(outputStream* st) {
00166   blueprint()->oop_print_on(this, st);
00167 }
00168 
00169 void memOopDesc::print_id_on(outputStream* st) {
00170   int id;
00171   if (GCInProgress || !(id = objectIDTable::insert(memOop(this))))
00172     st->print("(%#-6lx)", addr());
00173   else
00174     st->print("%d",id);
00175 }
00176 
00177 memOop as_memOop(void* p)
00178 {
00179     assert((int(p) & Tag_Mask) == 0, "not an aligned C pointer");
00180     return memOop(int(p) + Mem_Tag);
00181 }

Generated on Mon Oct 9 13:37:14 2006 for Strongtalk VM by  doxygen 1.4.7