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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 | 329 |
330 | 330 |
331 void JSObject::PrintProperties(std::ostream& os) { // NOLINT | 331 void JSObject::PrintProperties(std::ostream& os) { // NOLINT |
332 if (HasFastProperties()) { | 332 if (HasFastProperties()) { |
333 DescriptorArray* descs = map()->instance_descriptors(); | 333 DescriptorArray* descs = map()->instance_descriptors(); |
334 for (int i = 0; i < map()->NumberOfOwnDescriptors(); i++) { | 334 for (int i = 0; i < map()->NumberOfOwnDescriptors(); i++) { |
335 os << "\n "; | 335 os << "\n "; |
336 descs->GetKey(i)->NamePrint(os); | 336 descs->GetKey(i)->NamePrint(os); |
337 os << ": "; | 337 os << ": "; |
338 PropertyDetails details = descs->GetDetails(i); | 338 PropertyDetails details = descs->GetDetails(i); |
339 FieldIndex field_index; | |
340 switch (details.location()) { | 339 switch (details.location()) { |
341 case kField: { | 340 case kField: { |
342 field_index = FieldIndex::ForDescriptor(map(), i); | 341 FieldIndex field_index = FieldIndex::ForDescriptor(map(), i); |
343 if (IsUnboxedDoubleField(field_index)) { | 342 if (IsUnboxedDoubleField(field_index)) { |
344 os << "<unboxed double> " << RawFastDoublePropertyAt(field_index); | 343 os << "<unboxed double> " << RawFastDoublePropertyAt(field_index); |
345 } else { | 344 } else { |
346 os << Brief(RawFastPropertyAt(field_index)); | 345 os << Brief(RawFastPropertyAt(field_index)); |
347 } | 346 } |
348 break; | 347 break; |
349 } | 348 } |
350 case kDescriptor: | 349 case kDescriptor: |
351 os << Brief(descs->GetValue(i)); | 350 os << Brief(descs->GetValue(i)); |
352 break; | 351 break; |
353 } | 352 } |
354 os << " (" << (details.kind() == kData ? "data" : "accessor"); | 353 os << " "; |
355 switch (details.location()) { | 354 details.PrintAsFastTo(os, PropertyDetails::kForProperties); |
356 case kField: { | |
357 os << " field at offset " << field_index.property_index(); | |
358 break; | |
359 } | |
360 case kDescriptor: | |
361 break; | |
362 } | |
363 os << ")"; | |
364 } | 355 } |
365 } else if (IsJSGlobalObject()) { | 356 } else if (IsJSGlobalObject()) { |
366 global_dictionary()->Print(os); | 357 global_dictionary()->Print(os); |
367 } else { | 358 } else { |
368 property_dictionary()->Print(os); | 359 property_dictionary()->Print(os); |
369 } | 360 } |
370 } | 361 } |
371 | 362 |
372 namespace { | 363 namespace { |
373 | 364 |
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1141 void Cell::CellPrint(std::ostream& os) { // NOLINT | 1132 void Cell::CellPrint(std::ostream& os) { // NOLINT |
1142 HeapObject::PrintHeader(os, "Cell"); | 1133 HeapObject::PrintHeader(os, "Cell"); |
1143 os << "\n - value: " << Brief(value()); | 1134 os << "\n - value: " << Brief(value()); |
1144 os << "\n"; | 1135 os << "\n"; |
1145 } | 1136 } |
1146 | 1137 |
1147 | 1138 |
1148 void PropertyCell::PropertyCellPrint(std::ostream& os) { // NOLINT | 1139 void PropertyCell::PropertyCellPrint(std::ostream& os) { // NOLINT |
1149 HeapObject::PrintHeader(os, "PropertyCell"); | 1140 HeapObject::PrintHeader(os, "PropertyCell"); |
1150 os << "\n - value: " << Brief(value()); | 1141 os << "\n - value: " << Brief(value()); |
1151 os << "\n - details: " << property_details(); | 1142 os << "\n - details: "; |
| 1143 property_details().PrintAsSlowTo(os); |
1152 PropertyCellType cell_type = property_details().cell_type(); | 1144 PropertyCellType cell_type = property_details().cell_type(); |
1153 os << "\n - cell_type: "; | 1145 os << "\n - cell_type: "; |
1154 if (value()->IsTheHole(GetIsolate())) { | 1146 if (value()->IsTheHole(GetIsolate())) { |
1155 switch (cell_type) { | 1147 switch (cell_type) { |
1156 case PropertyCellType::kUninitialized: | 1148 case PropertyCellType::kUninitialized: |
1157 os << "Uninitialized"; | 1149 os << "Uninitialized"; |
1158 break; | 1150 break; |
1159 case PropertyCellType::kInvalidated: | 1151 case PropertyCellType::kInvalidated: |
1160 os << "Invalidated"; | 1152 os << "Invalidated"; |
1161 break; | 1153 break; |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1583 | 1575 |
1584 void DescriptorArray::Print() { | 1576 void DescriptorArray::Print() { |
1585 OFStream os(stdout); | 1577 OFStream os(stdout); |
1586 this->PrintDescriptors(os); | 1578 this->PrintDescriptors(os); |
1587 os << std::flush; | 1579 os << std::flush; |
1588 } | 1580 } |
1589 | 1581 |
1590 | 1582 |
1591 void DescriptorArray::PrintDescriptors(std::ostream& os) { // NOLINT | 1583 void DescriptorArray::PrintDescriptors(std::ostream& os) { // NOLINT |
1592 HandleScope scope(GetIsolate()); | 1584 HandleScope scope(GetIsolate()); |
1593 os << "Descriptor array #" << number_of_descriptors(); | 1585 os << "Descriptor array #" << number_of_descriptors() << ":"; |
1594 for (int i = 0; i < number_of_descriptors(); i++) { | 1586 for (int i = 0; i < number_of_descriptors(); i++) { |
1595 Descriptor desc; | 1587 Name* key = GetKey(i); |
1596 Get(i, &desc); | 1588 os << "\n [" << i << "]: "; |
1597 os << "\n " << i << ": " << desc; | 1589 #ifdef OBJECT_PRINT |
| 1590 key->NamePrint(os); |
| 1591 #else |
| 1592 key->ShortPrint(os); |
| 1593 #endif |
| 1594 os << " "; |
| 1595 PrintDescriptorDetails(os, i, PropertyDetails::kPrintFull); |
1598 } | 1596 } |
1599 os << "\n"; | 1597 os << "\n"; |
1600 } | 1598 } |
1601 | 1599 |
| 1600 void DescriptorArray::PrintDescriptorDetails(std::ostream& os, int descriptor, |
| 1601 PropertyDetails::PrintMode mode) { |
| 1602 PropertyDetails details = GetDetails(descriptor); |
| 1603 details.PrintAsFastTo(os, mode); |
| 1604 os << " @ "; |
| 1605 Object* value = GetValue(descriptor); |
| 1606 switch (details.location()) { |
| 1607 case kField: { |
| 1608 FieldType* field_type = Map::UnwrapFieldType(value); |
| 1609 field_type->PrintTo(os); |
| 1610 break; |
| 1611 } |
| 1612 case kDescriptor: |
| 1613 os << Brief(value); |
| 1614 if (value->IsAccessorPair()) { |
| 1615 AccessorPair* pair = AccessorPair::cast(value); |
| 1616 os << "(get: " << Brief(pair->getter()) |
| 1617 << ", set: " << Brief(pair->setter()) << ")"; |
| 1618 } |
| 1619 break; |
| 1620 } |
| 1621 } |
1602 | 1622 |
1603 void TransitionArray::Print() { | 1623 void TransitionArray::Print() { |
1604 OFStream os(stdout); | 1624 OFStream os(stdout); |
1605 TransitionArray::PrintTransitions(os, this); | 1625 TransitionArray::PrintTransitions(os, this); |
1606 os << "\n" << std::flush; | 1626 os << "\n" << std::flush; |
1607 } | 1627 } |
1608 | 1628 |
1609 | 1629 |
1610 void TransitionArray::PrintTransitions(std::ostream& os, Object* transitions, | 1630 void TransitionArray::PrintTransitions(std::ostream& os, Object* transitions, |
1611 bool print_header) { // NOLINT | 1631 bool print_header) { // NOLINT |
(...skipping 17 matching lines...) Expand all Loading... |
1629 } else if (key == heap->sealed_symbol()) { | 1649 } else if (key == heap->sealed_symbol()) { |
1630 os << "(transition to sealed)"; | 1650 os << "(transition to sealed)"; |
1631 } else if (key == heap->frozen_symbol()) { | 1651 } else if (key == heap->frozen_symbol()) { |
1632 os << "(transition to frozen)"; | 1652 os << "(transition to frozen)"; |
1633 } else if (key == heap->elements_transition_symbol()) { | 1653 } else if (key == heap->elements_transition_symbol()) { |
1634 os << "(transition to " << ElementsKindToString(target->elements_kind()) | 1654 os << "(transition to " << ElementsKindToString(target->elements_kind()) |
1635 << ")"; | 1655 << ")"; |
1636 } else if (key == heap->strict_function_transition_symbol()) { | 1656 } else if (key == heap->strict_function_transition_symbol()) { |
1637 os << " (transition to strict function)"; | 1657 os << " (transition to strict function)"; |
1638 } else { | 1658 } else { |
1639 PropertyDetails details = GetTargetDetails(key, target); | 1659 DCHECK(!IsSpecialTransition(key)); |
1640 os << "(transition to "; | 1660 os << "(transition to "; |
1641 if (details.location() == kDescriptor) { | 1661 int descriptor = target->LastAdded(); |
1642 os << "immutable "; | 1662 DescriptorArray* descriptors = target->instance_descriptors(); |
1643 } | 1663 descriptors->PrintDescriptorDetails(os, descriptor, |
1644 os << (details.kind() == kData ? "data" : "accessor"); | 1664 PropertyDetails::kForTransitions); |
1645 if (details.location() == kDescriptor) { | 1665 os << ")"; |
1646 Object* value = | |
1647 target->instance_descriptors()->GetValue(target->LastAdded()); | |
1648 os << " " << Brief(value); | |
1649 } else { | |
1650 os << " field"; | |
1651 } | |
1652 os << ", attrs: " << details.attributes() << ")"; | |
1653 } | 1666 } |
1654 os << " -> " << Brief(target); | 1667 os << " -> " << Brief(target); |
1655 } | 1668 } |
1656 } | 1669 } |
1657 | 1670 |
1658 | 1671 |
1659 void JSObject::PrintTransitions(std::ostream& os) { // NOLINT | 1672 void JSObject::PrintTransitions(std::ostream& os) { // NOLINT |
1660 Object* transitions = map()->raw_transitions(); | 1673 Object* transitions = map()->raw_transitions(); |
1661 int num_transitions = TransitionArray::NumberOfTransitions(transitions); | 1674 int num_transitions = TransitionArray::NumberOfTransitions(transitions); |
1662 if (num_transitions == 0) return; | 1675 if (num_transitions == 0) return; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1709 printf("Not a transition array\n"); | 1722 printf("Not a transition array\n"); |
1710 } else { | 1723 } else { |
1711 reinterpret_cast<i::TransitionArray*>(object)->Print(); | 1724 reinterpret_cast<i::TransitionArray*>(object)->Print(); |
1712 } | 1725 } |
1713 } | 1726 } |
1714 | 1727 |
1715 extern void _v8_internal_Print_StackTrace() { | 1728 extern void _v8_internal_Print_StackTrace() { |
1716 i::Isolate* isolate = i::Isolate::Current(); | 1729 i::Isolate* isolate = i::Isolate::Current(); |
1717 isolate->PrintStack(stdout); | 1730 isolate->PrintStack(stdout); |
1718 } | 1731 } |
OLD | NEW |