OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
937 return HeapObject::cast(first); | 937 return HeapObject::cast(first); |
938 } | 938 } |
939 | 939 |
940 | 940 |
941 class StaticMarkingVisitor : public StaticVisitorBase { | 941 class StaticMarkingVisitor : public StaticVisitorBase { |
942 public: | 942 public: |
943 static inline void IterateBody(Map* map, HeapObject* obj) { | 943 static inline void IterateBody(Map* map, HeapObject* obj) { |
944 table_.GetVisitor(map)(map, obj); | 944 table_.GetVisitor(map)(map, obj); |
945 } | 945 } |
946 | 946 |
947 template<int id> | 947 static void ObjectStatsVisitCore(StaticVisitorBase::VisitorId id, |
Yang
2012/07/18 14:23:02
We sometimes call this sort of stuff *Base. Maybe
| |
948 Map* map, HeapObject* obj); | |
949 | |
950 static void ObjectStatsCountFixedArray( | |
951 FixedArrayBase* fixed_array, | |
952 FixedArraySubInstanceType fast_type, | |
953 FixedArraySubInstanceType dictionary_type); | |
954 | |
955 template<StaticMarkingVisitor::VisitorId id> | |
948 class ObjectStatsTracker { | 956 class ObjectStatsTracker { |
949 public: | 957 public: |
950 static inline void Visit(Map* map, HeapObject* obj); | 958 static inline void Visit(Map* map, HeapObject* obj); |
951 }; | 959 }; |
952 | 960 |
953 static void Initialize(); | 961 static void Initialize(); |
954 | 962 |
955 INLINE(static void VisitPointer(Heap* heap, Object** p)) { | 963 INLINE(static void VisitPointer(Heap* heap, Object** p)) { |
956 MarkObjectByPointer(heap->mark_compact_collector(), p, p); | 964 MarkObjectByPointer(heap->mark_compact_collector(), p, p); |
957 } | 965 } |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1492 | 1500 |
1493 #undef SLOT_ADDR | 1501 #undef SLOT_ADDR |
1494 | 1502 |
1495 typedef void (*Callback)(Map* map, HeapObject* object); | 1503 typedef void (*Callback)(Map* map, HeapObject* object); |
1496 | 1504 |
1497 static VisitorDispatchTable<Callback> table_; | 1505 static VisitorDispatchTable<Callback> table_; |
1498 static VisitorDispatchTable<Callback> non_count_table_; | 1506 static VisitorDispatchTable<Callback> non_count_table_; |
1499 }; | 1507 }; |
1500 | 1508 |
1501 | 1509 |
1502 template<int id> | 1510 void StaticMarkingVisitor::ObjectStatsCountFixedArray( |
1503 void StaticMarkingVisitor::ObjectStatsTracker<id>::Visit( | 1511 FixedArrayBase* fixed_array, |
1504 Map* map, HeapObject* obj) { | 1512 FixedArraySubInstanceType fast_type, |
1513 FixedArraySubInstanceType dictionary_type) { | |
1514 Heap* heap = fixed_array->map()->GetHeap(); | |
1515 if (fixed_array->map() != heap->fixed_cow_array_map() && | |
1516 fixed_array->map() != heap->fixed_double_array_map() && | |
1517 fixed_array != heap->empty_fixed_array()) { | |
1518 if (fixed_array->IsDictionary()) { | |
1519 heap->RecordObjectStats(FIXED_ARRAY_TYPE, | |
1520 dictionary_type, | |
1521 fixed_array->Size()); | |
1522 } else { | |
1523 heap->RecordObjectStats(FIXED_ARRAY_TYPE, | |
1524 fast_type, | |
1525 fixed_array->Size()); | |
1526 } | |
1527 } | |
1528 } | |
1529 | |
1530 | |
1531 void StaticMarkingVisitor::ObjectStatsVisitCore( | |
1532 StaticVisitorBase::VisitorId id, Map* map, HeapObject* obj) { | |
1505 Heap* heap = map->GetHeap(); | 1533 Heap* heap = map->GetHeap(); |
1506 int object_size = obj->Size(); | 1534 int object_size = obj->Size(); |
1507 heap->RecordObjectStats(map->instance_type(), -1, object_size); | 1535 heap->RecordObjectStats(map->instance_type(), -1, object_size); |
1508 non_count_table_.GetVisitorById(static_cast<VisitorId>(id))(map, obj); | 1536 non_count_table_.GetVisitorById(id)(map, obj); |
1537 if (obj->IsJSObject()) { | |
1538 JSObject* object = JSObject::cast(obj); | |
1539 ObjectStatsCountFixedArray(object->elements(), | |
1540 DICTIONARY_ELEMENTS_SUB_TYPE, | |
1541 FAST_ELEMENTS_SUB_TYPE); | |
1542 ObjectStatsCountFixedArray(object->properties(), | |
1543 DICTIONARY_PROPERTIES_SUB_TYPE, | |
1544 FAST_PROPERTIES_SUB_TYPE); | |
1545 } else if (obj->IsJSArray()) { | |
1546 JSArray* array = JSArray::cast(obj); | |
1547 ObjectStatsCountFixedArray(array->elements(), | |
1548 DICTIONARY_ELEMENTS_SUB_TYPE, | |
1549 FAST_ELEMENTS_SUB_TYPE); | |
1550 ObjectStatsCountFixedArray(array->properties(), | |
1551 DICTIONARY_PROPERTIES_SUB_TYPE, | |
1552 FAST_PROPERTIES_SUB_TYPE); | |
Yang
2012/07/18 14:23:02
This looks exactly the same as the case above. Sin
| |
1553 } | |
1509 } | 1554 } |
1510 | 1555 |
1511 | 1556 |
1557 template<StaticMarkingVisitor::VisitorId id> | |
1558 void StaticMarkingVisitor::ObjectStatsTracker<id>::Visit( | |
1559 Map* map, HeapObject* obj) { | |
1560 ObjectStatsVisitCore(id, map, obj); | |
1561 } | |
1562 | |
1563 | |
1564 template<> | |
1565 class StaticMarkingVisitor::ObjectStatsTracker< | |
1566 StaticMarkingVisitor::kVisitMap> { | |
1567 public: | |
1568 static inline void Visit(Map* map, HeapObject* obj) { | |
1569 Heap* heap = map->GetHeap(); | |
1570 Map* map_obj = Map::cast(obj); | |
1571 ASSERT(map->instance_type() == MAP_TYPE); | |
1572 DescriptorArray* array = map_obj->instance_descriptors(); | |
1573 if (array != heap->empty_descriptor_array()) { | |
1574 int fixed_array_size = array->Size(); | |
1575 heap->RecordObjectStats(FIXED_ARRAY_TYPE, | |
1576 DESCRIPTOR_ARRAY_SUB_TYPE, | |
1577 fixed_array_size); | |
1578 } | |
1579 if (map_obj->HasTransitionArray()) { | |
1580 int fixed_array_size = map_obj->transitions()->Size(); | |
1581 heap->RecordObjectStats(FIXED_ARRAY_TYPE, | |
1582 TRANSITION_ARRAY_SUB_TYPE, | |
1583 fixed_array_size); | |
1584 } | |
1585 if (map_obj->code_cache() != heap->empty_fixed_array()) { | |
1586 heap->RecordObjectStats( | |
1587 FIXED_ARRAY_TYPE, | |
1588 MAP_CODE_CACHE_SUB_TYPE, | |
1589 FixedArray::cast(map_obj->code_cache())->Size()); | |
1590 } | |
1591 ObjectStatsVisitCore(kVisitMap, map, obj); | |
1592 } | |
1593 }; | |
1594 | |
1595 | |
1512 template<> | 1596 template<> |
1513 class StaticMarkingVisitor::ObjectStatsTracker< | 1597 class StaticMarkingVisitor::ObjectStatsTracker< |
1514 StaticMarkingVisitor::kVisitCode> { | 1598 StaticMarkingVisitor::kVisitCode> { |
1515 public: | 1599 public: |
1516 static inline void Visit(Map* map, HeapObject* obj) { | 1600 static inline void Visit(Map* map, HeapObject* obj) { |
1517 Heap* heap = map->GetHeap(); | 1601 Heap* heap = map->GetHeap(); |
1518 int object_size = obj->Size(); | 1602 int object_size = obj->Size(); |
1519 ASSERT(map->instance_type() == CODE_TYPE); | 1603 ASSERT(map->instance_type() == CODE_TYPE); |
1520 heap->RecordObjectStats(CODE_TYPE, -1, object_size); | |
1521 heap->RecordObjectStats(CODE_TYPE, Code::cast(obj)->kind(), object_size); | 1604 heap->RecordObjectStats(CODE_TYPE, Code::cast(obj)->kind(), object_size); |
1522 non_count_table_.GetVisitorById( | 1605 ObjectStatsVisitCore(kVisitCode, map, obj); |
1523 static_cast<VisitorId>(kVisitCode))(map, obj); | |
1524 } | 1606 } |
1525 }; | 1607 }; |
1526 | 1608 |
1609 | |
1610 template<> | |
1611 class StaticMarkingVisitor::ObjectStatsTracker< | |
1612 StaticMarkingVisitor::kVisitSharedFunctionInfo> { | |
1613 public: | |
1614 static inline void Visit(Map* map, HeapObject* obj) { | |
1615 Heap* heap = map->GetHeap(); | |
1616 SharedFunctionInfo* sfi = SharedFunctionInfo::cast(obj); | |
1617 if (sfi->scope_info() != heap->empty_fixed_array()) { | |
1618 heap->RecordObjectStats( | |
1619 FIXED_ARRAY_TYPE, | |
1620 SCOPE_INFO_SUB_TYPE, | |
1621 FixedArray::cast(sfi->scope_info())->Size()); | |
1622 } | |
1623 ObjectStatsVisitCore(kVisitSharedFunctionInfo, map, obj); | |
1624 } | |
1625 }; | |
1626 | |
1627 | |
1628 template<> | |
1629 class StaticMarkingVisitor::ObjectStatsTracker< | |
1630 StaticMarkingVisitor::kVisitFixedArray> { | |
1631 public: | |
1632 static inline void Visit(Map* map, HeapObject* obj) { | |
1633 Heap* heap = map->GetHeap(); | |
1634 FixedArray* fixed_array = FixedArray::cast(obj); | |
1635 if (fixed_array == heap->symbol_table()) { | |
1636 heap->RecordObjectStats( | |
1637 FIXED_ARRAY_TYPE, | |
1638 SYMBOL_TABLE_SUB_TYPE, | |
1639 fixed_array->Size()); | |
1640 } | |
1641 ObjectStatsVisitCore(kVisitFixedArray, map, obj); | |
1642 } | |
1643 }; | |
1644 | |
1527 | 1645 |
1528 void StaticMarkingVisitor::Initialize() { | 1646 void StaticMarkingVisitor::Initialize() { |
1529 table_.Register(kVisitShortcutCandidate, | 1647 table_.Register(kVisitShortcutCandidate, |
1530 &FixedBodyVisitor<StaticMarkingVisitor, | 1648 &FixedBodyVisitor<StaticMarkingVisitor, |
1531 ConsString::BodyDescriptor, | 1649 ConsString::BodyDescriptor, |
1532 void>::Visit); | 1650 void>::Visit); |
1533 | 1651 |
1534 table_.Register(kVisitConsString, | 1652 table_.Register(kVisitConsString, |
1535 &FixedBodyVisitor<StaticMarkingVisitor, | 1653 &FixedBodyVisitor<StaticMarkingVisitor, |
1536 ConsString::BodyDescriptor, | 1654 ConsString::BodyDescriptor, |
(...skipping 2647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4184 while (buffer != NULL) { | 4302 while (buffer != NULL) { |
4185 SlotsBuffer* next_buffer = buffer->next(); | 4303 SlotsBuffer* next_buffer = buffer->next(); |
4186 DeallocateBuffer(buffer); | 4304 DeallocateBuffer(buffer); |
4187 buffer = next_buffer; | 4305 buffer = next_buffer; |
4188 } | 4306 } |
4189 *buffer_address = NULL; | 4307 *buffer_address = NULL; |
4190 } | 4308 } |
4191 | 4309 |
4192 | 4310 |
4193 } } // namespace v8::internal | 4311 } } // namespace v8::internal |
OLD | NEW |