Revision: 15833
Author: [email protected]
Date: Tue Jul 23 08:15:00 2013
Log: Flush parallel recompilation queues on context dispose
notification.
[email protected]
BUG=
Review URL: https://codereview.chromium.org/19956004
http://code.google.com/p/v8/source/detail?r=15833
Modified:
/branches/bleeding_edge/src/api.cc
/branches/bleeding_edge/src/factory.cc
/branches/bleeding_edge/src/heap.cc
/branches/bleeding_edge/src/heap.h
/branches/bleeding_edge/src/isolate.cc
/branches/bleeding_edge/src/isolate.h
/branches/bleeding_edge/src/liveedit.cc
/branches/bleeding_edge/src/objects.cc
/branches/bleeding_edge/src/optimizing-compiler-thread.cc
/branches/bleeding_edge/src/optimizing-compiler-thread.h
/branches/bleeding_edge/src/runtime.cc
/branches/bleeding_edge/test/cctest/test-deoptimization.cc
=======================================
--- /branches/bleeding_edge/src/api.cc Wed Jul 17 06:12:48 2013
+++ /branches/bleeding_edge/src/api.cc Tue Jul 23 08:15:00 2013
@@ -770,7 +770,6 @@
i::Context* last_context =
isolate->handle_scope_implementer()->RestoreContext();
isolate->set_context(last_context);
- isolate->set_context_exit_happened(true);
}
=======================================
--- /branches/bleeding_edge/src/factory.cc Thu Jul 18 00:59:48 2013
+++ /branches/bleeding_edge/src/factory.cc Tue Jul 23 08:15:00 2013
@@ -673,7 +673,11 @@
function_info->allows_lazy_compilation() &&
!function_info->optimization_disabled() &&
!isolate()->DebuggerHasBreakPoints()) {
- result->MarkForLazyRecompilation();
+ if (FLAG_parallel_recompilation) {
+ result->MarkForParallelRecompilation();
+ } else {
+ result->MarkForLazyRecompilation();
+ }
}
return result;
}
=======================================
--- /branches/bleeding_edge/src/heap.cc Tue Jul 23 00:41:46 2013
+++ /branches/bleeding_edge/src/heap.cc Tue Jul 23 08:15:00 2013
@@ -701,6 +701,16 @@
return next_gc_likely_to_collect_more;
}
+
+
+int Heap::NotifyContextDisposed() {
+ if (FLAG_parallel_recompilation) {
+ // Flush the queued recompilation tasks.
+ isolate()->optimizing_compiler_thread()->Flush();
+ }
+ flush_monomorphic_ics_ = true;
+ return ++contexts_disposed_;
+}
void Heap::PerformScavenge() {
=======================================
--- /branches/bleeding_edge/src/heap.h Tue Jul 23 00:41:46 2013
+++ /branches/bleeding_edge/src/heap.h Tue Jul 23 08:15:00 2013
@@ -1252,10 +1252,7 @@
void EnsureHeapIsIterable();
// Notify the heap that a context has been disposed.
- int NotifyContextDisposed() {
- flush_monomorphic_ics_ = true;
- return ++contexts_disposed_;
- }
+ int NotifyContextDisposed();
// Utility to invoke the scavenger. This is needed in test code to
// ensure correct callback for weak global handles.
=======================================
--- /branches/bleeding_edge/src/isolate.cc Tue Jul 23 08:01:38 2013
+++ /branches/bleeding_edge/src/isolate.cc Tue Jul 23 08:15:00 2013
@@ -1777,7 +1777,6 @@
regexp_stack_(NULL),
date_cache_(NULL),
code_stub_interface_descriptors_(NULL),
- context_exit_happened_(false),
initialized_from_snapshot_(false),
cpu_profiler_(NULL),
heap_profiler_(NULL),
=======================================
--- /branches/bleeding_edge/src/isolate.h Tue Jul 23 08:01:38 2013
+++ /branches/bleeding_edge/src/isolate.h Tue Jul 23 08:15:00 2013
@@ -1058,13 +1058,6 @@
void SetTopLookupResult(LookupResult* top) {
thread_local_top_.top_lookup_result_ = top;
}
-
- bool context_exit_happened() {
- return context_exit_happened_;
- }
- void set_context_exit_happened(bool context_exit_happened) {
- context_exit_happened_ = context_exit_happened;
- }
bool initialized_from_snapshot() { return initialized_from_snapshot_; }
@@ -1313,10 +1306,6 @@
unibrow::Mapping<unibrow::Ecma262Canonicalize>
interp_canonicalize_mapping_;
CodeStubInterfaceDescriptor* code_stub_interface_descriptors_;
- // The garbage collector should be a little more aggressive when it knows
- // that a context was recently exited.
- bool context_exit_happened_;
-
// True if this isolate was initialized from a snapshot.
bool initialized_from_snapshot_;
=======================================
--- /branches/bleeding_edge/src/liveedit.cc Thu Jul 11 09:45:58 2013
+++ /branches/bleeding_edge/src/liveedit.cc Tue Jul 23 08:15:00 2013
@@ -1290,6 +1290,7 @@
if (code_scope_info->IsFixedArray()) {
shared_info->set_scope_info(ScopeInfo::cast(*code_scope_info));
}
+ shared_info->DisableOptimization("LiveEdit");
}
if (shared_info->debug_info()->IsDebugInfo()) {
=======================================
--- /branches/bleeding_edge/src/objects.cc Mon Jul 22 05:43:01 2013
+++ /branches/bleeding_edge/src/objects.cc Tue Jul 23 08:15:00 2013
@@ -9234,10 +9234,7 @@
ASSERT(is_compiled() || GetIsolate()->DebuggerHasBreakPoints());
ASSERT(!IsOptimized());
ASSERT(shared()->allows_lazy_compilation() || code()->optimizable());
- if (!FLAG_parallel_recompilation) {
- JSFunction::MarkForLazyRecompilation();
- return;
- }
+ ASSERT(FLAG_parallel_recompilation);
if (FLAG_trace_parallel_recompilation) {
PrintF(" ** Marking ");
PrintName();
=======================================
--- /branches/bleeding_edge/src/optimizing-compiler-thread.cc Tue Jul 2
02:04:45 2013
+++ /branches/bleeding_edge/src/optimizing-compiler-thread.cc Tue Jul 23
08:15:00 2013
@@ -60,12 +60,23 @@
OS::Sleep(FLAG_parallel_recompilation_delay);
}
- if (Acquire_Load(&stop_thread_)) {
- stop_semaphore_->Signal();
- if (FLAG_trace_parallel_recompilation) {
- time_spent_total_ = OS::Ticks() - epoch;
- }
- return;
+ switch (static_cast<StopFlag>(Acquire_Load(&stop_thread_))) {
+ case CONTINUE:
+ break;
+ case STOP:
+ if (FLAG_trace_parallel_recompilation) {
+ time_spent_total_ = OS::Ticks() - epoch;
+ }
+ stop_semaphore_->Signal();
+ return;
+ case FLUSH:
+ // Reset input queue semaphore.
+ delete input_queue_semaphore_;
+ input_queue_semaphore_ = OS::CreateSemaphore(0);
+ // Signal for main thread to start flushing.
+ stop_semaphore_->Signal();
+ // Return to start of consumer loop.
+ continue;
}
int64_t compiling_start = 0;
@@ -100,11 +111,43 @@
}
output_queue_.Enqueue(optimizing_compiler);
}
+
+
+void OptimizingCompilerThread::FlushQueue(
+ UnboundQueue<OptimizingCompiler*>* queue,
+ bool restore_function_code) {
+ ASSERT(!IsOptimizerThread());
+ OptimizingCompiler* optimizing_compiler;
+ // The optimizing compiler is allocated in the CompilationInfo's zone.
+ while (queue->Dequeue(&optimizing_compiler)) {
+ CompilationInfo* info = optimizing_compiler->info();
+ if (restore_function_code) {
+ Handle<JSFunction> function = info->closure();
+ function->ReplaceCode(function->shared()->code());
+ }
+ delete info;
+ }
+}
+
+
+void OptimizingCompilerThread::Flush() {
+ ASSERT(!IsOptimizerThread());
+ Release_Store(&stop_thread_, static_cast<AtomicWord>(FLUSH));
+ input_queue_semaphore_->Signal();
+
+ FlushQueue(&input_queue_, true);
+ NoBarrier_Store(&queue_length_, static_cast<AtomicWord>(0));
+
+ stop_semaphore_->Wait();
+ Release_Store(&stop_thread_, static_cast<AtomicWord>(CONTINUE));
+
+ FlushQueue(&output_queue_, true);
+}
void OptimizingCompilerThread::Stop() {
ASSERT(!IsOptimizerThread());
- Release_Store(&stop_thread_, static_cast<AtomicWord>(true));
+ Release_Store(&stop_thread_, static_cast<AtomicWord>(STOP));
input_queue_semaphore_->Signal();
stop_semaphore_->Wait();
@@ -114,14 +157,8 @@
while (NoBarrier_Load(&queue_length_) > 0) CompileNext();
InstallOptimizedFunctions();
} else {
- OptimizingCompiler* optimizing_compiler;
- // The optimizing compiler is allocated in the CompilationInfo's zone.
- while (input_queue_.Dequeue(&optimizing_compiler)) {
- delete optimizing_compiler->info();
- }
- while (output_queue_.Dequeue(&optimizing_compiler)) {
- delete optimizing_compiler->info();
- }
+ FlushQueue(&input_queue_, false);
+ FlushQueue(&output_queue_, false);
}
if (FLAG_trace_parallel_recompilation) {
=======================================
--- /branches/bleeding_edge/src/optimizing-compiler-thread.h Wed Jul 3
08:39:18 2013
+++ /branches/bleeding_edge/src/optimizing-compiler-thread.h Tue Jul 23
08:15:00 2013
@@ -54,13 +54,13 @@
install_mutex_(OS::CreateMutex()),
time_spent_compiling_(0),
time_spent_total_(0) {
- NoBarrier_Store(&stop_thread_, static_cast<AtomicWord>(false));
+ NoBarrier_Store(&stop_thread_, static_cast<AtomicWord>(CONTINUE));
NoBarrier_Store(&queue_length_, static_cast<AtomicWord>(0));
}
void Run();
void Stop();
- void CompileNext();
+ void Flush();
void QueueForOptimization(OptimizingCompiler* optimizing_compiler);
void InstallOptimizedFunctions();
@@ -92,6 +92,12 @@
}
private:
+ enum StopFlag { CONTINUE, STOP, FLUSH };
+
+ void FlushQueue(UnboundQueue<OptimizingCompiler*>* queue,
+ bool restore_function_code);
+ void CompileNext();
+
#ifdef DEBUG
int thread_id_;
Mutex* thread_id_mutex_;
=======================================
--- /branches/bleeding_edge/src/runtime.cc Tue Jul 23 06:44:15 2013
+++ /branches/bleeding_edge/src/runtime.cc Tue Jul 23 08:15:00 2013
@@ -8460,8 +8460,7 @@
}
CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
if (FLAG_parallel_recompilation && sync_with_compiler_thread) {
- while (function->IsMarkedForParallelRecompilation() ||
- function->IsInRecompileQueue() ||
+ while (function->IsInRecompileQueue() ||
function->IsMarkedForInstallingRecompiledCode()) {
isolate->optimizing_compiler_thread()->InstallOptimizedFunctions();
OS::Sleep(50);
=======================================
--- /branches/bleeding_edge/test/cctest/test-deoptimization.cc Mon May 13
07:18:05 2013
+++ /branches/bleeding_edge/test/cctest/test-deoptimization.cc Tue Jul 23
08:15:00 2013
@@ -77,23 +77,27 @@
// Utility class to set --allow-natives-syntax and --nouse-inlining when
// constructed and return to their default state when destroyed.
-class AllowNativesSyntaxNoInlining {
+class AllowNativesSyntaxNoInliningNoParallel {
public:
- AllowNativesSyntaxNoInlining()
+ AllowNativesSyntaxNoInliningNoParallel()
: allow_natives_syntax_(i::FLAG_allow_natives_syntax),
- use_inlining_(i::FLAG_use_inlining) {
+ use_inlining_(i::FLAG_use_inlining),
+ parallel_recompilation_(i::FLAG_parallel_recompilation) {
i::FLAG_allow_natives_syntax = true;
i::FLAG_use_inlining = false;
+ i::FLAG_parallel_recompilation = false;
}
- ~AllowNativesSyntaxNoInlining() {
+ ~AllowNativesSyntaxNoInliningNoParallel() {
i::FLAG_allow_natives_syntax = allow_natives_syntax_;
i::FLAG_use_inlining = use_inlining_;
+ i::FLAG_parallel_recompilation = parallel_recompilation_;
}
private:
bool allow_natives_syntax_;
bool use_inlining_;
+ bool parallel_recompilation_;
};
@@ -343,7 +347,7 @@
const char* f_source = "function f(x, y) { return x + y; };";
{
- AllowNativesSyntaxNoInlining options;
+ AllowNativesSyntaxNoInliningNoParallel options;
// Compile function f and collect to type feedback to insert binary op
stub
// call in the optimized code.
i::FLAG_prepare_always_opt = true;
@@ -401,7 +405,7 @@
binary_op);
char* f_source = f_source_buffer.start();
- AllowNativesSyntaxNoInlining options;
+ AllowNativesSyntaxNoInliningNoParallel options;
// Compile function f and collect to type feedback to insert binary op
stub
// call in the optimized code.
i::FLAG_prepare_always_opt = true;
@@ -493,7 +497,7 @@
const char* f_source = "function f(x, y) { return x < y; };";
{
- AllowNativesSyntaxNoInlining options;
+ AllowNativesSyntaxNoInliningNoParallel options;
// Compile function f and collect to type feedback to insert compare ic
// call in the optimized code.
i::FLAG_prepare_always_opt = true;
@@ -540,7 +544,7 @@
const char* g2_source = "function g2(x, y) { x[y] = 1; };";
{
- AllowNativesSyntaxNoInlining options;
+ AllowNativesSyntaxNoInliningNoParallel options;
// Compile functions and collect to type feedback to insert ic
// calls in the optimized code.
i::FLAG_prepare_always_opt = true;
@@ -620,7 +624,7 @@
const char* g2_source = "function g2(x, y) { x[y] = 1; };";
{
- AllowNativesSyntaxNoInlining options;
+ AllowNativesSyntaxNoInliningNoParallel options;
// Compile functions and collect to type feedback to insert ic
// calls in the optimized code.
i::FLAG_prepare_always_opt = true;
--
--
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/groups/opt_out.