Commit 5a5f863f authored by yangguo@chromium.org's avatar yangguo@chromium.org

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=titzer@chromium.org
BUG=

Review URL: https://codereview.chromium.org/23769007

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16609 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 4ef84b92
...@@ -1054,7 +1054,8 @@ bool Compiler::RecompileConcurrent(Handle<JSFunction> closure, ...@@ -1054,7 +1054,8 @@ bool Compiler::RecompileConcurrent(Handle<JSFunction> closure,
} }
bool Compiler::InstallOptimizedCode(OptimizingCompiler* optimizing_compiler) { Handle<Code> Compiler::InstallOptimizedCode(
OptimizingCompiler* optimizing_compiler) {
SmartPointer<CompilationInfo> info(optimizing_compiler->info()); SmartPointer<CompilationInfo> info(optimizing_compiler->info());
// The function may have already been optimized by OSR. Simply continue. // The function may have already been optimized by OSR. Simply continue.
// Except when OSR already disabled optimization for some reason. // Except when OSR already disabled optimization for some reason.
...@@ -1067,7 +1068,7 @@ bool Compiler::InstallOptimizedCode(OptimizingCompiler* optimizing_compiler) { ...@@ -1067,7 +1068,7 @@ bool Compiler::InstallOptimizedCode(OptimizingCompiler* optimizing_compiler) {
PrintF(" as it has been disabled.\n"); PrintF(" as it has been disabled.\n");
} }
ASSERT(!info->closure()->IsMarkedForInstallingRecompiledCode()); ASSERT(!info->closure()->IsMarkedForInstallingRecompiledCode());
return false; return Handle<Code>::null();
} }
Isolate* isolate = info->isolate(); Isolate* isolate = info->isolate();
...@@ -1114,7 +1115,8 @@ bool Compiler::InstallOptimizedCode(OptimizingCompiler* optimizing_compiler) { ...@@ -1114,7 +1115,8 @@ bool Compiler::InstallOptimizedCode(OptimizingCompiler* optimizing_compiler) {
// profiler ticks to prevent too soon re-opt after a deopt. // profiler ticks to prevent too soon re-opt after a deopt.
info->shared_info()->code()->set_profiler_ticks(0); info->shared_info()->code()->set_profiler_ticks(0);
ASSERT(!info->closure()->IsMarkedForInstallingRecompiledCode()); ASSERT(!info->closure()->IsMarkedForInstallingRecompiledCode());
return status == OptimizingCompiler::SUCCEEDED; return (status == OptimizingCompiler::SUCCEEDED) ? info->code()
: Handle<Code>::null();
} }
...@@ -1222,6 +1224,8 @@ Handle<Code> Compiler::CompileForConcurrentOSR(Handle<JSFunction> function) { ...@@ -1222,6 +1224,8 @@ Handle<Code> Compiler::CompileForConcurrentOSR(Handle<JSFunction> function) {
FindReadyOSRCandidate(function, pc_offset); FindReadyOSRCandidate(function, pc_offset);
if (compiler != NULL) { if (compiler != NULL) {
BailoutId ast_id = compiler->info()->osr_ast_id();
if (FLAG_trace_osr) { if (FLAG_trace_osr) {
PrintF("[COSR - optimization complete for "); PrintF("[COSR - optimization complete for ");
function->PrintName(); function->PrintName();
...@@ -1230,11 +1234,11 @@ Handle<Code> Compiler::CompileForConcurrentOSR(Handle<JSFunction> function) { ...@@ -1230,11 +1234,11 @@ Handle<Code> Compiler::CompileForConcurrentOSR(Handle<JSFunction> function) {
Deoptimizer::RevertInterruptCode(isolate, *unoptimized); Deoptimizer::RevertInterruptCode(isolate, *unoptimized);
// TODO(titzer): don't install the OSR code into the function. // 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(); isolate->optimizing_compiler_thread()->RemoveStaleOSRCandidates();
if (!succeeded) { if (result.is_null()) {
if (FLAG_trace_osr) { if (FLAG_trace_osr) {
PrintF("[COSR - optimization failed for "); PrintF("[COSR - optimization failed for ");
function->PrintName(); function->PrintName();
...@@ -1242,15 +1246,12 @@ Handle<Code> Compiler::CompileForConcurrentOSR(Handle<JSFunction> function) { ...@@ -1242,15 +1246,12 @@ Handle<Code> Compiler::CompileForConcurrentOSR(Handle<JSFunction> function) {
} }
return Handle<Code>::null(); return Handle<Code>::null();
} }
Handle<Code> result = compiler->info()->code();
// Check the result matches our expectations, and don't use it otherwise. // Check the result matches our expectations, and don't use it otherwise.
if (result->kind() == Code::OPTIMIZED_FUNCTION) { if (result->kind() == Code::OPTIMIZED_FUNCTION) {
DeoptimizationInputData* data = DeoptimizationInputData* data =
DeoptimizationInputData::cast(result->deoptimization_data()); DeoptimizationInputData::cast(result->deoptimization_data());
if (data->OsrPcOffset()->value() >= 0) { if (data->OsrPcOffset()->value() >= 0) {
BailoutId ast_id = compiler->info()->osr_ast_id();
ASSERT(BailoutId(data->OsrAstId()->value()) == ast_id); ASSERT(BailoutId(data->OsrAstId()->value()) == ast_id);
if (FLAG_trace_osr) { if (FLAG_trace_osr) {
PrintF("[COSR - entry at AST id %d, offset %d in optimized code]\n", PrintF("[COSR - entry at AST id %d, offset %d in optimized code]\n",
......
...@@ -625,7 +625,7 @@ class Compiler : public AllStatic { ...@@ -625,7 +625,7 @@ class Compiler : public AllStatic {
bool is_toplevel, bool is_toplevel,
Handle<Script> script); Handle<Script> script);
static bool InstallOptimizedCode(OptimizingCompiler* info); static Handle<Code> InstallOptimizedCode(OptimizingCompiler* info);
static Handle<Code> CompileForOnStackReplacement(Handle<JSFunction> function); static Handle<Code> CompileForOnStackReplacement(Handle<JSFunction> function);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment