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" |
| 32 | #include "macro-assembler.h" |
| 33 | |
| 34 | namespace v8 { namespace internal { |
| 35 | |
| 36 | #ifdef DEBUG |
| 37 | |
| 38 | static const char* TypeToString(InstanceType type); |
| 39 | |
| 40 | |
| 41 | void Object::Print() { |
| 42 | if (IsSmi()) { |
| 43 | Smi::cast(this)->SmiPrint(); |
| 44 | } else if (IsFailure()) { |
| 45 | Failure::cast(this)->FailurePrint(); |
| 46 | } else { |
| 47 | HeapObject::cast(this)->HeapObjectPrint(); |
| 48 | } |
| 49 | Flush(); |
| 50 | } |
| 51 | |
| 52 | |
| 53 | void Object::PrintLn() { |
| 54 | Print(); |
| 55 | PrintF("\n"); |
| 56 | } |
| 57 | |
| 58 | |
| 59 | void Object::Verify() { |
| 60 | if (IsSmi()) { |
| 61 | Smi::cast(this)->SmiVerify(); |
| 62 | } else if (IsFailure()) { |
| 63 | Failure::cast(this)->FailureVerify(); |
| 64 | } else { |
| 65 | HeapObject::cast(this)->HeapObjectVerify(); |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | |
| 70 | void Object::VerifyPointer(Object* p) { |
| 71 | if (p->IsHeapObject()) { |
| 72 | HeapObject::VerifyHeapPointer(p); |
| 73 | } else { |
| 74 | ASSERT(p->IsSmi()); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | |
| 79 | void Smi::SmiVerify() { |
| 80 | ASSERT(IsSmi()); |
| 81 | } |
| 82 | |
| 83 | |
| 84 | void Failure::FailureVerify() { |
| 85 | ASSERT(IsFailure()); |
| 86 | } |
| 87 | |
| 88 | |
| 89 | void HeapObject::PrintHeader(const char* id) { |
| 90 | PrintF("%p: [%s]\n", this, id); |
| 91 | } |
| 92 | |
| 93 | |
| 94 | void HeapObject::HeapObjectPrint() { |
| 95 | InstanceType instance_type = map()->instance_type(); |
| 96 | |
| 97 | HandleScope scope; |
| 98 | if (instance_type < FIRST_NONSTRING_TYPE) { |
| 99 | String::cast(this)->StringPrint(); |
| 100 | return; |
| 101 | } |
| 102 | |
| 103 | switch (instance_type) { |
| 104 | case MAP_TYPE: |
| 105 | Map::cast(this)->MapPrint(); |
| 106 | break; |
| 107 | case HEAP_NUMBER_TYPE: |
| 108 | HeapNumber::cast(this)->HeapNumberPrint(); |
| 109 | break; |
| 110 | case FIXED_ARRAY_TYPE: |
| 111 | FixedArray::cast(this)->FixedArrayPrint(); |
| 112 | break; |
| 113 | case BYTE_ARRAY_TYPE: |
| 114 | ByteArray::cast(this)->ByteArrayPrint(); |
| 115 | break; |
| 116 | case FILLER_TYPE: |
| 117 | PrintF("filler"); |
| 118 | break; |
| 119 | case JS_OBJECT_TYPE: // fall through |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 120 | case JS_CONTEXT_EXTENSION_OBJECT_TYPE: |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 121 | case JS_ARRAY_TYPE: |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 122 | case JS_REGEXP_TYPE: |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 123 | JSObject::cast(this)->JSObjectPrint(); |
| 124 | break; |
| 125 | case ODDBALL_TYPE: |
| 126 | Oddball::cast(this)->to_string()->Print(); |
| 127 | break; |
| 128 | case JS_FUNCTION_TYPE: |
| 129 | JSFunction::cast(this)->JSFunctionPrint(); |
| 130 | break; |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 131 | case JS_GLOBAL_PROXY_TYPE: |
| 132 | JSGlobalProxy::cast(this)->JSGlobalProxyPrint(); |
| 133 | break; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 134 | case JS_GLOBAL_OBJECT_TYPE: |
| 135 | JSGlobalObject::cast(this)->JSGlobalObjectPrint(); |
| 136 | break; |
| 137 | case JS_BUILTINS_OBJECT_TYPE: |
| 138 | JSBuiltinsObject::cast(this)->JSBuiltinsObjectPrint(); |
| 139 | break; |
| 140 | case JS_VALUE_TYPE: |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 141 | PrintF("Value wrapper around:"); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 142 | JSValue::cast(this)->value()->Print(); |
| 143 | break; |
| 144 | case CODE_TYPE: |
| 145 | Code::cast(this)->CodePrint(); |
| 146 | break; |
| 147 | case PROXY_TYPE: |
| 148 | Proxy::cast(this)->ProxyPrint(); |
| 149 | break; |
| 150 | case SHARED_FUNCTION_INFO_TYPE: |
| 151 | SharedFunctionInfo::cast(this)->SharedFunctionInfoPrint(); |
| 152 | break; |
| 153 | |
| 154 | #define MAKE_STRUCT_CASE(NAME, Name, name) \ |
| 155 | case NAME##_TYPE: \ |
| 156 | Name::cast(this)->Name##Print(); \ |
| 157 | break; |
| 158 | STRUCT_LIST(MAKE_STRUCT_CASE) |
| 159 | #undef MAKE_STRUCT_CASE |
| 160 | |
| 161 | default: |
| 162 | PrintF("UNKNOWN TYPE %d", map()->instance_type()); |
| 163 | UNREACHABLE(); |
| 164 | break; |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | |
| 169 | void HeapObject::HeapObjectVerify() { |
| 170 | InstanceType instance_type = map()->instance_type(); |
| 171 | |
| 172 | if (instance_type < FIRST_NONSTRING_TYPE) { |
| 173 | String::cast(this)->StringVerify(); |
| 174 | return; |
| 175 | } |
| 176 | |
| 177 | switch (instance_type) { |
| 178 | case MAP_TYPE: |
| 179 | Map::cast(this)->MapVerify(); |
| 180 | break; |
| 181 | case HEAP_NUMBER_TYPE: |
| 182 | HeapNumber::cast(this)->HeapNumberVerify(); |
| 183 | break; |
| 184 | case FIXED_ARRAY_TYPE: |
| 185 | FixedArray::cast(this)->FixedArrayVerify(); |
| 186 | break; |
| 187 | case BYTE_ARRAY_TYPE: |
| 188 | ByteArray::cast(this)->ByteArrayVerify(); |
| 189 | break; |
| 190 | case CODE_TYPE: |
| 191 | Code::cast(this)->CodeVerify(); |
| 192 | break; |
| 193 | case ODDBALL_TYPE: |
| 194 | Oddball::cast(this)->OddballVerify(); |
| 195 | break; |
| 196 | case JS_OBJECT_TYPE: |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 197 | case JS_CONTEXT_EXTENSION_OBJECT_TYPE: |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 198 | JSObject::cast(this)->JSObjectVerify(); |
| 199 | break; |
| 200 | case JS_VALUE_TYPE: |
| 201 | JSValue::cast(this)->JSValueVerify(); |
| 202 | break; |
| 203 | case JS_FUNCTION_TYPE: |
| 204 | JSFunction::cast(this)->JSFunctionVerify(); |
| 205 | break; |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 206 | case JS_GLOBAL_PROXY_TYPE: |
| 207 | JSGlobalProxy::cast(this)->JSGlobalProxyVerify(); |
| 208 | break; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 209 | case JS_GLOBAL_OBJECT_TYPE: |
| 210 | JSGlobalObject::cast(this)->JSGlobalObjectVerify(); |
| 211 | break; |
| 212 | case JS_BUILTINS_OBJECT_TYPE: |
| 213 | JSBuiltinsObject::cast(this)->JSBuiltinsObjectVerify(); |
| 214 | break; |
| 215 | case JS_ARRAY_TYPE: |
| 216 | JSArray::cast(this)->JSArrayVerify(); |
| 217 | break; |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 218 | case JS_REGEXP_TYPE: |
| 219 | JSRegExp::cast(this)->JSRegExpVerify(); |
| 220 | break; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 221 | case FILLER_TYPE: |
| 222 | break; |
| 223 | case PROXY_TYPE: |
| 224 | Proxy::cast(this)->ProxyVerify(); |
| 225 | break; |
| 226 | case SHARED_FUNCTION_INFO_TYPE: |
| 227 | SharedFunctionInfo::cast(this)->SharedFunctionInfoVerify(); |
| 228 | break; |
| 229 | |
| 230 | #define MAKE_STRUCT_CASE(NAME, Name, name) \ |
| 231 | case NAME##_TYPE: \ |
| 232 | Name::cast(this)->Name##Verify(); \ |
| 233 | break; |
| 234 | STRUCT_LIST(MAKE_STRUCT_CASE) |
| 235 | #undef MAKE_STRUCT_CASE |
| 236 | |
| 237 | default: |
| 238 | UNREACHABLE(); |
| 239 | break; |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | |
| 244 | void HeapObject::VerifyHeapPointer(Object* p) { |
| 245 | ASSERT(p->IsHeapObject()); |
| 246 | ASSERT(Heap::Contains(HeapObject::cast(p))); |
| 247 | } |
| 248 | |
| 249 | |
| 250 | void HeapNumber::HeapNumberVerify() { |
| 251 | ASSERT(IsHeapNumber()); |
| 252 | } |
| 253 | |
| 254 | |
| 255 | void ByteArray::ByteArrayPrint() { |
| 256 | PrintF("byte array, data starts at %p", GetDataStartAddress()); |
| 257 | } |
| 258 | |
| 259 | |
| 260 | void ByteArray::ByteArrayVerify() { |
| 261 | ASSERT(IsByteArray()); |
| 262 | } |
| 263 | |
| 264 | |
| 265 | void JSObject::PrintProperties() { |
| 266 | if (HasFastProperties()) { |
| 267 | for (DescriptorReader r(map()->instance_descriptors()); |
| 268 | !r.eos(); |
| 269 | r.advance()) { |
| 270 | PrintF(" "); |
| 271 | r.GetKey()->StringPrint(); |
| 272 | PrintF(": "); |
| 273 | if (r.type() == FIELD) { |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 274 | FastPropertyAt(r.GetFieldIndex())->ShortPrint(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 275 | PrintF(" (field at offset %d)\n", r.GetFieldIndex()); |
| 276 | } else if (r.type() == CONSTANT_FUNCTION) { |
| 277 | r.GetConstantFunction()->ShortPrint(); |
| 278 | PrintF(" (constant function)\n"); |
| 279 | } else if (r.type() == CALLBACKS) { |
| 280 | r.GetCallbacksObject()->ShortPrint(); |
| 281 | PrintF(" (callback)\n"); |
| 282 | } else if (r.type() == MAP_TRANSITION) { |
| 283 | PrintF(" (map transition)\n"); |
ager@chromium.org | ddb913d | 2009-01-27 10:01:48 +0000 | [diff] [blame] | 284 | } else if (r.type() == CONSTANT_TRANSITION) { |
| 285 | PrintF(" (constant transition)\n"); |
| 286 | } else if (r.type() == NULL_DESCRIPTOR) { |
| 287 | PrintF(" (null descriptor)\n"); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 288 | } else { |
| 289 | UNREACHABLE(); |
| 290 | } |
| 291 | } |
| 292 | } else { |
| 293 | property_dictionary()->Print(); |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | |
| 298 | void JSObject::PrintElements() { |
| 299 | if (HasFastElements()) { |
| 300 | FixedArray* p = FixedArray::cast(elements()); |
| 301 | for (int i = 0; i < p->length(); i++) { |
| 302 | PrintF(" %d: ", i); |
| 303 | p->get(i)->ShortPrint(); |
| 304 | PrintF("\n"); |
| 305 | } |
| 306 | } else { |
| 307 | elements()->Print(); |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | |
| 312 | void JSObject::JSObjectPrint() { |
| 313 | PrintF("%p: [JSObject]\n", this); |
| 314 | PrintF(" - map = %p\n", map()); |
| 315 | PrintF(" - prototype = %p\n", GetPrototype()); |
| 316 | PrintF(" {\n"); |
| 317 | PrintProperties(); |
| 318 | PrintElements(); |
| 319 | PrintF(" }\n"); |
| 320 | } |
| 321 | |
| 322 | |
| 323 | void JSObject::JSObjectVerify() { |
| 324 | VerifyHeapPointer(properties()); |
| 325 | VerifyHeapPointer(elements()); |
| 326 | if (HasFastProperties()) { |
| 327 | CHECK(map()->unused_property_fields() == |
ager@chromium.org | 7c537e2 | 2008-10-16 08:43:32 +0000 | [diff] [blame] | 328 | (map()->inobject_properties() + properties()->length() - |
| 329 | map()->NextFreePropertyIndex())); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 330 | } |
| 331 | } |
| 332 | |
| 333 | |
| 334 | static const char* TypeToString(InstanceType type) { |
| 335 | switch (type) { |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 336 | case INVALID_TYPE: return "INVALID"; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 337 | case MAP_TYPE: return "MAP"; |
| 338 | case HEAP_NUMBER_TYPE: return "HEAP_NUMBER"; |
| 339 | case SHORT_SYMBOL_TYPE: |
| 340 | case MEDIUM_SYMBOL_TYPE: |
| 341 | case LONG_SYMBOL_TYPE: return "SYMBOL"; |
| 342 | case SHORT_ASCII_SYMBOL_TYPE: |
| 343 | case MEDIUM_ASCII_SYMBOL_TYPE: |
| 344 | case LONG_ASCII_SYMBOL_TYPE: return "ASCII_SYMBOL"; |
| 345 | case SHORT_SLICED_SYMBOL_TYPE: |
| 346 | case MEDIUM_SLICED_SYMBOL_TYPE: |
| 347 | case LONG_SLICED_SYMBOL_TYPE: return "SLICED_SYMBOL"; |
| 348 | case SHORT_SLICED_ASCII_SYMBOL_TYPE: |
| 349 | case MEDIUM_SLICED_ASCII_SYMBOL_TYPE: |
| 350 | case LONG_SLICED_ASCII_SYMBOL_TYPE: return "SLICED_ASCII_SYMBOL"; |
| 351 | case SHORT_CONS_SYMBOL_TYPE: |
| 352 | case MEDIUM_CONS_SYMBOL_TYPE: |
| 353 | case LONG_CONS_SYMBOL_TYPE: return "CONS_SYMBOL"; |
| 354 | case SHORT_CONS_ASCII_SYMBOL_TYPE: |
| 355 | case MEDIUM_CONS_ASCII_SYMBOL_TYPE: |
| 356 | case LONG_CONS_ASCII_SYMBOL_TYPE: return "CONS_ASCII_SYMBOL"; |
| 357 | case SHORT_EXTERNAL_ASCII_SYMBOL_TYPE: |
| 358 | case MEDIUM_EXTERNAL_ASCII_SYMBOL_TYPE: |
| 359 | case LONG_EXTERNAL_ASCII_SYMBOL_TYPE: |
| 360 | case SHORT_EXTERNAL_SYMBOL_TYPE: |
| 361 | case MEDIUM_EXTERNAL_SYMBOL_TYPE: |
| 362 | case LONG_EXTERNAL_SYMBOL_TYPE: return "EXTERNAL_SYMBOL"; |
| 363 | case SHORT_ASCII_STRING_TYPE: |
| 364 | case MEDIUM_ASCII_STRING_TYPE: |
| 365 | case LONG_ASCII_STRING_TYPE: return "ASCII_STRING"; |
| 366 | case SHORT_STRING_TYPE: |
| 367 | case MEDIUM_STRING_TYPE: |
| 368 | case LONG_STRING_TYPE: return "TWO_BYTE_STRING"; |
| 369 | case SHORT_CONS_STRING_TYPE: |
| 370 | case MEDIUM_CONS_STRING_TYPE: |
| 371 | case LONG_CONS_STRING_TYPE: |
| 372 | case SHORT_CONS_ASCII_STRING_TYPE: |
| 373 | case MEDIUM_CONS_ASCII_STRING_TYPE: |
| 374 | case LONG_CONS_ASCII_STRING_TYPE: return "CONS_STRING"; |
| 375 | case SHORT_SLICED_STRING_TYPE: |
| 376 | case MEDIUM_SLICED_STRING_TYPE: |
| 377 | case LONG_SLICED_STRING_TYPE: |
| 378 | case SHORT_SLICED_ASCII_STRING_TYPE: |
| 379 | case MEDIUM_SLICED_ASCII_STRING_TYPE: |
| 380 | case LONG_SLICED_ASCII_STRING_TYPE: return "SLICED_STRING"; |
| 381 | case SHORT_EXTERNAL_ASCII_STRING_TYPE: |
| 382 | case MEDIUM_EXTERNAL_ASCII_STRING_TYPE: |
| 383 | case LONG_EXTERNAL_ASCII_STRING_TYPE: |
| 384 | case SHORT_EXTERNAL_STRING_TYPE: |
| 385 | case MEDIUM_EXTERNAL_STRING_TYPE: |
| 386 | case LONG_EXTERNAL_STRING_TYPE: return "EXTERNAL_STRING"; |
| 387 | case FIXED_ARRAY_TYPE: return "FIXED_ARRAY"; |
| 388 | case BYTE_ARRAY_TYPE: return "BYTE_ARRAY"; |
| 389 | case FILLER_TYPE: return "FILLER"; |
| 390 | case JS_OBJECT_TYPE: return "JS_OBJECT"; |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 391 | case JS_CONTEXT_EXTENSION_OBJECT_TYPE: return "JS_CONTEXT_EXTENSION_OBJECT"; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 392 | case ODDBALL_TYPE: return "ODDBALL"; |
| 393 | case SHARED_FUNCTION_INFO_TYPE: return "SHARED_FUNCTION_INFO"; |
| 394 | case JS_FUNCTION_TYPE: return "JS_FUNCTION"; |
| 395 | case CODE_TYPE: return "CODE"; |
| 396 | case JS_ARRAY_TYPE: return "JS_ARRAY"; |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 397 | case JS_REGEXP_TYPE: return "JS_REGEXP"; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 398 | case JS_VALUE_TYPE: return "JS_VALUE"; |
| 399 | case JS_GLOBAL_OBJECT_TYPE: return "JS_GLOBAL_OBJECT"; |
| 400 | case JS_BUILTINS_OBJECT_TYPE: return "JS_BUILTINS_OBJECT"; |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 401 | case JS_GLOBAL_PROXY_TYPE: return "JS_GLOBAL_PROXY"; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 402 | case PROXY_TYPE: return "PROXY"; |
| 403 | case SMI_TYPE: return "SMI"; |
| 404 | #define MAKE_STRUCT_CASE(NAME, Name, name) case NAME##_TYPE: return #NAME; |
| 405 | STRUCT_LIST(MAKE_STRUCT_CASE) |
| 406 | #undef MAKE_STRUCT_CASE |
| 407 | } |
| 408 | return "UNKNOWN"; |
| 409 | } |
| 410 | |
| 411 | |
| 412 | void Map::MapPrint() { |
| 413 | HeapObject::PrintHeader("Map"); |
| 414 | PrintF(" - type: %s\n", TypeToString(instance_type())); |
| 415 | PrintF(" - instance size: %d\n", instance_size()); |
| 416 | PrintF(" - unused property fields: %d\n", unused_property_fields()); |
ager@chromium.org | ddb913d | 2009-01-27 10:01:48 +0000 | [diff] [blame] | 417 | if (is_hidden_prototype()) { |
| 418 | PrintF(" - hidden_prototype\n"); |
| 419 | } |
| 420 | if (has_named_interceptor()) { |
| 421 | PrintF(" - named_interceptor\n"); |
| 422 | } |
| 423 | if (has_indexed_interceptor()) { |
| 424 | PrintF(" - indexed_interceptor\n"); |
| 425 | } |
| 426 | if (is_undetectable()) { |
| 427 | PrintF(" - undetectable\n"); |
| 428 | } |
| 429 | if (has_instance_call_handler()) { |
| 430 | PrintF(" - instance_call_handler\n"); |
| 431 | } |
| 432 | if (is_access_check_needed()) { |
| 433 | PrintF(" - access_check_needed\n"); |
| 434 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 435 | PrintF(" - instance descriptors: "); |
| 436 | instance_descriptors()->ShortPrint(); |
| 437 | PrintF("\n - prototype: "); |
| 438 | prototype()->ShortPrint(); |
| 439 | PrintF("\n - constructor: "); |
| 440 | constructor()->ShortPrint(); |
| 441 | PrintF("\n"); |
| 442 | } |
| 443 | |
| 444 | |
| 445 | void Map::MapVerify() { |
| 446 | ASSERT(!Heap::InNewSpace(this)); |
| 447 | ASSERT(FIRST_TYPE <= instance_type() && instance_type() <= LAST_TYPE); |
| 448 | ASSERT(kPointerSize <= instance_size() |
| 449 | && instance_size() < Heap::Capacity()); |
| 450 | VerifyHeapPointer(prototype()); |
| 451 | VerifyHeapPointer(instance_descriptors()); |
| 452 | } |
| 453 | |
| 454 | |
| 455 | void FixedArray::FixedArrayPrint() { |
| 456 | HeapObject::PrintHeader("FixedArray"); |
| 457 | PrintF(" - length: %d", length()); |
| 458 | for (int i = 0; i < length(); i++) { |
| 459 | PrintF("\n [%d]: ", i); |
| 460 | get(i)->ShortPrint(); |
| 461 | } |
| 462 | PrintF("\n"); |
| 463 | } |
| 464 | |
| 465 | |
| 466 | void FixedArray::FixedArrayVerify() { |
| 467 | for (int i = 0; i < length(); i++) { |
| 468 | Object* e = get(i); |
| 469 | if (e->IsHeapObject()) { |
| 470 | VerifyHeapPointer(e); |
| 471 | } else { |
| 472 | e->Verify(); |
| 473 | } |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | |
| 478 | void JSValue::JSValuePrint() { |
| 479 | HeapObject::PrintHeader("ValueObject"); |
| 480 | value()->Print(); |
| 481 | } |
| 482 | |
| 483 | |
| 484 | void JSValue::JSValueVerify() { |
| 485 | Object* v = value(); |
| 486 | if (v->IsHeapObject()) { |
| 487 | VerifyHeapPointer(v); |
| 488 | } |
| 489 | } |
| 490 | |
| 491 | |
| 492 | void String::StringPrint() { |
ager@chromium.org | 870a0b6 | 2008-11-04 11:43:05 +0000 | [diff] [blame] | 493 | StringShape shape(this); |
| 494 | if (shape.IsSymbol()) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 495 | PrintF("#"); |
ager@chromium.org | 870a0b6 | 2008-11-04 11:43:05 +0000 | [diff] [blame] | 496 | } else if (shape.IsCons()) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 497 | PrintF("c\""); |
| 498 | } else { |
| 499 | PrintF("\""); |
| 500 | } |
| 501 | |
| 502 | for (int i = 0; i < length(); i++) { |
ager@chromium.org | 870a0b6 | 2008-11-04 11:43:05 +0000 | [diff] [blame] | 503 | PrintF("%c", Get(shape, i)); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 504 | } |
| 505 | |
ager@chromium.org | 870a0b6 | 2008-11-04 11:43:05 +0000 | [diff] [blame] | 506 | if (!shape.IsSymbol()) PrintF("\""); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 507 | } |
| 508 | |
| 509 | |
| 510 | void String::StringVerify() { |
| 511 | CHECK(IsString()); |
| 512 | CHECK(length() >= 0 && length() <= Smi::kMaxValue); |
| 513 | if (IsSymbol()) { |
| 514 | CHECK(!Heap::InNewSpace(this)); |
| 515 | } |
| 516 | } |
| 517 | |
| 518 | |
| 519 | void JSFunction::JSFunctionPrint() { |
| 520 | HeapObject::PrintHeader("Function"); |
| 521 | PrintF(" - map = 0x%p\n", map()); |
| 522 | PrintF(" - is boilerplate: %s\n", IsBoilerplate() ? "yes" : "no"); |
| 523 | PrintF(" - initial_map = "); |
| 524 | if (has_initial_map()) { |
| 525 | initial_map()->ShortPrint(); |
| 526 | } |
| 527 | PrintF("\n - shared_info = "); |
| 528 | shared()->ShortPrint(); |
| 529 | PrintF("\n - name = "); |
| 530 | shared()->name()->Print(); |
| 531 | PrintF("\n - context = "); |
| 532 | unchecked_context()->ShortPrint(); |
| 533 | PrintF("\n - code = "); |
| 534 | code()->ShortPrint(); |
| 535 | PrintF("\n"); |
| 536 | |
| 537 | PrintProperties(); |
| 538 | PrintElements(); |
| 539 | |
| 540 | PrintF("\n"); |
| 541 | } |
| 542 | |
| 543 | |
| 544 | void JSFunction::JSFunctionVerify() { |
| 545 | CHECK(IsJSFunction()); |
| 546 | VerifyObjectField(kPrototypeOrInitialMapOffset); |
| 547 | } |
| 548 | |
| 549 | |
| 550 | void SharedFunctionInfo::SharedFunctionInfoPrint() { |
| 551 | HeapObject::PrintHeader("SharedFunctionInfo"); |
| 552 | PrintF(" - name: "); |
| 553 | name()->ShortPrint(); |
| 554 | PrintF("\n - expected_nof_properties: %d", expected_nof_properties()); |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 555 | PrintF("\n - instance class name = "); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 556 | instance_class_name()->Print(); |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 557 | PrintF("\n - code = "); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 558 | code()->ShortPrint(); |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 559 | PrintF("\n - source code = "); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 560 | GetSourceCode()->ShortPrint(); |
| 561 | PrintF("\n - lazy load: %s", |
| 562 | lazy_load_data() == Heap::undefined_value() ? "no" : "yes"); |
| 563 | // Script files are often large, hard to read. |
| 564 | // PrintF("\n - script ="); |
| 565 | // script()->Print(); |
| 566 | PrintF("\n - function token position = %d", function_token_position()); |
| 567 | PrintF("\n - start position = %d", start_position()); |
| 568 | PrintF("\n - end position = %d", end_position()); |
| 569 | PrintF("\n - is expression = %d", is_expression()); |
| 570 | PrintF("\n - debug info = "); |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 571 | debug_info()->ShortPrint(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 572 | PrintF("\n - length = %d", length()); |
| 573 | PrintF("\n"); |
| 574 | } |
| 575 | |
| 576 | void SharedFunctionInfo::SharedFunctionInfoVerify() { |
| 577 | CHECK(IsSharedFunctionInfo()); |
| 578 | VerifyObjectField(kNameOffset); |
| 579 | VerifyObjectField(kCodeOffset); |
| 580 | VerifyObjectField(kInstanceClassNameOffset); |
| 581 | VerifyObjectField(kExternalReferenceDataOffset); |
| 582 | VerifyObjectField(kLazyLoadDataOffset); |
| 583 | VerifyObjectField(kScriptOffset); |
| 584 | VerifyObjectField(kDebugInfoOffset); |
| 585 | } |
| 586 | |
| 587 | |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 588 | void JSGlobalProxy::JSGlobalProxyPrint() { |
| 589 | PrintF("global_proxy"); |
| 590 | JSObjectPrint(); |
| 591 | PrintF("context : "); |
| 592 | context()->ShortPrint(); |
| 593 | PrintF("\n"); |
| 594 | } |
| 595 | |
| 596 | |
| 597 | void JSGlobalProxy::JSGlobalProxyVerify() { |
| 598 | CHECK(IsJSGlobalProxy()); |
| 599 | JSObjectVerify(); |
| 600 | VerifyObjectField(JSGlobalProxy::kContextOffset); |
| 601 | // Make sure that this object has no properties, elements. |
| 602 | CHECK_EQ(0, properties()->length()); |
| 603 | CHECK_EQ(0, elements()->length()); |
| 604 | } |
| 605 | |
| 606 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 607 | void JSGlobalObject::JSGlobalObjectPrint() { |
| 608 | PrintF("global "); |
| 609 | JSObjectPrint(); |
kasperl@chromium.org | 5a8ca6c | 2008-10-23 13:57:19 +0000 | [diff] [blame] | 610 | PrintF("global context : "); |
| 611 | global_context()->ShortPrint(); |
| 612 | PrintF("\n"); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 613 | } |
| 614 | |
| 615 | |
| 616 | void JSGlobalObject::JSGlobalObjectVerify() { |
| 617 | CHECK(IsJSGlobalObject()); |
| 618 | JSObjectVerify(); |
| 619 | for (int i = GlobalObject::kBuiltinsOffset; |
| 620 | i < JSGlobalObject::kSize; |
| 621 | i += kPointerSize) { |
| 622 | VerifyObjectField(i); |
| 623 | } |
| 624 | } |
| 625 | |
| 626 | |
| 627 | void JSBuiltinsObject::JSBuiltinsObjectPrint() { |
| 628 | PrintF("builtins "); |
| 629 | JSObjectPrint(); |
| 630 | } |
| 631 | |
| 632 | |
| 633 | void JSBuiltinsObject::JSBuiltinsObjectVerify() { |
| 634 | CHECK(IsJSBuiltinsObject()); |
| 635 | JSObjectVerify(); |
| 636 | for (int i = GlobalObject::kBuiltinsOffset; |
| 637 | i < JSBuiltinsObject::kSize; |
| 638 | i += kPointerSize) { |
| 639 | VerifyObjectField(i); |
| 640 | } |
| 641 | } |
| 642 | |
| 643 | |
| 644 | void Oddball::OddballVerify() { |
| 645 | CHECK(IsOddball()); |
| 646 | VerifyHeapPointer(to_string()); |
| 647 | Object* number = to_number(); |
| 648 | if (number->IsHeapObject()) { |
| 649 | ASSERT(number == Heap::nan_value()); |
| 650 | } else { |
| 651 | ASSERT(number->IsSmi()); |
| 652 | int value = Smi::cast(number)->value(); |
| 653 | ASSERT(value == 0 || value == 1 || value == -1); |
| 654 | } |
| 655 | } |
| 656 | |
| 657 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 658 | void Code::CodePrint() { |
| 659 | HeapObject::PrintHeader("Code"); |
mads.s.ager | 31e7138 | 2008-08-13 09:32:07 +0000 | [diff] [blame] | 660 | #ifdef ENABLE_DISASSEMBLER |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame^] | 661 | Disassemble(NULL); |
mads.s.ager | 31e7138 | 2008-08-13 09:32:07 +0000 | [diff] [blame] | 662 | #endif |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 663 | } |
| 664 | |
| 665 | |
| 666 | void Code::CodeVerify() { |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 667 | CHECK(ic_flag() == IC_TARGET_IS_ADDRESS); |
kasperl@chromium.org | 061ef74 | 2009-02-27 12:16:20 +0000 | [diff] [blame] | 668 | CHECK(IsAligned(reinterpret_cast<intptr_t>(instruction_start()), |
| 669 | static_cast<intptr_t>(kCodeAlignment))); |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 670 | Address last_gc_pc = NULL; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 671 | for (RelocIterator it(this); !it.done(); it.next()) { |
| 672 | it.rinfo()->Verify(); |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 673 | // Ensure that GC will not iterate twice over the same pointer. |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 674 | if (RelocInfo::IsGCRelocMode(it.rinfo()->rmode())) { |
kasper.lund | 7276f14 | 2008-07-30 08:49:36 +0000 | [diff] [blame] | 675 | CHECK(it.rinfo()->pc() != last_gc_pc); |
| 676 | last_gc_pc = it.rinfo()->pc(); |
| 677 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 678 | } |
| 679 | } |
| 680 | |
| 681 | |
| 682 | void JSArray::JSArrayVerify() { |
| 683 | JSObjectVerify(); |
| 684 | ASSERT(length()->IsNumber() || length()->IsUndefined()); |
| 685 | ASSERT(elements()->IsUndefined() || elements()->IsFixedArray()); |
| 686 | } |
| 687 | |
| 688 | |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 689 | void JSRegExp::JSRegExpVerify() { |
| 690 | JSObjectVerify(); |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 691 | ASSERT(data()->IsUndefined() || data()->IsFixedArray()); |
| 692 | switch (TypeTag()) { |
| 693 | case JSRegExp::ATOM: { |
| 694 | FixedArray* arr = FixedArray::cast(data()); |
| 695 | ASSERT(arr->get(JSRegExp::kAtomPatternIndex)->IsString()); |
| 696 | break; |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 697 | } |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 698 | case JSRegExp::IRREGEXP: { |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame^] | 699 | bool is_native = FLAG_regexp_native; |
| 700 | #ifdef ARM |
| 701 | // No native regexp on arm yet. |
| 702 | is_native = false; |
| 703 | #endif |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 704 | FixedArray* arr = FixedArray::cast(data()); |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame^] | 705 | Object* ascii_data = arr->get(JSRegExp::kIrregexpASCIICodeIndex); |
| 706 | ASSERT(ascii_data->IsTheHole() |
| 707 | || (is_native ? ascii_data->IsCode() : ascii_data->IsByteArray())); |
| 708 | Object* uc16_data = arr->get(JSRegExp::kIrregexpUC16CodeIndex); |
| 709 | ASSERT(uc16_data->IsTheHole() |
| 710 | || (is_native ? uc16_data->IsCode() : uc16_data->IsByteArray())); |
| 711 | ASSERT(arr->get(JSRegExp::kIrregexpCaptureCountIndex)->IsSmi()); |
| 712 | ASSERT(arr->get(JSRegExp::kIrregexpMaxRegisterCountIndex)->IsSmi()); |
kasperl@chromium.org | 9fe21c6 | 2008-10-28 08:53:51 +0000 | [diff] [blame] | 713 | break; |
| 714 | } |
| 715 | default: |
| 716 | ASSERT_EQ(JSRegExp::NOT_COMPILED, TypeTag()); |
| 717 | ASSERT(data()->IsUndefined()); |
| 718 | break; |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 719 | } |
ager@chromium.org | 236ad96 | 2008-09-25 09:45:57 +0000 | [diff] [blame] | 720 | } |
| 721 | |
| 722 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 723 | void Proxy::ProxyPrint() { |
| 724 | PrintF("proxy to %p", proxy()); |
| 725 | } |
| 726 | |
| 727 | |
| 728 | void Proxy::ProxyVerify() { |
| 729 | ASSERT(IsProxy()); |
| 730 | } |
| 731 | |
| 732 | |
| 733 | void Dictionary::Print() { |
| 734 | int capacity = Capacity(); |
| 735 | for (int i = 0; i < capacity; i++) { |
| 736 | Object* k = KeyAt(i); |
| 737 | if (IsKey(k)) { |
| 738 | PrintF(" "); |
| 739 | if (k->IsString()) { |
| 740 | String::cast(k)->StringPrint(); |
| 741 | } else { |
| 742 | k->ShortPrint(); |
| 743 | } |
| 744 | PrintF(": "); |
| 745 | ValueAt(i)->ShortPrint(); |
| 746 | PrintF("\n"); |
| 747 | } |
| 748 | } |
| 749 | } |
| 750 | |
| 751 | |
| 752 | void AccessorInfo::AccessorInfoVerify() { |
| 753 | CHECK(IsAccessorInfo()); |
| 754 | VerifyPointer(getter()); |
| 755 | VerifyPointer(setter()); |
| 756 | VerifyPointer(name()); |
| 757 | VerifyPointer(data()); |
| 758 | VerifyPointer(flag()); |
| 759 | } |
| 760 | |
| 761 | void AccessorInfo::AccessorInfoPrint() { |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 762 | HeapObject::PrintHeader("AccessorInfo"); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 763 | PrintF("\n - getter: "); |
| 764 | getter()->ShortPrint(); |
| 765 | PrintF("\n - setter: "); |
| 766 | setter()->ShortPrint(); |
| 767 | PrintF("\n - name: "); |
| 768 | name()->ShortPrint(); |
| 769 | PrintF("\n - data: "); |
| 770 | data()->ShortPrint(); |
| 771 | PrintF("\n - flag: "); |
| 772 | flag()->ShortPrint(); |
| 773 | } |
| 774 | |
| 775 | void AccessCheckInfo::AccessCheckInfoVerify() { |
| 776 | CHECK(IsAccessCheckInfo()); |
| 777 | VerifyPointer(named_callback()); |
| 778 | VerifyPointer(indexed_callback()); |
| 779 | VerifyPointer(data()); |
| 780 | } |
| 781 | |
| 782 | void AccessCheckInfo::AccessCheckInfoPrint() { |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 783 | HeapObject::PrintHeader("AccessCheckInfo"); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 784 | PrintF("\n - named_callback: "); |
| 785 | named_callback()->ShortPrint(); |
| 786 | PrintF("\n - indexed_callback: "); |
| 787 | indexed_callback()->ShortPrint(); |
| 788 | PrintF("\n - data: "); |
| 789 | data()->ShortPrint(); |
| 790 | } |
| 791 | |
| 792 | void InterceptorInfo::InterceptorInfoVerify() { |
| 793 | CHECK(IsInterceptorInfo()); |
| 794 | VerifyPointer(getter()); |
| 795 | VerifyPointer(setter()); |
| 796 | VerifyPointer(query()); |
| 797 | VerifyPointer(deleter()); |
| 798 | VerifyPointer(enumerator()); |
| 799 | VerifyPointer(data()); |
| 800 | } |
| 801 | |
| 802 | void InterceptorInfo::InterceptorInfoPrint() { |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 803 | HeapObject::PrintHeader("InterceptorInfo"); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 804 | PrintF("\n - getter: "); |
| 805 | getter()->ShortPrint(); |
| 806 | PrintF("\n - setter: "); |
| 807 | setter()->ShortPrint(); |
| 808 | PrintF("\n - query: "); |
| 809 | query()->ShortPrint(); |
| 810 | PrintF("\n - deleter: "); |
| 811 | deleter()->ShortPrint(); |
| 812 | PrintF("\n - enumerator: "); |
| 813 | enumerator()->ShortPrint(); |
| 814 | PrintF("\n - data: "); |
| 815 | data()->ShortPrint(); |
| 816 | } |
| 817 | |
| 818 | void CallHandlerInfo::CallHandlerInfoVerify() { |
| 819 | CHECK(IsCallHandlerInfo()); |
| 820 | VerifyPointer(callback()); |
| 821 | VerifyPointer(data()); |
| 822 | } |
| 823 | |
| 824 | void CallHandlerInfo::CallHandlerInfoPrint() { |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 825 | HeapObject::PrintHeader("CallHandlerInfo"); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 826 | PrintF("\n - callback: "); |
| 827 | callback()->ShortPrint(); |
| 828 | PrintF("\n - data: "); |
| 829 | data()->ShortPrint(); |
| 830 | } |
| 831 | |
| 832 | void TemplateInfo::TemplateInfoVerify() { |
| 833 | VerifyPointer(tag()); |
| 834 | VerifyPointer(property_list()); |
| 835 | } |
| 836 | |
| 837 | void FunctionTemplateInfo::FunctionTemplateInfoVerify() { |
| 838 | CHECK(IsFunctionTemplateInfo()); |
| 839 | TemplateInfoVerify(); |
| 840 | VerifyPointer(serial_number()); |
| 841 | VerifyPointer(call_code()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 842 | VerifyPointer(property_accessors()); |
| 843 | VerifyPointer(prototype_template()); |
| 844 | VerifyPointer(parent_template()); |
| 845 | VerifyPointer(named_property_handler()); |
| 846 | VerifyPointer(indexed_property_handler()); |
| 847 | VerifyPointer(instance_template()); |
| 848 | VerifyPointer(signature()); |
| 849 | VerifyPointer(access_check_info()); |
| 850 | } |
| 851 | |
| 852 | void FunctionTemplateInfo::FunctionTemplateInfoPrint() { |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 853 | HeapObject::PrintHeader("FunctionTemplateInfo"); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 854 | PrintF("\n - tag: "); |
| 855 | tag()->ShortPrint(); |
| 856 | PrintF("\n - property_list: "); |
| 857 | property_list()->ShortPrint(); |
| 858 | PrintF("\n - serial_number: "); |
| 859 | serial_number()->ShortPrint(); |
| 860 | PrintF("\n - call_code: "); |
| 861 | call_code()->ShortPrint(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 862 | PrintF("\n - property_accessors: "); |
| 863 | property_accessors()->ShortPrint(); |
| 864 | PrintF("\n - prototype_template: "); |
| 865 | prototype_template()->ShortPrint(); |
| 866 | PrintF("\n - parent_template: "); |
| 867 | parent_template()->ShortPrint(); |
| 868 | PrintF("\n - named_property_handler: "); |
| 869 | named_property_handler()->ShortPrint(); |
| 870 | PrintF("\n - indexed_property_handler: "); |
| 871 | indexed_property_handler()->ShortPrint(); |
| 872 | PrintF("\n - instance_template: "); |
| 873 | instance_template()->ShortPrint(); |
| 874 | PrintF("\n - signature: "); |
| 875 | signature()->ShortPrint(); |
| 876 | PrintF("\n - access_check_info: "); |
| 877 | access_check_info()->ShortPrint(); |
| 878 | PrintF("\n - hidden_prototype: %s", hidden_prototype() ? "true" : "false"); |
| 879 | PrintF("\n - undetectable: %s", undetectable() ? "true" : "false"); |
| 880 | PrintF("\n - need_access_check: %s", needs_access_check() ? "true" : "false"); |
| 881 | } |
| 882 | |
| 883 | void ObjectTemplateInfo::ObjectTemplateInfoVerify() { |
| 884 | CHECK(IsObjectTemplateInfo()); |
| 885 | TemplateInfoVerify(); |
| 886 | VerifyPointer(constructor()); |
kasper.lund | 212ac23 | 2008-07-16 07:07:30 +0000 | [diff] [blame] | 887 | VerifyPointer(internal_field_count()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 888 | } |
| 889 | |
| 890 | void ObjectTemplateInfo::ObjectTemplateInfoPrint() { |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 891 | HeapObject::PrintHeader("ObjectTemplateInfo"); |
kasper.lund | 212ac23 | 2008-07-16 07:07:30 +0000 | [diff] [blame] | 892 | PrintF("\n - constructor: "); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 893 | constructor()->ShortPrint(); |
kasper.lund | 212ac23 | 2008-07-16 07:07:30 +0000 | [diff] [blame] | 894 | PrintF("\n - internal_field_count: "); |
| 895 | internal_field_count()->ShortPrint(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 896 | } |
| 897 | |
| 898 | void SignatureInfo::SignatureInfoVerify() { |
| 899 | CHECK(IsSignatureInfo()); |
| 900 | VerifyPointer(receiver()); |
| 901 | VerifyPointer(args()); |
| 902 | } |
| 903 | |
| 904 | void SignatureInfo::SignatureInfoPrint() { |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 905 | HeapObject::PrintHeader("SignatureInfo"); |
kasper.lund | 212ac23 | 2008-07-16 07:07:30 +0000 | [diff] [blame] | 906 | PrintF("\n - receiver: "); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 907 | receiver()->ShortPrint(); |
kasper.lund | 212ac23 | 2008-07-16 07:07:30 +0000 | [diff] [blame] | 908 | PrintF("\n - args: "); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 909 | args()->ShortPrint(); |
| 910 | } |
| 911 | |
| 912 | void TypeSwitchInfo::TypeSwitchInfoVerify() { |
| 913 | CHECK(IsTypeSwitchInfo()); |
| 914 | VerifyPointer(types()); |
| 915 | } |
| 916 | |
| 917 | void TypeSwitchInfo::TypeSwitchInfoPrint() { |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 918 | HeapObject::PrintHeader("TypeSwitchInfo"); |
kasper.lund | 212ac23 | 2008-07-16 07:07:30 +0000 | [diff] [blame] | 919 | PrintF("\n - types: "); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 920 | types()->ShortPrint(); |
| 921 | } |
| 922 | |
| 923 | |
| 924 | void Script::ScriptVerify() { |
| 925 | CHECK(IsScript()); |
| 926 | VerifyPointer(source()); |
| 927 | VerifyPointer(name()); |
| 928 | line_offset()->SmiVerify(); |
| 929 | column_offset()->SmiVerify(); |
| 930 | type()->SmiVerify(); |
| 931 | } |
| 932 | |
| 933 | |
| 934 | void Script::ScriptPrint() { |
| 935 | HeapObject::PrintHeader("Script"); |
| 936 | PrintF("\n - source: "); |
| 937 | source()->ShortPrint(); |
| 938 | PrintF("\n - name: "); |
| 939 | name()->ShortPrint(); |
| 940 | PrintF("\n - line_offset: "); |
| 941 | line_offset()->ShortPrint(); |
| 942 | PrintF("\n - column_offset: "); |
| 943 | column_offset()->ShortPrint(); |
| 944 | PrintF("\n - type: "); |
| 945 | type()->ShortPrint(); |
| 946 | PrintF("\n"); |
| 947 | } |
| 948 | |
| 949 | |
| 950 | void DebugInfo::DebugInfoVerify() { |
| 951 | CHECK(IsDebugInfo()); |
| 952 | VerifyPointer(shared()); |
| 953 | VerifyPointer(original_code()); |
| 954 | VerifyPointer(code()); |
| 955 | VerifyPointer(break_points()); |
| 956 | } |
| 957 | |
| 958 | |
| 959 | void DebugInfo::DebugInfoPrint() { |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 960 | HeapObject::PrintHeader("DebugInfo"); |
| 961 | PrintF("\n - shared: "); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 962 | shared()->ShortPrint(); |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 963 | PrintF("\n - original_code: "); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 964 | original_code()->ShortPrint(); |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 965 | PrintF("\n - code: "); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 966 | code()->ShortPrint(); |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 967 | PrintF("\n - break_points: "); |
| 968 | break_points()->Print(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 969 | } |
| 970 | |
| 971 | |
| 972 | void BreakPointInfo::BreakPointInfoVerify() { |
| 973 | CHECK(IsBreakPointInfo()); |
| 974 | code_position()->SmiVerify(); |
| 975 | source_position()->SmiVerify(); |
| 976 | statement_position()->SmiVerify(); |
| 977 | VerifyPointer(break_point_objects()); |
| 978 | } |
| 979 | |
| 980 | |
| 981 | void BreakPointInfo::BreakPointInfoPrint() { |
ager@chromium.org | 381abbb | 2009-02-25 13:23:22 +0000 | [diff] [blame] | 982 | HeapObject::PrintHeader("BreakPointInfo"); |
| 983 | PrintF("\n - code_position: %d", code_position()); |
| 984 | PrintF("\n - source_position: %d", source_position()); |
| 985 | PrintF("\n - statement_position: %d", statement_position()); |
| 986 | PrintF("\n - break_point_objects: "); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 987 | break_point_objects()->ShortPrint(); |
| 988 | } |
| 989 | |
| 990 | |
| 991 | void JSObject::IncrementSpillStatistics(SpillInformation* info) { |
| 992 | info->number_of_objects_++; |
| 993 | // Named properties |
| 994 | if (HasFastProperties()) { |
| 995 | info->number_of_objects_with_fast_properties_++; |
| 996 | info->number_of_fast_used_fields_ += map()->NextFreePropertyIndex(); |
| 997 | info->number_of_fast_unused_fields_ += map()->unused_property_fields(); |
| 998 | } else { |
| 999 | Dictionary* dict = property_dictionary(); |
| 1000 | info->number_of_slow_used_properties_ += dict->NumberOfElements(); |
| 1001 | info->number_of_slow_unused_properties_ += |
| 1002 | dict->Capacity() - dict->NumberOfElements(); |
| 1003 | } |
| 1004 | // Indexed properties |
| 1005 | if (HasFastElements()) { |
| 1006 | info->number_of_objects_with_fast_elements_++; |
| 1007 | int holes = 0; |
| 1008 | FixedArray* e = FixedArray::cast(elements()); |
| 1009 | int len = e->length(); |
| 1010 | for (int i = 0; i < len; i++) { |
| 1011 | if (e->get(i) == Heap::the_hole_value()) holes++; |
| 1012 | } |
| 1013 | info->number_of_fast_used_elements_ += len - holes; |
| 1014 | info->number_of_fast_unused_elements_ += holes; |
| 1015 | } else { |
| 1016 | Dictionary* dict = element_dictionary(); |
| 1017 | info->number_of_slow_used_elements_ += dict->NumberOfElements(); |
| 1018 | info->number_of_slow_unused_elements_ += |
| 1019 | dict->Capacity() - dict->NumberOfElements(); |
| 1020 | } |
| 1021 | } |
| 1022 | |
| 1023 | |
| 1024 | void JSObject::SpillInformation::Clear() { |
| 1025 | number_of_objects_ = 0; |
| 1026 | number_of_objects_with_fast_properties_ = 0; |
| 1027 | number_of_objects_with_fast_elements_ = 0; |
| 1028 | number_of_fast_used_fields_ = 0; |
| 1029 | number_of_fast_unused_fields_ = 0; |
| 1030 | number_of_slow_used_properties_ = 0; |
| 1031 | number_of_slow_unused_properties_ = 0; |
| 1032 | number_of_fast_used_elements_ = 0; |
| 1033 | number_of_fast_unused_elements_ = 0; |
| 1034 | number_of_slow_used_elements_ = 0; |
| 1035 | number_of_slow_unused_elements_ = 0; |
| 1036 | } |
| 1037 | |
| 1038 | void JSObject::SpillInformation::Print() { |
| 1039 | PrintF("\n JSObject Spill Statistics (#%d):\n", number_of_objects_); |
| 1040 | |
| 1041 | PrintF(" - fast properties (#%d): %d (used) %d (unused)\n", |
| 1042 | number_of_objects_with_fast_properties_, |
| 1043 | number_of_fast_used_fields_, number_of_fast_unused_fields_); |
| 1044 | |
| 1045 | PrintF(" - slow properties (#%d): %d (used) %d (unused)\n", |
| 1046 | number_of_objects_ - number_of_objects_with_fast_properties_, |
| 1047 | number_of_slow_used_properties_, number_of_slow_unused_properties_); |
| 1048 | |
| 1049 | PrintF(" - fast elements (#%d): %d (used) %d (unused)\n", |
| 1050 | number_of_objects_with_fast_elements_, |
| 1051 | number_of_fast_used_elements_, number_of_fast_unused_elements_); |
| 1052 | |
| 1053 | PrintF(" - slow elements (#%d): %d (used) %d (unused)\n", |
| 1054 | number_of_objects_ - number_of_objects_with_fast_elements_, |
| 1055 | number_of_slow_used_elements_, number_of_slow_unused_elements_); |
| 1056 | |
| 1057 | PrintF("\n"); |
| 1058 | } |
| 1059 | |
| 1060 | |
| 1061 | void DescriptorArray::PrintDescriptors() { |
| 1062 | PrintF("Descriptor array %d\n", number_of_descriptors()); |
| 1063 | int number = 0; |
| 1064 | for (DescriptorReader r(this); !r.eos(); r.advance()) { |
| 1065 | Descriptor desc; |
| 1066 | r.Get(&desc); |
| 1067 | PrintF(" %d: ", number++); |
| 1068 | desc.Print(); |
| 1069 | } |
| 1070 | PrintF("\n"); |
| 1071 | } |
| 1072 | |
| 1073 | |
mads.s.ager@gmail.com | 769cc96 | 2008-08-06 10:02:49 +0000 | [diff] [blame] | 1074 | bool DescriptorArray::IsSortedNoDuplicates() { |
| 1075 | String* current_key = NULL; |
| 1076 | uint32_t current = 0; |
| 1077 | for (DescriptorReader r(this); !r.eos(); r.advance()) { |
| 1078 | String* key = r.GetKey(); |
| 1079 | if (key == current_key) { |
| 1080 | PrintDescriptors(); |
| 1081 | return false; |
| 1082 | } |
| 1083 | current_key = key; |
| 1084 | uint32_t hash = r.GetKey()->Hash(); |
| 1085 | if (hash < current) { |
| 1086 | PrintDescriptors(); |
| 1087 | return false; |
| 1088 | } |
| 1089 | current = hash; |
| 1090 | } |
| 1091 | return true; |
| 1092 | } |
| 1093 | |
| 1094 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 1095 | #endif // DEBUG |
| 1096 | |
| 1097 | } } // namespace v8::internal |