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