Revision: 12843
Author: [email protected]
Date: Fri Nov 2 08:55:00 2012
Log: Revert r12825 and r12796 from trunk.
Revert "Fix code flusher to process weak function links."
Revert "Enable incremental code flushing."
[email protected]
Review URL: https://codereview.chromium.org/11360062
http://code.google.com/p/v8/source/detail?r=12843
Modified:
/trunk/src/contexts.cc
/trunk/src/heap.cc
/trunk/src/mark-compact.cc
/trunk/src/mark-compact.h
/trunk/src/objects-debug.cc
/trunk/src/version.cc
/trunk/test/cctest/test-heap.cc
=======================================
--- /trunk/src/contexts.cc Wed Oct 31 03:02:10 2012
+++ /trunk/src/contexts.cc Fri Nov 2 08:55:00 2012
@@ -250,6 +250,8 @@
element = JSFunction::cast(element)->next_function_link();
}
}
+
+ CHECK(function->next_function_link()->IsUndefined());
// Check that the context belongs to the weak native contexts list.
bool found = false;
@@ -263,16 +265,6 @@
}
CHECK(found);
#endif
-
- // If the function link field is already used then the function was
- // enqueued as a code flushing candidate and we remove it now.
- if (!function->next_function_link()->IsUndefined()) {
- CodeFlusher* flusher =
GetHeap()->mark_compact_collector()->code_flusher();
- flusher->EvictCandidate(function);
- }
-
- ASSERT(function->next_function_link()->IsUndefined());
-
function->set_next_function_link(get(OPTIMIZED_FUNCTIONS_LIST));
set(OPTIMIZED_FUNCTIONS_LIST, function);
}
=======================================
--- /trunk/src/heap.cc Wed Oct 31 03:02:10 2012
+++ /trunk/src/heap.cc Fri Nov 2 08:55:00 2012
@@ -420,14 +420,6 @@
gc_count_++;
unflattened_strings_length_ = 0;
- bool should_enable_code_flushing = FLAG_flush_code;
-#ifdef ENABLE_DEBUGGER_SUPPORT
- if (isolate_->debug()->IsLoaded() ||
isolate_->debug()->has_break_points()) {
- should_enable_code_flushing = false;
- }
-#endif
-
mark_compact_collector()->EnableCodeFlushing(should_enable_code_flushing);
-
#ifdef VERIFY_HEAP
if (FLAG_verify_heap) {
Verify();
@@ -1326,12 +1318,6 @@
scavenge_visitor.VisitPointer(reinterpret_cast<Object**>(value_address));
}
}
-
- // Copy objects reachable from the code flushing candidates list.
- MarkCompactCollector* collector = mark_compact_collector();
- if (collector->is_code_flushing_enabled()) {
-
collector->code_flusher()->IteratePointersToFromSpace(&scavenge_visitor);
- }
// Scavenge object reachable from the native contexts list directly.
scavenge_visitor.VisitPointer(BitCast<Object**>(&native_contexts_list_));
@@ -5547,7 +5533,6 @@
}
return symbol_table()->LookupSymbolIfExists(string, symbol);
}
-
void Heap::ZapFromSpace() {
NewSpacePageIterator it(new_space_.FromSpaceStart(),
=======================================
--- /trunk/src/mark-compact.cc Wed Oct 31 03:02:10 2012
+++ /trunk/src/mark-compact.cc Fri Nov 2 08:55:00 2012
@@ -924,47 +924,6 @@
shared_function_info_candidates_head_ = NULL;
}
-
-
-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;
- }
- }
-}
-
-
-void CodeFlusher::IteratePointersToFromSpace(ObjectVisitor* v) {
- Heap* heap = isolate_->heap();
-
- JSFunction** slot = &jsfunction_candidates_head_;
- JSFunction* candidate = jsfunction_candidates_head_;
- while (candidate != NULL) {
- if (heap->InFromSpace(candidate)) {
- v->VisitPointer(reinterpret_cast<Object**>(slot));
- }
- candidate = GetNextCandidate(*slot);
- slot = GetNextCandidateSlot(*slot);
- }
-}
MarkCompactCollector::~MarkCompactCollector() {
@@ -1471,8 +1430,21 @@
void MarkCompactCollector::PrepareForCodeFlushing() {
ASSERT(heap() == Isolate::Current()->heap());
- // If code flushing is disabled, there is no need to prepare for it.
- if (!is_code_flushing_enabled()) return;
+ // 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);
// Ensure that empty descriptor array is marked. Method
MarkDescriptorArray
// relies on it being marked before any other descriptor array.
@@ -2033,6 +2005,9 @@
// 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) {
=======================================
--- /trunk/src/mark-compact.h Wed Oct 31 03:02:10 2012
+++ /trunk/src/mark-compact.h Fri Nov 2 08:55:00 2012
@@ -420,38 +420,26 @@
shared_function_info_candidates_head_(NULL) {}
void AddCandidate(SharedFunctionInfo* shared_info) {
- if (GetNextCandidate(shared_info) == NULL) {
- SetNextCandidate(shared_info, shared_function_info_candidates_head_);
- shared_function_info_candidates_head_ = shared_info;
- }
+ SetNextCandidate(shared_info, shared_function_info_candidates_head_);
+ shared_function_info_candidates_head_ = shared_info;
}
void AddCandidate(JSFunction* function) {
ASSERT(function->code() == function->shared()->code());
- if (GetNextCandidate(function)->IsUndefined()) {
- SetNextCandidate(function, jsfunction_candidates_head_);
- jsfunction_candidates_head_ = function;
- }
+ ASSERT(function->next_function_link()->IsUndefined());
+ SetNextCandidate(function, jsfunction_candidates_head_);
+ jsfunction_candidates_head_ = function;
}
-
- void EvictCandidate(JSFunction* function);
void ProcessCandidates() {
ProcessSharedFunctionInfoCandidates();
ProcessJSFunctionCandidates();
}
-
- void IteratePointersToFromSpace(ObjectVisitor* v);
private:
void ProcessJSFunctionCandidates();
void ProcessSharedFunctionInfoCandidates();
- static JSFunction** GetNextCandidateSlot(JSFunction* candidate) {
- return reinterpret_cast<JSFunction**>(
- HeapObject::RawField(candidate,
JSFunction::kNextFunctionLinkOffset));
- }
-
static JSFunction* GetNextCandidate(JSFunction* candidate) {
Object* next_candidate = candidate->next_function_link();
return reinterpret_cast<JSFunction*>(next_candidate);
=======================================
--- /trunk/src/objects-debug.cc Wed Oct 31 03:02:10 2012
+++ /trunk/src/objects-debug.cc Fri Nov 2 08:55:00 2012
@@ -499,8 +499,7 @@
VerifyObjectField(kPrototypeOrInitialMapOffset);
VerifyObjectField(kNextFunctionLinkOffset);
CHECK(code()->IsCode());
- CHECK(next_function_link() == NULL ||
- next_function_link()->IsUndefined() ||
+ CHECK(next_function_link()->IsUndefined() ||
next_function_link()->IsJSFunction());
}
=======================================
--- /trunk/src/version.cc Wed Oct 31 03:02:10 2012
+++ /trunk/src/version.cc Fri Nov 2 08:55:00 2012
@@ -35,7 +35,7 @@
#define MAJOR_VERSION 3
#define MINOR_VERSION 15
#define BUILD_NUMBER 0
-#define PATCH_LEVEL 0
+#define PATCH_LEVEL 1
// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
#define IS_CANDIDATE_VERSION 0
=======================================
--- /trunk/test/cctest/test-heap.cc Wed Oct 31 03:02:10 2012
+++ /trunk/test/cctest/test-heap.cc Fri Nov 2 08:55:00 2012
@@ -21,19 +21,6 @@
v8::HandleScope scope;
env->Enter();
}
-
-
-// Go through all incremental marking steps in one swoop.
-static void SimulateIncrementalMarking() {
- IncrementalMarking* marking = HEAP->incremental_marking();
- CHECK(marking->IsStopped());
- marking->Start();
- CHECK(marking->IsMarking());
- while (!marking->IsComplete()) {
- marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
- }
- CHECK(marking->IsComplete());
-}
static void CheckMap(Map* map, int type, int instance_size) {
@@ -955,9 +942,9 @@
TEST(TestCodeFlushing) {
+ i::FLAG_allow_natives_syntax = true;
// If we do not flush code this test is invalid.
if (!FLAG_flush_code) return;
- i::FLAG_allow_natives_syntax = true;
InitializeVM();
v8::HandleScope scope;
const char* source = "function foo() {"
@@ -980,16 +967,18 @@
Handle<JSFunction> function(JSFunction::cast(func_value));
CHECK(function->shared()->is_compiled());
- // The code will survive at least two GCs.
- HEAP->CollectAllGarbage(Heap::kNoGCFlags);
- HEAP->CollectAllGarbage(Heap::kNoGCFlags);
+ // TODO(1609) Currently incremental marker does not support code
flushing.
+ HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
+ HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
+
CHECK(function->shared()->is_compiled());
- // Simulate several GCs that use full marking.
- const int kAgingThreshold = 6;
- for (int i = 0; i < kAgingThreshold; i++) {
- HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
- }
+ HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
+ HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
+ HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
+ HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
+ HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
+ HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
// foo should no longer be in the compilation cache
CHECK(!function->shared()->is_compiled() || function->IsOptimized());
@@ -999,138 +988,6 @@
CHECK(function->shared()->is_compiled());
CHECK(function->is_compiled());
}
-
-
-TEST(TestCodeFlushingIncremental) {
- // If we do not flush code this test is invalid.
- if (!FLAG_flush_code) return;
- i::FLAG_allow_natives_syntax = true;
- InitializeVM();
- v8::HandleScope scope;
- const char* source = "function foo() {"
- " var x = 42;"
- " var y = 42;"
- " var z = x + y;"
- "};"
- "foo()";
- Handle<String> foo_name = FACTORY->LookupAsciiSymbol("foo");
-
- // This compile will add the code to the compilation cache.
- { v8::HandleScope scope;
- CompileRun(source);
- }
-
- // Check function is compiled.
- Object* func_value = Isolate::Current()->context()->global_object()->
- GetProperty(*foo_name)->ToObjectChecked();
- CHECK(func_value->IsJSFunction());
- Handle<JSFunction> function(JSFunction::cast(func_value));
- CHECK(function->shared()->is_compiled());
-
- // The code will survive at least two GCs.
- HEAP->CollectAllGarbage(Heap::kNoGCFlags);
- HEAP->CollectAllGarbage(Heap::kNoGCFlags);
- CHECK(function->shared()->is_compiled());
-
- // Simulate several GCs that use incremental marking.
- const int kAgingThreshold = 6;
- for (int i = 0; i < kAgingThreshold; i++) {
- HEAP->incremental_marking()->Abort();
- SimulateIncrementalMarking();
- HEAP->CollectAllGarbage(Heap::kNoGCFlags);
- }
- CHECK(!function->shared()->is_compiled() || function->IsOptimized());
- CHECK(!function->is_compiled() || function->IsOptimized());
-
- // This compile will compile the function again.
- { v8::HandleScope scope;
- CompileRun("foo();");
- }
-
- // Simulate several GCs that use incremental marking but make sure
- // the loop breaks once the function is enqueued as a candidate.
- for (int i = 0; i < kAgingThreshold; i++) {
- HEAP->incremental_marking()->Abort();
- SimulateIncrementalMarking();
- if (!function->next_function_link()->IsUndefined()) break;
- HEAP->CollectAllGarbage(Heap::kNoGCFlags);
- }
-
- // Force optimization while incremental marking is active and while
- // the function is enqueued as a candidate.
- { v8::HandleScope scope;
- CompileRun("%OptimizeFunctionOnNextCall(foo); foo();");
- }
-
- // Simulate one final GC to make sure the candidate queue is sane.
- HEAP->CollectAllGarbage(Heap::kNoGCFlags);
- CHECK(function->shared()->is_compiled() || !function->IsOptimized());
- CHECK(function->is_compiled() || !function->IsOptimized());
-}
-
-
-TEST(TestCodeFlushingIncrementalScavenge) {
- // If we do not flush code this test is invalid.
- if (!FLAG_flush_code) return;
- i::FLAG_allow_natives_syntax = true;
- InitializeVM();
- v8::HandleScope scope;
- const char* source = "var foo = function() {"
- " var x = 42;"
- " var y = 42;"
- " var z = x + y;"
- "};"
- "foo();"
- "var bar = function() {"
- " var x = 23;"
- "};"
- "bar();";
- Handle<String> foo_name = FACTORY->LookupAsciiSymbol("foo");
- Handle<String> bar_name = FACTORY->LookupAsciiSymbol("bar");
-
- // Perfrom one initial GC to enable code flushing.
- HEAP->CollectAllGarbage(Heap::kNoGCFlags);
-
- // This compile will add the code to the compilation cache.
- { v8::HandleScope scope;
- CompileRun(source);
- }
-
- // Check functions are compiled.
- Object* func_value = Isolate::Current()->context()->global_object()->
- GetProperty(*foo_name)->ToObjectChecked();
- CHECK(func_value->IsJSFunction());
- Handle<JSFunction> function(JSFunction::cast(func_value));
- CHECK(function->shared()->is_compiled());
- Object* func_value2 = Isolate::Current()->context()->global_object()->
- GetProperty(*bar_name)->ToObjectChecked();
- CHECK(func_value2->IsJSFunction());
- Handle<JSFunction> function2(JSFunction::cast(func_value2));
- CHECK(function2->shared()->is_compiled());
-
- // Clear references to functions so that one of them can die.
- { v8::HandleScope scope;
- CompileRun("foo = 0; bar = 0;");
- }
-
- // Bump the code age so that flushing is triggered while the function
- // object is still located in new-space.
- const int kAgingThreshold = 6;
- function->shared()->set_code_age(kAgingThreshold);
- function2->shared()->set_code_age(kAgingThreshold);
-
- // Simulate incremental marking so that the functions are enqueued as
- // code flushing candidates. Then kill one of the functions. Finally
- // perform a scavenge while incremental marking is still running.
- SimulateIncrementalMarking();
- *function2.location() = NULL;
- HEAP->CollectGarbage(NEW_SPACE, "test scavenge while marking");
-
- // Simulate one final GC to make sure the candidate queue is sane.
- HEAP->CollectAllGarbage(Heap::kNoGCFlags);
- CHECK(!function->shared()->is_compiled() || function->IsOptimized());
- CHECK(!function->is_compiled() || function->IsOptimized());
-}
// Count the number of native contexts in the weak list of native contexts.
@@ -1908,6 +1765,19 @@
static int CountMapTransitions(Map* map) {
return map->transitions()->number_of_transitions();
}
+
+
+// Go through all incremental marking steps in one swoop.
+static void SimulateIncrementalMarking() {
+ IncrementalMarking* marking = HEAP->incremental_marking();
+ CHECK(marking->IsStopped());
+ marking->Start();
+ CHECK(marking->IsMarking());
+ while (!marking->IsComplete()) {
+ marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
+ }
+ CHECK(marking->IsComplete());
+}
// Test that map transitions are cleared and maps are collected with
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev