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