| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 break; | 108 break; |
| 109 case HEAP_NUMBER_TYPE: | 109 case HEAP_NUMBER_TYPE: |
| 110 HeapNumber::cast(this)->HeapNumberPrint(); | 110 HeapNumber::cast(this)->HeapNumberPrint(); |
| 111 break; | 111 break; |
| 112 case FIXED_ARRAY_TYPE: | 112 case FIXED_ARRAY_TYPE: |
| 113 FixedArray::cast(this)->FixedArrayPrint(); | 113 FixedArray::cast(this)->FixedArrayPrint(); |
| 114 break; | 114 break; |
| 115 case BYTE_ARRAY_TYPE: | 115 case BYTE_ARRAY_TYPE: |
| 116 ByteArray::cast(this)->ByteArrayPrint(); | 116 ByteArray::cast(this)->ByteArrayPrint(); |
| 117 break; | 117 break; |
| 118 case PIXEL_ARRAY_TYPE: |
| 119 PixelArray::cast(this)->PixelArrayPrint(); |
| 120 break; |
| 118 case FILLER_TYPE: | 121 case FILLER_TYPE: |
| 119 PrintF("filler"); | 122 PrintF("filler"); |
| 120 break; | 123 break; |
| 121 case JS_OBJECT_TYPE: // fall through | 124 case JS_OBJECT_TYPE: // fall through |
| 122 case JS_CONTEXT_EXTENSION_OBJECT_TYPE: | 125 case JS_CONTEXT_EXTENSION_OBJECT_TYPE: |
| 123 case JS_ARRAY_TYPE: | 126 case JS_ARRAY_TYPE: |
| 124 case JS_REGEXP_TYPE: | 127 case JS_REGEXP_TYPE: |
| 125 JSObject::cast(this)->JSObjectPrint(); | 128 JSObject::cast(this)->JSObjectPrint(); |
| 126 break; | 129 break; |
| 127 case ODDBALL_TYPE: | 130 case ODDBALL_TYPE: |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 break; | 187 break; |
| 185 case HEAP_NUMBER_TYPE: | 188 case HEAP_NUMBER_TYPE: |
| 186 HeapNumber::cast(this)->HeapNumberVerify(); | 189 HeapNumber::cast(this)->HeapNumberVerify(); |
| 187 break; | 190 break; |
| 188 case FIXED_ARRAY_TYPE: | 191 case FIXED_ARRAY_TYPE: |
| 189 FixedArray::cast(this)->FixedArrayVerify(); | 192 FixedArray::cast(this)->FixedArrayVerify(); |
| 190 break; | 193 break; |
| 191 case BYTE_ARRAY_TYPE: | 194 case BYTE_ARRAY_TYPE: |
| 192 ByteArray::cast(this)->ByteArrayVerify(); | 195 ByteArray::cast(this)->ByteArrayVerify(); |
| 193 break; | 196 break; |
| 197 case PIXEL_ARRAY_TYPE: |
| 198 PixelArray::cast(this)->PixelArrayVerify(); |
| 199 break; |
| 194 case CODE_TYPE: | 200 case CODE_TYPE: |
| 195 Code::cast(this)->CodeVerify(); | 201 Code::cast(this)->CodeVerify(); |
| 196 break; | 202 break; |
| 197 case ODDBALL_TYPE: | 203 case ODDBALL_TYPE: |
| 198 Oddball::cast(this)->OddballVerify(); | 204 Oddball::cast(this)->OddballVerify(); |
| 199 break; | 205 break; |
| 200 case JS_OBJECT_TYPE: | 206 case JS_OBJECT_TYPE: |
| 201 case JS_CONTEXT_EXTENSION_OBJECT_TYPE: | 207 case JS_CONTEXT_EXTENSION_OBJECT_TYPE: |
| 202 JSObject::cast(this)->JSObjectVerify(); | 208 JSObject::cast(this)->JSObjectVerify(); |
| 203 break; | 209 break; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 void HeapNumber::HeapNumberVerify() { | 263 void HeapNumber::HeapNumberVerify() { |
| 258 ASSERT(IsHeapNumber()); | 264 ASSERT(IsHeapNumber()); |
| 259 } | 265 } |
| 260 | 266 |
| 261 | 267 |
| 262 void ByteArray::ByteArrayPrint() { | 268 void ByteArray::ByteArrayPrint() { |
| 263 PrintF("byte array, data starts at %p", GetDataStartAddress()); | 269 PrintF("byte array, data starts at %p", GetDataStartAddress()); |
| 264 } | 270 } |
| 265 | 271 |
| 266 | 272 |
| 273 void PixelArray::PixelArrayPrint() { |
| 274 PrintF("pixel array"); |
| 275 } |
| 276 |
| 277 |
| 267 void ByteArray::ByteArrayVerify() { | 278 void ByteArray::ByteArrayVerify() { |
| 268 ASSERT(IsByteArray()); | 279 ASSERT(IsByteArray()); |
| 269 } | 280 } |
| 270 | 281 |
| 271 | 282 |
| 283 void PixelArray::PixelArrayVerify() { |
| 284 ASSERT(IsPixelArray()); |
| 285 } |
| 286 |
| 287 |
| 272 void JSObject::PrintProperties() { | 288 void JSObject::PrintProperties() { |
| 273 if (HasFastProperties()) { | 289 if (HasFastProperties()) { |
| 274 DescriptorArray* descs = map()->instance_descriptors(); | 290 DescriptorArray* descs = map()->instance_descriptors(); |
| 275 for (int i = 0; i < descs->number_of_descriptors(); i++) { | 291 for (int i = 0; i < descs->number_of_descriptors(); i++) { |
| 276 PrintF(" "); | 292 PrintF(" "); |
| 277 descs->GetKey(i)->StringPrint(); | 293 descs->GetKey(i)->StringPrint(); |
| 278 PrintF(": "); | 294 PrintF(": "); |
| 279 switch (descs->GetType(i)) { | 295 switch (descs->GetType(i)) { |
| 280 case FIELD: { | 296 case FIELD: { |
| 281 int index = descs->GetFieldIndex(i); | 297 int index = descs->GetFieldIndex(i); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 305 break; | 321 break; |
| 306 } | 322 } |
| 307 } | 323 } |
| 308 } else { | 324 } else { |
| 309 property_dictionary()->Print(); | 325 property_dictionary()->Print(); |
| 310 } | 326 } |
| 311 } | 327 } |
| 312 | 328 |
| 313 | 329 |
| 314 void JSObject::PrintElements() { | 330 void JSObject::PrintElements() { |
| 315 if (HasFastElements()) { | 331 switch (GetElementsKind()) { |
| 316 FixedArray* p = FixedArray::cast(elements()); | 332 case FAST_ELEMENTS: { |
| 317 for (int i = 0; i < p->length(); i++) { | 333 // Print in array notation for non-sparse arrays. |
| 318 PrintF(" %d: ", i); | 334 FixedArray* p = FixedArray::cast(elements()); |
| 319 p->get(i)->ShortPrint(); | 335 for (int i = 0; i < p->length(); i++) { |
| 320 PrintF("\n"); | 336 PrintF(" %d: ", i); |
| 337 p->get(i)->ShortPrint(); |
| 338 PrintF("\n"); |
| 339 } |
| 340 break; |
| 321 } | 341 } |
| 322 } else { | 342 case PIXEL_ELEMENTS: { |
| 323 elements()->Print(); | 343 PixelArray* p = PixelArray::cast(elements()); |
| 344 for (int i = 0; i < p->length(); i++) { |
| 345 PrintF(" %d: %d\n", i, p->get(i)); |
| 346 } |
| 347 break; |
| 348 } |
| 349 case DICTIONARY_ELEMENTS: |
| 350 elements()->Print(); |
| 351 break; |
| 352 default: |
| 353 UNREACHABLE(); |
| 354 break; |
| 324 } | 355 } |
| 325 } | 356 } |
| 326 | 357 |
| 327 | 358 |
| 328 void JSObject::JSObjectPrint() { | 359 void JSObject::JSObjectPrint() { |
| 329 PrintF("%p: [JSObject]\n", this); | 360 PrintF("%p: [JSObject]\n", this); |
| 330 PrintF(" - map = %p\n", map()); | 361 PrintF(" - map = %p\n", map()); |
| 331 PrintF(" - prototype = %p\n", GetPrototype()); | 362 PrintF(" - prototype = %p\n", GetPrototype()); |
| 332 PrintF(" {\n"); | 363 PrintF(" {\n"); |
| 333 PrintProperties(); | 364 PrintProperties(); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 case MEDIUM_SLICED_ASCII_STRING_TYPE: | 426 case MEDIUM_SLICED_ASCII_STRING_TYPE: |
| 396 case LONG_SLICED_ASCII_STRING_TYPE: return "SLICED_STRING"; | 427 case LONG_SLICED_ASCII_STRING_TYPE: return "SLICED_STRING"; |
| 397 case SHORT_EXTERNAL_ASCII_STRING_TYPE: | 428 case SHORT_EXTERNAL_ASCII_STRING_TYPE: |
| 398 case MEDIUM_EXTERNAL_ASCII_STRING_TYPE: | 429 case MEDIUM_EXTERNAL_ASCII_STRING_TYPE: |
| 399 case LONG_EXTERNAL_ASCII_STRING_TYPE: | 430 case LONG_EXTERNAL_ASCII_STRING_TYPE: |
| 400 case SHORT_EXTERNAL_STRING_TYPE: | 431 case SHORT_EXTERNAL_STRING_TYPE: |
| 401 case MEDIUM_EXTERNAL_STRING_TYPE: | 432 case MEDIUM_EXTERNAL_STRING_TYPE: |
| 402 case LONG_EXTERNAL_STRING_TYPE: return "EXTERNAL_STRING"; | 433 case LONG_EXTERNAL_STRING_TYPE: return "EXTERNAL_STRING"; |
| 403 case FIXED_ARRAY_TYPE: return "FIXED_ARRAY"; | 434 case FIXED_ARRAY_TYPE: return "FIXED_ARRAY"; |
| 404 case BYTE_ARRAY_TYPE: return "BYTE_ARRAY"; | 435 case BYTE_ARRAY_TYPE: return "BYTE_ARRAY"; |
| 436 case PIXEL_ARRAY_TYPE: return "PIXEL_ARRAY"; |
| 405 case FILLER_TYPE: return "FILLER"; | 437 case FILLER_TYPE: return "FILLER"; |
| 406 case JS_OBJECT_TYPE: return "JS_OBJECT"; | 438 case JS_OBJECT_TYPE: return "JS_OBJECT"; |
| 407 case JS_CONTEXT_EXTENSION_OBJECT_TYPE: return "JS_CONTEXT_EXTENSION_OBJECT"; | 439 case JS_CONTEXT_EXTENSION_OBJECT_TYPE: return "JS_CONTEXT_EXTENSION_OBJECT"; |
| 408 case ODDBALL_TYPE: return "ODDBALL"; | 440 case ODDBALL_TYPE: return "ODDBALL"; |
| 409 case JS_GLOBAL_PROPERTY_CELL_TYPE: return "JS_GLOBAL_PROPERTY_CELL"; | 441 case JS_GLOBAL_PROPERTY_CELL_TYPE: return "JS_GLOBAL_PROPERTY_CELL"; |
| 410 case SHARED_FUNCTION_INFO_TYPE: return "SHARED_FUNCTION_INFO"; | 442 case SHARED_FUNCTION_INFO_TYPE: return "SHARED_FUNCTION_INFO"; |
| 411 case JS_FUNCTION_TYPE: return "JS_FUNCTION"; | 443 case JS_FUNCTION_TYPE: return "JS_FUNCTION"; |
| 412 case CODE_TYPE: return "CODE"; | 444 case CODE_TYPE: return "CODE"; |
| 413 case JS_ARRAY_TYPE: return "JS_ARRAY"; | 445 case JS_ARRAY_TYPE: return "JS_ARRAY"; |
| 414 case JS_REGEXP_TYPE: return "JS_REGEXP"; | 446 case JS_REGEXP_TYPE: return "JS_REGEXP"; |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1008 info->number_of_objects_with_fast_properties_++; | 1040 info->number_of_objects_with_fast_properties_++; |
| 1009 info->number_of_fast_used_fields_ += map()->NextFreePropertyIndex(); | 1041 info->number_of_fast_used_fields_ += map()->NextFreePropertyIndex(); |
| 1010 info->number_of_fast_unused_fields_ += map()->unused_property_fields(); | 1042 info->number_of_fast_unused_fields_ += map()->unused_property_fields(); |
| 1011 } else { | 1043 } else { |
| 1012 StringDictionary* dict = property_dictionary(); | 1044 StringDictionary* dict = property_dictionary(); |
| 1013 info->number_of_slow_used_properties_ += dict->NumberOfElements(); | 1045 info->number_of_slow_used_properties_ += dict->NumberOfElements(); |
| 1014 info->number_of_slow_unused_properties_ += | 1046 info->number_of_slow_unused_properties_ += |
| 1015 dict->Capacity() - dict->NumberOfElements(); | 1047 dict->Capacity() - dict->NumberOfElements(); |
| 1016 } | 1048 } |
| 1017 // Indexed properties | 1049 // Indexed properties |
| 1018 if (HasFastElements()) { | 1050 switch (GetElementsKind()) { |
| 1019 info->number_of_objects_with_fast_elements_++; | 1051 case FAST_ELEMENTS: { |
| 1020 int holes = 0; | 1052 info->number_of_objects_with_fast_elements_++; |
| 1021 FixedArray* e = FixedArray::cast(elements()); | 1053 int holes = 0; |
| 1022 int len = e->length(); | 1054 FixedArray* e = FixedArray::cast(elements()); |
| 1023 for (int i = 0; i < len; i++) { | 1055 int len = e->length(); |
| 1024 if (e->get(i) == Heap::the_hole_value()) holes++; | 1056 for (int i = 0; i < len; i++) { |
| 1057 if (e->get(i) == Heap::the_hole_value()) holes++; |
| 1058 } |
| 1059 info->number_of_fast_used_elements_ += len - holes; |
| 1060 info->number_of_fast_unused_elements_ += holes; |
| 1061 break; |
| 1025 } | 1062 } |
| 1026 info->number_of_fast_used_elements_ += len - holes; | 1063 case PIXEL_ELEMENTS: { |
| 1027 info->number_of_fast_unused_elements_ += holes; | 1064 info->number_of_objects_with_fast_elements_++; |
| 1028 } else { | 1065 PixelArray* e = PixelArray::cast(elements()); |
| 1029 NumberDictionary* dict = element_dictionary(); | 1066 info->number_of_fast_used_elements_ += e->length(); |
| 1030 info->number_of_slow_used_elements_ += dict->NumberOfElements(); | 1067 break; |
| 1031 info->number_of_slow_unused_elements_ += | 1068 } |
| 1032 dict->Capacity() - dict->NumberOfElements(); | 1069 case DICTIONARY_ELEMENTS: { |
| 1070 NumberDictionary* dict = element_dictionary(); |
| 1071 info->number_of_slow_used_elements_ += dict->NumberOfElements(); |
| 1072 info->number_of_slow_unused_elements_ += |
| 1073 dict->Capacity() - dict->NumberOfElements(); |
| 1074 break; |
| 1075 } |
| 1076 default: |
| 1077 UNREACHABLE(); |
| 1078 break; |
| 1033 } | 1079 } |
| 1034 } | 1080 } |
| 1035 | 1081 |
| 1036 | 1082 |
| 1037 void JSObject::SpillInformation::Clear() { | 1083 void JSObject::SpillInformation::Clear() { |
| 1038 number_of_objects_ = 0; | 1084 number_of_objects_ = 0; |
| 1039 number_of_objects_with_fast_properties_ = 0; | 1085 number_of_objects_with_fast_properties_ = 0; |
| 1040 number_of_objects_with_fast_elements_ = 0; | 1086 number_of_objects_with_fast_elements_ = 0; |
| 1041 number_of_fast_used_fields_ = 0; | 1087 number_of_fast_used_fields_ = 0; |
| 1042 number_of_fast_unused_fields_ = 0; | 1088 number_of_fast_unused_fields_ = 0; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 } | 1146 } |
| 1101 current = hash; | 1147 current = hash; |
| 1102 } | 1148 } |
| 1103 return true; | 1149 return true; |
| 1104 } | 1150 } |
| 1105 | 1151 |
| 1106 | 1152 |
| 1107 #endif // DEBUG | 1153 #endif // DEBUG |
| 1108 | 1154 |
| 1109 } } // namespace v8::internal | 1155 } } // namespace v8::internal |
| OLD | NEW |