Revision: 24483
Author: [email protected]
Date: Thu Oct 9 09:21:46 2014 UTC
Log: Store local copies of flags needed on the background thread
BUG=none
[email protected]
LOG=n
Review URL: https://codereview.chromium.org/639353002
https://code.google.com/p/v8/source/detail?r=24483
Modified:
/branches/bleeding_edge/src/optimizing-compiler-thread.cc
/branches/bleeding_edge/src/optimizing-compiler-thread.h
=======================================
--- /branches/bleeding_edge/src/optimizing-compiler-thread.cc Tue Oct 7
09:54:18 2014 UTC
+++ /branches/bleeding_edge/src/optimizing-compiler-thread.cc Thu Oct 9
09:21:46 2014 UTC
@@ -82,12 +82,12 @@
DisallowHandleAllocation no_handles;
DisallowHandleDereference no_deref;
- if (FLAG_job_based_recompilation) {
+ if (job_based_recompilation_) {
return;
}
base::ElapsedTimer total_timer;
- if (FLAG_trace_concurrent_recompilation) total_timer.Start();
+ if (tracing_enabled_) total_timer.Start();
while (true) {
input_queue_semaphore_.Wait();
@@ -101,7 +101,7 @@
case CONTINUE:
break;
case STOP:
- if (FLAG_trace_concurrent_recompilation) {
+ if (tracing_enabled_) {
time_spent_total_ = total_timer.Elapsed();
}
stop_semaphore_.Signal();
@@ -119,11 +119,11 @@
}
base::ElapsedTimer compiling_timer;
- if (FLAG_trace_concurrent_recompilation) compiling_timer.Start();
+ if (tracing_enabled_) compiling_timer.Start();
CompileNext();
- if (FLAG_trace_concurrent_recompilation) {
+ if (tracing_enabled_) {
time_spent_compiling_ += compiling_timer.Elapsed();
}
}
@@ -132,7 +132,7 @@
OptimizedCompileJob* OptimizingCompilerThread::NextInput() {
base::LockGuard<base::Mutex> access_input_queue_(&input_queue_mutex_);
- DCHECK(!FLAG_job_based_recompilation);
+ DCHECK(!job_based_recompilation_);
if (input_queue_length_ == 0) return NULL;
OptimizedCompileJob* job = input_queue_[InputQueueIndex(0)];
DCHECK_NE(NULL, job);
@@ -181,7 +181,7 @@
void OptimizingCompilerThread::FlushInputQueue(bool restore_function_code)
{
- DCHECK(!FLAG_job_based_recompilation);
+ DCHECK(!job_based_recompilation_);
OptimizedCompileJob* job;
while ((job = NextInput())) {
// This should not block, since we have one signal on the input queue
@@ -220,13 +220,13 @@
DCHECK(!IsOptimizerThread());
base::Release_Store(&stop_thread_, static_cast<base::AtomicWord>(FLUSH));
if (FLAG_block_concurrent_recompilation) Unblock();
- if (!FLAG_job_based_recompilation) {
+ if (!job_based_recompilation_) {
input_queue_semaphore_.Signal();
stop_semaphore_.Wait();
}
FlushOutputQueue(true);
if (FLAG_concurrent_osr) FlushOsrBuffer(true);
- if (FLAG_trace_concurrent_recompilation) {
+ if (tracing_enabled_) {
PrintF(" ** Flushed concurrent recompilation queues.\n");
}
}
@@ -236,12 +236,12 @@
DCHECK(!IsOptimizerThread());
base::Release_Store(&stop_thread_, static_cast<base::AtomicWord>(STOP));
if (FLAG_block_concurrent_recompilation) Unblock();
- if (!FLAG_job_based_recompilation) {
+ if (!job_based_recompilation_) {
input_queue_semaphore_.Signal();
stop_semaphore_.Wait();
}
- if (FLAG_job_based_recompilation) {
+ if (job_based_recompilation_) {
while (true) {
{
base::LockGuard<base::Mutex>
access_input_queue(&input_queue_mutex_);
@@ -261,13 +261,12 @@
if (FLAG_concurrent_osr) FlushOsrBuffer(false);
- if (FLAG_trace_concurrent_recompilation) {
+ if (tracing_enabled_) {
double percentage = time_spent_compiling_.PercentOf(time_spent_total_);
PrintF(" ** Compiler thread did %.2f%% useful work\n", percentage);
}
- if ((FLAG_trace_osr || FLAG_trace_concurrent_recompilation) &&
- FLAG_concurrent_osr) {
+ if ((FLAG_trace_osr || tracing_enabled_) && FLAG_concurrent_osr) {
PrintF("[COSR hit rate %d / %d]\n", osr_hits_, osr_attempts_);
}
@@ -297,7 +296,7 @@
BackEdgeTable::RemoveStackCheck(code, offset);
} else {
if (function->IsOptimized()) {
- if (FLAG_trace_concurrent_recompilation) {
+ if (tracing_enabled_) {
PrintF(" ** Aborting compilation for ");
function->ShortPrint();
PrintF(" as it has already been optimized.\n");
@@ -334,7 +333,7 @@
input_queue_[InputQueueIndex(input_queue_length_)] = job;
input_queue_length_++;
}
- if (FLAG_job_based_recompilation) {
+ if (job_based_recompilation_) {
V8::GetCurrentPlatform()->CallOnBackgroundThread(
new CompileTask(isolate_, job), v8::Platform::kShortRunningTask);
} else if (FLAG_block_concurrent_recompilation) {
@@ -347,7 +346,7 @@
void OptimizingCompilerThread::Unblock() {
DCHECK(!IsOptimizerThread());
- if (FLAG_job_based_recompilation) {
+ if (job_based_recompilation_) {
return;
}
while (blocked_jobs_ > 0) {
=======================================
--- /branches/bleeding_edge/src/optimizing-compiler-thread.h Tue Oct 7
07:29:24 2014 UTC
+++ /branches/bleeding_edge/src/optimizing-compiler-thread.h Thu Oct 9
09:21:46 2014 UTC
@@ -37,7 +37,9 @@
osr_buffer_cursor_(0),
osr_hits_(0),
osr_attempts_(0),
- blocked_jobs_(0) {
+ blocked_jobs_(0),
+ tracing_enabled_(FLAG_trace_concurrent_recompilation),
+ job_based_recompilation_(FLAG_job_based_recompilation) {
base::NoBarrier_Store(&stop_thread_,
static_cast<base::AtomicWord>(CONTINUE));
input_queue_ = NewArray<OptimizedCompileJob*>(input_queue_capacity_);
@@ -140,6 +142,14 @@
int osr_attempts_;
int blocked_jobs_;
+
+ // Copies of FLAG_trace_concurrent_recompilation and
+ // FLAG_job_based_recompilation that will be used from the background
thread.
+ //
+ // Since flags might get modified while the background thread is
running, it
+ // is not safe to access them directly.
+ bool tracing_enabled_;
+ bool job_based_recompilation_;
};
} } // namespace v8::internal
--
--
v8-dev mailing list
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.