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