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

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

Issue 10792014: Track counts/sizes of CODE sub types with --track-gc-object-stats (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 929 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 template<int id>
948 class ObjectStatsTracker { 948 class ObjectStatsTracker {
949 public: 949 public:
950 static inline void Visit(Map* map, HeapObject* obj) { 950 static inline void Visit(Map* map, HeapObject* obj);
951 Heap* heap = map->GetHeap();
952 int object_size = obj->Size();
953 heap->RecordObjectStats(map->instance_type(), object_size);
954 non_count_table_.GetVisitorById(static_cast<VisitorId>(id))(map, obj);
955 }
956 }; 951 };
957 952
958 static void Initialize() { 953 static void Initialize();
959 table_.Register(kVisitShortcutCandidate,
960 &FixedBodyVisitor<StaticMarkingVisitor,
961 ConsString::BodyDescriptor,
962 void>::Visit);
963
964 table_.Register(kVisitConsString,
965 &FixedBodyVisitor<StaticMarkingVisitor,
966 ConsString::BodyDescriptor,
967 void>::Visit);
968
969 table_.Register(kVisitSlicedString,
970 &FixedBodyVisitor<StaticMarkingVisitor,
971 SlicedString::BodyDescriptor,
972 void>::Visit);
973
974 table_.Register(kVisitFixedArray,
975 &FlexibleBodyVisitor<StaticMarkingVisitor,
976 FixedArray::BodyDescriptor,
977 void>::Visit);
978
979 table_.Register(kVisitGlobalContext, &VisitGlobalContext);
980
981 table_.Register(kVisitFixedDoubleArray, DataObjectVisitor::Visit);
982
983 table_.Register(kVisitByteArray, &DataObjectVisitor::Visit);
984 table_.Register(kVisitFreeSpace, &DataObjectVisitor::Visit);
985 table_.Register(kVisitSeqAsciiString, &DataObjectVisitor::Visit);
986 table_.Register(kVisitSeqTwoByteString, &DataObjectVisitor::Visit);
987
988 table_.Register(kVisitJSWeakMap, &VisitJSWeakMap);
989
990 table_.Register(kVisitOddball,
991 &FixedBodyVisitor<StaticMarkingVisitor,
992 Oddball::BodyDescriptor,
993 void>::Visit);
994 table_.Register(kVisitMap,
995 &FixedBodyVisitor<StaticMarkingVisitor,
996 Map::BodyDescriptor,
997 void>::Visit);
998
999 table_.Register(kVisitCode, &VisitCode);
1000
1001 table_.Register(kVisitSharedFunctionInfo,
1002 &VisitSharedFunctionInfoAndFlushCode);
1003
1004 table_.Register(kVisitJSFunction,
1005 &VisitJSFunctionAndFlushCode);
1006
1007 table_.Register(kVisitJSRegExp,
1008 &VisitRegExpAndFlushCode);
1009
1010 table_.Register(kVisitPropertyCell,
1011 &FixedBodyVisitor<StaticMarkingVisitor,
1012 JSGlobalPropertyCell::BodyDescriptor,
1013 void>::Visit);
1014
1015 table_.RegisterSpecializations<DataObjectVisitor,
1016 kVisitDataObject,
1017 kVisitDataObjectGeneric>();
1018
1019 table_.RegisterSpecializations<JSObjectVisitor,
1020 kVisitJSObject,
1021 kVisitJSObjectGeneric>();
1022
1023 table_.RegisterSpecializations<StructObjectVisitor,
1024 kVisitStruct,
1025 kVisitStructGeneric>();
1026
1027 if (FLAG_track_gc_object_stats) {
1028 // Copy the visitor table to make call-through possible.
1029 non_count_table_.CopyFrom(&table_);
1030 #define VISITOR_ID_COUNT_FUNCTION(id)\
1031 table_.Register(kVisit##id, ObjectStatsTracker<kVisit##id>::Visit);
1032 VISITOR_ID_LIST(VISITOR_ID_COUNT_FUNCTION)
1033 #undef VISITOR_ID_COUNT_FUNCTION
1034 }
1035 }
1036 954
1037 INLINE(static void VisitPointer(Heap* heap, Object** p)) { 955 INLINE(static void VisitPointer(Heap* heap, Object** p)) {
1038 MarkObjectByPointer(heap->mark_compact_collector(), p, p); 956 MarkObjectByPointer(heap->mark_compact_collector(), p, p);
1039 } 957 }
1040 958
1041 INLINE(static void VisitPointers(Heap* heap, Object** start, Object** end)) { 959 INLINE(static void VisitPointers(Heap* heap, Object** start, Object** end)) {
1042 // Mark all objects pointed to in [start, end). 960 // Mark all objects pointed to in [start, end).
1043 const int kMinRangeForMarkingRecursion = 64; 961 const int kMinRangeForMarkingRecursion = 64;
1044 if (end - start >= kMinRangeForMarkingRecursion) { 962 if (end - start >= kMinRangeForMarkingRecursion) {
1045 if (VisitUnmarkedObjects(heap, start, end)) return; 963 if (VisitUnmarkedObjects(heap, start, end)) return;
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 1492
1575 #undef SLOT_ADDR 1493 #undef SLOT_ADDR
1576 1494
1577 typedef void (*Callback)(Map* map, HeapObject* object); 1495 typedef void (*Callback)(Map* map, HeapObject* object);
1578 1496
1579 static VisitorDispatchTable<Callback> table_; 1497 static VisitorDispatchTable<Callback> table_;
1580 static VisitorDispatchTable<Callback> non_count_table_; 1498 static VisitorDispatchTable<Callback> non_count_table_;
1581 }; 1499 };
1582 1500
1583 1501
1502 template<int id>
1503 void StaticMarkingVisitor::ObjectStatsTracker<id>::Visit(
1504 Map* map, HeapObject* obj) {
1505 Heap* heap = map->GetHeap();
1506 int object_size = obj->Size();
1507 heap->RecordObjectStats(map->instance_type(), -1, object_size);
1508 non_count_table_.GetVisitorById(static_cast<VisitorId>(id))(map, obj);
1509 }
1510
1511
1512 template<>
1513 class StaticMarkingVisitor::ObjectStatsTracker<
1514 StaticMarkingVisitor::kVisitCode> {
1515 public:
1516 static inline void Visit(Map* map, HeapObject* obj) {
1517 Heap* heap = map->GetHeap();
1518 int object_size = obj->Size();
1519 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);
1522 non_count_table_.GetVisitorById(
1523 static_cast<VisitorId>(kVisitCode))(map, obj);
1524 }
1525 };
1526
1527
1528 void StaticMarkingVisitor::Initialize() {
1529 table_.Register(kVisitShortcutCandidate,
1530 &FixedBodyVisitor<StaticMarkingVisitor,
1531 ConsString::BodyDescriptor,
1532 void>::Visit);
1533
1534 table_.Register(kVisitConsString,
1535 &FixedBodyVisitor<StaticMarkingVisitor,
1536 ConsString::BodyDescriptor,
1537 void>::Visit);
1538
1539 table_.Register(kVisitSlicedString,
1540 &FixedBodyVisitor<StaticMarkingVisitor,
1541 SlicedString::BodyDescriptor,
1542 void>::Visit);
1543
1544 table_.Register(kVisitFixedArray,
1545 &FlexibleBodyVisitor<StaticMarkingVisitor,
1546 FixedArray::BodyDescriptor,
1547 void>::Visit);
1548
1549 table_.Register(kVisitGlobalContext, &VisitGlobalContext);
1550
1551 table_.Register(kVisitFixedDoubleArray, DataObjectVisitor::Visit);
1552
1553 table_.Register(kVisitByteArray, &DataObjectVisitor::Visit);
1554 table_.Register(kVisitFreeSpace, &DataObjectVisitor::Visit);
1555 table_.Register(kVisitSeqAsciiString, &DataObjectVisitor::Visit);
1556 table_.Register(kVisitSeqTwoByteString, &DataObjectVisitor::Visit);
1557
1558 table_.Register(kVisitJSWeakMap, &VisitJSWeakMap);
1559
1560 table_.Register(kVisitOddball,
1561 &FixedBodyVisitor<StaticMarkingVisitor,
1562 Oddball::BodyDescriptor,
1563 void>::Visit);
1564 table_.Register(kVisitMap,
1565 &FixedBodyVisitor<StaticMarkingVisitor,
1566 Map::BodyDescriptor,
1567 void>::Visit);
1568
1569 table_.Register(kVisitCode, &VisitCode);
1570
1571 table_.Register(kVisitSharedFunctionInfo,
1572 &VisitSharedFunctionInfoAndFlushCode);
1573
1574 table_.Register(kVisitJSFunction,
1575 &VisitJSFunctionAndFlushCode);
1576
1577 table_.Register(kVisitJSRegExp,
1578 &VisitRegExpAndFlushCode);
1579
1580 table_.Register(kVisitPropertyCell,
1581 &FixedBodyVisitor<StaticMarkingVisitor,
1582 JSGlobalPropertyCell::BodyDescriptor,
1583 void>::Visit);
1584
1585 table_.RegisterSpecializations<DataObjectVisitor,
1586 kVisitDataObject,
1587 kVisitDataObjectGeneric>();
1588
1589 table_.RegisterSpecializations<JSObjectVisitor,
1590 kVisitJSObject,
1591 kVisitJSObjectGeneric>();
1592
1593 table_.RegisterSpecializations<StructObjectVisitor,
1594 kVisitStruct,
1595 kVisitStructGeneric>();
1596
1597 if (FLAG_track_gc_object_stats) {
1598 // Copy the visitor table to make call-through possible.
1599 non_count_table_.CopyFrom(&table_);
1600 #define VISITOR_ID_COUNT_FUNCTION(id) \
1601 table_.Register(kVisit##id, ObjectStatsTracker<kVisit##id>::Visit);
1602 VISITOR_ID_LIST(VISITOR_ID_COUNT_FUNCTION)
1603 #undef VISITOR_ID_COUNT_FUNCTION
1604 }
1605 }
1606
1607
1584 VisitorDispatchTable<StaticMarkingVisitor::Callback> 1608 VisitorDispatchTable<StaticMarkingVisitor::Callback>
1585 StaticMarkingVisitor::table_; 1609 StaticMarkingVisitor::table_;
1586 VisitorDispatchTable<StaticMarkingVisitor::Callback> 1610 VisitorDispatchTable<StaticMarkingVisitor::Callback>
1587 StaticMarkingVisitor::non_count_table_; 1611 StaticMarkingVisitor::non_count_table_;
1588 1612
1589 1613
1590 class MarkingVisitor : public ObjectVisitor { 1614 class MarkingVisitor : public ObjectVisitor {
1591 public: 1615 public:
1592 explicit MarkingVisitor(Heap* heap) : heap_(heap) { } 1616 explicit MarkingVisitor(Heap* heap) : heap_(heap) { }
1593 1617
(...skipping 2566 matching lines...) Expand 10 before | Expand all | Expand 10 after
4160 while (buffer != NULL) { 4184 while (buffer != NULL) {
4161 SlotsBuffer* next_buffer = buffer->next(); 4185 SlotsBuffer* next_buffer = buffer->next();
4162 DeallocateBuffer(buffer); 4186 DeallocateBuffer(buffer);
4163 buffer = next_buffer; 4187 buffer = next_buffer;
4164 } 4188 }
4165 *buffer_address = NULL; 4189 *buffer_address = NULL;
4166 } 4190 }
4167 4191
4168 4192
4169 } } // namespace v8::internal 4193 } } // 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