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