Revision: 16609
Author:   yang...@chromium.org
Date:     Tue Sep 10 11:09:22 2013 UTC
Log:      Fix concurrent osr.

InstallOptimizedCode aquires ownership on the compilation info and deletes
it on return, tearing down the attached zone.  The OptimizingCompiler
object is a zone object allocated in just that zone, so it also gets
deleted.  Effectively, InstallOptimizedCode cleans up when it's done, so
the OptimizingCompiler object it receives is invalidated afterwards.

R=tit...@chromium.org
BUG=

Review URL: https://codereview.chromium.org/23769007
http://code.google.com/p/v8/source/detail?r=16609

Modified:
 /branches/bleeding_edge/src/compiler.cc
 /branches/bleeding_edge/src/compiler.h

=======================================
--- /branches/bleeding_edge/src/compiler.cc     Mon Sep  9 16:34:40 2013 UTC
+++ /branches/bleeding_edge/src/compiler.cc     Tue Sep 10 11:09:22 2013 UTC
@@ -1054,7 +1054,8 @@
 }


-bool Compiler::InstallOptimizedCode(OptimizingCompiler* optimizing_compiler) {
+Handle<Code> Compiler::InstallOptimizedCode(
+    OptimizingCompiler* optimizing_compiler) {
   SmartPointer<CompilationInfo> info(optimizing_compiler->info());
   // The function may have already been optimized by OSR.  Simply continue.
   // Except when OSR already disabled optimization for some reason.
@@ -1067,7 +1068,7 @@
       PrintF(" as it has been disabled.\n");
     }
     ASSERT(!info->closure()->IsMarkedForInstallingRecompiledCode());
-    return false;
+    return Handle<Code>::null();
   }

   Isolate* isolate = info->isolate();
@@ -1114,7 +1115,8 @@
   // profiler ticks to prevent too soon re-opt after a deopt.
   info->shared_info()->code()->set_profiler_ticks(0);
   ASSERT(!info->closure()->IsMarkedForInstallingRecompiledCode());
-  return status == OptimizingCompiler::SUCCEEDED;
+  return (status == OptimizingCompiler::SUCCEEDED) ? info->code()
+                                                   : Handle<Code>::null();
 }


@@ -1222,6 +1224,8 @@
FindReadyOSRCandidate(function, pc_offset);

   if (compiler != NULL) {
+    BailoutId ast_id = compiler->info()->osr_ast_id();
+
     if (FLAG_trace_osr) {
       PrintF("[COSR - optimization complete for ");
       function->PrintName();
@@ -1230,11 +1234,11 @@
     Deoptimizer::RevertInterruptCode(isolate, *unoptimized);

     // TODO(titzer): don't install the OSR code into the function.
-    bool succeeded = InstallOptimizedCode(compiler);
+    Handle<Code> result = InstallOptimizedCode(compiler);

     isolate->optimizing_compiler_thread()->RemoveStaleOSRCandidates();

-    if (!succeeded) {
+    if (result.is_null()) {
       if (FLAG_trace_osr) {
         PrintF("[COSR - optimization failed for ");
         function->PrintName();
@@ -1242,15 +1246,12 @@
       }
       return Handle<Code>::null();
     }
-    Handle<Code> result = compiler->info()->code();
-
// Check the result matches our expectations, and don't use it otherwise.
     if (result->kind() == Code::OPTIMIZED_FUNCTION) {
       DeoptimizationInputData* data =
           DeoptimizationInputData::cast(result->deoptimization_data());

       if (data->OsrPcOffset()->value() >= 0) {
-        BailoutId ast_id = compiler->info()->osr_ast_id();
         ASSERT(BailoutId(data->OsrAstId()->value()) == ast_id);
         if (FLAG_trace_osr) {
PrintF("[COSR - entry at AST id %d, offset %d in optimized code]\n",
=======================================
--- /branches/bleeding_edge/src/compiler.h      Mon Sep  9 16:34:40 2013 UTC
+++ /branches/bleeding_edge/src/compiler.h      Tue Sep 10 11:09:22 2013 UTC
@@ -625,7 +625,7 @@
                               bool is_toplevel,
                               Handle<Script> script);

-  static bool InstallOptimizedCode(OptimizingCompiler* info);
+  static Handle<Code> InstallOptimizedCode(OptimizingCompiler* info);

static Handle<Code> CompileForOnStackReplacement(Handle<JSFunction> function);

--
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to