OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/profiler/heap-snapshot-generator.h" | 5 #include "src/profiler/heap-snapshot-generator.h" |
6 | 6 |
7 #include "src/code-stubs.h" | 7 #include "src/code-stubs.h" |
8 #include "src/conversions.h" | 8 #include "src/conversions.h" |
9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
10 #include "src/objects-body-descriptors.h" | 10 #include "src/objects-body-descriptors.h" |
(...skipping 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1551 i, array->get(i), array->OffsetOfElementAt(i)); | 1551 i, array->get(i), array->OffsetOfElementAt(i)); |
1552 } else { | 1552 } else { |
1553 SetInternalReference(array, entry, | 1553 SetInternalReference(array, entry, |
1554 i, array->get(i), array->OffsetOfElementAt(i)); | 1554 i, array->get(i), array->OffsetOfElementAt(i)); |
1555 } | 1555 } |
1556 } | 1556 } |
1557 } | 1557 } |
1558 | 1558 |
1559 | 1559 |
1560 void V8HeapExplorer::ExtractPropertyReferences(JSObject* js_obj, int entry) { | 1560 void V8HeapExplorer::ExtractPropertyReferences(JSObject* js_obj, int entry) { |
| 1561 Isolate* isolate = js_obj->GetIsolate(); |
1561 if (js_obj->HasFastProperties()) { | 1562 if (js_obj->HasFastProperties()) { |
1562 DescriptorArray* descs = js_obj->map()->instance_descriptors(); | 1563 DescriptorArray* descs = js_obj->map()->instance_descriptors(); |
1563 int real_size = js_obj->map()->NumberOfOwnDescriptors(); | 1564 int real_size = js_obj->map()->NumberOfOwnDescriptors(); |
1564 for (int i = 0; i < real_size; i++) { | 1565 for (int i = 0; i < real_size; i++) { |
1565 PropertyDetails details = descs->GetDetails(i); | 1566 PropertyDetails details = descs->GetDetails(i); |
1566 switch (details.location()) { | 1567 switch (details.location()) { |
1567 case kField: { | 1568 case kField: { |
1568 Representation r = details.representation(); | 1569 Representation r = details.representation(); |
1569 if (r.IsSmi() || r.IsDouble()) break; | 1570 if (r.IsSmi() || r.IsDouble()) break; |
1570 | 1571 |
(...skipping 13 matching lines...) Expand all Loading... |
1584 descs->GetValue(i)); | 1585 descs->GetValue(i)); |
1585 break; | 1586 break; |
1586 } | 1587 } |
1587 } | 1588 } |
1588 } else if (js_obj->IsJSGlobalObject()) { | 1589 } else if (js_obj->IsJSGlobalObject()) { |
1589 // We assume that global objects can only have slow properties. | 1590 // We assume that global objects can only have slow properties. |
1590 GlobalDictionary* dictionary = js_obj->global_dictionary(); | 1591 GlobalDictionary* dictionary = js_obj->global_dictionary(); |
1591 int length = dictionary->Capacity(); | 1592 int length = dictionary->Capacity(); |
1592 for (int i = 0; i < length; ++i) { | 1593 for (int i = 0; i < length; ++i) { |
1593 Object* k = dictionary->KeyAt(i); | 1594 Object* k = dictionary->KeyAt(i); |
1594 if (dictionary->IsKey(k)) { | 1595 if (dictionary->IsKey(isolate, k)) { |
1595 DCHECK(dictionary->ValueAt(i)->IsPropertyCell()); | 1596 DCHECK(dictionary->ValueAt(i)->IsPropertyCell()); |
1596 PropertyCell* cell = PropertyCell::cast(dictionary->ValueAt(i)); | 1597 PropertyCell* cell = PropertyCell::cast(dictionary->ValueAt(i)); |
1597 Object* value = cell->value(); | 1598 Object* value = cell->value(); |
1598 PropertyDetails details = cell->property_details(); | 1599 PropertyDetails details = cell->property_details(); |
1599 SetDataOrAccessorPropertyReference(details.kind(), js_obj, entry, | 1600 SetDataOrAccessorPropertyReference(details.kind(), js_obj, entry, |
1600 Name::cast(k), value); | 1601 Name::cast(k), value); |
1601 } | 1602 } |
1602 } | 1603 } |
1603 } else { | 1604 } else { |
1604 NameDictionary* dictionary = js_obj->property_dictionary(); | 1605 NameDictionary* dictionary = js_obj->property_dictionary(); |
1605 int length = dictionary->Capacity(); | 1606 int length = dictionary->Capacity(); |
1606 for (int i = 0; i < length; ++i) { | 1607 for (int i = 0; i < length; ++i) { |
1607 Object* k = dictionary->KeyAt(i); | 1608 Object* k = dictionary->KeyAt(i); |
1608 if (dictionary->IsKey(k)) { | 1609 if (dictionary->IsKey(isolate, k)) { |
1609 Object* value = dictionary->ValueAt(i); | 1610 Object* value = dictionary->ValueAt(i); |
1610 PropertyDetails details = dictionary->DetailsAt(i); | 1611 PropertyDetails details = dictionary->DetailsAt(i); |
1611 SetDataOrAccessorPropertyReference(details.kind(), js_obj, entry, | 1612 SetDataOrAccessorPropertyReference(details.kind(), js_obj, entry, |
1612 Name::cast(k), value); | 1613 Name::cast(k), value); |
1613 } | 1614 } |
1614 } | 1615 } |
1615 } | 1616 } |
1616 } | 1617 } |
1617 | 1618 |
1618 | 1619 |
1619 void V8HeapExplorer::ExtractAccessorPairProperty(JSObject* js_obj, int entry, | 1620 void V8HeapExplorer::ExtractAccessorPairProperty(JSObject* js_obj, int entry, |
1620 Name* key, | 1621 Name* key, |
1621 Object* callback_obj, | 1622 Object* callback_obj, |
1622 int field_offset) { | 1623 int field_offset) { |
1623 if (!callback_obj->IsAccessorPair()) return; | 1624 if (!callback_obj->IsAccessorPair()) return; |
1624 AccessorPair* accessors = AccessorPair::cast(callback_obj); | 1625 AccessorPair* accessors = AccessorPair::cast(callback_obj); |
1625 SetPropertyReference(js_obj, entry, key, accessors, NULL, field_offset); | 1626 SetPropertyReference(js_obj, entry, key, accessors, NULL, field_offset); |
1626 Object* getter = accessors->getter(); | 1627 Object* getter = accessors->getter(); |
1627 if (!getter->IsOddball()) { | 1628 if (!getter->IsOddball()) { |
1628 SetPropertyReference(js_obj, entry, key, getter, "get %s"); | 1629 SetPropertyReference(js_obj, entry, key, getter, "get %s"); |
1629 } | 1630 } |
1630 Object* setter = accessors->setter(); | 1631 Object* setter = accessors->setter(); |
1631 if (!setter->IsOddball()) { | 1632 if (!setter->IsOddball()) { |
1632 SetPropertyReference(js_obj, entry, key, setter, "set %s"); | 1633 SetPropertyReference(js_obj, entry, key, setter, "set %s"); |
1633 } | 1634 } |
1634 } | 1635 } |
1635 | 1636 |
1636 | 1637 |
1637 void V8HeapExplorer::ExtractElementReferences(JSObject* js_obj, int entry) { | 1638 void V8HeapExplorer::ExtractElementReferences(JSObject* js_obj, int entry) { |
| 1639 Isolate* isolate = js_obj->GetIsolate(); |
1638 if (js_obj->HasFastObjectElements()) { | 1640 if (js_obj->HasFastObjectElements()) { |
1639 FixedArray* elements = FixedArray::cast(js_obj->elements()); | 1641 FixedArray* elements = FixedArray::cast(js_obj->elements()); |
1640 int length = js_obj->IsJSArray() ? | 1642 int length = js_obj->IsJSArray() ? |
1641 Smi::cast(JSArray::cast(js_obj)->length())->value() : | 1643 Smi::cast(JSArray::cast(js_obj)->length())->value() : |
1642 elements->length(); | 1644 elements->length(); |
1643 for (int i = 0; i < length; ++i) { | 1645 for (int i = 0; i < length; ++i) { |
1644 if (!elements->get(i)->IsTheHole(heap_->isolate())) { | 1646 if (!elements->get(i)->IsTheHole(isolate)) { |
1645 SetElementReference(js_obj, entry, i, elements->get(i)); | 1647 SetElementReference(js_obj, entry, i, elements->get(i)); |
1646 } | 1648 } |
1647 } | 1649 } |
1648 } else if (js_obj->HasDictionaryElements()) { | 1650 } else if (js_obj->HasDictionaryElements()) { |
1649 SeededNumberDictionary* dictionary = js_obj->element_dictionary(); | 1651 SeededNumberDictionary* dictionary = js_obj->element_dictionary(); |
1650 int length = dictionary->Capacity(); | 1652 int length = dictionary->Capacity(); |
1651 for (int i = 0; i < length; ++i) { | 1653 for (int i = 0; i < length; ++i) { |
1652 Object* k = dictionary->KeyAt(i); | 1654 Object* k = dictionary->KeyAt(i); |
1653 if (dictionary->IsKey(heap_, k)) { | 1655 if (dictionary->IsKey(isolate, k)) { |
1654 DCHECK(k->IsNumber()); | 1656 DCHECK(k->IsNumber()); |
1655 uint32_t index = static_cast<uint32_t>(k->Number()); | 1657 uint32_t index = static_cast<uint32_t>(k->Number()); |
1656 SetElementReference(js_obj, entry, index, dictionary->ValueAt(i)); | 1658 SetElementReference(js_obj, entry, index, dictionary->ValueAt(i)); |
1657 } | 1659 } |
1658 } | 1660 } |
1659 } | 1661 } |
1660 } | 1662 } |
1661 | 1663 |
1662 | 1664 |
1663 void V8HeapExplorer::ExtractInternalReferences(JSObject* js_obj, int entry) { | 1665 void V8HeapExplorer::ExtractInternalReferences(JSObject* js_obj, int entry) { |
(...skipping 1450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3114 for (int i = 1; i < sorted_strings.length(); ++i) { | 3116 for (int i = 1; i < sorted_strings.length(); ++i) { |
3115 writer_->AddCharacter(','); | 3117 writer_->AddCharacter(','); |
3116 SerializeString(sorted_strings[i]); | 3118 SerializeString(sorted_strings[i]); |
3117 if (writer_->aborted()) return; | 3119 if (writer_->aborted()) return; |
3118 } | 3120 } |
3119 } | 3121 } |
3120 | 3122 |
3121 | 3123 |
3122 } // namespace internal | 3124 } // namespace internal |
3123 } // namespace v8 | 3125 } // namespace v8 |
OLD | NEW |