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/disasm.h" | 10 #include "src/disasm.h" |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 break; | 311 break; |
312 } | 312 } |
313 } | 313 } |
314 } else if (IsJSGlobalObject()) { | 314 } else if (IsJSGlobalObject()) { |
315 global_dictionary()->Print(os); | 315 global_dictionary()->Print(os); |
316 } else { | 316 } else { |
317 property_dictionary()->Print(os); | 317 property_dictionary()->Print(os); |
318 } | 318 } |
319 } | 319 } |
320 | 320 |
| 321 namespace { |
| 322 |
| 323 template <class T> |
| 324 double GetScalarElement(T* array, int index) { |
| 325 return array->get_scalar(index); |
| 326 } |
| 327 |
| 328 double GetScalarElement(FixedDoubleArray* array, int index) { |
| 329 if (array->is_the_hole(index)) return bit_cast<double>(kHoleNanInt64); |
| 330 return array->get_scalar(index); |
| 331 } |
| 332 |
| 333 bool is_the_hole(double maybe_hole) { |
| 334 return bit_cast<uint64_t>(maybe_hole) == kHoleNanInt64; |
| 335 } |
| 336 |
| 337 } // namespace |
| 338 |
321 template <class T, bool print_the_hole> | 339 template <class T, bool print_the_hole> |
322 static void DoPrintElements(std::ostream& os, Object* object) { // NOLINT | 340 static void DoPrintElements(std::ostream& os, Object* object) { // NOLINT |
323 T* array = T::cast(object); | 341 T* array = T::cast(object); |
324 if (array->length() == 0) return; | 342 if (array->length() == 0) return; |
325 int previous_index = 0; | 343 int previous_index = 0; |
326 double previous_value = array->get_scalar(0); | 344 double previous_value = GetScalarElement(array, 0); |
327 double value = 0.0; | 345 double value = 0.0; |
328 int i; | 346 int i; |
329 for (i = 1; i <= array->length(); i++) { | 347 for (i = 1; i <= array->length(); i++) { |
330 if (i < array->length()) value = array->get_scalar(i); | 348 if (i < array->length()) value = GetScalarElement(array, i); |
331 bool values_are_nan = std::isnan(previous_value) && std::isnan(value); | 349 bool values_are_nan = std::isnan(previous_value) && std::isnan(value); |
332 if ((previous_value == value || values_are_nan) && i != array->length()) { | 350 if (i != array->length() && (previous_value == value || values_are_nan) && |
| 351 is_the_hole(previous_value) == is_the_hole(value)) { |
333 continue; | 352 continue; |
334 } | 353 } |
335 os << "\n"; | 354 os << "\n"; |
336 std::stringstream ss; | 355 std::stringstream ss; |
337 ss << previous_index; | 356 ss << previous_index; |
338 if (previous_index != i - 1) { | 357 if (previous_index != i - 1) { |
339 ss << '-' << (i - 1); | 358 ss << '-' << (i - 1); |
340 } | 359 } |
341 os << std::setw(12) << ss.str() << ": "; | 360 os << std::setw(12) << ss.str() << ": "; |
342 if (print_the_hole && | 361 if (print_the_hole && is_the_hole(previous_value)) { |
343 FixedDoubleArray::cast(object)->is_the_hole(previous_index)) { | |
344 os << "<the_hole>"; | 362 os << "<the_hole>"; |
345 } else { | 363 } else { |
346 os << previous_value; | 364 os << previous_value; |
347 } | 365 } |
348 previous_index = i; | 366 previous_index = i; |
349 previous_value = value; | 367 previous_value = value; |
350 } | 368 } |
351 } | 369 } |
352 | 370 |
353 | 371 |
(...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1501 printf("Not a transition array\n"); | 1519 printf("Not a transition array\n"); |
1502 } else { | 1520 } else { |
1503 reinterpret_cast<i::TransitionArray*>(object)->Print(); | 1521 reinterpret_cast<i::TransitionArray*>(object)->Print(); |
1504 } | 1522 } |
1505 } | 1523 } |
1506 | 1524 |
1507 extern void _v8_internal_Print_StackTrace() { | 1525 extern void _v8_internal_Print_StackTrace() { |
1508 i::Isolate* isolate = i::Isolate::Current(); | 1526 i::Isolate* isolate = i::Isolate::Current(); |
1509 isolate->PrintStack(stdout); | 1527 isolate->PrintStack(stdout); |
1510 } | 1528 } |
OLD | NEW |