Commit 42d70714 authored by yangguo@chromium.org's avatar yangguo@chromium.org

Disposing an OSR job should only restore the back edge state.

R=titzer@chromium.org
BUG=

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16978 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 77c60c9a
...@@ -534,7 +534,7 @@ class RecompileJob: public ZoneObject { ...@@ -534,7 +534,7 @@ class RecompileJob: public ZoneObject {
} }
void WaitForInstall() { void WaitForInstall() {
ASSERT(!info_->osr_ast_id().IsNone()); ASSERT(info_->is_osr());
awaiting_install_ = true; awaiting_install_ = true;
} }
......
...@@ -114,13 +114,17 @@ void OptimizingCompilerThread::CompileNext() { ...@@ -114,13 +114,17 @@ void OptimizingCompilerThread::CompileNext() {
} }
static void DisposeRecompileJob(RecompileJob* compiler, static void DisposeRecompileJob(RecompileJob* job,
bool restore_function_code) { bool restore_function_code) {
// The recompile job is allocated in the CompilationInfo's zone. // The recompile job is allocated in the CompilationInfo's zone.
CompilationInfo* info = compiler->info(); CompilationInfo* info = job->info();
if (restore_function_code) { if (restore_function_code) {
Handle<JSFunction> function = info->closure(); if (info->is_osr()) {
function->ReplaceCode(function->shared()->code()); if (!job->IsWaitingForInstall()) BackEdgeTable::RemoveStackCheck(info);
} else {
Handle<JSFunction> function = info->closure();
function->ReplaceCode(function->shared()->code());
}
} }
delete info; delete info;
} }
...@@ -132,8 +136,8 @@ void OptimizingCompilerThread::FlushInputQueue(bool restore_function_code) { ...@@ -132,8 +136,8 @@ void OptimizingCompilerThread::FlushInputQueue(bool restore_function_code) {
// This should not block, since we have one signal on the input queue // This should not block, since we have one signal on the input queue
// semaphore corresponding to each element in the input queue. // semaphore corresponding to each element in the input queue.
input_queue_semaphore_.Wait(); input_queue_semaphore_.Wait();
if (job->info()->osr_ast_id().IsNone()) { // OSR jobs are dealt with separately.
// OSR jobs are dealt with separately. if (!job->info()->is_osr()) {
DisposeRecompileJob(job, restore_function_code); DisposeRecompileJob(job, restore_function_code);
} }
} }
...@@ -147,8 +151,8 @@ void OptimizingCompilerThread::FlushOutputQueue(bool restore_function_code) { ...@@ -147,8 +151,8 @@ void OptimizingCompilerThread::FlushOutputQueue(bool restore_function_code) {
{ LockGuard<Mutex> access_queue(&queue_mutex_); { LockGuard<Mutex> access_queue(&queue_mutex_);
if (!output_queue_.Dequeue(&job)) break; if (!output_queue_.Dequeue(&job)) break;
} }
if (job->info()->osr_ast_id().IsNone()) { // OSR jobs are dealt with separately.
// OSR jobs are dealt with separately. if (!job->info()->is_osr()) {
DisposeRecompileJob(job, restore_function_code); DisposeRecompileJob(job, restore_function_code);
} }
} }
...@@ -221,9 +225,7 @@ void OptimizingCompilerThread::InstallOptimizedFunctions() { ...@@ -221,9 +225,7 @@ void OptimizingCompilerThread::InstallOptimizedFunctions() {
if (!output_queue_.Dequeue(&job)) break; if (!output_queue_.Dequeue(&job)) break;
} }
CompilationInfo* info = job->info(); CompilationInfo* info = job->info();
if (info->osr_ast_id().IsNone()) { if (info->is_osr()) {
Compiler::InstallOptimizedCode(job);
} else {
if (FLAG_trace_osr) { if (FLAG_trace_osr) {
PrintF("[COSR - "); PrintF("[COSR - ");
info->closure()->PrintName(); info->closure()->PrintName();
...@@ -232,6 +234,8 @@ void OptimizingCompilerThread::InstallOptimizedFunctions() { ...@@ -232,6 +234,8 @@ void OptimizingCompilerThread::InstallOptimizedFunctions() {
} }
job->WaitForInstall(); job->WaitForInstall();
BackEdgeTable::RemoveStackCheck(info); BackEdgeTable::RemoveStackCheck(info);
} else {
Compiler::InstallOptimizedCode(job);
} }
} }
} }
...@@ -242,9 +246,7 @@ void OptimizingCompilerThread::QueueForOptimization(RecompileJob* job) { ...@@ -242,9 +246,7 @@ void OptimizingCompilerThread::QueueForOptimization(RecompileJob* job) {
ASSERT(!IsOptimizerThread()); ASSERT(!IsOptimizerThread());
Barrier_AtomicIncrement(&queue_length_, static_cast<Atomic32>(1)); Barrier_AtomicIncrement(&queue_length_, static_cast<Atomic32>(1));
CompilationInfo* info = job->info(); CompilationInfo* info = job->info();
if (info->osr_ast_id().IsNone()) { if (info->is_osr()) {
info->closure()->MarkInRecompileQueue();
} else {
if (FLAG_trace_concurrent_recompilation) { if (FLAG_trace_concurrent_recompilation) {
PrintF(" ** Queueing "); PrintF(" ** Queueing ");
info->closure()->PrintName(); info->closure()->PrintName();
...@@ -253,6 +255,8 @@ void OptimizingCompilerThread::QueueForOptimization(RecompileJob* job) { ...@@ -253,6 +255,8 @@ void OptimizingCompilerThread::QueueForOptimization(RecompileJob* job) {
AddToOsrBuffer(job); AddToOsrBuffer(job);
osr_attempts_++; osr_attempts_++;
BackEdgeTable::AddStackCheck(info); BackEdgeTable::AddStackCheck(info);
} else {
info->closure()->MarkInRecompileQueue();
} }
input_queue_.Enqueue(job); input_queue_.Enqueue(job);
input_queue_semaphore_.Signal(); input_queue_semaphore_.Signal();
...@@ -317,7 +321,6 @@ void OptimizingCompilerThread::AddToOsrBuffer(RecompileJob* job) { ...@@ -317,7 +321,6 @@ void OptimizingCompilerThread::AddToOsrBuffer(RecompileJob* job) {
info->closure()->PrintName(); info->closure()->PrintName();
PrintF(", AST id %d]\n", info->osr_ast_id().ToInt()); PrintF(", AST id %d]\n", info->osr_ast_id().ToInt());
} }
BackEdgeTable::RemoveStackCheck(info);
DisposeRecompileJob(stale, false); DisposeRecompileJob(stale, false);
break; break;
} }
......
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