memOop.hpp

Go to the documentation of this file.
00001 /* Copyright 1994 - 1996 LongView Technologies L.L.C. $Revision: 1.38 $ */
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 // memOops are all oops that actually take up space in the heap (i.e.,
00025 // aren't immediates like smis)
00026 
00027 // Again (see oop.hpp), memOops are tagged (ST oops) but memOopDesc*s are
00028 // untagged C pointers.  
00029 
00030 // should clean up order of member functions  -Urs
00031 
00032 class memOopDesc: public oopDesc {
00033  protected:
00034   // instance variable
00035   // markOop _mark;                     // see comment in oop.hpp
00036   klassOop _klass_field;                // the receiver's class
00037   
00038  public:
00039   // returns the header size of a memOop
00040   static int header_size()              { return sizeof(memOopDesc)/oopSize; }
00041 
00042   // field offsets for code generation
00043   static int mark_byte_offset()         { return (0 * oopSize) - Mem_Tag; }
00044   static int klass_byte_offset()        { return (1 * oopSize) - Mem_Tag; }
00045 
00046   // coercions
00047   friend memOop as_memOop(void* p);
00048 
00049   // conversion from memOop to memOopDesc*
00050   memOopDesc* addr() const              { return (memOopDesc*) (int(this) - Mem_Tag); }
00051   
00052   // space operations, is_old/new work w/o conversion to memOopDesc*
00053   // since oop > pointer (Mem_Tag >= 0)!
00054   bool is_old() const                   { return (char*)this >= Universe::old_gen.low_boundary;  }
00055   bool is_new() const                   { return (char*)this <  Universe::new_gen.high_boundary; }
00056 
00057   // mark accessors
00058   markOop mark() const                  { return addr()->_mark; }
00059 
00060   void set_mark(markOop m)              { addr()->_mark = m; }
00061   void set_mark(memOop p)               { set_mark(markOop(p)); }
00062   void set_mark(oop* p)                 { set_mark(markOop(p)); }
00063 
00064   oop* klass_addr() const               { return (oop*) &addr()->_klass_field; }
00065 
00066   void set_klass_field(klassOop k, bool cs = true) {
00067     // %optimization
00068     //   since klasses are tenured the store check can be avoided
00069     addr()->_klass_field = k;
00070   }
00071 
00072   klassOop klass_field() const          { return addr()->_klass_field; }
00073 
00074   Klass* blueprint() const {
00075     // %include-conflict "return klass_field()->klass_part();"
00076     // To avoid include problems the above code has be translated into:
00077     return (Klass*) (((char*) klass_field()) + sizeof(memOopDesc) - Mem_Tag);
00078   }
00079 
00080   // mark operations
00081   
00082   // use this after a copy to get a new mark
00083   void init_mark() { 
00084     set_mark(markOopDesc::tagged_prototype());
00085   }
00086   void init_untagged_contents_mark() {
00087     set_mark(markOopDesc::untagged_prototype());
00088   }
00089 
00090   void mark_as_dying() { 
00091     set_mark(mark()->set_near_death());
00092   }
00093 
00094   // Notification queue support
00095   bool is_queued() const                { return mark()->is_queued();       }
00096   void set_queued()                     { set_mark(mark()->set_queued());   }
00097   void clear_queued()                   { set_mark(mark()->clear_queued()); }
00098 
00099   // mark operations
00100   inline smi identity_hash();           // inlined in memOop.inline.hpp
00101   void set_identity_hash(smi);
00102 
00103   // memory operations
00104   oop scavenge();
00105   void follow_contents();
00106 
00107   // scavenge the header part (see oop_scavenge_contents)
00108   inline void scavenge_header();
00109   // scavenge the body [begin..[end
00110   inline void scavenge_body(int begin, int end);
00111 
00112   inline void scavenge_tenured_header() {}
00113   inline void scavenge_tenured_body(int begin, int end);
00114 
00115   // Scavenge all pointers in this object and return the oop size
00116   inline int scavenge_contents();
00117   // Scavenge all pointers in this object and return the oop size
00118   // has_new_pointers reports if the object has pointers to new space.
00119   inline int scavenge_tenured_contents();
00120 
00121   // Copy this object to survivor space and return the new address
00122   // (called by scavenge)
00123   oop copy_to_survivor_space();
00124 
00125   // MarkSweep support
00126   inline void follow_header();
00127   inline void follow_body(int begin, int end);
00128 
00129   // support for iterating through all oops of an object (see oop_oop_iterate).
00130   inline void oop_iterate_header(OopClosure* blk);
00131   inline void oop_iterate_body(OopClosure* blk, int begin, int end);
00132 
00133   // support for iterate the layout of an object (see oop_layout_iterate).
00134   inline void layout_iterate_header(ObjectLayoutClosure* blk);
00135          void layout_iterate_body(ObjectLayoutClosure* blk, int begin, int end);
00136 
00137   // support for initializing objects (see allocateObject[Size]).
00138   inline void initialize_header(bool has_untagged, klassOop klass);
00139   inline void initialize_body(int begin, int end);
00140 
00141   bool verify();
00142 
00143   // forwarding operations
00144   bool is_forwarded()                   { return mark()->is_mem(); }
00145   void forward_to(memOop p) {
00146     assert(p->is_mem(), "forwarding to something that's not a memOop");
00147     set_mark(p);
00148   }
00149   memOop forwardee()                    { return memOop(mark()); }
00150   
00151   // marking operations
00152   bool is_gc_marked()                   { return !mark()->has_sentinel(); } // Changed from mark()->is_smi(), Lars
00153 
00154   // GC operations (see discussion in universe_more.cpp for rational)
00155   void gc_store_size();                 // Store object size in age field and remembered set
00156   int  gc_retrieve_size();              // Retrieve object size from age field and remembered set
00157 
00158   // accessors
00159   oop* oops(int which = 0)              { return &((oop*) addr())[which]; }
00160   
00161   oop raw_at(int which)                 { return *oops(which); }
00162   inline void raw_at_put(int which, oop contents, bool cs = true);
00163 
00164   // accessing instance variables 
00165   bool is_within_instVar_bounds(int index);
00166   oop instVarAt(int index);
00167   oop instVarAtPut(int index, oop value);
00168   
00169   // iterators
00170   void oop_iterate(OopClosure* blk);   
00171   void layout_iterate(ObjectLayoutClosure* blk);
00172 
00173   // Returns the oop size of this object
00174   int size() const;
00175   
00176   // printing operation
00177   void print_id_on(outputStream* st);
00178   void print_on(outputStream* st);
00179 
00180   // bootstrapping operations
00181   void bootstrap_object(bootstrap* st);
00182   void bootstrap_header(bootstrap* st);
00183   void bootstrap_body(bootstrap* st, int h_size);
00184   
00185   friend memOopKlass;
00186 };
00187 
00188 

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