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

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: Turn flag off by default 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
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) {
Michael Starzinger 2012/07/17 10:48:16 Can we move the implementation of this method out
danno 2012/07/17 11:57:10 Done.
951 Heap* heap = map->GetHeap(); 951 Heap* heap = map->GetHeap();
952 int object_size = obj->Size(); 952 int object_size = obj->Size();
953 heap->RecordObjectStats(map->instance_type(), object_size); 953 heap->RecordObjectStats(map->instance_type(), -1, object_size);
954 non_count_table_.GetVisitorById(static_cast<VisitorId>(id))(map, obj); 954 non_count_table_.GetVisitorById(static_cast<VisitorId>(id))(map, obj);
955 } 955 }
956 }; 956 };
957 957
958 static void Initialize() { 958 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 959
1037 INLINE(static void VisitPointer(Heap* heap, Object** p)) { 960 INLINE(static void VisitPointer(Heap* heap, Object** p)) {
1038 MarkObjectByPointer(heap->mark_compact_collector(), p, p); 961 MarkObjectByPointer(heap->mark_compact_collector(), p, p);
1039 } 962 }
1040 963
1041 INLINE(static void VisitPointers(Heap* heap, Object** start, Object** end)) { 964 INLINE(static void VisitPointers(Heap* heap, Object** start, Object** end)) {
1042 // Mark all objects pointed to in [start, end). 965 // Mark all objects pointed to in [start, end).
1043 const int kMinRangeForMarkingRecursion = 64; 966 const int kMinRangeForMarkingRecursion = 64;
1044 if (end - start >= kMinRangeForMarkingRecursion) { 967 if (end - start >= kMinRangeForMarkingRecursion) {
1045 if (VisitUnmarkedObjects(heap, start, end)) return; 968 if (VisitUnmarkedObjects(heap, start, end)) return;
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 1497
1575 #undef SLOT_ADDR 1498 #undef SLOT_ADDR
1576 1499
1577 typedef void (*Callback)(Map* map, HeapObject* object); 1500 typedef void (*Callback)(Map* map, HeapObject* object);
1578 1501
1579 static VisitorDispatchTable<Callback> table_; 1502 static VisitorDispatchTable<Callback> table_;
1580 static VisitorDispatchTable<Callback> non_count_table_; 1503 static VisitorDispatchTable<Callback> non_count_table_;
1581 }; 1504 };
1582 1505
1583 1506
1507 template<>
1508 class StaticMarkingVisitor::ObjectStatsTracker<
1509 StaticMarkingVisitor::kVisitCode> {
1510 public:
1511 static inline void Visit(Map* map, HeapObject* obj) {
1512 Heap* heap = map->GetHeap();
1513 int object_size = obj->Size();
1514 ASSERT(map->instance_type() == CODE_TYPE);
1515 heap->RecordObjectStats(CODE_TYPE, -1, object_size);
1516 heap->RecordObjectStats(CODE_TYPE, Code::cast(obj)->kind(), object_size);
1517 non_count_table_.GetVisitorById(
1518 static_cast<VisitorId>(kVisitCode))(map, obj);
1519 }
1520 };
1521
1522
1523 void StaticMarkingVisitor::Initialize() {
1524 table_.Register(kVisitShortcutCandidate,
1525 &FixedBodyVisitor<StaticMarkingVisitor,
1526 ConsString::BodyDescriptor,
1527 void>::Visit);
1528
1529 table_.Register(kVisitConsString,
1530 &FixedBodyVisitor<StaticMarkingVisitor,
1531 ConsString::BodyDescriptor,
1532 void>::Visit);
1533
1534 table_.Register(kVisitSlicedString,
1535 &FixedBodyVisitor<StaticMarkingVisitor,
1536 SlicedString::BodyDescriptor,
1537 void>::Visit);
1538
1539 table_.Register(kVisitFixedArray,
1540 &FlexibleBodyVisitor<StaticMarkingVisitor,
1541 FixedArray::BodyDescriptor,
1542 void>::Visit);
1543
1544 table_.Register(kVisitGlobalContext, &VisitGlobalContext);
1545
1546 table_.Register(kVisitFixedDoubleArray, DataObjectVisitor::Visit);
1547
1548 table_.Register(kVisitByteArray, &DataObjectVisitor::Visit);
1549 table_.Register(kVisitFreeSpace, &DataObjectVisitor::Visit);
1550 table_.Register(kVisitSeqAsciiString, &DataObjectVisitor::Visit);
1551 table_.Register(kVisitSeqTwoByteString, &DataObjectVisitor::Visit);
1552
1553 table_.Register(kVisitJSWeakMap, &VisitJSWeakMap);
1554
1555 table_.Register(kVisitOddball,
1556 &FixedBodyVisitor<StaticMarkingVisitor,
1557 Oddball::BodyDescriptor,
1558 void>::Visit);
1559 table_.Register(kVisitMap,
1560 &FixedBodyVisitor<StaticMarkingVisitor,
1561 Map::BodyDescriptor,
1562 void>::Visit);
1563
1564 table_.Register(kVisitCode, &VisitCode);
1565
1566 table_.Register(kVisitSharedFunctionInfo,
1567 &VisitSharedFunctionInfoAndFlushCode);
1568
1569 table_.Register(kVisitJSFunction,
1570 &VisitJSFunctionAndFlushCode);
1571
1572 table_.Register(kVisitJSRegExp,
1573 &VisitRegExpAndFlushCode);
1574
1575 table_.Register(kVisitPropertyCell,
1576 &FixedBodyVisitor<StaticMarkingVisitor,
1577 JSGlobalPropertyCell::BodyDescriptor,
1578 void>::Visit);
1579
1580 table_.RegisterSpecializations<DataObjectVisitor,
1581 kVisitDataObject,
1582 kVisitDataObjectGeneric>();
1583
1584 table_.RegisterSpecializations<JSObjectVisitor,
1585 kVisitJSObject,
1586 kVisitJSObjectGeneric>();
1587
1588 table_.RegisterSpecializations<StructObjectVisitor,
1589 kVisitStruct,
1590 kVisitStructGeneric>();
1591
1592 if (FLAG_track_gc_object_stats) {
1593 // Copy the visitor table to make call-through possible.
1594 non_count_table_.CopyFrom(&table_);
1595 #define VISITOR_ID_COUNT_FUNCTION(id) \
1596 table_.Register(kVisit##id, ObjectStatsTracker<kVisit##id>::Visit);
1597 VISITOR_ID_LIST(VISITOR_ID_COUNT_FUNCTION)
1598 #undef VISITOR_ID_COUNT_FUNCTION
1599 }
1600 }
1601
1602
1584 VisitorDispatchTable<StaticMarkingVisitor::Callback> 1603 VisitorDispatchTable<StaticMarkingVisitor::Callback>
1585 StaticMarkingVisitor::table_; 1604 StaticMarkingVisitor::table_;
1586 VisitorDispatchTable<StaticMarkingVisitor::Callback> 1605 VisitorDispatchTable<StaticMarkingVisitor::Callback>
1587 StaticMarkingVisitor::non_count_table_; 1606 StaticMarkingVisitor::non_count_table_;
1588 1607
1589 1608
1590 class MarkingVisitor : public ObjectVisitor { 1609 class MarkingVisitor : public ObjectVisitor {
1591 public: 1610 public:
1592 explicit MarkingVisitor(Heap* heap) : heap_(heap) { } 1611 explicit MarkingVisitor(Heap* heap) : heap_(heap) { }
1593 1612
(...skipping 2589 matching lines...) Expand 10 before | Expand all | Expand 10 after
4183 while (buffer != NULL) { 4202 while (buffer != NULL) {
4184 SlotsBuffer* next_buffer = buffer->next(); 4203 SlotsBuffer* next_buffer = buffer->next();
4185 DeallocateBuffer(buffer); 4204 DeallocateBuffer(buffer);
4186 buffer = next_buffer; 4205 buffer = next_buffer;
4187 } 4206 }
4188 *buffer_address = NULL; 4207 *buffer_address = NULL;
4189 } 4208 }
4190 4209
4191 4210
4192 } } // namespace v8::internal 4211 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698