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 kHoleNanDouble; | |
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 ((previous_value == value || values_are_nan) && i != array->length()) { |
333 continue; | 351 // Values are not equal if only one of the is the hole. |
Jakob Kummerow
2016/08/31 14:56:09
nit: s/the/them/
| |
352 if (!(is_the_hole(previous_value) ^ is_the_hole(value))) { | |
Jakob Kummerow
2016/08/31 14:56:09
nit: !(a ^ b) === (a == b)
...and after that repl
| |
353 continue; | |
354 } | |
334 } | 355 } |
335 os << "\n"; | 356 os << "\n"; |
336 std::stringstream ss; | 357 std::stringstream ss; |
337 ss << previous_index; | 358 ss << previous_index; |
338 if (previous_index != i - 1) { | 359 if (previous_index != i - 1) { |
339 ss << '-' << (i - 1); | 360 ss << '-' << (i - 1); |
340 } | 361 } |
341 os << std::setw(12) << ss.str() << ": "; | 362 os << std::setw(12) << ss.str() << ": "; |
342 if (print_the_hole && | 363 if (print_the_hole && is_the_hole(previous_value)) { |
343 FixedDoubleArray::cast(object)->is_the_hole(previous_index)) { | |
344 os << "<the_hole>"; | 364 os << "<the_hole>"; |
345 } else { | 365 } else { |
346 os << previous_value; | 366 os << previous_value; |
347 } | 367 } |
348 previous_index = i; | 368 previous_index = i; |
349 previous_value = value; | 369 previous_value = value; |
350 } | 370 } |
351 } | 371 } |
352 | 372 |
353 | 373 |
(...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1516 printf("Not a transition array\n"); | 1536 printf("Not a transition array\n"); |
1517 } else { | 1537 } else { |
1518 reinterpret_cast<i::TransitionArray*>(object)->Print(); | 1538 reinterpret_cast<i::TransitionArray*>(object)->Print(); |
1519 } | 1539 } |
1520 } | 1540 } |
1521 | 1541 |
1522 extern void _v8_internal_Print_StackTrace() { | 1542 extern void _v8_internal_Print_StackTrace() { |
1523 i::Isolate* isolate = i::Isolate::Current(); | 1543 i::Isolate* isolate = i::Isolate::Current(); |
1524 isolate->PrintStack(stdout); | 1544 isolate->PrintStack(stdout); |
1525 } | 1545 } |
OLD | NEW |