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 | } |
| 542 | } |
| 543 | |
| 544 | |
| 545 | static const char* TypeToString(InstanceType type) { |
| 546 | switch (type) { |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 547 | case INVALID_TYPE: return "INVALID"; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 548 | case MAP_TYPE: return "MAP"; |
| 549 | case HEAP_NUMBER_TYPE: return "HEAP_NUMBER"; |
sgjesse@chromium.org | ac6aa17 | 2009-12-04 12:29:05 +0000 | [diff] [blame] | 550 | case SYMBOL_TYPE: return "SYMBOL"; |
| 551 | case ASCII_SYMBOL_TYPE: return "ASCII_SYMBOL"; |
| 552 | case CONS_SYMBOL_TYPE: return "CONS_SYMBOL"; |
| 553 | case CONS_ASCII_SYMBOL_TYPE: return "CONS_ASCII_SYMBOL"; |
| 554 | case EXTERNAL_ASCII_SYMBOL_TYPE: |
| 555 | case EXTERNAL_SYMBOL_TYPE: return "EXTERNAL_SYMBOL"; |
| 556 | case ASCII_STRING_TYPE: return "ASCII_STRING"; |
| 557 | case STRING_TYPE: return "TWO_BYTE_STRING"; |
| 558 | case CONS_STRING_TYPE: |
| 559 | case CONS_ASCII_STRING_TYPE: return "CONS_STRING"; |
| 560 | case EXTERNAL_ASCII_STRING_TYPE: |
| 561 | case EXTERNAL_STRING_TYPE: return "EXTERNAL_STRING"; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 562 | case FIXED_ARRAY_TYPE: return "FIXED_ARRAY"; |
| 563 | case BYTE_ARRAY_TYPE: return "BYTE_ARRAY"; |
sgjesse@chromium.org | 0b6db59 | 2009-07-30 14:48:31 +0000 | [diff] [blame] | 564 | case PIXEL_ARRAY_TYPE: return "PIXEL_ARRAY"; |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 565 | case EXTERNAL_BYTE_ARRAY_TYPE: return "EXTERNAL_BYTE_ARRAY"; |
| 566 | case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: |
| 567 | return "EXTERNAL_UNSIGNED_BYTE_ARRAY"; |
| 568 | case EXTERNAL_SHORT_ARRAY_TYPE: return "EXTERNAL_SHORT_ARRAY"; |
| 569 | case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: |
| 570 | return "EXTERNAL_UNSIGNED_SHORT_ARRAY"; |
| 571 | case EXTERNAL_INT_ARRAY_TYPE: return "EXTERNAL_INT_ARRAY"; |
| 572 | case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: |
| 573 | return "EXTERNAL_UNSIGNED_INT_ARRAY"; |
| 574 | case EXTERNAL_FLOAT_ARRAY_TYPE: return "EXTERNAL_FLOAT_ARRAY"; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 575 | case FILLER_TYPE: return "FILLER"; |
| 576 | case JS_OBJECT_TYPE: return "JS_OBJECT"; |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 577 | case JS_CONTEXT_EXTENSION_OBJECT_TYPE: return "JS_CONTEXT_EXTENSION_OBJECT"; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 578 | case ODDBALL_TYPE: return "ODDBALL"; |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 579 | case JS_GLOBAL_PROPERTY_CELL_TYPE: return "JS_GLOBAL_PROPERTY_CELL"; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 580 | case SHARED_FUNCTION_INFO_TYPE: return "SHARED_FUNCTION_INFO"; |
| 581 | case JS_FUNCTION_TYPE: return "JS_FUNCTION"; |
| 582 | case CODE_TYPE: return "CODE"; |
| 583 | case JS_ARRAY_TYPE: return "JS_ARRAY"; |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 584 | case JS_REGEXP_TYPE: return "JS_REGEXP"; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 585 | case JS_VALUE_TYPE: return "JS_VALUE"; |
| 586 | case JS_GLOBAL_OBJECT_TYPE: return "JS_GLOBAL_OBJECT"; |
| 587 | case JS_BUILTINS_OBJECT_TYPE: return "JS_BUILTINS_OBJECT"; |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 588 | case JS_GLOBAL_PROXY_TYPE: return "JS_GLOBAL_PROXY"; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 589 | case PROXY_TYPE: return "PROXY"; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 590 | #define MAKE_STRUCT_CASE(NAME, Name, name) case NAME##_TYPE: return #NAME; |
| 591 | STRUCT_LIST(MAKE_STRUCT_CASE) |
| 592 | #undef MAKE_STRUCT_CASE |
| 593 | } |
| 594 | return "UNKNOWN"; |
| 595 | } |
| 596 | |
| 597 | |
| 598 | void Map::MapPrint() { |
| 599 | HeapObject::PrintHeader("Map"); |
| 600 | PrintF(" - type: %s\n", TypeToString(instance_type())); |
| 601 | PrintF(" - instance size: %d\n", instance_size()); |
sgjesse@chromium.org | 911335c | 2009-08-19 12:59:44 +0000 | [diff] [blame] | 602 | PrintF(" - inobject properties: %d\n", inobject_properties()); |
ager@chromium.org | 18ad94b | 2009-09-02 08:22:29 +0000 | [diff] [blame] | 603 | PrintF(" - pre-allocated property fields: %d\n", |
| 604 | pre_allocated_property_fields()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 605 | PrintF(" - unused property fields: %d\n", unused_property_fields()); |
ager@chromium.org | ddb913d | 2009-01-27 10:01:48 +0000 | [diff] [blame] | 606 | if (is_hidden_prototype()) { |
| 607 | PrintF(" - hidden_prototype\n"); |
| 608 | } |
| 609 | if (has_named_interceptor()) { |
| 610 | PrintF(" - named_interceptor\n"); |
| 611 | } |
| 612 | if (has_indexed_interceptor()) { |
| 613 | PrintF(" - indexed_interceptor\n"); |
| 614 | } |
| 615 | if (is_undetectable()) { |
| 616 | PrintF(" - undetectable\n"); |
| 617 | } |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 618 | if (needs_loading()) { |
| 619 | PrintF(" - needs_loading\n"); |
| 620 | } |
ager@chromium.org | ddb913d | 2009-01-27 10:01:48 +0000 | [diff] [blame] | 621 | if (has_instance_call_handler()) { |
| 622 | PrintF(" - instance_call_handler\n"); |
| 623 | } |
| 624 | if (is_access_check_needed()) { |
| 625 | PrintF(" - access_check_needed\n"); |
| 626 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 627 | PrintF(" - instance descriptors: "); |
| 628 | instance_descriptors()->ShortPrint(); |
| 629 | PrintF("\n - prototype: "); |
| 630 | prototype()->ShortPrint(); |
| 631 | PrintF("\n - constructor: "); |
| 632 | constructor()->ShortPrint(); |
| 633 | PrintF("\n"); |
| 634 | } |
| 635 | |
| 636 | |
| 637 | void Map::MapVerify() { |
| 638 | ASSERT(!Heap::InNewSpace(this)); |
| 639 | ASSERT(FIRST_TYPE <= instance_type() && instance_type() <= LAST_TYPE); |
| 640 | ASSERT(kPointerSize <= instance_size() |
| 641 | && instance_size() < Heap::Capacity()); |
| 642 | VerifyHeapPointer(prototype()); |
| 643 | VerifyHeapPointer(instance_descriptors()); |
| 644 | } |
| 645 | |
| 646 | |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 647 | void CodeCache::CodeCachePrint() { |
| 648 | HeapObject::PrintHeader("CodeCache"); |
| 649 | PrintF("\n - default_cache: "); |
| 650 | default_cache()->ShortPrint(); |
| 651 | PrintF("\n - normal_type_cache: "); |
| 652 | normal_type_cache()->ShortPrint(); |
| 653 | } |
| 654 | |
| 655 | |
| 656 | void CodeCache::CodeCacheVerify() { |
| 657 | VerifyHeapPointer(default_cache()); |
| 658 | VerifyHeapPointer(normal_type_cache()); |
| 659 | ASSERT(default_cache()->IsFixedArray()); |
| 660 | ASSERT(normal_type_cache()->IsUndefined() |
| 661 | || normal_type_cache()->IsCodeCacheHashTable()); |
| 662 | } |
| 663 | |
| 664 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 665 | void FixedArray::FixedArrayPrint() { |
| 666 | HeapObject::PrintHeader("FixedArray"); |
| 667 | PrintF(" - length: %d", length()); |
| 668 | for (int i = 0; i < length(); i++) { |
| 669 | PrintF("\n [%d]: ", i); |
| 670 | get(i)->ShortPrint(); |
| 671 | } |
| 672 | PrintF("\n"); |
| 673 | } |
| 674 | |
| 675 | |
| 676 | void FixedArray::FixedArrayVerify() { |
| 677 | for (int i = 0; i < length(); i++) { |
| 678 | Object* e = get(i); |
| 679 | if (e->IsHeapObject()) { |
| 680 | VerifyHeapPointer(e); |
| 681 | } else { |
| 682 | e->Verify(); |
| 683 | } |
| 684 | } |
| 685 | } |
| 686 | |
| 687 | |
| 688 | void JSValue::JSValuePrint() { |
| 689 | HeapObject::PrintHeader("ValueObject"); |
| 690 | value()->Print(); |
| 691 | } |
| 692 | |
| 693 | |
| 694 | void JSValue::JSValueVerify() { |
| 695 | Object* v = value(); |
| 696 | if (v->IsHeapObject()) { |
| 697 | VerifyHeapPointer(v); |
| 698 | } |
| 699 | } |
| 700 | |
| 701 | |
| 702 | void String::StringPrint() { |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 703 | if (StringShape(this).IsSymbol()) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 704 | PrintF("#"); |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 705 | } else if (StringShape(this).IsCons()) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 706 | PrintF("c\""); |
| 707 | } else { |
| 708 | PrintF("\""); |
| 709 | } |
| 710 | |
| 711 | for (int i = 0; i < length(); i++) { |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 712 | PrintF("%c", Get(i)); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 713 | } |
| 714 | |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 715 | if (!StringShape(this).IsSymbol()) PrintF("\""); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 716 | } |
| 717 | |
| 718 | |
| 719 | void String::StringVerify() { |
| 720 | CHECK(IsString()); |
| 721 | CHECK(length() >= 0 && length() <= Smi::kMaxValue); |
| 722 | if (IsSymbol()) { |
| 723 | CHECK(!Heap::InNewSpace(this)); |
| 724 | } |
| 725 | } |
| 726 | |
| 727 | |
| 728 | void JSFunction::JSFunctionPrint() { |
| 729 | HeapObject::PrintHeader("Function"); |
| 730 | PrintF(" - map = 0x%p\n", map()); |
| 731 | PrintF(" - is boilerplate: %s\n", IsBoilerplate() ? "yes" : "no"); |
| 732 | PrintF(" - initial_map = "); |
| 733 | if (has_initial_map()) { |
| 734 | initial_map()->ShortPrint(); |
| 735 | } |
| 736 | PrintF("\n - shared_info = "); |
| 737 | shared()->ShortPrint(); |
| 738 | PrintF("\n - name = "); |
| 739 | shared()->name()->Print(); |
| 740 | PrintF("\n - context = "); |
| 741 | unchecked_context()->ShortPrint(); |
| 742 | PrintF("\n - code = "); |
| 743 | code()->ShortPrint(); |
| 744 | PrintF("\n"); |
| 745 | |
| 746 | PrintProperties(); |
| 747 | PrintElements(); |
| 748 | |
| 749 | PrintF("\n"); |
| 750 | } |
| 751 | |
| 752 | |
| 753 | void JSFunction::JSFunctionVerify() { |
| 754 | CHECK(IsJSFunction()); |
| 755 | VerifyObjectField(kPrototypeOrInitialMapOffset); |
| 756 | } |
| 757 | |
| 758 | |
| 759 | void SharedFunctionInfo::SharedFunctionInfoPrint() { |
| 760 | HeapObject::PrintHeader("SharedFunctionInfo"); |
| 761 | PrintF(" - name: "); |
| 762 | name()->ShortPrint(); |
| 763 | PrintF("\n - expected_nof_properties: %d", expected_nof_properties()); |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 764 | PrintF("\n - instance class name = "); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 765 | instance_class_name()->Print(); |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 766 | PrintF("\n - code = "); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 767 | code()->ShortPrint(); |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 768 | PrintF("\n - source code = "); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 769 | GetSourceCode()->ShortPrint(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 770 | // Script files are often large, hard to read. |
| 771 | // PrintF("\n - script ="); |
| 772 | // script()->Print(); |
| 773 | PrintF("\n - function token position = %d", function_token_position()); |
| 774 | PrintF("\n - start position = %d", start_position()); |
| 775 | PrintF("\n - end position = %d", end_position()); |
| 776 | PrintF("\n - is expression = %d", is_expression()); |
| 777 | PrintF("\n - debug info = "); |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 778 | debug_info()->ShortPrint(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 779 | PrintF("\n - length = %d", length()); |
sgjesse@chromium.org | 911335c | 2009-08-19 12:59:44 +0000 | [diff] [blame] | 780 | PrintF("\n - has_only_simple_this_property_assignments = %d", |
| 781 | has_only_simple_this_property_assignments()); |
| 782 | PrintF("\n - this_property_assignments = "); |
| 783 | this_property_assignments()->ShortPrint(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 784 | PrintF("\n"); |
| 785 | } |
| 786 | |
| 787 | void SharedFunctionInfo::SharedFunctionInfoVerify() { |
| 788 | CHECK(IsSharedFunctionInfo()); |
| 789 | VerifyObjectField(kNameOffset); |
| 790 | VerifyObjectField(kCodeOffset); |
| 791 | VerifyObjectField(kInstanceClassNameOffset); |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame^] | 792 | VerifyObjectField(kFunctionDataOffset); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 793 | VerifyObjectField(kScriptOffset); |
| 794 | VerifyObjectField(kDebugInfoOffset); |
| 795 | } |
| 796 | |
| 797 | |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 798 | void JSGlobalProxy::JSGlobalProxyPrint() { |
| 799 | PrintF("global_proxy"); |
| 800 | JSObjectPrint(); |
| 801 | PrintF("context : "); |
| 802 | context()->ShortPrint(); |
| 803 | PrintF("\n"); |
| 804 | } |
| 805 | |
| 806 | |
| 807 | void JSGlobalProxy::JSGlobalProxyVerify() { |
| 808 | CHECK(IsJSGlobalProxy()); |
| 809 | JSObjectVerify(); |
| 810 | VerifyObjectField(JSGlobalProxy::kContextOffset); |
| 811 | // Make sure that this object has no properties, elements. |
| 812 | CHECK_EQ(0, properties()->length()); |
| 813 | CHECK_EQ(0, elements()->length()); |
| 814 | } |
| 815 | |
| 816 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 817 | void JSGlobalObject::JSGlobalObjectPrint() { |
| 818 | PrintF("global "); |
| 819 | JSObjectPrint(); |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 820 | PrintF("global context : "); |
| 821 | global_context()->ShortPrint(); |
| 822 | PrintF("\n"); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 823 | } |
| 824 | |
| 825 | |
| 826 | void JSGlobalObject::JSGlobalObjectVerify() { |
| 827 | CHECK(IsJSGlobalObject()); |
| 828 | JSObjectVerify(); |
| 829 | for (int i = GlobalObject::kBuiltinsOffset; |
| 830 | i < JSGlobalObject::kSize; |
| 831 | i += kPointerSize) { |
| 832 | VerifyObjectField(i); |
| 833 | } |
| 834 | } |
| 835 | |
| 836 | |
| 837 | void JSBuiltinsObject::JSBuiltinsObjectPrint() { |
| 838 | PrintF("builtins "); |
| 839 | JSObjectPrint(); |
| 840 | } |
| 841 | |
| 842 | |
| 843 | void JSBuiltinsObject::JSBuiltinsObjectVerify() { |
| 844 | CHECK(IsJSBuiltinsObject()); |
| 845 | JSObjectVerify(); |
| 846 | for (int i = GlobalObject::kBuiltinsOffset; |
| 847 | i < JSBuiltinsObject::kSize; |
| 848 | i += kPointerSize) { |
| 849 | VerifyObjectField(i); |
| 850 | } |
| 851 | } |
| 852 | |
| 853 | |
| 854 | void Oddball::OddballVerify() { |
| 855 | CHECK(IsOddball()); |
| 856 | VerifyHeapPointer(to_string()); |
| 857 | Object* number = to_number(); |
| 858 | if (number->IsHeapObject()) { |
| 859 | ASSERT(number == Heap::nan_value()); |
| 860 | } else { |
| 861 | ASSERT(number->IsSmi()); |
| 862 | int value = Smi::cast(number)->value(); |
sgjesse@chromium.org | c81c894 | 2009-08-21 10:54:26 +0000 | [diff] [blame] | 863 | ASSERT(value == 0 || value == 1 || value == -1 || |
| 864 | value == -2 || value == -3); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 865 | } |
| 866 | } |
| 867 | |
| 868 | |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 869 | void JSGlobalPropertyCell::JSGlobalPropertyCellVerify() { |
| 870 | CHECK(IsJSGlobalPropertyCell()); |
| 871 | VerifyObjectField(kValueOffset); |
| 872 | } |
| 873 | |
| 874 | |
| 875 | void JSGlobalPropertyCell::JSGlobalPropertyCellPrint() { |
| 876 | HeapObject::PrintHeader("JSGlobalPropertyCell"); |
| 877 | } |
| 878 | |
| 879 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 880 | void Code::CodePrint() { |
| 881 | HeapObject::PrintHeader("Code"); |
mads.s.ager | 31e7138 | 2008-08-13 09:32:07 +0000 | [diff] [blame] | 882 | #ifdef ENABLE_DISASSEMBLER |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 883 | Disassemble(NULL); |
mads.s.ager | 31e7138 | 2008-08-13 09:32:07 +0000 | [diff] [blame] | 884 | #endif |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 885 | } |
| 886 | |
| 887 | |
| 888 | void Code::CodeVerify() { |
kasperl@chromium.org | 061ef74 | 2009-02-27 12:16:20 +0000 | [diff] [blame] | 889 | CHECK(IsAligned(reinterpret_cast<intptr_t>(instruction_start()), |
| 890 | static_cast<intptr_t>(kCodeAlignment))); |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 891 | Address last_gc_pc = NULL; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 892 | for (RelocIterator it(this); !it.done(); it.next()) { |
| 893 | it.rinfo()->Verify(); |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 894 | // Ensure that GC will not iterate twice over the same pointer. |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 895 | if (RelocInfo::IsGCRelocMode(it.rinfo()->rmode())) { |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 896 | CHECK(it.rinfo()->pc() != last_gc_pc); |
| 897 | last_gc_pc = it.rinfo()->pc(); |
| 898 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 899 | } |
| 900 | } |
| 901 | |
| 902 | |
| 903 | void JSArray::JSArrayVerify() { |
| 904 | JSObjectVerify(); |
| 905 | ASSERT(length()->IsNumber() || length()->IsUndefined()); |
| 906 | ASSERT(elements()->IsUndefined() || elements()->IsFixedArray()); |
| 907 | } |
| 908 | |
| 909 | |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 910 | void JSRegExp::JSRegExpVerify() { |
| 911 | JSObjectVerify(); |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 912 | ASSERT(data()->IsUndefined() || data()->IsFixedArray()); |
| 913 | switch (TypeTag()) { |
| 914 | case JSRegExp::ATOM: { |
| 915 | FixedArray* arr = FixedArray::cast(data()); |
| 916 | ASSERT(arr->get(JSRegExp::kAtomPatternIndex)->IsString()); |
| 917 | break; |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 918 | } |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 919 | case JSRegExp::IRREGEXP: { |
kasperl@chromium.org | 68ac009 | 2009-07-09 06:00:35 +0000 | [diff] [blame] | 920 | bool is_native = RegExpImpl::UsesNativeRegExp(); |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 921 | |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 922 | FixedArray* arr = FixedArray::cast(data()); |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 923 | Object* ascii_data = arr->get(JSRegExp::kIrregexpASCIICodeIndex); |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 924 | // TheHole : Not compiled yet. |
| 925 | // JSObject: Compilation error. |
| 926 | // Code/ByteArray: Compiled code. |
| 927 | ASSERT(ascii_data->IsTheHole() || ascii_data->IsJSObject() || |
| 928 | (is_native ? ascii_data->IsCode() : ascii_data->IsByteArray())); |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 929 | Object* uc16_data = arr->get(JSRegExp::kIrregexpUC16CodeIndex); |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 930 | ASSERT(uc16_data->IsTheHole() || ascii_data->IsJSObject() || |
| 931 | (is_native ? uc16_data->IsCode() : uc16_data->IsByteArray())); |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 932 | ASSERT(arr->get(JSRegExp::kIrregexpCaptureCountIndex)->IsSmi()); |
| 933 | ASSERT(arr->get(JSRegExp::kIrregexpMaxRegisterCountIndex)->IsSmi()); |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 934 | break; |
| 935 | } |
| 936 | default: |
| 937 | ASSERT_EQ(JSRegExp::NOT_COMPILED, TypeTag()); |
| 938 | ASSERT(data()->IsUndefined()); |
| 939 | break; |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 940 | } |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 941 | } |
| 942 | |
| 943 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 944 | void Proxy::ProxyPrint() { |
| 945 | PrintF("proxy to %p", proxy()); |
| 946 | } |
| 947 | |
| 948 | |
| 949 | void Proxy::ProxyVerify() { |
| 950 | ASSERT(IsProxy()); |
| 951 | } |
| 952 | |
| 953 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 954 | void AccessorInfo::AccessorInfoVerify() { |
| 955 | CHECK(IsAccessorInfo()); |
| 956 | VerifyPointer(getter()); |
| 957 | VerifyPointer(setter()); |
| 958 | VerifyPointer(name()); |
| 959 | VerifyPointer(data()); |
| 960 | VerifyPointer(flag()); |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 961 | VerifyPointer(load_stub_cache()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 962 | } |
| 963 | |
| 964 | void AccessorInfo::AccessorInfoPrint() { |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 965 | HeapObject::PrintHeader("AccessorInfo"); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 966 | PrintF("\n - getter: "); |
| 967 | getter()->ShortPrint(); |
| 968 | PrintF("\n - setter: "); |
| 969 | setter()->ShortPrint(); |
| 970 | PrintF("\n - name: "); |
| 971 | name()->ShortPrint(); |
| 972 | PrintF("\n - data: "); |
| 973 | data()->ShortPrint(); |
| 974 | PrintF("\n - flag: "); |
| 975 | flag()->ShortPrint(); |
| 976 | } |
| 977 | |
| 978 | void AccessCheckInfo::AccessCheckInfoVerify() { |
| 979 | CHECK(IsAccessCheckInfo()); |
| 980 | VerifyPointer(named_callback()); |
| 981 | VerifyPointer(indexed_callback()); |
| 982 | VerifyPointer(data()); |
| 983 | } |
| 984 | |
| 985 | void AccessCheckInfo::AccessCheckInfoPrint() { |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 986 | HeapObject::PrintHeader("AccessCheckInfo"); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 987 | PrintF("\n - named_callback: "); |
| 988 | named_callback()->ShortPrint(); |
| 989 | PrintF("\n - indexed_callback: "); |
| 990 | indexed_callback()->ShortPrint(); |
| 991 | PrintF("\n - data: "); |
| 992 | data()->ShortPrint(); |
| 993 | } |
| 994 | |
| 995 | void InterceptorInfo::InterceptorInfoVerify() { |
| 996 | CHECK(IsInterceptorInfo()); |
| 997 | VerifyPointer(getter()); |
| 998 | VerifyPointer(setter()); |
| 999 | VerifyPointer(query()); |
| 1000 | VerifyPointer(deleter()); |
| 1001 | VerifyPointer(enumerator()); |
| 1002 | VerifyPointer(data()); |
| 1003 | } |
| 1004 | |
| 1005 | void InterceptorInfo::InterceptorInfoPrint() { |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 1006 | HeapObject::PrintHeader("InterceptorInfo"); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1007 | PrintF("\n - getter: "); |
| 1008 | getter()->ShortPrint(); |
| 1009 | PrintF("\n - setter: "); |
| 1010 | setter()->ShortPrint(); |
| 1011 | PrintF("\n - query: "); |
| 1012 | query()->ShortPrint(); |
| 1013 | PrintF("\n - deleter: "); |
| 1014 | deleter()->ShortPrint(); |
| 1015 | PrintF("\n - enumerator: "); |
| 1016 | enumerator()->ShortPrint(); |
| 1017 | PrintF("\n - data: "); |
| 1018 | data()->ShortPrint(); |
| 1019 | } |
| 1020 | |
| 1021 | void CallHandlerInfo::CallHandlerInfoVerify() { |
| 1022 | CHECK(IsCallHandlerInfo()); |
| 1023 | VerifyPointer(callback()); |
| 1024 | VerifyPointer(data()); |
| 1025 | } |
| 1026 | |
| 1027 | void CallHandlerInfo::CallHandlerInfoPrint() { |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 1028 | HeapObject::PrintHeader("CallHandlerInfo"); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1029 | PrintF("\n - callback: "); |
| 1030 | callback()->ShortPrint(); |
| 1031 | PrintF("\n - data: "); |
| 1032 | data()->ShortPrint(); |
| 1033 | } |
| 1034 | |
| 1035 | void TemplateInfo::TemplateInfoVerify() { |
| 1036 | VerifyPointer(tag()); |
| 1037 | VerifyPointer(property_list()); |
| 1038 | } |
| 1039 | |
| 1040 | void FunctionTemplateInfo::FunctionTemplateInfoVerify() { |
| 1041 | CHECK(IsFunctionTemplateInfo()); |
| 1042 | TemplateInfoVerify(); |
| 1043 | VerifyPointer(serial_number()); |
| 1044 | VerifyPointer(call_code()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1045 | VerifyPointer(property_accessors()); |
| 1046 | VerifyPointer(prototype_template()); |
| 1047 | VerifyPointer(parent_template()); |
| 1048 | VerifyPointer(named_property_handler()); |
| 1049 | VerifyPointer(indexed_property_handler()); |
| 1050 | VerifyPointer(instance_template()); |
| 1051 | VerifyPointer(signature()); |
| 1052 | VerifyPointer(access_check_info()); |
| 1053 | } |
| 1054 | |
| 1055 | void FunctionTemplateInfo::FunctionTemplateInfoPrint() { |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 1056 | HeapObject::PrintHeader("FunctionTemplateInfo"); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 1057 | PrintF("\n - class name: "); |
| 1058 | class_name()->ShortPrint(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1059 | PrintF("\n - tag: "); |
| 1060 | tag()->ShortPrint(); |
| 1061 | PrintF("\n - property_list: "); |
| 1062 | property_list()->ShortPrint(); |
| 1063 | PrintF("\n - serial_number: "); |
| 1064 | serial_number()->ShortPrint(); |
| 1065 | PrintF("\n - call_code: "); |
| 1066 | call_code()->ShortPrint(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1067 | PrintF("\n - property_accessors: "); |
| 1068 | property_accessors()->ShortPrint(); |
| 1069 | PrintF("\n - prototype_template: "); |
| 1070 | prototype_template()->ShortPrint(); |
| 1071 | PrintF("\n - parent_template: "); |
| 1072 | parent_template()->ShortPrint(); |
| 1073 | PrintF("\n - named_property_handler: "); |
| 1074 | named_property_handler()->ShortPrint(); |
| 1075 | PrintF("\n - indexed_property_handler: "); |
| 1076 | indexed_property_handler()->ShortPrint(); |
| 1077 | PrintF("\n - instance_template: "); |
| 1078 | instance_template()->ShortPrint(); |
| 1079 | PrintF("\n - signature: "); |
| 1080 | signature()->ShortPrint(); |
| 1081 | PrintF("\n - access_check_info: "); |
| 1082 | access_check_info()->ShortPrint(); |
| 1083 | PrintF("\n - hidden_prototype: %s", hidden_prototype() ? "true" : "false"); |
| 1084 | PrintF("\n - undetectable: %s", undetectable() ? "true" : "false"); |
| 1085 | PrintF("\n - need_access_check: %s", needs_access_check() ? "true" : "false"); |
| 1086 | } |
| 1087 | |
| 1088 | void ObjectTemplateInfo::ObjectTemplateInfoVerify() { |
| 1089 | CHECK(IsObjectTemplateInfo()); |
| 1090 | TemplateInfoVerify(); |
| 1091 | VerifyPointer(constructor()); |
kasper.lund | 212ac23 | 2008-07-16 07:07:30 +0000 | [diff] [blame] | 1092 | VerifyPointer(internal_field_count()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1093 | } |
| 1094 | |
| 1095 | void ObjectTemplateInfo::ObjectTemplateInfoPrint() { |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 1096 | HeapObject::PrintHeader("ObjectTemplateInfo"); |
kasper.lund | 212ac23 | 2008-07-16 07:07:30 +0000 | [diff] [blame] | 1097 | PrintF("\n - constructor: "); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1098 | constructor()->ShortPrint(); |
kasper.lund | 212ac23 | 2008-07-16 07:07:30 +0000 | [diff] [blame] | 1099 | PrintF("\n - internal_field_count: "); |
| 1100 | internal_field_count()->ShortPrint(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1101 | } |
| 1102 | |
| 1103 | void SignatureInfo::SignatureInfoVerify() { |
| 1104 | CHECK(IsSignatureInfo()); |
| 1105 | VerifyPointer(receiver()); |
| 1106 | VerifyPointer(args()); |
| 1107 | } |
| 1108 | |
| 1109 | void SignatureInfo::SignatureInfoPrint() { |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 1110 | HeapObject::PrintHeader("SignatureInfo"); |
kasper.lund | 212ac23 | 2008-07-16 07:07:30 +0000 | [diff] [blame] | 1111 | PrintF("\n - receiver: "); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1112 | receiver()->ShortPrint(); |
kasper.lund | 212ac23 | 2008-07-16 07:07:30 +0000 | [diff] [blame] | 1113 | PrintF("\n - args: "); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1114 | args()->ShortPrint(); |
| 1115 | } |
| 1116 | |
| 1117 | void TypeSwitchInfo::TypeSwitchInfoVerify() { |
| 1118 | CHECK(IsTypeSwitchInfo()); |
| 1119 | VerifyPointer(types()); |
| 1120 | } |
| 1121 | |
| 1122 | void TypeSwitchInfo::TypeSwitchInfoPrint() { |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 1123 | HeapObject::PrintHeader("TypeSwitchInfo"); |
kasper.lund | 212ac23 | 2008-07-16 07:07:30 +0000 | [diff] [blame] | 1124 | PrintF("\n - types: "); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1125 | types()->ShortPrint(); |
| 1126 | } |
| 1127 | |
| 1128 | |
| 1129 | void Script::ScriptVerify() { |
| 1130 | CHECK(IsScript()); |
| 1131 | VerifyPointer(source()); |
| 1132 | VerifyPointer(name()); |
| 1133 | line_offset()->SmiVerify(); |
| 1134 | column_offset()->SmiVerify(); |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 1135 | VerifyPointer(data()); |
| 1136 | VerifyPointer(wrapper()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1137 | type()->SmiVerify(); |
sgjesse@chromium.org | 499aaa5 | 2009-11-30 08:07:20 +0000 | [diff] [blame] | 1138 | VerifyPointer(line_ends()); |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 1139 | VerifyPointer(id()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1140 | } |
| 1141 | |
| 1142 | |
| 1143 | void Script::ScriptPrint() { |
| 1144 | HeapObject::PrintHeader("Script"); |
| 1145 | PrintF("\n - source: "); |
| 1146 | source()->ShortPrint(); |
| 1147 | PrintF("\n - name: "); |
| 1148 | name()->ShortPrint(); |
| 1149 | PrintF("\n - line_offset: "); |
| 1150 | line_offset()->ShortPrint(); |
| 1151 | PrintF("\n - column_offset: "); |
| 1152 | column_offset()->ShortPrint(); |
| 1153 | PrintF("\n - type: "); |
| 1154 | type()->ShortPrint(); |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 1155 | PrintF("\n - id: "); |
| 1156 | id()->ShortPrint(); |
sgjesse@chromium.org | 499aaa5 | 2009-11-30 08:07:20 +0000 | [diff] [blame] | 1157 | PrintF("\n - data: "); |
| 1158 | data()->ShortPrint(); |
| 1159 | PrintF("\n - context data: "); |
| 1160 | context_data()->ShortPrint(); |
| 1161 | PrintF("\n - wrapper: "); |
| 1162 | wrapper()->ShortPrint(); |
| 1163 | PrintF("\n - compilation type: "); |
| 1164 | compilation_type()->ShortPrint(); |
| 1165 | PrintF("\n - line ends: "); |
| 1166 | line_ends()->ShortPrint(); |
sgjesse@chromium.org | 9818059 | 2009-12-02 08:17:28 +0000 | [diff] [blame] | 1167 | PrintF("\n - eval from shared: "); |
| 1168 | eval_from_shared()->ShortPrint(); |
sgjesse@chromium.org | 499aaa5 | 2009-11-30 08:07:20 +0000 | [diff] [blame] | 1169 | PrintF("\n - eval from instructions offset: "); |
| 1170 | eval_from_instructions_offset()->ShortPrint(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1171 | PrintF("\n"); |
| 1172 | } |
| 1173 | |
| 1174 | |
kasperl@chromium.org | e959c18 | 2009-07-27 08:59:04 +0000 | [diff] [blame] | 1175 | #ifdef ENABLE_DEBUGGER_SUPPORT |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1176 | void DebugInfo::DebugInfoVerify() { |
| 1177 | CHECK(IsDebugInfo()); |
| 1178 | VerifyPointer(shared()); |
| 1179 | VerifyPointer(original_code()); |
| 1180 | VerifyPointer(code()); |
| 1181 | VerifyPointer(break_points()); |
| 1182 | } |
| 1183 | |
| 1184 | |
| 1185 | void DebugInfo::DebugInfoPrint() { |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 1186 | HeapObject::PrintHeader("DebugInfo"); |
| 1187 | PrintF("\n - shared: "); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1188 | shared()->ShortPrint(); |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 1189 | PrintF("\n - original_code: "); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1190 | original_code()->ShortPrint(); |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 1191 | PrintF("\n - code: "); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1192 | code()->ShortPrint(); |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 1193 | PrintF("\n - break_points: "); |
| 1194 | break_points()->Print(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1195 | } |
| 1196 | |
| 1197 | |
| 1198 | void BreakPointInfo::BreakPointInfoVerify() { |
| 1199 | CHECK(IsBreakPointInfo()); |
| 1200 | code_position()->SmiVerify(); |
| 1201 | source_position()->SmiVerify(); |
| 1202 | statement_position()->SmiVerify(); |
| 1203 | VerifyPointer(break_point_objects()); |
| 1204 | } |
| 1205 | |
| 1206 | |
| 1207 | void BreakPointInfo::BreakPointInfoPrint() { |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 1208 | HeapObject::PrintHeader("BreakPointInfo"); |
| 1209 | PrintF("\n - code_position: %d", code_position()); |
| 1210 | PrintF("\n - source_position: %d", source_position()); |
| 1211 | PrintF("\n - statement_position: %d", statement_position()); |
| 1212 | PrintF("\n - break_point_objects: "); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1213 | break_point_objects()->ShortPrint(); |
| 1214 | } |
kasperl@chromium.org | e959c18 | 2009-07-27 08:59:04 +0000 | [diff] [blame] | 1215 | #endif |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1216 | |
| 1217 | |
| 1218 | void JSObject::IncrementSpillStatistics(SpillInformation* info) { |
| 1219 | info->number_of_objects_++; |
| 1220 | // Named properties |
| 1221 | if (HasFastProperties()) { |
| 1222 | info->number_of_objects_with_fast_properties_++; |
| 1223 | info->number_of_fast_used_fields_ += map()->NextFreePropertyIndex(); |
| 1224 | info->number_of_fast_unused_fields_ += map()->unused_property_fields(); |
| 1225 | } else { |
kasperl@chromium.org | 86f77b7 | 2009-07-06 08:21:57 +0000 | [diff] [blame] | 1226 | StringDictionary* dict = property_dictionary(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1227 | info->number_of_slow_used_properties_ += dict->NumberOfElements(); |
| 1228 | info->number_of_slow_unused_properties_ += |
| 1229 | dict->Capacity() - dict->NumberOfElements(); |
| 1230 | } |
| 1231 | // Indexed properties |
sgjesse@chromium.org | 0b6db59 | 2009-07-30 14:48:31 +0000 | [diff] [blame] | 1232 | switch (GetElementsKind()) { |
| 1233 | case FAST_ELEMENTS: { |
| 1234 | info->number_of_objects_with_fast_elements_++; |
| 1235 | int holes = 0; |
| 1236 | FixedArray* e = FixedArray::cast(elements()); |
| 1237 | int len = e->length(); |
| 1238 | for (int i = 0; i < len; i++) { |
| 1239 | if (e->get(i) == Heap::the_hole_value()) holes++; |
| 1240 | } |
| 1241 | info->number_of_fast_used_elements_ += len - holes; |
| 1242 | info->number_of_fast_unused_elements_ += holes; |
| 1243 | break; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1244 | } |
sgjesse@chromium.org | 0b6db59 | 2009-07-30 14:48:31 +0000 | [diff] [blame] | 1245 | case PIXEL_ELEMENTS: { |
| 1246 | info->number_of_objects_with_fast_elements_++; |
| 1247 | PixelArray* e = PixelArray::cast(elements()); |
| 1248 | info->number_of_fast_used_elements_ += e->length(); |
| 1249 | break; |
| 1250 | } |
| 1251 | case DICTIONARY_ELEMENTS: { |
| 1252 | NumberDictionary* dict = element_dictionary(); |
| 1253 | info->number_of_slow_used_elements_ += dict->NumberOfElements(); |
| 1254 | info->number_of_slow_unused_elements_ += |
| 1255 | dict->Capacity() - dict->NumberOfElements(); |
| 1256 | break; |
| 1257 | } |
| 1258 | default: |
| 1259 | UNREACHABLE(); |
| 1260 | break; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1261 | } |
| 1262 | } |
| 1263 | |
| 1264 | |
| 1265 | void JSObject::SpillInformation::Clear() { |
| 1266 | number_of_objects_ = 0; |
| 1267 | number_of_objects_with_fast_properties_ = 0; |
| 1268 | number_of_objects_with_fast_elements_ = 0; |
| 1269 | number_of_fast_used_fields_ = 0; |
| 1270 | number_of_fast_unused_fields_ = 0; |
| 1271 | number_of_slow_used_properties_ = 0; |
| 1272 | number_of_slow_unused_properties_ = 0; |
| 1273 | number_of_fast_used_elements_ = 0; |
| 1274 | number_of_fast_unused_elements_ = 0; |
| 1275 | number_of_slow_used_elements_ = 0; |
| 1276 | number_of_slow_unused_elements_ = 0; |
| 1277 | } |
| 1278 | |
| 1279 | void JSObject::SpillInformation::Print() { |
| 1280 | PrintF("\n JSObject Spill Statistics (#%d):\n", number_of_objects_); |
| 1281 | |
| 1282 | PrintF(" - fast properties (#%d): %d (used) %d (unused)\n", |
| 1283 | number_of_objects_with_fast_properties_, |
| 1284 | number_of_fast_used_fields_, number_of_fast_unused_fields_); |
| 1285 | |
| 1286 | PrintF(" - slow properties (#%d): %d (used) %d (unused)\n", |
| 1287 | number_of_objects_ - number_of_objects_with_fast_properties_, |
| 1288 | number_of_slow_used_properties_, number_of_slow_unused_properties_); |
| 1289 | |
| 1290 | PrintF(" - fast elements (#%d): %d (used) %d (unused)\n", |
| 1291 | number_of_objects_with_fast_elements_, |
| 1292 | number_of_fast_used_elements_, number_of_fast_unused_elements_); |
| 1293 | |
| 1294 | PrintF(" - slow elements (#%d): %d (used) %d (unused)\n", |
| 1295 | number_of_objects_ - number_of_objects_with_fast_elements_, |
| 1296 | number_of_slow_used_elements_, number_of_slow_unused_elements_); |
| 1297 | |
| 1298 | PrintF("\n"); |
| 1299 | } |
| 1300 | |
| 1301 | |
| 1302 | void DescriptorArray::PrintDescriptors() { |
| 1303 | PrintF("Descriptor array %d\n", number_of_descriptors()); |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 1304 | for (int i = 0; i < number_of_descriptors(); i++) { |
| 1305 | PrintF(" %d: ", i); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1306 | Descriptor desc; |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 1307 | Get(i, &desc); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1308 | desc.Print(); |
| 1309 | } |
| 1310 | PrintF("\n"); |
| 1311 | } |
| 1312 | |
| 1313 | |
mads.s.ager@gmail.com | 769cc96 | 2008-08-06 10:02:49 +0000 | [diff] [blame] | 1314 | bool DescriptorArray::IsSortedNoDuplicates() { |
| 1315 | String* current_key = NULL; |
| 1316 | uint32_t current = 0; |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 1317 | for (int i = 0; i < number_of_descriptors(); i++) { |
| 1318 | String* key = GetKey(i); |
mads.s.ager@gmail.com | 769cc96 | 2008-08-06 10:02:49 +0000 | [diff] [blame] | 1319 | if (key == current_key) { |
| 1320 | PrintDescriptors(); |
| 1321 | return false; |
| 1322 | } |
| 1323 | current_key = key; |
kasperl@chromium.org | defbd10 | 2009-07-13 14:04:26 +0000 | [diff] [blame] | 1324 | uint32_t hash = GetKey(i)->Hash(); |
mads.s.ager@gmail.com | 769cc96 | 2008-08-06 10:02:49 +0000 | [diff] [blame] | 1325 | if (hash < current) { |
| 1326 | PrintDescriptors(); |
| 1327 | return false; |
| 1328 | } |
| 1329 | current = hash; |
| 1330 | } |
| 1331 | return true; |
| 1332 | } |
| 1333 | |
| 1334 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1335 | #endif // DEBUG |
| 1336 | |
| 1337 | } } // namespace v8::internal |