Chromium Code Reviews| Index: src/mark-compact.cc |
| diff --git a/src/mark-compact.cc b/src/mark-compact.cc |
| index 9606092713a0e311ebe9e13b23eb04394d87c95a..412baf5d2fd3aca8f4b5d0c0c96e14268438de0b 100644 |
| --- a/src/mark-compact.cc |
| +++ b/src/mark-compact.cc |
| @@ -82,6 +82,16 @@ class VerifyMarkingVisitor: public ObjectVisitor { |
| } |
| } |
| } |
| + |
|
Michael Starzinger
2013/01/21 10:31:48
Drop one of the empty newlines.
|
| + |
| + void VisitEmbeddedPointer(RelocInfo* rinfo) { |
| + ASSERT(rinfo->rmode() == RelocInfo::EMBEDDED_OBJECT); |
| + if (rinfo->host()->kind() != Code::OPTIMIZED_FUNCTION || |
| + !rinfo->target_object()->IsMap() || |
| + !Map::cast(rinfo->target_object())->CanTransition()) { |
| + VisitPointer(rinfo->target_object_address()); |
| + } |
| + } |
| }; |
| @@ -823,6 +833,13 @@ void MarkCompactCollector::Prepare(GCTracer* tracer) { |
| #endif |
| } |
| +class DeoptimizeMarkedCodeFilter : public OptimizedFunctionFilter { |
| + public: |
| + virtual bool TakeFunction(JSFunction* function) { |
| + return function->code()->marked_for_deoptimization(); |
| + } |
| +}; |
| + |
| void MarkCompactCollector::Finish() { |
| #ifdef DEBUG |
| @@ -834,6 +851,9 @@ void MarkCompactCollector::Finish() { |
| // GC, because it relies on the new address of certain old space |
| // objects (empty string, illegal builtin). |
| heap()->isolate()->stub_cache()->Clear(); |
| + |
| + DeoptimizeMarkedCodeFilter filter; |
| + Deoptimizer::DeoptimizeAllFunctionsWith(&filter); |
| } |
| @@ -2178,9 +2198,7 @@ void MarkCompactCollector::ClearNonLiveTransitions() { |
| if (map->IsFreeSpace()) continue; |
| ASSERT(map->IsMap()); |
| - // Only JSObject and subtypes have map transitions and back pointers. |
| - STATIC_ASSERT(LAST_TYPE == LAST_JS_OBJECT_TYPE); |
| - if (map->instance_type() < FIRST_JS_OBJECT_TYPE) continue; |
| + if (!map->CanTransition()) continue; |
| if (map_mark.Get() && |
| map->attached_to_shared_function_info()) { |
| @@ -2192,6 +2210,12 @@ void MarkCompactCollector::ClearNonLiveTransitions() { |
| ClearNonLivePrototypeTransitions(map); |
| ClearNonLiveMapTransitions(map, map_mark); |
| + |
| + if (map_mark.Get()) { |
| + ClearNonLiveDependentCodes(map); |
| + } else { |
| + DeoptimizeLiveDependentCodes(map); |
|
Michael Starzinger
2013/01/21 10:31:48
How about naming this ClearAndDeoptimizeDependentC
ulan
2013/01/21 13:11:57
Done.
|
| + } |
| } |
| } |
| @@ -2260,6 +2284,46 @@ void MarkCompactCollector::ClearNonLiveMapTransitions(Map* map, |
| } |
| +void MarkCompactCollector::DeoptimizeLiveDependentCodes(Map* map) { |
| + AssertNoAllocation no_allocation_scope; |
| + DependentCodes* codes = map->dependent_codes(); |
| + int number_of_codes = codes->number_of_codes(); |
| + if (number_of_codes == 0) return; |
| + for (int i = 0; i < number_of_codes; i++) { |
| + Code* code = codes->code_at(i); |
| + if (IsMarked(code) && !code->marked_for_deoptimization()) { |
| + code->set_marked_for_deoptimization(true); |
| + } |
| + codes->clear_code_at(i); |
| + } |
| + map->set_dependent_codes(DependentCodes::cast(heap()->empty_fixed_array())); |
| +} |
| + |
| + |
| +void MarkCompactCollector::ClearNonLiveDependentCodes(Map* map) { |
| + AssertNoAllocation no_allocation_scope; |
| + DependentCodes* codes = map->dependent_codes(); |
| + int number_of_codes = codes->number_of_codes(); |
| + if (number_of_codes == 0) return; |
| + int new_number_of_codes = 0; |
| + for (int i = 0; i < number_of_codes; i++) { |
| + Code* code = codes->code_at(i); |
| + if (IsMarked(code) && !code->marked_for_deoptimization()) { |
| + if (new_number_of_codes != i) { |
| + codes->set_code_at(new_number_of_codes, code); |
| + Object** slot = codes->code_slot_at(new_number_of_codes); |
| + RecordSlot(slot, slot, code); |
| + new_number_of_codes++; |
| + } |
| + } |
| + } |
| + for (int i = new_number_of_codes; i < number_of_codes; i++) { |
| + codes->clear_code_at(i); |
| + } |
| + codes->set_number_of_codes(new_number_of_codes); |
| +} |
| + |
| + |
| void MarkCompactCollector::ProcessWeakMaps() { |
| Object* weak_map_obj = encountered_weak_maps(); |
| while (weak_map_obj != Smi::FromInt(0)) { |