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