made a copy
[strongtalk-kjk.git] / vm / oops / oop.cpp
blob22313655cf58a94f38f6ee480b6da5e204677ae6
1 /* Copyright 1994, 1995 LongView Technologies L.L.C. $Revision: 1.19 $ */
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 # include "incls/_precompiled.incl"
25 # include "incls/_oop.cpp.incl"
27 // Called during bootstrapping for computing vtbl values see (create_*Klass)
28 oopDesc::oopDesc() {
29 if (!bootstrapping) ShouldNotCallThis();
32 void oopDesc::print_value_on(outputStream* st) {
33 if (is_mark()) {
34 markOop(this)->print_on(st);
35 } else if (is_smi()) {
36 smiOop(this)->print_on(st);
37 } else {
38 #ifdef ASSERT
39 // In the debug version unused space is cleared after scavenge.
40 // This means if we try printing an oop pointing to unused space
41 // its klass() is NULL.
42 // The following hack can print such oops.
43 if (klass()->addr() == NULL) {
44 st->print("Wrong Oop(0x%lx)", this);
45 } else
46 #endif
47 blueprint()->oop_print_value_on(this, st);
51 void oopDesc::print_on(outputStream* st) {
52 if (is_mark()) {
53 markOop(this)->print_on(st);
54 } else if (is_smi()) {
55 smiOop(this)->print_on(st);
56 } else {
57 memOop(this)->print_on(st);
61 void oopDesc::print() { print_on(std); }
62 void oopDesc::print_value() { print_value_on(std); }
64 char* oopDesc::print_string() {
65 stringStream* st = new stringStream(50);
66 print_on(st);
67 return st->as_string();
70 char* oopDesc::print_value_string() {
71 stringStream* st = new stringStream(50);
72 print_value_on(st);
73 return st->as_string();