Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(706)

Side by Side Diff: src/mark-compact.cc

Issue 10797008: Refine object stats for FixedArrays. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/heap.cc ('k') | src/objects.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 ObjectStatsVisitBase(StaticVisitorBase::VisitorId id,
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
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::ObjectStatsVisitBase(
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 }
1509 } 1546 }
1510 1547
1511 1548
1549 template<StaticMarkingVisitor::VisitorId id>
1550 void StaticMarkingVisitor::ObjectStatsTracker<id>::Visit(
1551 Map* map, HeapObject* obj) {
1552 ObjectStatsVisitBase(id, map, obj);
1553 }
1554
1555
1556 template<>
1557 class StaticMarkingVisitor::ObjectStatsTracker<
1558 StaticMarkingVisitor::kVisitMap> {
1559 public:
1560 static inline void Visit(Map* map, HeapObject* obj) {
1561 Heap* heap = map->GetHeap();
1562 Map* map_obj = Map::cast(obj);
1563 ASSERT(map->instance_type() == MAP_TYPE);
1564 DescriptorArray* array = map_obj->instance_descriptors();
1565 if (array != heap->empty_descriptor_array()) {
1566 int fixed_array_size = array->Size();
1567 heap->RecordObjectStats(FIXED_ARRAY_TYPE,
1568 DESCRIPTOR_ARRAY_SUB_TYPE,
1569 fixed_array_size);
1570 }
1571 if (map_obj->HasTransitionArray()) {
1572 int fixed_array_size = map_obj->transitions()->Size();
1573 heap->RecordObjectStats(FIXED_ARRAY_TYPE,
1574 TRANSITION_ARRAY_SUB_TYPE,
1575 fixed_array_size);
1576 }
1577 if (map_obj->code_cache() != heap->empty_fixed_array()) {
1578 heap->RecordObjectStats(
1579 FIXED_ARRAY_TYPE,
1580 MAP_CODE_CACHE_SUB_TYPE,
1581 FixedArray::cast(map_obj->code_cache())->Size());
1582 }
1583 ObjectStatsVisitBase(kVisitMap, map, obj);
1584 }
1585 };
1586
1587
1512 template<> 1588 template<>
1513 class StaticMarkingVisitor::ObjectStatsTracker< 1589 class StaticMarkingVisitor::ObjectStatsTracker<
1514 StaticMarkingVisitor::kVisitCode> { 1590 StaticMarkingVisitor::kVisitCode> {
1515 public: 1591 public:
1516 static inline void Visit(Map* map, HeapObject* obj) { 1592 static inline void Visit(Map* map, HeapObject* obj) {
1517 Heap* heap = map->GetHeap(); 1593 Heap* heap = map->GetHeap();
1518 int object_size = obj->Size(); 1594 int object_size = obj->Size();
1519 ASSERT(map->instance_type() == CODE_TYPE); 1595 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); 1596 heap->RecordObjectStats(CODE_TYPE, Code::cast(obj)->kind(), object_size);
1522 non_count_table_.GetVisitorById( 1597 ObjectStatsVisitBase(kVisitCode, map, obj);
1523 static_cast<VisitorId>(kVisitCode))(map, obj);
1524 } 1598 }
1525 }; 1599 };
1526 1600
1601
1602 template<>
1603 class StaticMarkingVisitor::ObjectStatsTracker<
1604 StaticMarkingVisitor::kVisitSharedFunctionInfo> {
1605 public:
1606 static inline void Visit(Map* map, HeapObject* obj) {
1607 Heap* heap = map->GetHeap();
1608 SharedFunctionInfo* sfi = SharedFunctionInfo::cast(obj);
1609 if (sfi->scope_info() != heap->empty_fixed_array()) {
1610 heap->RecordObjectStats(
1611 FIXED_ARRAY_TYPE,
1612 SCOPE_INFO_SUB_TYPE,
1613 FixedArray::cast(sfi->scope_info())->Size());
1614 }
1615 ObjectStatsVisitBase(kVisitSharedFunctionInfo, map, obj);
1616 }
1617 };
1618
1619
1620 template<>
1621 class StaticMarkingVisitor::ObjectStatsTracker<
1622 StaticMarkingVisitor::kVisitFixedArray> {
1623 public:
1624 static inline void Visit(Map* map, HeapObject* obj) {
1625 Heap* heap = map->GetHeap();
1626 FixedArray* fixed_array = FixedArray::cast(obj);
1627 if (fixed_array == heap->symbol_table()) {
1628 heap->RecordObjectStats(
1629 FIXED_ARRAY_TYPE,
1630 SYMBOL_TABLE_SUB_TYPE,
1631 fixed_array->Size());
1632 }
1633 ObjectStatsVisitBase(kVisitFixedArray, map, obj);
1634 }
1635 };
1636
1527 1637
1528 void StaticMarkingVisitor::Initialize() { 1638 void StaticMarkingVisitor::Initialize() {
1529 table_.Register(kVisitShortcutCandidate, 1639 table_.Register(kVisitShortcutCandidate,
1530 &FixedBodyVisitor<StaticMarkingVisitor, 1640 &FixedBodyVisitor<StaticMarkingVisitor,
1531 ConsString::BodyDescriptor, 1641 ConsString::BodyDescriptor,
1532 void>::Visit); 1642 void>::Visit);
1533 1643
1534 table_.Register(kVisitConsString, 1644 table_.Register(kVisitConsString,
1535 &FixedBodyVisitor<StaticMarkingVisitor, 1645 &FixedBodyVisitor<StaticMarkingVisitor,
1536 ConsString::BodyDescriptor, 1646 ConsString::BodyDescriptor,
(...skipping 2632 matching lines...) Expand 10 before | Expand all | Expand 10 after
4169 while (buffer != NULL) { 4279 while (buffer != NULL) {
4170 SlotsBuffer* next_buffer = buffer->next(); 4280 SlotsBuffer* next_buffer = buffer->next();
4171 DeallocateBuffer(buffer); 4281 DeallocateBuffer(buffer);
4172 buffer = next_buffer; 4282 buffer = next_buffer;
4173 } 4283 }
4174 *buffer_address = NULL; 4284 *buffer_address = NULL;
4175 } 4285 }
4176 4286
4177 4287
4178 } } // namespace v8::internal 4288 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698