Index: src/mark-compact.cc |
diff --git a/src/mark-compact.cc b/src/mark-compact.cc |
index 37fec4e8b8312e2adf9b38113aefa257aa28cbf4..693e1d1c873cf53d7109193e62bfba53bfee2e3c 100644 |
--- a/src/mark-compact.cc |
+++ b/src/mark-compact.cc |
@@ -861,11 +861,13 @@ void MarkCompactCollector::Finish() { |
void CodeFlusher::ProcessJSFunctionCandidates() { |
Code* lazy_compile = isolate_->builtins()->builtin(Builtins::kLazyCompile); |
+ Object* undefined = isolate_->heap()->undefined_value(); |
JSFunction* candidate = jsfunction_candidates_head_; |
JSFunction* next_candidate; |
while (candidate != NULL) { |
next_candidate = GetNextCandidate(candidate); |
+ ClearNextCandidate(candidate, undefined); |
SharedFunctionInfo* shared = candidate->shared(); |
@@ -874,8 +876,8 @@ void CodeFlusher::ProcessJSFunctionCandidates() { |
if (!code_mark.Get()) { |
shared->set_code(lazy_compile); |
candidate->set_code(lazy_compile); |
- } else { |
- candidate->set_code(shared->code()); |
+ } else if (code == lazy_compile) { |
+ candidate->set_code(lazy_compile); |
} |
// We are in the middle of a GC cycle so the write barrier in the code |
@@ -904,7 +906,7 @@ void CodeFlusher::ProcessSharedFunctionInfoCandidates() { |
SharedFunctionInfo* next_candidate; |
while (candidate != NULL) { |
next_candidate = GetNextCandidate(candidate); |
- SetNextCandidate(candidate, NULL); |
+ ClearNextCandidate(candidate); |
Code* code = candidate->code(); |
MarkBit code_mark = Marking::MarkBitFrom(code); |
@@ -924,6 +926,32 @@ void CodeFlusher::ProcessSharedFunctionInfoCandidates() { |
} |
+void CodeFlusher::EvictCandidate(JSFunction* function) { |
+ ASSERT(!function->next_function_link()->IsUndefined()); |
+ Object* undefined = isolate_->heap()->undefined_value(); |
+ |
+ JSFunction* candidate = jsfunction_candidates_head_; |
+ JSFunction* next_candidate; |
+ if (candidate == function) { |
+ next_candidate = GetNextCandidate(function); |
+ jsfunction_candidates_head_ = next_candidate; |
+ ClearNextCandidate(function, undefined); |
+ } else { |
+ while (candidate != NULL) { |
+ next_candidate = GetNextCandidate(candidate); |
+ |
+ if (next_candidate == function) { |
+ next_candidate = GetNextCandidate(function); |
+ SetNextCandidate(candidate, next_candidate); |
+ ClearNextCandidate(function, undefined); |
+ } |
+ |
+ candidate = next_candidate; |
+ } |
+ } |
+} |
+ |
+ |
MarkCompactCollector::~MarkCompactCollector() { |
if (code_flusher_ != NULL) { |
delete code_flusher_; |
@@ -1428,21 +1456,8 @@ void MarkCompactCollector::PrepareThreadForCodeFlushing(Isolate* isolate, |
void MarkCompactCollector::PrepareForCodeFlushing() { |
ASSERT(heap() == Isolate::Current()->heap()); |
- // TODO(1609) Currently incremental marker does not support code flushing. |
- if (!FLAG_flush_code || was_marked_incrementally_) { |
- EnableCodeFlushing(false); |
- return; |
- } |
- |
-#ifdef ENABLE_DEBUGGER_SUPPORT |
- if (heap()->isolate()->debug()->IsLoaded() || |
- heap()->isolate()->debug()->has_break_points()) { |
- EnableCodeFlushing(false); |
- return; |
- } |
-#endif |
- |
- EnableCodeFlushing(true); |
+ // If code flushing is disabled, there is no need to prepare for it. |
+ if (!is_code_flushing_enabled()) return; |
// Ensure that empty descriptor array is marked. Method MarkDescriptorArray |
// relies on it being marked before any other descriptor array. |
@@ -2003,9 +2018,6 @@ void MarkCompactCollector::AfterMarking() { |
// Flush code from collected candidates. |
if (is_code_flushing_enabled()) { |
code_flusher_->ProcessCandidates(); |
- // TODO(1609) Currently incremental marker does not support code flushing, |
- // we need to disable it before incremental marking steps for next cycle. |
- EnableCodeFlushing(false); |
} |
if (!FLAG_watch_ic_patching) { |