Reorder SharedFunctionInfo setup in lazy compile, quick fix for crbug.com/49099
authorricow@chromium.org <ricow@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 19 Jul 2010 06:29:30 +0000 (06:29 +0000)
committerricow@chromium.org <ricow@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 19 Jul 2010 06:29:30 +0000 (06:29 +0000)
This fixes issue 49099 (http://crbug.com/49099) that makes chromium
crash if a gc is triggered by setting the scopeinfo in CompileLazy. If
this gc triggers code flushing the compiled function could be flushed,
causing the ASSERT(shared->is_compiled()) to fail. By reordering the
two methods we make sure that no allocation happens before the end of
the method.

Review URL: http://codereview.chromium.org/3035006

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

src/compiler.cc

index 0d1fe99..d87d9da 100755 (executable)
@@ -449,8 +449,12 @@ bool Compiler::CompileLazy(CompilationInfo* info) {
                             code);
 
   // Update the shared function info with the compiled code and the scope info.
-  shared->set_code(*code);
+  // Please note, that the order of the sharedfunction initialization is
+  // important since set_scope_info might trigger a GC, causing the ASSERT
+  // below to be invalid if the code was flushed. By settting the code
+  // object last we avoid this.
   shared->set_scope_info(*SerializedScopeInfo::Create(info->scope()));
+  shared->set_code(*code);
 
   // Set the expected number of properties for instances.
   SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count());