Commit 3adb5446 authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

[wrapper-tracing] Cache wrapper tracing status in ThreadState

Bug: 
Change-Id: I23ad4603ce6dcc8934827e0cfbef0f8427afe5ad
Reviewed-on: https://chromium-review.googlesource.com/600189
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491830}
parent bfeb34d8
...@@ -37,6 +37,7 @@ void ScriptWrappableVisitor::TracePrologue() { ...@@ -37,6 +37,7 @@ void ScriptWrappableVisitor::TracePrologue() {
CHECK(marking_deque_.IsEmpty()); CHECK(marking_deque_.IsEmpty());
CHECK(verifier_deque_.IsEmpty()); CHECK(verifier_deque_.IsEmpty());
tracing_in_progress_ = true; tracing_in_progress_ = true;
ThreadState::Current()->SetWrapperTracingInProgress(true);
} }
void ScriptWrappableVisitor::EnterFinalPause() { void ScriptWrappableVisitor::EnterFinalPause() {
...@@ -58,6 +59,7 @@ void ScriptWrappableVisitor::TraceEpilogue() { ...@@ -58,6 +59,7 @@ void ScriptWrappableVisitor::TraceEpilogue() {
should_cleanup_ = true; should_cleanup_ = true;
tracing_in_progress_ = false; tracing_in_progress_ = false;
ThreadState::Current()->SetWrapperTracingInProgress(false);
ScheduleIdleLazyCleanup(); ScheduleIdleLazyCleanup();
} }
...@@ -65,6 +67,7 @@ void ScriptWrappableVisitor::AbortTracing() { ...@@ -65,6 +67,7 @@ void ScriptWrappableVisitor::AbortTracing() {
CHECK(ThreadState::Current()); CHECK(ThreadState::Current());
should_cleanup_ = true; should_cleanup_ = true;
tracing_in_progress_ = false; tracing_in_progress_ = false;
ThreadState::Current()->SetWrapperTracingInProgress(false);
PerformCleanup(); PerformCleanup();
} }
...@@ -223,7 +226,8 @@ void ScriptWrappableVisitor::WriteBarrier( ...@@ -223,7 +226,8 @@ void ScriptWrappableVisitor::WriteBarrier(
v8::Isolate* isolate, v8::Isolate* isolate,
const void* src_object, const void* src_object,
const TraceWrapperV8Reference<v8::Value>* dst_object) { const TraceWrapperV8Reference<v8::Value>* dst_object) {
if (!src_object || !dst_object || dst_object->IsEmpty()) { if (!src_object || !dst_object || dst_object->IsEmpty() ||
!ThreadState::Current()->WrapperTracingInProgress()) {
return; return;
} }
// We only require a write barrier if |srcObject| is already marked. Note // We only require a write barrier if |srcObject| is already marked. Note
...@@ -239,7 +243,8 @@ void ScriptWrappableVisitor::WriteBarrier( ...@@ -239,7 +243,8 @@ void ScriptWrappableVisitor::WriteBarrier(
void ScriptWrappableVisitor::WriteBarrier( void ScriptWrappableVisitor::WriteBarrier(
v8::Isolate* isolate, v8::Isolate* isolate,
const v8::Persistent<v8::Object>* dst_object) { const v8::Persistent<v8::Object>* dst_object) {
if (!dst_object || dst_object->IsEmpty()) { if (!dst_object || dst_object->IsEmpty() ||
!ThreadState::Current()->WrapperTracingInProgress()) {
return; return;
} }
CurrentVisitor(isolate)->MarkWrapper(&(dst_object->As<v8::Value>())); CurrentVisitor(isolate)->MarkWrapper(&(dst_object->As<v8::Value>()));
......
...@@ -117,6 +117,13 @@ class PLATFORM_EXPORT ScriptWrappableVisitor : public v8::EmbedderHeapTracer, ...@@ -117,6 +117,13 @@ class PLATFORM_EXPORT ScriptWrappableVisitor : public v8::EmbedderHeapTracer,
if (!src_object || !dst_object) { if (!src_object || !dst_object) {
return; return;
} }
const ThreadState* thread_state = ThreadState::Current();
DCHECK(thread_state);
// Bail out if tracing is not in progress.
if (!thread_state->WrapperTracingInProgress())
return;
// We only require a write barrier if |srcObject| is already marked. Note // We only require a write barrier if |srcObject| is already marked. Note
// that this implicitly disables the write barrier when the GC is not // that this implicitly disables the write barrier when the GC is not
// active as object will not be marked in this case. // active as object will not be marked in this case.
...@@ -124,8 +131,6 @@ class PLATFORM_EXPORT ScriptWrappableVisitor : public v8::EmbedderHeapTracer, ...@@ -124,8 +131,6 @@ class PLATFORM_EXPORT ScriptWrappableVisitor : public v8::EmbedderHeapTracer,
return; return;
} }
const ThreadState* thread_state = ThreadState::Current();
DCHECK(thread_state);
// If the wrapper is already marked we can bail out here. // If the wrapper is already marked we can bail out here.
if (TraceTrait<T>::GetHeapObjectHeader(dst_object)->IsWrapperHeaderMarked()) if (TraceTrait<T>::GetHeapObjectHeader(dst_object)->IsWrapperHeaderMarked())
return; return;
......
...@@ -123,6 +123,8 @@ ThreadState::ThreadState() ...@@ -123,6 +123,8 @@ ThreadState::ThreadState()
isolate_(nullptr), isolate_(nullptr),
trace_dom_wrappers_(nullptr), trace_dom_wrappers_(nullptr),
invalidate_dead_objects_in_wrappers_marking_deque_(nullptr), invalidate_dead_objects_in_wrappers_marking_deque_(nullptr),
perform_cleanup_(nullptr),
wrapper_tracing_in_progress_(false),
#if defined(ADDRESS_SANITIZER) #if defined(ADDRESS_SANITIZER)
asan_fake_stack_(__asan_get_current_fake_stack()), asan_fake_stack_(__asan_get_current_fake_stack()),
#endif #endif
......
...@@ -292,6 +292,11 @@ class PLATFORM_EXPORT ThreadState { ...@@ -292,6 +292,11 @@ class PLATFORM_EXPORT ThreadState {
object_resurrection_forbidden_ = false; object_resurrection_forbidden_ = false;
} }
bool WrapperTracingInProgress() const { return wrapper_tracing_in_progress_; }
void SetWrapperTracingInProgress(bool value) {
wrapper_tracing_in_progress_ = value;
}
class MainThreadGCForbiddenScope final { class MainThreadGCForbiddenScope final {
STACK_ALLOCATED(); STACK_ALLOCATED();
...@@ -679,6 +684,7 @@ class PLATFORM_EXPORT ThreadState { ...@@ -679,6 +684,7 @@ class PLATFORM_EXPORT ThreadState {
void (*trace_dom_wrappers_)(v8::Isolate*, Visitor*); void (*trace_dom_wrappers_)(v8::Isolate*, Visitor*);
void (*invalidate_dead_objects_in_wrappers_marking_deque_)(v8::Isolate*); void (*invalidate_dead_objects_in_wrappers_marking_deque_)(v8::Isolate*);
void (*perform_cleanup_)(v8::Isolate*); void (*perform_cleanup_)(v8::Isolate*);
bool wrapper_tracing_in_progress_;
#if defined(ADDRESS_SANITIZER) #if defined(ADDRESS_SANITIZER)
void* asan_fake_stack_; void* asan_fake_stack_;
......
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