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> |
| 948 class ObjectStatsTracker { |
| 949 public: |
| 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 }; |
| 957 |
947 static void Initialize() { | 958 static void Initialize() { |
948 table_.Register(kVisitShortcutCandidate, | 959 table_.Register(kVisitShortcutCandidate, |
949 &FixedBodyVisitor<StaticMarkingVisitor, | 960 &FixedBodyVisitor<StaticMarkingVisitor, |
950 ConsString::BodyDescriptor, | 961 ConsString::BodyDescriptor, |
951 void>::Visit); | 962 void>::Visit); |
952 | 963 |
953 table_.Register(kVisitConsString, | 964 table_.Register(kVisitConsString, |
954 &FixedBodyVisitor<StaticMarkingVisitor, | 965 &FixedBodyVisitor<StaticMarkingVisitor, |
955 ConsString::BodyDescriptor, | 966 ConsString::BodyDescriptor, |
956 void>::Visit); | 967 void>::Visit); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 kVisitDataObject, | 1016 kVisitDataObject, |
1006 kVisitDataObjectGeneric>(); | 1017 kVisitDataObjectGeneric>(); |
1007 | 1018 |
1008 table_.RegisterSpecializations<JSObjectVisitor, | 1019 table_.RegisterSpecializations<JSObjectVisitor, |
1009 kVisitJSObject, | 1020 kVisitJSObject, |
1010 kVisitJSObjectGeneric>(); | 1021 kVisitJSObjectGeneric>(); |
1011 | 1022 |
1012 table_.RegisterSpecializations<StructObjectVisitor, | 1023 table_.RegisterSpecializations<StructObjectVisitor, |
1013 kVisitStruct, | 1024 kVisitStruct, |
1014 kVisitStructGeneric>(); | 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 } |
1015 } | 1035 } |
1016 | 1036 |
1017 INLINE(static void VisitPointer(Heap* heap, Object** p)) { | 1037 INLINE(static void VisitPointer(Heap* heap, Object** p)) { |
1018 MarkObjectByPointer(heap->mark_compact_collector(), p, p); | 1038 MarkObjectByPointer(heap->mark_compact_collector(), p, p); |
1019 } | 1039 } |
1020 | 1040 |
1021 INLINE(static void VisitPointers(Heap* heap, Object** start, Object** end)) { | 1041 INLINE(static void VisitPointers(Heap* heap, Object** start, Object** end)) { |
1022 // Mark all objects pointed to in [start, end). | 1042 // Mark all objects pointed to in [start, end). |
1023 const int kMinRangeForMarkingRecursion = 64; | 1043 const int kMinRangeForMarkingRecursion = 64; |
1024 if (end - start >= kMinRangeForMarkingRecursion) { | 1044 if (end - start >= kMinRangeForMarkingRecursion) { |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1550 VisitPointers(heap, | 1570 VisitPointers(heap, |
1551 SLOT_ADDR(object, SharedFunctionInfo::kOptimizedCodeMapOffset), | 1571 SLOT_ADDR(object, SharedFunctionInfo::kOptimizedCodeMapOffset), |
1552 SLOT_ADDR(object, SharedFunctionInfo::kSize)); | 1572 SLOT_ADDR(object, SharedFunctionInfo::kSize)); |
1553 } | 1573 } |
1554 | 1574 |
1555 #undef SLOT_ADDR | 1575 #undef SLOT_ADDR |
1556 | 1576 |
1557 typedef void (*Callback)(Map* map, HeapObject* object); | 1577 typedef void (*Callback)(Map* map, HeapObject* object); |
1558 | 1578 |
1559 static VisitorDispatchTable<Callback> table_; | 1579 static VisitorDispatchTable<Callback> table_; |
| 1580 static VisitorDispatchTable<Callback> non_count_table_; |
1560 }; | 1581 }; |
1561 | 1582 |
1562 | 1583 |
1563 VisitorDispatchTable<StaticMarkingVisitor::Callback> | 1584 VisitorDispatchTable<StaticMarkingVisitor::Callback> |
1564 StaticMarkingVisitor::table_; | 1585 StaticMarkingVisitor::table_; |
| 1586 VisitorDispatchTable<StaticMarkingVisitor::Callback> |
| 1587 StaticMarkingVisitor::non_count_table_; |
1565 | 1588 |
1566 | 1589 |
1567 class MarkingVisitor : public ObjectVisitor { | 1590 class MarkingVisitor : public ObjectVisitor { |
1568 public: | 1591 public: |
1569 explicit MarkingVisitor(Heap* heap) : heap_(heap) { } | 1592 explicit MarkingVisitor(Heap* heap) : heap_(heap) { } |
1570 | 1593 |
1571 void VisitPointer(Object** p) { | 1594 void VisitPointer(Object** p) { |
1572 StaticMarkingVisitor::VisitPointer(heap_, p); | 1595 StaticMarkingVisitor::VisitPointer(heap_, p); |
1573 } | 1596 } |
1574 | 1597 |
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2430 | 2453 |
2431 // Flush code from collected candidates. | 2454 // Flush code from collected candidates. |
2432 if (is_code_flushing_enabled()) { | 2455 if (is_code_flushing_enabled()) { |
2433 code_flusher_->ProcessCandidates(); | 2456 code_flusher_->ProcessCandidates(); |
2434 } | 2457 } |
2435 | 2458 |
2436 if (!FLAG_watch_ic_patching) { | 2459 if (!FLAG_watch_ic_patching) { |
2437 // Clean up dead objects from the runtime profiler. | 2460 // Clean up dead objects from the runtime profiler. |
2438 heap()->isolate()->runtime_profiler()->RemoveDeadSamples(); | 2461 heap()->isolate()->runtime_profiler()->RemoveDeadSamples(); |
2439 } | 2462 } |
| 2463 |
| 2464 if (FLAG_track_gc_object_stats) { |
| 2465 heap()->CheckpointObjectStats(); |
| 2466 } |
2440 } | 2467 } |
2441 | 2468 |
2442 | 2469 |
2443 void MarkCompactCollector::ProcessMapCaches() { | 2470 void MarkCompactCollector::ProcessMapCaches() { |
2444 Object* raw_context = heap()->global_contexts_list_; | 2471 Object* raw_context = heap()->global_contexts_list_; |
2445 while (raw_context != heap()->undefined_value()) { | 2472 while (raw_context != heap()->undefined_value()) { |
2446 Context* context = reinterpret_cast<Context*>(raw_context); | 2473 Context* context = reinterpret_cast<Context*>(raw_context); |
2447 if (IsMarked(context)) { | 2474 if (IsMarked(context)) { |
2448 HeapObject* raw_map_cache = | 2475 HeapObject* raw_map_cache = |
2449 HeapObject::cast(context->get(Context::MAP_CACHE_INDEX)); | 2476 HeapObject::cast(context->get(Context::MAP_CACHE_INDEX)); |
(...skipping 1706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4156 while (buffer != NULL) { | 4183 while (buffer != NULL) { |
4157 SlotsBuffer* next_buffer = buffer->next(); | 4184 SlotsBuffer* next_buffer = buffer->next(); |
4158 DeallocateBuffer(buffer); | 4185 DeallocateBuffer(buffer); |
4159 buffer = next_buffer; | 4186 buffer = next_buffer; |
4160 } | 4187 } |
4161 *buffer_address = NULL; | 4188 *buffer_address = NULL; |
4162 } | 4189 } |
4163 | 4190 |
4164 | 4191 |
4165 } } // namespace v8::internal | 4192 } } // namespace v8::internal |
OLD | NEW |