memOopKlass.cpp

Go to the documentation of this file.
00001 /* Copyright 1994, 1995 LongView Technologies L.L.C. $Revision: 1.37 $ */
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/_memOopKlass.cpp.incl"
00026 
00027 void set_memOopKlass_vtbl(Klass* k) {
00028   memOopKlass o;
00029   k->set_vtbl_value(o.vtbl_value());
00030 }
00031 
00032 int memOopKlass::oop_scavenge_contents(oop obj) {
00033   int size = non_indexable_size();
00034   // header
00035   memOop(obj)->scavenge_header();
00036   // instance variables
00037   memOop(obj)->scavenge_body(memOopDesc::header_size(), size);
00038   return size;
00039 }
00040 
00041 int memOopKlass::oop_scavenge_tenured_contents(oop obj) {
00042   int size = non_indexable_size();
00043   // header
00044   memOop(obj)->scavenge_tenured_header();
00045   // instance variables
00046   memOop(obj)->scavenge_tenured_body(memOopDesc::header_size(), size);
00047   return size;
00048 }
00049 
00050 void memOopKlass::oop_follow_contents(oop obj) {
00051   // header
00052   memOop(obj)->follow_header();
00053   // instance variables
00054   memOop(obj)->follow_body(memOopDesc::header_size(), non_indexable_size());
00055 }
00056 
00057 bool memOopKlass::oop_verify(oop obj) {
00058   return Universe::verify_oop(memOop(obj));
00059 }
00060 
00061 void memOopKlass::oop_layout_iterate(oop obj, ObjectLayoutClosure* blk) {
00062   // header
00063   memOop(obj)->layout_iterate_header(blk);
00064   // instance variables
00065   memOop(obj)->layout_iterate_body(blk, memOopDesc::header_size(), non_indexable_size());
00066 }
00067 
00068 void memOopKlass::oop_oop_iterate(oop obj, OopClosure* blk) {
00069   // header
00070   memOop(obj)->oop_iterate_header(blk);
00071   // instance variables
00072   memOop(obj)->oop_iterate_body(blk, memOopDesc::header_size(), non_indexable_size());
00073 }
00074 
00075 void memOopKlass::oop_print_on(oop obj, outputStream* st) {
00076   PrintObjectClosure blk(st);
00077   blk.do_object(memOop(obj));
00078   memOop(obj)->layout_iterate(&blk);
00079 }
00080 
00081 void memOopKlass::oop_print_value_on(oop obj, outputStream* st) {
00082        if (obj == nilObj)   st->print("nil");
00083   else if (obj == trueObj)  st->print("true");
00084   else if (obj == falseObj) st->print("false");
00085   else {
00086     if (PrintObjectID) {
00087       memOop(obj)->print_id_on(st);
00088       st->print("-");
00089     }
00090     print_name_on(st);
00091   }
00092   if (PrintOopAddress) st->print(" (%#x)", this);
00093 }
00094 
00095 oop memOopKlass::allocateObject() {
00096   klassOop k    = as_klassOop();
00097   int      size = non_indexable_size();
00098   // allocate
00099   memOop obj = as_memOop(Universe::allocate(size, (memOop*)&k));
00100   // header
00101   obj->initialize_header(has_untagged_contents(), k);
00102   // instance variables
00103   obj->initialize_body(memOopDesc::header_size(), size);
00104   return obj;
00105 }
00106 
00107 oop memOopKlass::allocateObjectSize(int size) {
00108   return markSymbol(vmSymbols::not_indexable());
00109 }
00110 
00111 klassOop memOopKlass::create_subclass(mixinOop mixin, Format format) {
00112   assert(can_be_subclassed(), "must be able to subclass this");
00113   if (format == mem_klass)             return memOopKlass::create_class(as_klassOop(), mixin);
00114 
00115   if (format == objArray_klass)        return objArrayKlass::create_class(as_klassOop(), mixin);
00116   if (format == byteArray_klass)       return byteArrayKlass::create_class(as_klassOop(), mixin);
00117   if (format == doubleByteArray_klass) return doubleByteArrayKlass::create_class(as_klassOop(), mixin);
00118   if (format == weakArray_klass)       return weakArrayKlass::create_class(as_klassOop(), mixin);
00119 
00120   if (number_of_instance_variables() > 0) {
00121     warning("super class has instance variables when mixing in special mixin");
00122     return NULL;
00123   }
00124 
00125   if (format == mixin_klass)           return mixinKlass::create_class(as_klassOop(), mixin);
00126   if (format == proxy_klass)           return proxyKlass::create_class(as_klassOop(), mixin);
00127   if (format == process_klass)         return processKlass::create_class(as_klassOop(), mixin);
00128   return NULL;
00129 }
00130 
00131 klassOop memOopKlass::create_class(klassOop super_class, mixinOop mixin) {
00132   memOopKlass o;
00133   return create_generic_class(super_class, mixin, o.vtbl_value());
00134 }
00135 
00136 oop memOopKlass::oop_shallow_copy(oop obj, bool tenured) {
00137   // Do not copy oddballs (nil, true, false)
00138   if (obj == nilObj)   return obj;
00139   if (obj == trueObj)  return obj;
00140   if (obj == falseObj) return obj;
00141 
00142   int  len   = memOop(obj)->size();
00143   // Important to preserve obj (in case of scavenge).
00144   oop* clone = tenured ? Universe::allocate_tenured(len) : Universe::allocate(len, (memOop*)&obj);
00145   oop* to    = clone;
00146   oop* from  = (oop*) memOop(obj)->addr();
00147   oop* end   = to + len;
00148   while (to < end) *to++ = *from++;
00149 
00150   if (!as_memOop(clone)->is_new()) {
00151     // Remember to update the remembered set if the clone is in old space.
00152     // Note:
00153     //   should we do something special for arrays.
00154     Universe::remembered_set->record_store(clone);
00155   }
00156   return as_memOop(clone);
00157 }

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