ager@chromium.org | 9258b6b | 2008-09-11 09:11:10 +0000 | [diff] [blame] | 1 | // Copyright 2006-2008 the V8 project authors. All rights reserved. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | #include "v8.h" |
| 29 | |
| 30 | #include "disassembler.h" |
| 31 | #include "disasm.h" |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 32 | #include "jsregexp.h" |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 33 | #include "objects-visiting.h" |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 34 | |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 35 | namespace v8 { |
| 36 | namespace internal { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 37 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 38 | #ifdef OBJECT_PRINT |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 39 | |
| 40 | static const char* TypeToString(InstanceType type); |
| 41 | |
| 42 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 43 | void MaybeObject::Print(FILE* out) { |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 44 | Object* this_as_object; |
| 45 | if (ToObject(&this_as_object)) { |
| 46 | if (this_as_object->IsSmi()) { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 47 | Smi::cast(this_as_object)->SmiPrint(out); |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 48 | } else { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 49 | HeapObject::cast(this_as_object)->HeapObjectPrint(out); |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 50 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 51 | } else { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 52 | Failure::cast(this)->FailurePrint(out); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 53 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 54 | Flush(out); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 58 | void MaybeObject::PrintLn(FILE* out) { |
| 59 | Print(out); |
| 60 | PrintF(out, "\n"); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 61 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 62 | #endif // OBJECT_PRINT |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 63 | |
| 64 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 65 | #ifdef DEBUG |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 66 | void MaybeObject::Verify() { |
| 67 | Object* this_as_object; |
| 68 | if (ToObject(&this_as_object)) { |
| 69 | if (this_as_object->IsSmi()) { |
| 70 | Smi::cast(this_as_object)->SmiVerify(); |
| 71 | } else { |
| 72 | HeapObject::cast(this_as_object)->HeapObjectVerify(); |
| 73 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 74 | } else { |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 75 | Failure::cast(this)->FailureVerify(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 76 | } |
| 77 | } |
| 78 | |
| 79 | |
| 80 | void Object::VerifyPointer(Object* p) { |
| 81 | if (p->IsHeapObject()) { |
| 82 | HeapObject::VerifyHeapPointer(p); |
| 83 | } else { |
| 84 | ASSERT(p->IsSmi()); |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | |
| 89 | void Smi::SmiVerify() { |
| 90 | ASSERT(IsSmi()); |
| 91 | } |
| 92 | |
| 93 | |
| 94 | void Failure::FailureVerify() { |
| 95 | ASSERT(IsFailure()); |
| 96 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 97 | #endif // DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 98 | |
| 99 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 100 | #ifdef OBJECT_PRINT |
| 101 | void HeapObject::PrintHeader(FILE* out, const char* id) { |
| 102 | PrintF(out, "%p: [%s]\n", reinterpret_cast<void*>(this), id); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 106 | void HeapObject::HeapObjectPrint(FILE* out) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 107 | InstanceType instance_type = map()->instance_type(); |
| 108 | |
| 109 | HandleScope scope; |
| 110 | if (instance_type < FIRST_NONSTRING_TYPE) { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 111 | String::cast(this)->StringPrint(out); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 112 | return; |
| 113 | } |
| 114 | |
| 115 | switch (instance_type) { |
| 116 | case MAP_TYPE: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 117 | Map::cast(this)->MapPrint(out); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 118 | break; |
| 119 | case HEAP_NUMBER_TYPE: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 120 | HeapNumber::cast(this)->HeapNumberPrint(out); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 121 | break; |
| 122 | case FIXED_ARRAY_TYPE: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 123 | FixedArray::cast(this)->FixedArrayPrint(out); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 124 | break; |
| 125 | case BYTE_ARRAY_TYPE: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 126 | ByteArray::cast(this)->ByteArrayPrint(out); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 127 | break; |
sgjesse@chromium.org | 0b6db59 | 2009-07-30 14:48:31 +0000 | [diff] [blame] | 128 | case PIXEL_ARRAY_TYPE: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 129 | PixelArray::cast(this)->PixelArrayPrint(out); |
sgjesse@chromium.org | 0b6db59 | 2009-07-30 14:48:31 +0000 | [diff] [blame] | 130 | break; |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 131 | case EXTERNAL_BYTE_ARRAY_TYPE: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 132 | ExternalByteArray::cast(this)->ExternalByteArrayPrint(out); |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 133 | break; |
| 134 | case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 135 | ExternalUnsignedByteArray::cast(this) |
| 136 | ->ExternalUnsignedByteArrayPrint(out); |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 137 | break; |
| 138 | case EXTERNAL_SHORT_ARRAY_TYPE: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 139 | ExternalShortArray::cast(this)->ExternalShortArrayPrint(out); |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 140 | break; |
| 141 | case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 142 | ExternalUnsignedShortArray::cast(this) |
| 143 | ->ExternalUnsignedShortArrayPrint(out); |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 144 | break; |
| 145 | case EXTERNAL_INT_ARRAY_TYPE: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 146 | ExternalIntArray::cast(this)->ExternalIntArrayPrint(out); |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 147 | break; |
| 148 | case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 149 | ExternalUnsignedIntArray::cast(this)->ExternalUnsignedIntArrayPrint(out); |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 150 | break; |
| 151 | case EXTERNAL_FLOAT_ARRAY_TYPE: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 152 | ExternalFloatArray::cast(this)->ExternalFloatArrayPrint(out); |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 153 | break; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 154 | case FILLER_TYPE: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 155 | PrintF(out, "filler"); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 156 | break; |
| 157 | case JS_OBJECT_TYPE: // fall through |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 158 | case JS_CONTEXT_EXTENSION_OBJECT_TYPE: |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 159 | case JS_ARRAY_TYPE: |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 160 | case JS_REGEXP_TYPE: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 161 | JSObject::cast(this)->JSObjectPrint(out); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 162 | break; |
| 163 | case ODDBALL_TYPE: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 164 | Oddball::cast(this)->to_string()->Print(out); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 165 | break; |
| 166 | case JS_FUNCTION_TYPE: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 167 | JSFunction::cast(this)->JSFunctionPrint(out); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 168 | break; |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 169 | case JS_GLOBAL_PROXY_TYPE: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 170 | JSGlobalProxy::cast(this)->JSGlobalProxyPrint(out); |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 171 | break; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 172 | case JS_GLOBAL_OBJECT_TYPE: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 173 | JSGlobalObject::cast(this)->JSGlobalObjectPrint(out); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 174 | break; |
| 175 | case JS_BUILTINS_OBJECT_TYPE: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 176 | JSBuiltinsObject::cast(this)->JSBuiltinsObjectPrint(out); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 177 | break; |
| 178 | case JS_VALUE_TYPE: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 179 | PrintF(out, "Value wrapper around:"); |
| 180 | JSValue::cast(this)->value()->Print(out); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 181 | break; |
| 182 | case CODE_TYPE: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 183 | Code::cast(this)->CodePrint(out); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 184 | break; |
| 185 | case PROXY_TYPE: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 186 | Proxy::cast(this)->ProxyPrint(out); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 187 | break; |
| 188 | case SHARED_FUNCTION_INFO_TYPE: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 189 | SharedFunctionInfo::cast(this)->SharedFunctionInfoPrint(out); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 190 | break; |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 191 | case JS_GLOBAL_PROPERTY_CELL_TYPE: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 192 | JSGlobalPropertyCell::cast(this)->JSGlobalPropertyCellPrint(out); |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 193 | break; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 194 | #define MAKE_STRUCT_CASE(NAME, Name, name) \ |
| 195 | case NAME##_TYPE: \ |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 196 | Name::cast(this)->Name##Print(out); \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 197 | break; |
| 198 | STRUCT_LIST(MAKE_STRUCT_CASE) |
| 199 | #undef MAKE_STRUCT_CASE |
| 200 | |
| 201 | default: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 202 | PrintF(out, "UNKNOWN TYPE %d", map()->instance_type()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 203 | UNREACHABLE(); |
| 204 | break; |
| 205 | } |
| 206 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 207 | #endif // OBJECT_PRINT |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 208 | |
| 209 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 210 | #ifdef DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 211 | void HeapObject::HeapObjectVerify() { |
| 212 | InstanceType instance_type = map()->instance_type(); |
| 213 | |
| 214 | if (instance_type < FIRST_NONSTRING_TYPE) { |
| 215 | String::cast(this)->StringVerify(); |
| 216 | return; |
| 217 | } |
| 218 | |
| 219 | switch (instance_type) { |
| 220 | case MAP_TYPE: |
| 221 | Map::cast(this)->MapVerify(); |
| 222 | break; |
| 223 | case HEAP_NUMBER_TYPE: |
| 224 | HeapNumber::cast(this)->HeapNumberVerify(); |
| 225 | break; |
| 226 | case FIXED_ARRAY_TYPE: |
| 227 | FixedArray::cast(this)->FixedArrayVerify(); |
| 228 | break; |
| 229 | case BYTE_ARRAY_TYPE: |
| 230 | ByteArray::cast(this)->ByteArrayVerify(); |
| 231 | break; |
sgjesse@chromium.org | 0b6db59 | 2009-07-30 14:48:31 +0000 | [diff] [blame] | 232 | case PIXEL_ARRAY_TYPE: |
| 233 | PixelArray::cast(this)->PixelArrayVerify(); |
| 234 | break; |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 235 | case EXTERNAL_BYTE_ARRAY_TYPE: |
| 236 | ExternalByteArray::cast(this)->ExternalByteArrayVerify(); |
| 237 | break; |
| 238 | case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: |
| 239 | ExternalUnsignedByteArray::cast(this)->ExternalUnsignedByteArrayVerify(); |
| 240 | break; |
| 241 | case EXTERNAL_SHORT_ARRAY_TYPE: |
| 242 | ExternalShortArray::cast(this)->ExternalShortArrayVerify(); |
| 243 | break; |
| 244 | case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: |
| 245 | ExternalUnsignedShortArray::cast(this)-> |
| 246 | ExternalUnsignedShortArrayVerify(); |
| 247 | break; |
| 248 | case EXTERNAL_INT_ARRAY_TYPE: |
| 249 | ExternalIntArray::cast(this)->ExternalIntArrayVerify(); |
| 250 | break; |
| 251 | case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: |
| 252 | ExternalUnsignedIntArray::cast(this)->ExternalUnsignedIntArrayVerify(); |
| 253 | break; |
| 254 | case EXTERNAL_FLOAT_ARRAY_TYPE: |
| 255 | ExternalFloatArray::cast(this)->ExternalFloatArrayVerify(); |
| 256 | break; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 257 | case CODE_TYPE: |
| 258 | Code::cast(this)->CodeVerify(); |
| 259 | break; |
| 260 | case ODDBALL_TYPE: |
| 261 | Oddball::cast(this)->OddballVerify(); |
| 262 | break; |
| 263 | case JS_OBJECT_TYPE: |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 264 | case JS_CONTEXT_EXTENSION_OBJECT_TYPE: |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 265 | JSObject::cast(this)->JSObjectVerify(); |
| 266 | break; |
| 267 | case JS_VALUE_TYPE: |
| 268 | JSValue::cast(this)->JSValueVerify(); |
| 269 | break; |
| 270 | case JS_FUNCTION_TYPE: |
| 271 | JSFunction::cast(this)->JSFunctionVerify(); |
| 272 | break; |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 273 | case JS_GLOBAL_PROXY_TYPE: |
| 274 | JSGlobalProxy::cast(this)->JSGlobalProxyVerify(); |
| 275 | break; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 276 | case JS_GLOBAL_OBJECT_TYPE: |
| 277 | JSGlobalObject::cast(this)->JSGlobalObjectVerify(); |
| 278 | break; |
| 279 | case JS_BUILTINS_OBJECT_TYPE: |
| 280 | JSBuiltinsObject::cast(this)->JSBuiltinsObjectVerify(); |
| 281 | break; |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 282 | case JS_GLOBAL_PROPERTY_CELL_TYPE: |
| 283 | JSGlobalPropertyCell::cast(this)->JSGlobalPropertyCellVerify(); |
| 284 | break; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 285 | case JS_ARRAY_TYPE: |
| 286 | JSArray::cast(this)->JSArrayVerify(); |
| 287 | break; |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 288 | case JS_REGEXP_TYPE: |
| 289 | JSRegExp::cast(this)->JSRegExpVerify(); |
| 290 | break; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 291 | case FILLER_TYPE: |
| 292 | break; |
| 293 | case PROXY_TYPE: |
| 294 | Proxy::cast(this)->ProxyVerify(); |
| 295 | break; |
| 296 | case SHARED_FUNCTION_INFO_TYPE: |
| 297 | SharedFunctionInfo::cast(this)->SharedFunctionInfoVerify(); |
| 298 | break; |
| 299 | |
| 300 | #define MAKE_STRUCT_CASE(NAME, Name, name) \ |
| 301 | case NAME##_TYPE: \ |
| 302 | Name::cast(this)->Name##Verify(); \ |
| 303 | break; |
| 304 | STRUCT_LIST(MAKE_STRUCT_CASE) |
| 305 | #undef MAKE_STRUCT_CASE |
| 306 | |
| 307 | default: |
| 308 | UNREACHABLE(); |
| 309 | break; |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | |
| 314 | void HeapObject::VerifyHeapPointer(Object* p) { |
| 315 | ASSERT(p->IsHeapObject()); |
| 316 | ASSERT(Heap::Contains(HeapObject::cast(p))); |
| 317 | } |
| 318 | |
| 319 | |
| 320 | void HeapNumber::HeapNumberVerify() { |
| 321 | ASSERT(IsHeapNumber()); |
| 322 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 323 | #endif // DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 324 | |
| 325 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 326 | #ifdef OBJECT_PRINT |
| 327 | void ByteArray::ByteArrayPrint(FILE* out) { |
| 328 | PrintF(out, "byte array, data starts at %p", GetDataStartAddress()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 329 | } |
| 330 | |
| 331 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 332 | void PixelArray::PixelArrayPrint(FILE* out) { |
| 333 | PrintF(out, "pixel array"); |
sgjesse@chromium.org | 0b6db59 | 2009-07-30 14:48:31 +0000 | [diff] [blame] | 334 | } |
| 335 | |
| 336 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 337 | void ExternalByteArray::ExternalByteArrayPrint(FILE* out) { |
| 338 | PrintF(out, "external byte array"); |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 339 | } |
| 340 | |
| 341 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 342 | void ExternalUnsignedByteArray::ExternalUnsignedByteArrayPrint(FILE* out) { |
| 343 | PrintF(out, "external unsigned byte array"); |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 344 | } |
| 345 | |
| 346 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 347 | void ExternalShortArray::ExternalShortArrayPrint(FILE* out) { |
| 348 | PrintF(out, "external short array"); |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 349 | } |
| 350 | |
| 351 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 352 | void ExternalUnsignedShortArray::ExternalUnsignedShortArrayPrint(FILE* out) { |
| 353 | PrintF(out, "external unsigned short array"); |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 354 | } |
| 355 | |
| 356 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 357 | void ExternalIntArray::ExternalIntArrayPrint(FILE* out) { |
| 358 | PrintF(out, "external int array"); |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 359 | } |
| 360 | |
| 361 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 362 | void ExternalUnsignedIntArray::ExternalUnsignedIntArrayPrint(FILE* out) { |
| 363 | PrintF(out, "external unsigned int array"); |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 367 | void ExternalFloatArray::ExternalFloatArrayPrint(FILE* out) { |
| 368 | PrintF(out, "external float array"); |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 369 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 370 | #endif // OBJECT_PRINT |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 371 | |
| 372 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 373 | #ifdef DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 374 | void ByteArray::ByteArrayVerify() { |
| 375 | ASSERT(IsByteArray()); |
| 376 | } |
| 377 | |
| 378 | |
sgjesse@chromium.org | 0b6db59 | 2009-07-30 14:48:31 +0000 | [diff] [blame] | 379 | void PixelArray::PixelArrayVerify() { |
| 380 | ASSERT(IsPixelArray()); |
| 381 | } |
| 382 | |
| 383 | |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 384 | void ExternalByteArray::ExternalByteArrayVerify() { |
| 385 | ASSERT(IsExternalByteArray()); |
| 386 | } |
| 387 | |
| 388 | |
| 389 | void ExternalUnsignedByteArray::ExternalUnsignedByteArrayVerify() { |
| 390 | ASSERT(IsExternalUnsignedByteArray()); |
| 391 | } |
| 392 | |
| 393 | |
| 394 | void ExternalShortArray::ExternalShortArrayVerify() { |
| 395 | ASSERT(IsExternalShortArray()); |
| 396 | } |
| 397 | |
| 398 | |
| 399 | void ExternalUnsignedShortArray::ExternalUnsignedShortArrayVerify() { |
| 400 | ASSERT(IsExternalUnsignedShortArray()); |
| 401 | } |
| 402 | |
| 403 | |
| 404 | void ExternalIntArray::ExternalIntArrayVerify() { |
| 405 | ASSERT(IsExternalIntArray()); |
| 406 | } |
| 407 | |
| 408 | |
| 409 | void ExternalUnsignedIntArray::ExternalUnsignedIntArrayVerify() { |
| 410 | ASSERT(IsExternalUnsignedIntArray()); |
| 411 | } |
| 412 | |
| 413 | |
| 414 | void ExternalFloatArray::ExternalFloatArrayVerify() { |
| 415 | ASSERT(IsExternalFloatArray()); |
| 416 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 417 | #endif // DEBUG |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 418 | |
| 419 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 420 | #ifdef OBJECT_PRINT |
| 421 | void JSObject::PrintProperties(FILE* out) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 422 | if (HasFastProperties()) { |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 423 | DescriptorArray* descs = map()->instance_descriptors(); |
| 424 | for (int i = 0; i < descs->number_of_descriptors(); i++) { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 425 | PrintF(out, " "); |
| 426 | descs->GetKey(i)->StringPrint(out); |
| 427 | PrintF(out, ": "); |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 428 | switch (descs->GetType(i)) { |
| 429 | case FIELD: { |
| 430 | int index = descs->GetFieldIndex(i); |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 431 | FastPropertyAt(index)->ShortPrint(out); |
| 432 | PrintF(out, " (field at offset %d)\n", index); |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 433 | break; |
| 434 | } |
| 435 | case CONSTANT_FUNCTION: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 436 | descs->GetConstantFunction(i)->ShortPrint(out); |
| 437 | PrintF(out, " (constant function)\n"); |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 438 | break; |
| 439 | case CALLBACKS: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 440 | descs->GetCallbacksObject(i)->ShortPrint(out); |
| 441 | PrintF(out, " (callback)\n"); |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 442 | break; |
| 443 | case MAP_TRANSITION: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 444 | PrintF(out, " (map transition)\n"); |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 445 | break; |
| 446 | case CONSTANT_TRANSITION: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 447 | PrintF(out, " (constant transition)\n"); |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 448 | break; |
| 449 | case NULL_DESCRIPTOR: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 450 | PrintF(out, " (null descriptor)\n"); |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 451 | break; |
| 452 | default: |
| 453 | UNREACHABLE(); |
| 454 | break; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 455 | } |
| 456 | } |
| 457 | } else { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 458 | property_dictionary()->Print(out); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 459 | } |
| 460 | } |
| 461 | |
| 462 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 463 | void JSObject::PrintElements(FILE* out) { |
sgjesse@chromium.org | 0b6db59 | 2009-07-30 14:48:31 +0000 | [diff] [blame] | 464 | switch (GetElementsKind()) { |
| 465 | case FAST_ELEMENTS: { |
| 466 | // Print in array notation for non-sparse arrays. |
| 467 | FixedArray* p = FixedArray::cast(elements()); |
| 468 | for (int i = 0; i < p->length(); i++) { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 469 | PrintF(out, " %d: ", i); |
| 470 | p->get(i)->ShortPrint(out); |
| 471 | PrintF(out, "\n"); |
sgjesse@chromium.org | 0b6db59 | 2009-07-30 14:48:31 +0000 | [diff] [blame] | 472 | } |
| 473 | break; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 474 | } |
sgjesse@chromium.org | 0b6db59 | 2009-07-30 14:48:31 +0000 | [diff] [blame] | 475 | case PIXEL_ELEMENTS: { |
| 476 | PixelArray* p = PixelArray::cast(elements()); |
| 477 | for (int i = 0; i < p->length(); i++) { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 478 | PrintF(out, " %d: %d\n", i, p->get(i)); |
sgjesse@chromium.org | 0b6db59 | 2009-07-30 14:48:31 +0000 | [diff] [blame] | 479 | } |
| 480 | break; |
| 481 | } |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 482 | case EXTERNAL_BYTE_ELEMENTS: { |
| 483 | ExternalByteArray* p = ExternalByteArray::cast(elements()); |
| 484 | for (int i = 0; i < p->length(); i++) { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 485 | PrintF(out, " %d: %d\n", i, static_cast<int>(p->get(i))); |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 486 | } |
| 487 | break; |
| 488 | } |
| 489 | case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: { |
| 490 | ExternalUnsignedByteArray* p = |
| 491 | ExternalUnsignedByteArray::cast(elements()); |
| 492 | for (int i = 0; i < p->length(); i++) { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 493 | PrintF(out, " %d: %d\n", i, static_cast<int>(p->get(i))); |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 494 | } |
| 495 | break; |
| 496 | } |
| 497 | case EXTERNAL_SHORT_ELEMENTS: { |
| 498 | ExternalShortArray* p = ExternalShortArray::cast(elements()); |
| 499 | for (int i = 0; i < p->length(); i++) { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 500 | PrintF(out, " %d: %d\n", i, static_cast<int>(p->get(i))); |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 501 | } |
| 502 | break; |
| 503 | } |
| 504 | case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: { |
| 505 | ExternalUnsignedShortArray* p = |
| 506 | ExternalUnsignedShortArray::cast(elements()); |
| 507 | for (int i = 0; i < p->length(); i++) { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 508 | PrintF(out, " %d: %d\n", i, static_cast<int>(p->get(i))); |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 509 | } |
| 510 | break; |
| 511 | } |
| 512 | case EXTERNAL_INT_ELEMENTS: { |
| 513 | ExternalIntArray* p = ExternalIntArray::cast(elements()); |
| 514 | for (int i = 0; i < p->length(); i++) { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 515 | PrintF(out, " %d: %d\n", i, static_cast<int>(p->get(i))); |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 516 | } |
| 517 | break; |
| 518 | } |
| 519 | case EXTERNAL_UNSIGNED_INT_ELEMENTS: { |
| 520 | ExternalUnsignedIntArray* p = |
| 521 | ExternalUnsignedIntArray::cast(elements()); |
| 522 | for (int i = 0; i < p->length(); i++) { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 523 | PrintF(out, " %d: %d\n", i, static_cast<int>(p->get(i))); |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 524 | } |
| 525 | break; |
| 526 | } |
| 527 | case EXTERNAL_FLOAT_ELEMENTS: { |
| 528 | ExternalFloatArray* p = ExternalFloatArray::cast(elements()); |
| 529 | for (int i = 0; i < p->length(); i++) { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 530 | PrintF(out, " %d: %f\n", i, p->get(i)); |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 531 | } |
| 532 | break; |
| 533 | } |
sgjesse@chromium.org | 0b6db59 | 2009-07-30 14:48:31 +0000 | [diff] [blame] | 534 | case DICTIONARY_ELEMENTS: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 535 | elements()->Print(out); |
sgjesse@chromium.org | 0b6db59 | 2009-07-30 14:48:31 +0000 | [diff] [blame] | 536 | break; |
| 537 | default: |
| 538 | UNREACHABLE(); |
| 539 | break; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 540 | } |
| 541 | } |
| 542 | |
| 543 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 544 | void JSObject::JSObjectPrint(FILE* out) { |
| 545 | PrintF(out, "%p: [JSObject]\n", reinterpret_cast<void*>(this)); |
| 546 | PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map())); |
| 547 | PrintF(out, " - prototype = %p\n", reinterpret_cast<void*>(GetPrototype())); |
| 548 | PrintF(out, " {\n"); |
| 549 | PrintProperties(out); |
| 550 | PrintElements(out); |
| 551 | PrintF(out, " }\n"); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 552 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 553 | #endif // OBJECT_PRINT |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 554 | |
| 555 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 556 | #ifdef DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 557 | void JSObject::JSObjectVerify() { |
| 558 | VerifyHeapPointer(properties()); |
| 559 | VerifyHeapPointer(elements()); |
| 560 | if (HasFastProperties()) { |
sgjesse@chromium.org | 911335c | 2009-08-19 12:59:44 +0000 | [diff] [blame] | 561 | CHECK_EQ(map()->unused_property_fields(), |
| 562 | (map()->inobject_properties() + properties()->length() - |
| 563 | map()->NextFreePropertyIndex())); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 564 | } |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 565 | ASSERT(map()->has_fast_elements() == |
ricow@chromium.org | 0b9f850 | 2010-08-18 07:45:01 +0000 | [diff] [blame] | 566 | (elements()->map() == Heap::fixed_array_map() || |
| 567 | elements()->map() == Heap::fixed_cow_array_map())); |
fschneider@chromium.org | 40b9da3 | 2010-06-28 11:29:21 +0000 | [diff] [blame] | 568 | ASSERT(map()->has_fast_elements() == HasFastElements()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 569 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 570 | #endif // DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 571 | |
| 572 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 573 | #ifdef OBJECT_PRINT |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 574 | static const char* TypeToString(InstanceType type) { |
| 575 | switch (type) { |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 576 | case INVALID_TYPE: return "INVALID"; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 577 | case MAP_TYPE: return "MAP"; |
| 578 | case HEAP_NUMBER_TYPE: return "HEAP_NUMBER"; |
sgjesse@chromium.org | ac6aa17 | 2009-12-04 12:29:05 +0000 | [diff] [blame] | 579 | case SYMBOL_TYPE: return "SYMBOL"; |
| 580 | case ASCII_SYMBOL_TYPE: return "ASCII_SYMBOL"; |
| 581 | case CONS_SYMBOL_TYPE: return "CONS_SYMBOL"; |
| 582 | case CONS_ASCII_SYMBOL_TYPE: return "CONS_ASCII_SYMBOL"; |
| 583 | case EXTERNAL_ASCII_SYMBOL_TYPE: |
ricow@chromium.org | 5ad5ace | 2010-06-23 09:06:43 +0000 | [diff] [blame] | 584 | case EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE: |
sgjesse@chromium.org | ac6aa17 | 2009-12-04 12:29:05 +0000 | [diff] [blame] | 585 | case EXTERNAL_SYMBOL_TYPE: return "EXTERNAL_SYMBOL"; |
| 586 | case ASCII_STRING_TYPE: return "ASCII_STRING"; |
| 587 | case STRING_TYPE: return "TWO_BYTE_STRING"; |
| 588 | case CONS_STRING_TYPE: |
| 589 | case CONS_ASCII_STRING_TYPE: return "CONS_STRING"; |
| 590 | case EXTERNAL_ASCII_STRING_TYPE: |
ricow@chromium.org | 5ad5ace | 2010-06-23 09:06:43 +0000 | [diff] [blame] | 591 | case EXTERNAL_STRING_WITH_ASCII_DATA_TYPE: |
sgjesse@chromium.org | ac6aa17 | 2009-12-04 12:29:05 +0000 | [diff] [blame] | 592 | case EXTERNAL_STRING_TYPE: return "EXTERNAL_STRING"; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 593 | case FIXED_ARRAY_TYPE: return "FIXED_ARRAY"; |
| 594 | case BYTE_ARRAY_TYPE: return "BYTE_ARRAY"; |
sgjesse@chromium.org | 0b6db59 | 2009-07-30 14:48:31 +0000 | [diff] [blame] | 595 | case PIXEL_ARRAY_TYPE: return "PIXEL_ARRAY"; |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 596 | case EXTERNAL_BYTE_ARRAY_TYPE: return "EXTERNAL_BYTE_ARRAY"; |
| 597 | case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: |
| 598 | return "EXTERNAL_UNSIGNED_BYTE_ARRAY"; |
| 599 | case EXTERNAL_SHORT_ARRAY_TYPE: return "EXTERNAL_SHORT_ARRAY"; |
| 600 | case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: |
| 601 | return "EXTERNAL_UNSIGNED_SHORT_ARRAY"; |
| 602 | case EXTERNAL_INT_ARRAY_TYPE: return "EXTERNAL_INT_ARRAY"; |
| 603 | case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: |
| 604 | return "EXTERNAL_UNSIGNED_INT_ARRAY"; |
| 605 | case EXTERNAL_FLOAT_ARRAY_TYPE: return "EXTERNAL_FLOAT_ARRAY"; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 606 | case FILLER_TYPE: return "FILLER"; |
| 607 | case JS_OBJECT_TYPE: return "JS_OBJECT"; |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 608 | case JS_CONTEXT_EXTENSION_OBJECT_TYPE: return "JS_CONTEXT_EXTENSION_OBJECT"; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 609 | case ODDBALL_TYPE: return "ODDBALL"; |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 610 | case JS_GLOBAL_PROPERTY_CELL_TYPE: return "JS_GLOBAL_PROPERTY_CELL"; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 611 | case SHARED_FUNCTION_INFO_TYPE: return "SHARED_FUNCTION_INFO"; |
| 612 | case JS_FUNCTION_TYPE: return "JS_FUNCTION"; |
| 613 | case CODE_TYPE: return "CODE"; |
| 614 | case JS_ARRAY_TYPE: return "JS_ARRAY"; |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 615 | case JS_REGEXP_TYPE: return "JS_REGEXP"; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 616 | case JS_VALUE_TYPE: return "JS_VALUE"; |
| 617 | case JS_GLOBAL_OBJECT_TYPE: return "JS_GLOBAL_OBJECT"; |
| 618 | case JS_BUILTINS_OBJECT_TYPE: return "JS_BUILTINS_OBJECT"; |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 619 | case JS_GLOBAL_PROXY_TYPE: return "JS_GLOBAL_PROXY"; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 620 | case PROXY_TYPE: return "PROXY"; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 621 | #define MAKE_STRUCT_CASE(NAME, Name, name) case NAME##_TYPE: return #NAME; |
| 622 | STRUCT_LIST(MAKE_STRUCT_CASE) |
| 623 | #undef MAKE_STRUCT_CASE |
| 624 | } |
| 625 | return "UNKNOWN"; |
| 626 | } |
| 627 | |
| 628 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 629 | void Map::MapPrint(FILE* out) { |
| 630 | HeapObject::PrintHeader(out, "Map"); |
| 631 | PrintF(out, " - type: %s\n", TypeToString(instance_type())); |
| 632 | PrintF(out, " - instance size: %d\n", instance_size()); |
| 633 | PrintF(out, " - inobject properties: %d\n", inobject_properties()); |
| 634 | PrintF(out, " - pre-allocated property fields: %d\n", |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 635 | pre_allocated_property_fields()); |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 636 | PrintF(out, " - unused property fields: %d\n", unused_property_fields()); |
ager@chromium.org | ddb913d | 2009-01-27 10:01:48 +0000 | [diff] [blame] | 637 | if (is_hidden_prototype()) { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 638 | PrintF(out, " - hidden_prototype\n"); |
ager@chromium.org | ddb913d | 2009-01-27 10:01:48 +0000 | [diff] [blame] | 639 | } |
| 640 | if (has_named_interceptor()) { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 641 | PrintF(out, " - named_interceptor\n"); |
ager@chromium.org | ddb913d | 2009-01-27 10:01:48 +0000 | [diff] [blame] | 642 | } |
| 643 | if (has_indexed_interceptor()) { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 644 | PrintF(out, " - indexed_interceptor\n"); |
ager@chromium.org | ddb913d | 2009-01-27 10:01:48 +0000 | [diff] [blame] | 645 | } |
| 646 | if (is_undetectable()) { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 647 | PrintF(out, " - undetectable\n"); |
ager@chromium.org | ddb913d | 2009-01-27 10:01:48 +0000 | [diff] [blame] | 648 | } |
| 649 | if (has_instance_call_handler()) { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 650 | PrintF(out, " - instance_call_handler\n"); |
ager@chromium.org | ddb913d | 2009-01-27 10:01:48 +0000 | [diff] [blame] | 651 | } |
| 652 | if (is_access_check_needed()) { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 653 | PrintF(out, " - access_check_needed\n"); |
ager@chromium.org | ddb913d | 2009-01-27 10:01:48 +0000 | [diff] [blame] | 654 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 655 | PrintF(out, " - instance descriptors: "); |
| 656 | instance_descriptors()->ShortPrint(out); |
| 657 | PrintF(out, "\n - prototype: "); |
| 658 | prototype()->ShortPrint(out); |
| 659 | PrintF(out, "\n - constructor: "); |
| 660 | constructor()->ShortPrint(out); |
| 661 | PrintF(out, "\n"); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 662 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 663 | #endif // OBJECT_PRINT |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 664 | |
| 665 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 666 | #ifdef DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 667 | void Map::MapVerify() { |
| 668 | ASSERT(!Heap::InNewSpace(this)); |
| 669 | ASSERT(FIRST_TYPE <= instance_type() && instance_type() <= LAST_TYPE); |
erik.corry@gmail.com | 145eff5 | 2010-08-23 11:36:18 +0000 | [diff] [blame] | 670 | ASSERT(instance_size() == kVariableSizeSentinel || |
| 671 | (kPointerSize <= instance_size() && |
| 672 | instance_size() < Heap::Capacity())); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 673 | VerifyHeapPointer(prototype()); |
| 674 | VerifyHeapPointer(instance_descriptors()); |
| 675 | } |
| 676 | |
| 677 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 678 | void Map::SharedMapVerify() { |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 679 | MapVerify(); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 680 | ASSERT(is_shared()); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 681 | ASSERT_EQ(Heap::empty_descriptor_array(), instance_descriptors()); |
| 682 | ASSERT_EQ(Heap::empty_fixed_array(), code_cache()); |
| 683 | ASSERT_EQ(0, pre_allocated_property_fields()); |
| 684 | ASSERT_EQ(0, unused_property_fields()); |
| 685 | ASSERT_EQ(StaticVisitorBase::GetVisitorId(instance_type(), instance_size()), |
| 686 | visitor_id()); |
| 687 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 688 | #endif // DEBUG |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 689 | |
| 690 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 691 | #ifdef OBJECT_PRINT |
| 692 | void CodeCache::CodeCachePrint(FILE* out) { |
| 693 | HeapObject::PrintHeader(out, "CodeCache"); |
| 694 | PrintF(out, "\n - default_cache: "); |
| 695 | default_cache()->ShortPrint(out); |
| 696 | PrintF(out, "\n - normal_type_cache: "); |
| 697 | normal_type_cache()->ShortPrint(out); |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 698 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 699 | #endif // OBJECT_PRINT |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 700 | |
| 701 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 702 | #ifdef DEBUG |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 703 | void CodeCache::CodeCacheVerify() { |
| 704 | VerifyHeapPointer(default_cache()); |
| 705 | VerifyHeapPointer(normal_type_cache()); |
| 706 | ASSERT(default_cache()->IsFixedArray()); |
| 707 | ASSERT(normal_type_cache()->IsUndefined() |
| 708 | || normal_type_cache()->IsCodeCacheHashTable()); |
| 709 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 710 | #endif // DEBUG |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 711 | |
| 712 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 713 | #ifdef OBJECT_PRINT |
| 714 | void FixedArray::FixedArrayPrint(FILE* out) { |
| 715 | HeapObject::PrintHeader(out, "FixedArray"); |
| 716 | PrintF(out, " - length: %d", length()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 717 | for (int i = 0; i < length(); i++) { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 718 | PrintF(out, "\n [%d]: ", i); |
| 719 | get(i)->ShortPrint(out); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 720 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 721 | PrintF(out, "\n"); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 722 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 723 | #endif // OBJECT_PRINT |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 724 | |
| 725 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 726 | #ifdef DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 727 | void FixedArray::FixedArrayVerify() { |
| 728 | for (int i = 0; i < length(); i++) { |
| 729 | Object* e = get(i); |
| 730 | if (e->IsHeapObject()) { |
| 731 | VerifyHeapPointer(e); |
| 732 | } else { |
| 733 | e->Verify(); |
| 734 | } |
| 735 | } |
| 736 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 737 | #endif // DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 738 | |
| 739 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 740 | #ifdef OBJECT_PRINT |
| 741 | void JSValue::JSValuePrint(FILE* out) { |
| 742 | HeapObject::PrintHeader(out, "ValueObject"); |
| 743 | value()->Print(out); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 744 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 745 | #endif // OBJECT_PRINT |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 746 | |
| 747 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 748 | #ifdef DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 749 | void JSValue::JSValueVerify() { |
| 750 | Object* v = value(); |
| 751 | if (v->IsHeapObject()) { |
| 752 | VerifyHeapPointer(v); |
| 753 | } |
| 754 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 755 | #endif // DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 756 | |
| 757 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 758 | #ifdef OBJECT_PRINT |
| 759 | void String::StringPrint(FILE* out) { |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 760 | if (StringShape(this).IsSymbol()) { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 761 | PrintF(out, "#"); |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 762 | } else if (StringShape(this).IsCons()) { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 763 | PrintF(out, "c\""); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 764 | } else { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 765 | PrintF(out, "\""); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 766 | } |
| 767 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 768 | const char truncated_epilogue[] = "...<truncated>"; |
| 769 | int len = length(); |
| 770 | if (!FLAG_use_verbose_printer) { |
| 771 | if (len > 100) { |
| 772 | len = 100 - sizeof(truncated_epilogue); |
| 773 | } |
| 774 | } |
| 775 | for (int i = 0; i < len; i++) { |
| 776 | PrintF(out, "%c", Get(i)); |
| 777 | } |
| 778 | if (len != length()) { |
| 779 | PrintF(out, "%s", truncated_epilogue); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 780 | } |
| 781 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 782 | if (!StringShape(this).IsSymbol()) PrintF(out, "\""); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 783 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 784 | #endif // OBJECT_PRINT |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 785 | |
| 786 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 787 | #ifdef DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 788 | void String::StringVerify() { |
| 789 | CHECK(IsString()); |
| 790 | CHECK(length() >= 0 && length() <= Smi::kMaxValue); |
| 791 | if (IsSymbol()) { |
| 792 | CHECK(!Heap::InNewSpace(this)); |
| 793 | } |
| 794 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 795 | #endif // DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 796 | |
| 797 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 798 | #ifdef OBJECT_PRINT |
| 799 | void JSFunction::JSFunctionPrint(FILE* out) { |
| 800 | HeapObject::PrintHeader(out, "Function"); |
| 801 | PrintF(out, " - map = 0x%p\n", reinterpret_cast<void*>(map())); |
| 802 | PrintF(out, " - initial_map = "); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 803 | if (has_initial_map()) { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 804 | initial_map()->ShortPrint(out); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 805 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 806 | PrintF(out, "\n - shared_info = "); |
| 807 | shared()->ShortPrint(out); |
| 808 | PrintF(out, "\n - name = "); |
| 809 | shared()->name()->Print(out); |
| 810 | PrintF(out, "\n - context = "); |
| 811 | unchecked_context()->ShortPrint(out); |
| 812 | PrintF(out, "\n - code = "); |
| 813 | code()->ShortPrint(out); |
| 814 | PrintF(out, "\n"); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 815 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 816 | PrintProperties(out); |
| 817 | PrintElements(out); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 818 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 819 | PrintF(out, "\n"); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 820 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 821 | #endif // OBJECT_PRINT |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 822 | |
| 823 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 824 | #ifdef DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 825 | void JSFunction::JSFunctionVerify() { |
| 826 | CHECK(IsJSFunction()); |
| 827 | VerifyObjectField(kPrototypeOrInitialMapOffset); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 828 | VerifyObjectField(kNextFunctionLinkOffset); |
| 829 | CHECK(next_function_link()->IsUndefined() || |
| 830 | next_function_link()->IsJSFunction()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 831 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 832 | #endif // DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 833 | |
| 834 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 835 | #ifdef OBJECT_PRINT |
| 836 | void SharedFunctionInfo::SharedFunctionInfoPrint(FILE* out) { |
| 837 | HeapObject::PrintHeader(out, "SharedFunctionInfo"); |
| 838 | PrintF(out, " - name: "); |
| 839 | name()->ShortPrint(out); |
| 840 | PrintF(out, "\n - expected_nof_properties: %d", expected_nof_properties()); |
| 841 | PrintF(out, "\n - instance class name = "); |
| 842 | instance_class_name()->Print(out); |
| 843 | PrintF(out, "\n - code = "); |
| 844 | code()->ShortPrint(out); |
| 845 | PrintF(out, "\n - source code = "); |
| 846 | GetSourceCode()->ShortPrint(out); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 847 | // Script files are often large, hard to read. |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 848 | // PrintF(out, "\n - script ="); |
| 849 | // script()->Print(out); |
| 850 | PrintF(out, "\n - function token position = %d", function_token_position()); |
| 851 | PrintF(out, "\n - start position = %d", start_position()); |
| 852 | PrintF(out, "\n - end position = %d", end_position()); |
| 853 | PrintF(out, "\n - is expression = %d", is_expression()); |
| 854 | PrintF(out, "\n - debug info = "); |
| 855 | debug_info()->ShortPrint(out); |
| 856 | PrintF(out, "\n - length = %d", length()); |
| 857 | PrintF(out, "\n - has_only_simple_this_property_assignments = %d", |
sgjesse@chromium.org | 911335c | 2009-08-19 12:59:44 +0000 | [diff] [blame] | 858 | has_only_simple_this_property_assignments()); |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 859 | PrintF(out, "\n - this_property_assignments = "); |
| 860 | this_property_assignments()->ShortPrint(out); |
| 861 | PrintF(out, "\n"); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 862 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 863 | #endif // OBJECT_PRINT |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 864 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 865 | |
| 866 | #ifdef DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 867 | void SharedFunctionInfo::SharedFunctionInfoVerify() { |
| 868 | CHECK(IsSharedFunctionInfo()); |
| 869 | VerifyObjectField(kNameOffset); |
| 870 | VerifyObjectField(kCodeOffset); |
ager@chromium.org | 6a2b0aa | 2010-07-13 20:58:03 +0000 | [diff] [blame] | 871 | VerifyObjectField(kScopeInfoOffset); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 872 | VerifyObjectField(kInstanceClassNameOffset); |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 873 | VerifyObjectField(kFunctionDataOffset); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 874 | VerifyObjectField(kScriptOffset); |
| 875 | VerifyObjectField(kDebugInfoOffset); |
| 876 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 877 | #endif // DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 878 | |
| 879 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 880 | #ifdef OBJECT_PRINT |
| 881 | void JSGlobalProxy::JSGlobalProxyPrint(FILE* out) { |
| 882 | PrintF(out, "global_proxy"); |
| 883 | JSObjectPrint(out); |
| 884 | PrintF(out, "context : "); |
| 885 | context()->ShortPrint(out); |
| 886 | PrintF(out, "\n"); |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 887 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 888 | #endif // OBJECT_PRINT |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 889 | |
| 890 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 891 | #ifdef DEBUG |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 892 | void JSGlobalProxy::JSGlobalProxyVerify() { |
| 893 | CHECK(IsJSGlobalProxy()); |
| 894 | JSObjectVerify(); |
| 895 | VerifyObjectField(JSGlobalProxy::kContextOffset); |
| 896 | // Make sure that this object has no properties, elements. |
| 897 | CHECK_EQ(0, properties()->length()); |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 898 | CHECK(HasFastElements()); |
| 899 | CHECK_EQ(0, FixedArray::cast(elements())->length()); |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 900 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 901 | #endif // DEBUG |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 902 | |
| 903 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 904 | #ifdef OBJECT_PRINT |
| 905 | void JSGlobalObject::JSGlobalObjectPrint(FILE* out) { |
| 906 | PrintF(out, "global "); |
| 907 | JSObjectPrint(out); |
| 908 | PrintF(out, "global context : "); |
| 909 | global_context()->ShortPrint(out); |
| 910 | PrintF(out, "\n"); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 911 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 912 | #endif // OBJECT_PRINT |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 913 | |
| 914 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 915 | #ifdef DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 916 | void JSGlobalObject::JSGlobalObjectVerify() { |
| 917 | CHECK(IsJSGlobalObject()); |
| 918 | JSObjectVerify(); |
| 919 | for (int i = GlobalObject::kBuiltinsOffset; |
| 920 | i < JSGlobalObject::kSize; |
| 921 | i += kPointerSize) { |
| 922 | VerifyObjectField(i); |
| 923 | } |
| 924 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 925 | #endif // DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 926 | |
| 927 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 928 | #ifdef OBJECT_PRINT |
| 929 | void JSBuiltinsObject::JSBuiltinsObjectPrint(FILE* out) { |
| 930 | PrintF(out, "builtins "); |
| 931 | JSObjectPrint(out); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 932 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 933 | #endif // OBJECT_PRINT |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 934 | |
| 935 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 936 | #ifdef DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 937 | void JSBuiltinsObject::JSBuiltinsObjectVerify() { |
| 938 | CHECK(IsJSBuiltinsObject()); |
| 939 | JSObjectVerify(); |
| 940 | for (int i = GlobalObject::kBuiltinsOffset; |
| 941 | i < JSBuiltinsObject::kSize; |
| 942 | i += kPointerSize) { |
| 943 | VerifyObjectField(i); |
| 944 | } |
| 945 | } |
| 946 | |
| 947 | |
| 948 | void Oddball::OddballVerify() { |
| 949 | CHECK(IsOddball()); |
| 950 | VerifyHeapPointer(to_string()); |
| 951 | Object* number = to_number(); |
| 952 | if (number->IsHeapObject()) { |
| 953 | ASSERT(number == Heap::nan_value()); |
| 954 | } else { |
| 955 | ASSERT(number->IsSmi()); |
| 956 | int value = Smi::cast(number)->value(); |
sgjesse@chromium.org | c81c894 | 2009-08-21 10:54:26 +0000 | [diff] [blame] | 957 | ASSERT(value == 0 || value == 1 || value == -1 || |
| 958 | value == -2 || value == -3); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 959 | } |
| 960 | } |
| 961 | |
| 962 | |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 963 | void JSGlobalPropertyCell::JSGlobalPropertyCellVerify() { |
| 964 | CHECK(IsJSGlobalPropertyCell()); |
| 965 | VerifyObjectField(kValueOffset); |
| 966 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 967 | #endif // DEBUG |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 968 | |
| 969 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 970 | #ifdef OBJECT_PRINT |
| 971 | void JSGlobalPropertyCell::JSGlobalPropertyCellPrint(FILE* out) { |
| 972 | HeapObject::PrintHeader(out, "JSGlobalPropertyCell"); |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 973 | } |
| 974 | |
| 975 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 976 | void Code::CodePrint(FILE* out) { |
| 977 | HeapObject::PrintHeader(out, "Code"); |
mads.s.ager | 31e7138 | 2008-08-13 09:32:07 +0000 | [diff] [blame] | 978 | #ifdef ENABLE_DISASSEMBLER |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 979 | if (FLAG_use_verbose_printer) { |
| 980 | Disassemble(NULL, out); |
| 981 | } |
mads.s.ager | 31e7138 | 2008-08-13 09:32:07 +0000 | [diff] [blame] | 982 | #endif |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 983 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 984 | #endif // OBJECT_PRINT |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 985 | |
| 986 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 987 | #ifdef DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 988 | void Code::CodeVerify() { |
kasperl@chromium.org | 061ef74 | 2009-02-27 12:16:20 +0000 | [diff] [blame] | 989 | CHECK(IsAligned(reinterpret_cast<intptr_t>(instruction_start()), |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 990 | kCodeAlignment)); |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 991 | Address last_gc_pc = NULL; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 992 | for (RelocIterator it(this); !it.done(); it.next()) { |
| 993 | it.rinfo()->Verify(); |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 994 | // Ensure that GC will not iterate twice over the same pointer. |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 995 | if (RelocInfo::IsGCRelocMode(it.rinfo()->rmode())) { |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 996 | CHECK(it.rinfo()->pc() != last_gc_pc); |
| 997 | last_gc_pc = it.rinfo()->pc(); |
| 998 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 999 | } |
| 1000 | } |
| 1001 | |
| 1002 | |
| 1003 | void JSArray::JSArrayVerify() { |
| 1004 | JSObjectVerify(); |
| 1005 | ASSERT(length()->IsNumber() || length()->IsUndefined()); |
| 1006 | ASSERT(elements()->IsUndefined() || elements()->IsFixedArray()); |
| 1007 | } |
| 1008 | |
| 1009 | |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 1010 | void JSRegExp::JSRegExpVerify() { |
| 1011 | JSObjectVerify(); |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 1012 | ASSERT(data()->IsUndefined() || data()->IsFixedArray()); |
| 1013 | switch (TypeTag()) { |
| 1014 | case JSRegExp::ATOM: { |
| 1015 | FixedArray* arr = FixedArray::cast(data()); |
| 1016 | ASSERT(arr->get(JSRegExp::kAtomPatternIndex)->IsString()); |
| 1017 | break; |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 1018 | } |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 1019 | case JSRegExp::IRREGEXP: { |
kasperl@chromium.org | 68ac009 | 2009-07-09 06:00:35 +0000 | [diff] [blame] | 1020 | bool is_native = RegExpImpl::UsesNativeRegExp(); |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 1021 | |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 1022 | FixedArray* arr = FixedArray::cast(data()); |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 1023 | Object* ascii_data = arr->get(JSRegExp::kIrregexpASCIICodeIndex); |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 1024 | // TheHole : Not compiled yet. |
| 1025 | // JSObject: Compilation error. |
| 1026 | // Code/ByteArray: Compiled code. |
| 1027 | ASSERT(ascii_data->IsTheHole() || ascii_data->IsJSObject() || |
| 1028 | (is_native ? ascii_data->IsCode() : ascii_data->IsByteArray())); |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 1029 | Object* uc16_data = arr->get(JSRegExp::kIrregexpUC16CodeIndex); |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 1030 | ASSERT(uc16_data->IsTheHole() || ascii_data->IsJSObject() || |
| 1031 | (is_native ? uc16_data->IsCode() : uc16_data->IsByteArray())); |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 1032 | ASSERT(arr->get(JSRegExp::kIrregexpCaptureCountIndex)->IsSmi()); |
| 1033 | ASSERT(arr->get(JSRegExp::kIrregexpMaxRegisterCountIndex)->IsSmi()); |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 1034 | break; |
| 1035 | } |
| 1036 | default: |
| 1037 | ASSERT_EQ(JSRegExp::NOT_COMPILED, TypeTag()); |
| 1038 | ASSERT(data()->IsUndefined()); |
| 1039 | break; |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 1040 | } |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 1041 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1042 | #endif // DEBUG |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 1043 | |
| 1044 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1045 | #ifdef OBJECT_PRINT |
| 1046 | void Proxy::ProxyPrint(FILE* out) { |
| 1047 | PrintF(out, "proxy to %p", proxy()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1048 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1049 | #endif // OBJECT_PRINT |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1050 | |
| 1051 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1052 | #ifdef DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1053 | void Proxy::ProxyVerify() { |
| 1054 | ASSERT(IsProxy()); |
| 1055 | } |
| 1056 | |
| 1057 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1058 | void AccessorInfo::AccessorInfoVerify() { |
| 1059 | CHECK(IsAccessorInfo()); |
| 1060 | VerifyPointer(getter()); |
| 1061 | VerifyPointer(setter()); |
| 1062 | VerifyPointer(name()); |
| 1063 | VerifyPointer(data()); |
| 1064 | VerifyPointer(flag()); |
| 1065 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1066 | #endif // DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1067 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1068 | |
| 1069 | #ifdef OBJECT_PRINT |
| 1070 | void AccessorInfo::AccessorInfoPrint(FILE* out) { |
| 1071 | HeapObject::PrintHeader(out, "AccessorInfo"); |
| 1072 | PrintF(out, "\n - getter: "); |
| 1073 | getter()->ShortPrint(out); |
| 1074 | PrintF(out, "\n - setter: "); |
| 1075 | setter()->ShortPrint(out); |
| 1076 | PrintF(out, "\n - name: "); |
| 1077 | name()->ShortPrint(out); |
| 1078 | PrintF(out, "\n - data: "); |
| 1079 | data()->ShortPrint(out); |
| 1080 | PrintF(out, "\n - flag: "); |
| 1081 | flag()->ShortPrint(out); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1082 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1083 | #endif // OBJECT_PRINT |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1084 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1085 | |
| 1086 | #ifdef DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1087 | void AccessCheckInfo::AccessCheckInfoVerify() { |
| 1088 | CHECK(IsAccessCheckInfo()); |
| 1089 | VerifyPointer(named_callback()); |
| 1090 | VerifyPointer(indexed_callback()); |
| 1091 | VerifyPointer(data()); |
| 1092 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1093 | #endif // DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1094 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1095 | |
| 1096 | #ifdef OBJECT_PRINT |
| 1097 | void AccessCheckInfo::AccessCheckInfoPrint(FILE* out) { |
| 1098 | HeapObject::PrintHeader(out, "AccessCheckInfo"); |
| 1099 | PrintF(out, "\n - named_callback: "); |
| 1100 | named_callback()->ShortPrint(out); |
| 1101 | PrintF(out, "\n - indexed_callback: "); |
| 1102 | indexed_callback()->ShortPrint(out); |
| 1103 | PrintF(out, "\n - data: "); |
| 1104 | data()->ShortPrint(out); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1105 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1106 | #endif // OBJECT_PRINT |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1107 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1108 | |
| 1109 | #ifdef DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1110 | void InterceptorInfo::InterceptorInfoVerify() { |
| 1111 | CHECK(IsInterceptorInfo()); |
| 1112 | VerifyPointer(getter()); |
| 1113 | VerifyPointer(setter()); |
| 1114 | VerifyPointer(query()); |
| 1115 | VerifyPointer(deleter()); |
| 1116 | VerifyPointer(enumerator()); |
| 1117 | VerifyPointer(data()); |
| 1118 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1119 | #endif // DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1120 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1121 | |
| 1122 | #ifdef OBJECT_PRINT |
| 1123 | void InterceptorInfo::InterceptorInfoPrint(FILE* out) { |
| 1124 | HeapObject::PrintHeader(out, "InterceptorInfo"); |
| 1125 | PrintF(out, "\n - getter: "); |
| 1126 | getter()->ShortPrint(out); |
| 1127 | PrintF(out, "\n - setter: "); |
| 1128 | setter()->ShortPrint(out); |
| 1129 | PrintF(out, "\n - query: "); |
| 1130 | query()->ShortPrint(out); |
| 1131 | PrintF(out, "\n - deleter: "); |
| 1132 | deleter()->ShortPrint(out); |
| 1133 | PrintF(out, "\n - enumerator: "); |
| 1134 | enumerator()->ShortPrint(out); |
| 1135 | PrintF(out, "\n - data: "); |
| 1136 | data()->ShortPrint(out); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1137 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1138 | #endif // OBJECT_PRINT |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1139 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1140 | |
| 1141 | #ifdef DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1142 | void CallHandlerInfo::CallHandlerInfoVerify() { |
| 1143 | CHECK(IsCallHandlerInfo()); |
| 1144 | VerifyPointer(callback()); |
| 1145 | VerifyPointer(data()); |
| 1146 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1147 | #endif // DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1148 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1149 | |
| 1150 | #ifdef OBJECT_PRINT |
| 1151 | void CallHandlerInfo::CallHandlerInfoPrint(FILE* out) { |
| 1152 | HeapObject::PrintHeader(out, "CallHandlerInfo"); |
| 1153 | PrintF(out, "\n - callback: "); |
| 1154 | callback()->ShortPrint(out); |
| 1155 | PrintF(out, "\n - data: "); |
| 1156 | data()->ShortPrint(out); |
| 1157 | PrintF(out, "\n - call_stub_cache: "); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1158 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1159 | #endif // OBJECT_PRINT |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1160 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1161 | |
| 1162 | #ifdef DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1163 | void TemplateInfo::TemplateInfoVerify() { |
| 1164 | VerifyPointer(tag()); |
| 1165 | VerifyPointer(property_list()); |
| 1166 | } |
| 1167 | |
| 1168 | void FunctionTemplateInfo::FunctionTemplateInfoVerify() { |
| 1169 | CHECK(IsFunctionTemplateInfo()); |
| 1170 | TemplateInfoVerify(); |
| 1171 | VerifyPointer(serial_number()); |
| 1172 | VerifyPointer(call_code()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1173 | VerifyPointer(property_accessors()); |
| 1174 | VerifyPointer(prototype_template()); |
| 1175 | VerifyPointer(parent_template()); |
| 1176 | VerifyPointer(named_property_handler()); |
| 1177 | VerifyPointer(indexed_property_handler()); |
| 1178 | VerifyPointer(instance_template()); |
| 1179 | VerifyPointer(signature()); |
| 1180 | VerifyPointer(access_check_info()); |
| 1181 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1182 | #endif // DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1183 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1184 | |
| 1185 | #ifdef OBJECT_PRINT |
| 1186 | void FunctionTemplateInfo::FunctionTemplateInfoPrint(FILE* out) { |
| 1187 | HeapObject::PrintHeader(out, "FunctionTemplateInfo"); |
| 1188 | PrintF(out, "\n - class name: "); |
| 1189 | class_name()->ShortPrint(out); |
| 1190 | PrintF(out, "\n - tag: "); |
| 1191 | tag()->ShortPrint(out); |
| 1192 | PrintF(out, "\n - property_list: "); |
| 1193 | property_list()->ShortPrint(out); |
| 1194 | PrintF(out, "\n - serial_number: "); |
| 1195 | serial_number()->ShortPrint(out); |
| 1196 | PrintF(out, "\n - call_code: "); |
| 1197 | call_code()->ShortPrint(out); |
| 1198 | PrintF(out, "\n - property_accessors: "); |
| 1199 | property_accessors()->ShortPrint(out); |
| 1200 | PrintF(out, "\n - prototype_template: "); |
| 1201 | prototype_template()->ShortPrint(out); |
| 1202 | PrintF(out, "\n - parent_template: "); |
| 1203 | parent_template()->ShortPrint(out); |
| 1204 | PrintF(out, "\n - named_property_handler: "); |
| 1205 | named_property_handler()->ShortPrint(out); |
| 1206 | PrintF(out, "\n - indexed_property_handler: "); |
| 1207 | indexed_property_handler()->ShortPrint(out); |
| 1208 | PrintF(out, "\n - instance_template: "); |
| 1209 | instance_template()->ShortPrint(out); |
| 1210 | PrintF(out, "\n - signature: "); |
| 1211 | signature()->ShortPrint(out); |
| 1212 | PrintF(out, "\n - access_check_info: "); |
| 1213 | access_check_info()->ShortPrint(out); |
| 1214 | PrintF(out, "\n - hidden_prototype: %s", |
| 1215 | hidden_prototype() ? "true" : "false"); |
| 1216 | PrintF(out, "\n - undetectable: %s", undetectable() ? "true" : "false"); |
| 1217 | PrintF(out, "\n - need_access_check: %s", |
| 1218 | needs_access_check() ? "true" : "false"); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1219 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1220 | #endif // OBJECT_PRINT |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1221 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1222 | |
| 1223 | #ifdef DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1224 | void ObjectTemplateInfo::ObjectTemplateInfoVerify() { |
| 1225 | CHECK(IsObjectTemplateInfo()); |
| 1226 | TemplateInfoVerify(); |
| 1227 | VerifyPointer(constructor()); |
kasper.lund | 212ac23 | 2008-07-16 07:07:30 +0000 | [diff] [blame] | 1228 | VerifyPointer(internal_field_count()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1229 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1230 | #endif // DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1231 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1232 | |
| 1233 | #ifdef OBJECT_PRINT |
| 1234 | void ObjectTemplateInfo::ObjectTemplateInfoPrint(FILE* out) { |
| 1235 | HeapObject::PrintHeader(out, "ObjectTemplateInfo"); |
| 1236 | PrintF(out, "\n - constructor: "); |
| 1237 | constructor()->ShortPrint(out); |
| 1238 | PrintF(out, "\n - internal_field_count: "); |
| 1239 | internal_field_count()->ShortPrint(out); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1240 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1241 | #endif // OBJECT_PRINT |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1242 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1243 | |
| 1244 | #ifdef DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1245 | void SignatureInfo::SignatureInfoVerify() { |
| 1246 | CHECK(IsSignatureInfo()); |
| 1247 | VerifyPointer(receiver()); |
| 1248 | VerifyPointer(args()); |
| 1249 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1250 | #endif // DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1251 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1252 | |
| 1253 | #ifdef OBJECT_PRINT |
| 1254 | void SignatureInfo::SignatureInfoPrint(FILE* out) { |
| 1255 | HeapObject::PrintHeader(out, "SignatureInfo"); |
| 1256 | PrintF(out, "\n - receiver: "); |
| 1257 | receiver()->ShortPrint(out); |
| 1258 | PrintF(out, "\n - args: "); |
| 1259 | args()->ShortPrint(out); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1260 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1261 | #endif // OBJECT_PRINT |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1262 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1263 | |
| 1264 | #ifdef DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1265 | void TypeSwitchInfo::TypeSwitchInfoVerify() { |
| 1266 | CHECK(IsTypeSwitchInfo()); |
| 1267 | VerifyPointer(types()); |
| 1268 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1269 | #endif // DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1270 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1271 | |
| 1272 | #ifdef OBJECT_PRINT |
| 1273 | void TypeSwitchInfo::TypeSwitchInfoPrint(FILE* out) { |
| 1274 | HeapObject::PrintHeader(out, "TypeSwitchInfo"); |
| 1275 | PrintF(out, "\n - types: "); |
| 1276 | types()->ShortPrint(out); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1277 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1278 | #endif // OBJECT_PRINT |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1279 | |
| 1280 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1281 | #ifdef DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1282 | void Script::ScriptVerify() { |
| 1283 | CHECK(IsScript()); |
| 1284 | VerifyPointer(source()); |
| 1285 | VerifyPointer(name()); |
| 1286 | line_offset()->SmiVerify(); |
| 1287 | column_offset()->SmiVerify(); |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 1288 | VerifyPointer(data()); |
| 1289 | VerifyPointer(wrapper()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1290 | type()->SmiVerify(); |
sgjesse@chromium.org | 499aaa5 | 2009-11-30 08:07:20 +0000 | [diff] [blame] | 1291 | VerifyPointer(line_ends()); |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 1292 | VerifyPointer(id()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1293 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1294 | #endif // DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1295 | |
| 1296 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1297 | #ifdef OBJECT_PRINT |
| 1298 | void Script::ScriptPrint(FILE* out) { |
| 1299 | HeapObject::PrintHeader(out, "Script"); |
| 1300 | PrintF(out, "\n - source: "); |
| 1301 | source()->ShortPrint(out); |
| 1302 | PrintF(out, "\n - name: "); |
| 1303 | name()->ShortPrint(out); |
| 1304 | PrintF(out, "\n - line_offset: "); |
| 1305 | line_offset()->ShortPrint(out); |
| 1306 | PrintF(out, "\n - column_offset: "); |
| 1307 | column_offset()->ShortPrint(out); |
| 1308 | PrintF(out, "\n - type: "); |
| 1309 | type()->ShortPrint(out); |
| 1310 | PrintF(out, "\n - id: "); |
| 1311 | id()->ShortPrint(out); |
| 1312 | PrintF(out, "\n - data: "); |
| 1313 | data()->ShortPrint(out); |
| 1314 | PrintF(out, "\n - context data: "); |
| 1315 | context_data()->ShortPrint(out); |
| 1316 | PrintF(out, "\n - wrapper: "); |
| 1317 | wrapper()->ShortPrint(out); |
| 1318 | PrintF(out, "\n - compilation type: "); |
| 1319 | compilation_type()->ShortPrint(out); |
| 1320 | PrintF(out, "\n - line ends: "); |
| 1321 | line_ends()->ShortPrint(out); |
| 1322 | PrintF(out, "\n - eval from shared: "); |
| 1323 | eval_from_shared()->ShortPrint(out); |
| 1324 | PrintF(out, "\n - eval from instructions offset: "); |
| 1325 | eval_from_instructions_offset()->ShortPrint(out); |
| 1326 | PrintF(out, "\n"); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1327 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1328 | #endif // OBJECT_PRINT |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1329 | |
| 1330 | |
kasperl@chromium.org | e959c18 | 2009-07-27 08:59:04 +0000 | [diff] [blame] | 1331 | #ifdef ENABLE_DEBUGGER_SUPPORT |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1332 | #ifdef DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1333 | void DebugInfo::DebugInfoVerify() { |
| 1334 | CHECK(IsDebugInfo()); |
| 1335 | VerifyPointer(shared()); |
| 1336 | VerifyPointer(original_code()); |
| 1337 | VerifyPointer(code()); |
| 1338 | VerifyPointer(break_points()); |
| 1339 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1340 | #endif // DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1341 | |
| 1342 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1343 | #ifdef OBJECT_PRINT |
| 1344 | void DebugInfo::DebugInfoPrint(FILE* out) { |
| 1345 | HeapObject::PrintHeader(out, "DebugInfo"); |
| 1346 | PrintF(out, "\n - shared: "); |
| 1347 | shared()->ShortPrint(out); |
| 1348 | PrintF(out, "\n - original_code: "); |
| 1349 | original_code()->ShortPrint(out); |
| 1350 | PrintF(out, "\n - code: "); |
| 1351 | code()->ShortPrint(out); |
| 1352 | PrintF(out, "\n - break_points: "); |
| 1353 | break_points()->Print(out); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1354 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1355 | #endif // OBJECT_PRINT |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1356 | |
| 1357 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1358 | #ifdef DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1359 | void BreakPointInfo::BreakPointInfoVerify() { |
| 1360 | CHECK(IsBreakPointInfo()); |
| 1361 | code_position()->SmiVerify(); |
| 1362 | source_position()->SmiVerify(); |
| 1363 | statement_position()->SmiVerify(); |
| 1364 | VerifyPointer(break_point_objects()); |
| 1365 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1366 | #endif // DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1367 | |
| 1368 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1369 | #ifdef OBJECT_PRINT |
| 1370 | void BreakPointInfo::BreakPointInfoPrint(FILE* out) { |
| 1371 | HeapObject::PrintHeader(out, "BreakPointInfo"); |
| 1372 | PrintF(out, "\n - code_position: %d", code_position()->value()); |
| 1373 | PrintF(out, "\n - source_position: %d", source_position()->value()); |
| 1374 | PrintF(out, "\n - statement_position: %d", statement_position()->value()); |
| 1375 | PrintF(out, "\n - break_point_objects: "); |
| 1376 | break_point_objects()->ShortPrint(out); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1377 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1378 | #endif // OBJECT_PRINT |
| 1379 | #endif // ENABLE_DEBUGGER_SUPPORT |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1380 | |
| 1381 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1382 | #ifdef DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1383 | void JSObject::IncrementSpillStatistics(SpillInformation* info) { |
| 1384 | info->number_of_objects_++; |
| 1385 | // Named properties |
| 1386 | if (HasFastProperties()) { |
| 1387 | info->number_of_objects_with_fast_properties_++; |
| 1388 | info->number_of_fast_used_fields_ += map()->NextFreePropertyIndex(); |
| 1389 | info->number_of_fast_unused_fields_ += map()->unused_property_fields(); |
| 1390 | } else { |
kasperl@chromium.org | 86f77b7 | 2009-07-06 08:21:57 +0000 | [diff] [blame] | 1391 | StringDictionary* dict = property_dictionary(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1392 | info->number_of_slow_used_properties_ += dict->NumberOfElements(); |
| 1393 | info->number_of_slow_unused_properties_ += |
| 1394 | dict->Capacity() - dict->NumberOfElements(); |
| 1395 | } |
| 1396 | // Indexed properties |
sgjesse@chromium.org | 0b6db59 | 2009-07-30 14:48:31 +0000 | [diff] [blame] | 1397 | switch (GetElementsKind()) { |
| 1398 | case FAST_ELEMENTS: { |
| 1399 | info->number_of_objects_with_fast_elements_++; |
| 1400 | int holes = 0; |
| 1401 | FixedArray* e = FixedArray::cast(elements()); |
| 1402 | int len = e->length(); |
| 1403 | for (int i = 0; i < len; i++) { |
| 1404 | if (e->get(i) == Heap::the_hole_value()) holes++; |
| 1405 | } |
| 1406 | info->number_of_fast_used_elements_ += len - holes; |
| 1407 | info->number_of_fast_unused_elements_ += holes; |
| 1408 | break; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1409 | } |
sgjesse@chromium.org | 0b6db59 | 2009-07-30 14:48:31 +0000 | [diff] [blame] | 1410 | case PIXEL_ELEMENTS: { |
| 1411 | info->number_of_objects_with_fast_elements_++; |
| 1412 | PixelArray* e = PixelArray::cast(elements()); |
| 1413 | info->number_of_fast_used_elements_ += e->length(); |
| 1414 | break; |
| 1415 | } |
| 1416 | case DICTIONARY_ELEMENTS: { |
| 1417 | NumberDictionary* dict = element_dictionary(); |
| 1418 | info->number_of_slow_used_elements_ += dict->NumberOfElements(); |
| 1419 | info->number_of_slow_unused_elements_ += |
| 1420 | dict->Capacity() - dict->NumberOfElements(); |
| 1421 | break; |
| 1422 | } |
| 1423 | default: |
| 1424 | UNREACHABLE(); |
| 1425 | break; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1426 | } |
| 1427 | } |
| 1428 | |
| 1429 | |
| 1430 | void JSObject::SpillInformation::Clear() { |
| 1431 | number_of_objects_ = 0; |
| 1432 | number_of_objects_with_fast_properties_ = 0; |
| 1433 | number_of_objects_with_fast_elements_ = 0; |
| 1434 | number_of_fast_used_fields_ = 0; |
| 1435 | number_of_fast_unused_fields_ = 0; |
| 1436 | number_of_slow_used_properties_ = 0; |
| 1437 | number_of_slow_unused_properties_ = 0; |
| 1438 | number_of_fast_used_elements_ = 0; |
| 1439 | number_of_fast_unused_elements_ = 0; |
| 1440 | number_of_slow_used_elements_ = 0; |
| 1441 | number_of_slow_unused_elements_ = 0; |
| 1442 | } |
| 1443 | |
| 1444 | void JSObject::SpillInformation::Print() { |
| 1445 | PrintF("\n JSObject Spill Statistics (#%d):\n", number_of_objects_); |
| 1446 | |
| 1447 | PrintF(" - fast properties (#%d): %d (used) %d (unused)\n", |
| 1448 | number_of_objects_with_fast_properties_, |
| 1449 | number_of_fast_used_fields_, number_of_fast_unused_fields_); |
| 1450 | |
| 1451 | PrintF(" - slow properties (#%d): %d (used) %d (unused)\n", |
| 1452 | number_of_objects_ - number_of_objects_with_fast_properties_, |
| 1453 | number_of_slow_used_properties_, number_of_slow_unused_properties_); |
| 1454 | |
| 1455 | PrintF(" - fast elements (#%d): %d (used) %d (unused)\n", |
| 1456 | number_of_objects_with_fast_elements_, |
| 1457 | number_of_fast_used_elements_, number_of_fast_unused_elements_); |
| 1458 | |
| 1459 | PrintF(" - slow elements (#%d): %d (used) %d (unused)\n", |
| 1460 | number_of_objects_ - number_of_objects_with_fast_elements_, |
| 1461 | number_of_slow_used_elements_, number_of_slow_unused_elements_); |
| 1462 | |
| 1463 | PrintF("\n"); |
| 1464 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1465 | #endif // DEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1466 | |
| 1467 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1468 | #ifdef OBJECT_PRINT |
| 1469 | void DescriptorArray::PrintDescriptors(FILE* out) { |
| 1470 | PrintF(out, "Descriptor array %d\n", number_of_descriptors()); |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 1471 | for (int i = 0; i < number_of_descriptors(); i++) { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1472 | PrintF(out, " %d: ", i); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1473 | Descriptor desc; |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 1474 | Get(i, &desc); |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1475 | desc.Print(out); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1476 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1477 | PrintF(out, "\n"); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1478 | } |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1479 | #endif // OBJECT_PRINT |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1480 | |
| 1481 | |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame^] | 1482 | #ifdef DEBUG |
mads.s.ager@gmail.com | 769cc96 | 2008-08-06 10:02:49 +0000 | [diff] [blame] | 1483 | bool DescriptorArray::IsSortedNoDuplicates() { |
| 1484 | String* current_key = NULL; |
| 1485 | uint32_t current = 0; |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 1486 | for (int i = 0; i < number_of_descriptors(); i++) { |
| 1487 | String* key = GetKey(i); |
mads.s.ager@gmail.com | 769cc96 | 2008-08-06 10:02:49 +0000 | [diff] [blame] | 1488 | if (key == current_key) { |
| 1489 | PrintDescriptors(); |
| 1490 | return false; |
| 1491 | } |
| 1492 | current_key = key; |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 1493 | uint32_t hash = GetKey(i)->Hash(); |
mads.s.ager@gmail.com | 769cc96 | 2008-08-06 10:02:49 +0000 | [diff] [blame] | 1494 | if (hash < current) { |
| 1495 | PrintDescriptors(); |
| 1496 | return false; |
| 1497 | } |
| 1498 | current = hash; |
| 1499 | } |
| 1500 | return true; |
| 1501 | } |
| 1502 | |
| 1503 | |
ager@chromium.org | ac091b7 | 2010-05-05 07:34:42 +0000 | [diff] [blame] | 1504 | void JSFunctionResultCache::JSFunctionResultCacheVerify() { |
| 1505 | JSFunction::cast(get(kFactoryIndex))->Verify(); |
| 1506 | |
| 1507 | int size = Smi::cast(get(kCacheSizeIndex))->value(); |
| 1508 | ASSERT(kEntriesIndex <= size); |
| 1509 | ASSERT(size <= length()); |
| 1510 | ASSERT_EQ(0, size % kEntrySize); |
| 1511 | |
| 1512 | int finger = Smi::cast(get(kFingerIndex))->value(); |
| 1513 | ASSERT(kEntriesIndex <= finger); |
| 1514 | ASSERT(finger < size || finger == kEntriesIndex); |
| 1515 | ASSERT_EQ(0, finger % kEntrySize); |
| 1516 | |
| 1517 | if (FLAG_enable_slow_asserts) { |
| 1518 | for (int i = kEntriesIndex; i < size; i++) { |
| 1519 | ASSERT(!get(i)->IsTheHole()); |
| 1520 | get(i)->Verify(); |
| 1521 | } |
| 1522 | for (int i = size; i < length(); i++) { |
| 1523 | ASSERT(get(i)->IsTheHole()); |
| 1524 | get(i)->Verify(); |
| 1525 | } |
| 1526 | } |
| 1527 | } |
| 1528 | |
| 1529 | |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 1530 | void NormalizedMapCache::NormalizedMapCacheVerify() { |
| 1531 | FixedArray::cast(this)->Verify(); |
| 1532 | if (FLAG_enable_slow_asserts) { |
| 1533 | for (int i = 0; i < length(); i++) { |
| 1534 | Object* e = get(i); |
| 1535 | if (e->IsMap()) { |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 1536 | Map::cast(e)->SharedMapVerify(); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 1537 | } else { |
| 1538 | ASSERT(e->IsUndefined()); |
| 1539 | } |
| 1540 | } |
| 1541 | } |
| 1542 | } |
| 1543 | |
| 1544 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1545 | #endif // DEBUG |
| 1546 | |
| 1547 | } } // namespace v8::internal |