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 // oopDesc is the top of the oop hierarchy. The xxxDesc classes describe 00025 // the format of ST objects so the fields can be accessed from C++. 00026 // Caution: "oop" pointers to xxxDesc structures (e.g., oop, proxyOop) are 00027 // TAGGED and thus should not be used to access the fields. Rather, 00028 // convert the xxxOop to a xxxDesc* with the ->addr() function, then 00029 // work with the xxxDesc* pointer. 00030 // So, xxxOop pointers are tagged, but xxxDesc* pointers aren't. 00031 // NB: the above is true only for memOops 00032 00033 extern "C" oop nilObj; 00034 00035 class oopDesc { 00036 // protected: 00037 public: 00038 // The _mark instance variable is here rather than in memOop (where 00039 // it belongs) because many C++ compilers have trouble with empty 00040 // objects (size 0), i.e., give them nonzero length which messes up 00041 // all the subclasses. 00042 // So, to be perfectly clear, not all oopDescs truly have a _mark word; 00043 // only the ones below memOop do. 00044 markOop _mark; 00045 00046 public: 00047 // Called during bootstrapping for computing vtbl values see (create_*Klass) 00048 oopDesc(); 00049 00050 // tag checks 00051 int tag() const { return maskBits(int(this), Tag_Mask); } 00052 bool is_smi() const { return tag() == Int_Tag; } 00053 bool is_mem() const { return tag() == Mem_Tag; } 00054 bool is_mark() const { return tag() == Mark_Tag; } 00055 00056 // tag dispatchers (inlined in oop.inline.h) 00057 inline Klass* blueprint() const; 00058 inline klassOop klass() const; 00059 00060 inline smi identity_hash(); 00061 00062 // memory management 00063 inline oop scavenge(); 00064 inline oop relocate(); 00065 00066 // generation testers (inlined in oop.inline.h) 00067 inline bool is_old() const; 00068 inline bool is_new() const; 00069 inline generation* my_generation(); 00070 00071 // type test operations (inlined in oop.inline.h) 00072 inline bool is_double() const; 00073 inline bool is_block() const; 00074 inline bool is_byteArray() const; 00075 inline bool is_doubleByteArray() const; 00076 inline bool is_doubleValueArray() const; 00077 inline bool is_symbol() const; 00078 inline bool is_objArray() const; 00079 inline bool is_weakArray() const; 00080 inline bool is_klass() const; 00081 inline bool is_process() const; 00082 inline bool is_vframe() const; 00083 inline bool is_method() const; 00084 inline bool is_proxy() const; 00085 inline bool is_mixin() const; 00086 inline bool is_association() const; 00087 inline bool is_context() const; 00088 inline bool is_indexable() const; 00089 00090 // Returns is the oop is the nil object 00091 inline bool is_nil() const { return this == nilObj; } 00092 00093 // Primitives 00094 inline oop primitive_allocate(); 00095 inline oop primitive_allocate_size(int size); 00096 00097 inline oop shallow_copy(bool tenured); 00098 00099 inline bool verify(); 00100 00101 // FIX LATER 00102 oop gc_mark() { return this; } 00103 oop gc_unmark() { return this; } 00104 00105 // printing functions for VM debugging 00106 void print_on(outputStream* st); // First level print 00107 void print_value_on(outputStream* st); // Prints oop as <ClassName>(<objectID>). 00108 00109 // printing on default output stream 00110 void print(); 00111 void print_value(); 00112 00113 // return the print strings 00114 char* print_string(); 00115 char* print_value_string(); 00116 00117 friend memOopKlass; 00118 };