Parallel recompilation: fix off-by-one in deferred handle scope iteration.
authoryangguo@chromium.org <yangguo@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 18 Mar 2013 11:26:09 +0000 (11:26 +0000)
committeryangguo@chromium.org <yangguo@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 18 Mar 2013 11:26:09 +0000 (11:26 +0000)
R=jkummerow@chromium.org
BUG=

Review URL: https://chromiumcodereview.appspot.com/12650005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13962 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/api.cc
src/compiler.cc
test/cctest/test-heap.cc

index d2c1402..136a7f2 100644 (file)
@@ -6971,7 +6971,7 @@ void HandleScopeImplementer::IterateThis(ObjectVisitor* v) {
   for (int i = blocks()->length() - 2; i >= 0; --i) {
     Object** block = blocks()->at(i);
     if (last_handle_before_deferred_block_ != NULL &&
-        (last_handle_before_deferred_block_ < &block[kHandleBlockSize]) &&
+        (last_handle_before_deferred_block_ <= &block[kHandleBlockSize]) &&
         (last_handle_before_deferred_block_ >= block)) {
       v->VisitPointers(block, last_handle_before_deferred_block_);
       ASSERT(!found_block_before_deferred);
index e51fb42..21ea25f 100644 (file)
@@ -943,11 +943,11 @@ void Compiler::RecompileParallel(Handle<JSFunction> closure) {
             new(info->zone()) OptimizingCompiler(*info);
         OptimizingCompiler::Status status = compiler->CreateGraph();
         if (status == OptimizingCompiler::SUCCEEDED) {
+          info.Detach();
+          shared->code()->set_profiler_ticks(0);
           // Do a scavenge to put off the next scavenge as far as possible.
           // This may ease the issue that GVN blocks the next scavenge.
           isolate->heap()->CollectGarbage(NEW_SPACE, "parallel recompile");
-          shared->code()->set_profiler_ticks(0);
-          info.Detach();
           isolate->optimizing_compiler_thread()->QueueForOptimization(compiler);
         } else if (status == OptimizingCompiler::BAILED_OUT) {
           isolate->clear_pending_exception();
index e1da9ef..a710385 100644 (file)
@@ -3017,3 +3017,31 @@ TEST(Regress173458) {
   heap->CollectAllGarbage(Heap::kNoGCFlags);
   heap->CollectAllGarbage(Heap::kNoGCFlags);
 }
+
+
+class DummyVisitor : public ObjectVisitor {
+ public:
+  void VisitPointers(Object** start, Object** end) { }
+};
+
+
+TEST(DeferredHandles) {
+  InitializeVM();
+  Isolate* isolate = Isolate::Current();
+  Heap* heap = isolate->heap();
+  v8::HandleScope scope;
+  v8::ImplementationUtilities::HandleScopeData* data =
+      isolate->handle_scope_data();
+  Handle<Object> init(heap->empty_string(), isolate);
+  while (data->next < data->limit) {
+    Handle<Object> obj(heap->empty_string(), isolate);
+  }
+  // An entire block of handles has been filled.
+  // Next handle would require a new block.
+  ASSERT(data->next == data->limit);
+
+  DeferredHandleScope deferred(isolate);
+  DummyVisitor visitor;
+  isolate->handle_scope_implementer()->Iterate(&visitor);
+  deferred.Detach();
+}