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 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
919 isolate_->heap()->mark_compact_collector()-> | 919 isolate_->heap()->mark_compact_collector()-> |
920 RecordSlot(code_slot, code_slot, *code_slot); | 920 RecordSlot(code_slot, code_slot, *code_slot); |
921 | 921 |
922 candidate = next_candidate; | 922 candidate = next_candidate; |
923 } | 923 } |
924 | 924 |
925 shared_function_info_candidates_head_ = NULL; | 925 shared_function_info_candidates_head_ = NULL; |
926 } | 926 } |
927 | 927 |
928 | 928 |
929 void CodeFlusher::EvictCandidate(JSFunction* function) { | |
930 ASSERT(!function->next_function_link()->IsUndefined()); | |
931 Object* undefined = isolate_->heap()->undefined_value(); | |
932 | |
933 JSFunction* candidate = jsfunction_candidates_head_; | |
934 JSFunction* next_candidate; | |
935 if (candidate == function) { | |
936 next_candidate = GetNextCandidate(function); | |
937 jsfunction_candidates_head_ = next_candidate; | |
938 ClearNextCandidate(function, undefined); | |
939 } else { | |
940 while (candidate != NULL) { | |
941 next_candidate = GetNextCandidate(candidate); | |
942 | |
943 if (next_candidate == function) { | |
944 next_candidate = GetNextCandidate(function); | |
945 SetNextCandidate(candidate, next_candidate); | |
946 ClearNextCandidate(function, undefined); | |
947 } | |
948 | |
949 candidate = next_candidate; | |
950 } | |
951 } | |
952 } | |
953 | |
954 | |
955 void CodeFlusher::IteratePointersToFromSpace(ObjectVisitor* v) { | |
956 Heap* heap = isolate_->heap(); | |
957 | |
958 JSFunction** slot = &jsfunction_candidates_head_; | |
959 JSFunction* candidate = jsfunction_candidates_head_; | |
960 while (candidate != NULL) { | |
961 if (heap->InFromSpace(candidate)) { | |
962 v->VisitPointer(reinterpret_cast<Object**>(slot)); | |
963 } | |
964 candidate = GetNextCandidate(*slot); | |
965 slot = GetNextCandidateSlot(*slot); | |
966 } | |
967 } | |
968 | |
969 | |
970 MarkCompactCollector::~MarkCompactCollector() { | 929 MarkCompactCollector::~MarkCompactCollector() { |
971 if (code_flusher_ != NULL) { | 930 if (code_flusher_ != NULL) { |
972 delete code_flusher_; | 931 delete code_flusher_; |
973 code_flusher_ = NULL; | 932 code_flusher_ = NULL; |
974 } | 933 } |
975 } | 934 } |
976 | 935 |
977 | 936 |
978 static inline HeapObject* ShortCircuitConsString(Object** p) { | 937 static inline HeapObject* ShortCircuitConsString(Object** p) { |
979 // Optimization: If the heap object pointed to by p is a non-symbol | 938 // Optimization: If the heap object pointed to by p is a non-symbol |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1464 MarkCompactMarkingVisitor::MarkInlinedFunctionsCode(heap(), | 1423 MarkCompactMarkingVisitor::MarkInlinedFunctionsCode(heap(), |
1465 frame->LookupCode()); | 1424 frame->LookupCode()); |
1466 } | 1425 } |
1467 } | 1426 } |
1468 } | 1427 } |
1469 | 1428 |
1470 | 1429 |
1471 void MarkCompactCollector::PrepareForCodeFlushing() { | 1430 void MarkCompactCollector::PrepareForCodeFlushing() { |
1472 ASSERT(heap() == Isolate::Current()->heap()); | 1431 ASSERT(heap() == Isolate::Current()->heap()); |
1473 | 1432 |
1474 // If code flushing is disabled, there is no need to prepare for it. | 1433 // TODO(1609) Currently incremental marker does not support code flushing. |
1475 if (!is_code_flushing_enabled()) return; | 1434 if (!FLAG_flush_code || was_marked_incrementally_) { |
| 1435 EnableCodeFlushing(false); |
| 1436 return; |
| 1437 } |
| 1438 |
| 1439 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 1440 if (heap()->isolate()->debug()->IsLoaded() || |
| 1441 heap()->isolate()->debug()->has_break_points()) { |
| 1442 EnableCodeFlushing(false); |
| 1443 return; |
| 1444 } |
| 1445 #endif |
| 1446 |
| 1447 EnableCodeFlushing(true); |
1476 | 1448 |
1477 // Ensure that empty descriptor array is marked. Method MarkDescriptorArray | 1449 // Ensure that empty descriptor array is marked. Method MarkDescriptorArray |
1478 // relies on it being marked before any other descriptor array. | 1450 // relies on it being marked before any other descriptor array. |
1479 HeapObject* descriptor_array = heap()->empty_descriptor_array(); | 1451 HeapObject* descriptor_array = heap()->empty_descriptor_array(); |
1480 MarkBit descriptor_array_mark = Marking::MarkBitFrom(descriptor_array); | 1452 MarkBit descriptor_array_mark = Marking::MarkBitFrom(descriptor_array); |
1481 MarkObject(descriptor_array, descriptor_array_mark); | 1453 MarkObject(descriptor_array, descriptor_array_mark); |
1482 | 1454 |
1483 // Make sure we are not referencing the code from the stack. | 1455 // Make sure we are not referencing the code from the stack. |
1484 ASSERT(this == heap()->mark_compact_collector()); | 1456 ASSERT(this == heap()->mark_compact_collector()); |
1485 PrepareThreadForCodeFlushing(heap()->isolate(), | 1457 PrepareThreadForCodeFlushing(heap()->isolate(), |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2026 MarkCompactWeakObjectRetainer mark_compact_object_retainer; | 1998 MarkCompactWeakObjectRetainer mark_compact_object_retainer; |
2027 heap()->ProcessWeakReferences(&mark_compact_object_retainer); | 1999 heap()->ProcessWeakReferences(&mark_compact_object_retainer); |
2028 | 2000 |
2029 // Remove object groups after marking phase. | 2001 // Remove object groups after marking phase. |
2030 heap()->isolate()->global_handles()->RemoveObjectGroups(); | 2002 heap()->isolate()->global_handles()->RemoveObjectGroups(); |
2031 heap()->isolate()->global_handles()->RemoveImplicitRefGroups(); | 2003 heap()->isolate()->global_handles()->RemoveImplicitRefGroups(); |
2032 | 2004 |
2033 // Flush code from collected candidates. | 2005 // Flush code from collected candidates. |
2034 if (is_code_flushing_enabled()) { | 2006 if (is_code_flushing_enabled()) { |
2035 code_flusher_->ProcessCandidates(); | 2007 code_flusher_->ProcessCandidates(); |
| 2008 // TODO(1609) Currently incremental marker does not support code flushing, |
| 2009 // we need to disable it before incremental marking steps for next cycle. |
| 2010 EnableCodeFlushing(false); |
2036 } | 2011 } |
2037 | 2012 |
2038 if (!FLAG_watch_ic_patching) { | 2013 if (!FLAG_watch_ic_patching) { |
2039 // Clean up dead objects from the runtime profiler. | 2014 // Clean up dead objects from the runtime profiler. |
2040 heap()->isolate()->runtime_profiler()->RemoveDeadSamples(); | 2015 heap()->isolate()->runtime_profiler()->RemoveDeadSamples(); |
2041 } | 2016 } |
2042 | 2017 |
2043 if (FLAG_track_gc_object_stats) { | 2018 if (FLAG_track_gc_object_stats) { |
2044 heap()->CheckpointObjectStats(); | 2019 heap()->CheckpointObjectStats(); |
2045 } | 2020 } |
(...skipping 1742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3788 while (buffer != NULL) { | 3763 while (buffer != NULL) { |
3789 SlotsBuffer* next_buffer = buffer->next(); | 3764 SlotsBuffer* next_buffer = buffer->next(); |
3790 DeallocateBuffer(buffer); | 3765 DeallocateBuffer(buffer); |
3791 buffer = next_buffer; | 3766 buffer = next_buffer; |
3792 } | 3767 } |
3793 *buffer_address = NULL; | 3768 *buffer_address = NULL; |
3794 } | 3769 } |
3795 | 3770 |
3796 | 3771 |
3797 } } // namespace v8::internal | 3772 } } // namespace v8::internal |
OLD | NEW |