| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/objects.h" | 5 #include "src/objects.h" |
| 6 | 6 |
| 7 #include <iomanip> | 7 #include <iomanip> |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 global_dictionary()->Print(os); | 358 global_dictionary()->Print(os); |
| 359 } else { | 359 } else { |
| 360 property_dictionary()->Print(os); | 360 property_dictionary()->Print(os); |
| 361 } | 361 } |
| 362 return true; | 362 return true; |
| 363 } | 363 } |
| 364 | 364 |
| 365 namespace { | 365 namespace { |
| 366 | 366 |
| 367 template <class T> | 367 template <class T> |
| 368 bool IsTheHoleAt(T* array, int index) { |
| 369 return false; |
| 370 } |
| 371 |
| 372 template <> |
| 373 bool IsTheHoleAt(FixedDoubleArray* array, int index) { |
| 374 return array->is_the_hole(index); |
| 375 } |
| 376 |
| 377 template <class T> |
| 368 double GetScalarElement(T* array, int index) { | 378 double GetScalarElement(T* array, int index) { |
| 379 if (IsTheHoleAt(array, index)) return NAN; |
| 369 return array->get_scalar(index); | 380 return array->get_scalar(index); |
| 370 } | 381 } |
| 371 | 382 |
| 372 double GetScalarElement(FixedDoubleArray* array, int index) { | 383 template <class T> |
| 373 if (array->is_the_hole(index)) return bit_cast<double>(kHoleNanInt64); | |
| 374 return array->get_scalar(index); | |
| 375 } | |
| 376 | |
| 377 bool is_the_hole(double maybe_hole) { | |
| 378 return bit_cast<uint64_t>(maybe_hole) == kHoleNanInt64; | |
| 379 } | |
| 380 | |
| 381 template <class T, bool print_the_hole> | |
| 382 void DoPrintElements(std::ostream& os, Object* object) { // NOLINT | 384 void DoPrintElements(std::ostream& os, Object* object) { // NOLINT |
| 385 const bool print_the_hole = std::is_same<T, FixedDoubleArray>::value; |
| 383 T* array = T::cast(object); | 386 T* array = T::cast(object); |
| 384 if (array->length() == 0) return; | 387 if (array->length() == 0) return; |
| 385 int previous_index = 0; | 388 int previous_index = 0; |
| 386 double previous_value = GetScalarElement(array, 0); | 389 double previous_value = GetScalarElement(array, 0); |
| 387 double value = 0.0; | 390 double value = 0.0; |
| 388 int i; | 391 int i; |
| 389 for (i = 1; i <= array->length(); i++) { | 392 for (i = 1; i <= array->length(); i++) { |
| 390 if (i < array->length()) value = GetScalarElement(array, i); | 393 if (i < array->length()) value = GetScalarElement(array, i); |
| 391 bool values_are_nan = std::isnan(previous_value) && std::isnan(value); | 394 bool values_are_nan = std::isnan(previous_value) && std::isnan(value); |
| 392 if (i != array->length() && (previous_value == value || values_are_nan) && | 395 if (i != array->length() && (previous_value == value || values_are_nan) && |
| 393 is_the_hole(previous_value) == is_the_hole(value)) { | 396 IsTheHoleAt(array, i - 1) == IsTheHoleAt(array, i)) { |
| 394 continue; | 397 continue; |
| 395 } | 398 } |
| 396 os << "\n"; | 399 os << "\n"; |
| 397 std::stringstream ss; | 400 std::stringstream ss; |
| 398 ss << previous_index; | 401 ss << previous_index; |
| 399 if (previous_index != i - 1) { | 402 if (previous_index != i - 1) { |
| 400 ss << '-' << (i - 1); | 403 ss << '-' << (i - 1); |
| 401 } | 404 } |
| 402 os << std::setw(12) << ss.str() << ": "; | 405 os << std::setw(12) << ss.str() << ": "; |
| 403 if (print_the_hole && is_the_hole(previous_value)) { | 406 if (print_the_hole && IsTheHoleAt(array, i - 1)) { |
| 404 os << "<the_hole>"; | 407 os << "<the_hole>"; |
| 405 } else { | 408 } else { |
| 406 os << previous_value; | 409 os << previous_value; |
| 407 } | 410 } |
| 408 previous_index = i; | 411 previous_index = i; |
| 409 previous_value = value; | 412 previous_value = value; |
| 410 } | 413 } |
| 411 } | 414 } |
| 412 | 415 |
| 413 void PrintFixedArrayElements(std::ostream& os, FixedArray* array) { | 416 void PrintFixedArrayElements(std::ostream& os, FixedArray* array) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 443 case FAST_HOLEY_SMI_ELEMENTS: | 446 case FAST_HOLEY_SMI_ELEMENTS: |
| 444 case FAST_SMI_ELEMENTS: | 447 case FAST_SMI_ELEMENTS: |
| 445 case FAST_HOLEY_ELEMENTS: | 448 case FAST_HOLEY_ELEMENTS: |
| 446 case FAST_ELEMENTS: | 449 case FAST_ELEMENTS: |
| 447 case FAST_STRING_WRAPPER_ELEMENTS: { | 450 case FAST_STRING_WRAPPER_ELEMENTS: { |
| 448 PrintFixedArrayElements(os, FixedArray::cast(elements())); | 451 PrintFixedArrayElements(os, FixedArray::cast(elements())); |
| 449 break; | 452 break; |
| 450 } | 453 } |
| 451 case FAST_HOLEY_DOUBLE_ELEMENTS: | 454 case FAST_HOLEY_DOUBLE_ELEMENTS: |
| 452 case FAST_DOUBLE_ELEMENTS: { | 455 case FAST_DOUBLE_ELEMENTS: { |
| 453 DoPrintElements<FixedDoubleArray, true>(os, elements()); | 456 DoPrintElements<FixedDoubleArray>(os, elements()); |
| 454 break; | 457 break; |
| 455 } | 458 } |
| 456 | 459 |
| 457 #define PRINT_ELEMENTS(Type, type, TYPE, elementType, size) \ | 460 #define PRINT_ELEMENTS(Type, type, TYPE, elementType, size) \ |
| 458 case TYPE##_ELEMENTS: { \ | 461 case TYPE##_ELEMENTS: { \ |
| 459 DoPrintElements<Fixed##Type##Array, false>(os, elements()); \ | 462 DoPrintElements<Fixed##Type##Array>(os, elements()); \ |
| 460 break; \ | 463 break; \ |
| 461 } | 464 } |
| 462 TYPED_ARRAYS(PRINT_ELEMENTS) | 465 TYPED_ARRAYS(PRINT_ELEMENTS) |
| 463 #undef PRINT_ELEMENTS | 466 #undef PRINT_ELEMENTS |
| 464 | 467 |
| 465 case DICTIONARY_ELEMENTS: | 468 case DICTIONARY_ELEMENTS: |
| 466 case SLOW_STRING_WRAPPER_ELEMENTS: | 469 case SLOW_STRING_WRAPPER_ELEMENTS: |
| 467 SeededNumberDictionary::cast(elements())->Print(os); | 470 SeededNumberDictionary::cast(elements())->Print(os); |
| 468 break; | 471 break; |
| 469 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: | 472 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: |
| 470 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS: { | 473 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS: { |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 os << "\n - length: " << length(); | 650 os << "\n - length: " << length(); |
| 648 PrintFixedArrayElements(os, this); | 651 PrintFixedArrayElements(os, this); |
| 649 os << "\n"; | 652 os << "\n"; |
| 650 } | 653 } |
| 651 | 654 |
| 652 | 655 |
| 653 void FixedDoubleArray::FixedDoubleArrayPrint(std::ostream& os) { // NOLINT | 656 void FixedDoubleArray::FixedDoubleArrayPrint(std::ostream& os) { // NOLINT |
| 654 HeapObject::PrintHeader(os, "FixedDoubleArray"); | 657 HeapObject::PrintHeader(os, "FixedDoubleArray"); |
| 655 os << "\n - map = " << Brief(map()); | 658 os << "\n - map = " << Brief(map()); |
| 656 os << "\n - length: " << length(); | 659 os << "\n - length: " << length(); |
| 657 DoPrintElements<FixedDoubleArray, true>(os, this); | 660 DoPrintElements<FixedDoubleArray>(os, this); |
| 658 os << "\n"; | 661 os << "\n"; |
| 659 } | 662 } |
| 660 | 663 |
| 661 | 664 |
| 662 void TransitionArray::TransitionArrayPrint(std::ostream& os) { // NOLINT | 665 void TransitionArray::TransitionArrayPrint(std::ostream& os) { // NOLINT |
| 663 HeapObject::PrintHeader(os, "TransitionArray"); | 666 HeapObject::PrintHeader(os, "TransitionArray"); |
| 664 os << "\n - capacity: " << length(); | 667 os << "\n - capacity: " << length(); |
| 665 for (int i = 0; i < length(); i++) { | 668 for (int i = 0; i < length(); i++) { |
| 666 os << "\n [" << i << "]: " << Brief(get(i)); | 669 os << "\n [" << i << "]: " << Brief(get(i)); |
| 667 if (i == kNextLinkIndex) os << " (next link)"; | 670 if (i == kNextLinkIndex) os << " (next link)"; |
| (...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1721 printf("Not a transition array\n"); | 1724 printf("Not a transition array\n"); |
| 1722 } else { | 1725 } else { |
| 1723 reinterpret_cast<i::TransitionArray*>(object)->Print(); | 1726 reinterpret_cast<i::TransitionArray*>(object)->Print(); |
| 1724 } | 1727 } |
| 1725 } | 1728 } |
| 1726 | 1729 |
| 1727 extern void _v8_internal_Print_StackTrace() { | 1730 extern void _v8_internal_Print_StackTrace() { |
| 1728 i::Isolate* isolate = i::Isolate::Current(); | 1731 i::Isolate* isolate = i::Isolate::Current(); |
| 1729 isolate->PrintStack(stdout); | 1732 isolate->PrintStack(stdout); |
| 1730 } | 1733 } |
| OLD | NEW |