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() {
CHECK(marking_deque_.IsEmpty());
CHECK(verifier_deque_.IsEmpty());
tracing_in_progress_ = true;
ThreadState::Current()->SetWrapperTracingInProgress(true);
}
void ScriptWrappableVisitor::EnterFinalPause() {
......@@ -58,6 +59,7 @@ void ScriptWrappableVisitor::TraceEpilogue() {
should_cleanup_ = true;
tracing_in_progress_ = false;
ThreadState::Current()->SetWrapperTracingInProgress(false);
ScheduleIdleLazyCleanup();
}
......@@ -65,6 +67,7 @@ void ScriptWrappableVisitor::AbortTracing() {
CHECK(ThreadState::Current());
should_cleanup_ = true;
tracing_in_progress_ = false;
ThreadState::Current()->SetWrapperTracingInProgress(false);
PerformCleanup();
}
......@@ -223,7 +226,8 @@ void ScriptWrappableVisitor::WriteBarrier(
v8::Isolate* isolate,
const void* src_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;
}
// We only require a write barrier if |srcObject| is already marked. Note
......@@ -239,7 +243,8 @@ void ScriptWrappableVisitor::WriteBarrier(
void ScriptWrappableVisitor::WriteBarrier(
v8::Isolate* isolate,
const v8::Persistent<v8::Object>* dst_object) {
if (!dst_object || dst_object->IsEmpty()) {
if (!dst_object || dst_object->IsEmpty() ||
!ThreadState::Current()->WrapperTracingInProgress()) {
return;
}
CurrentVisitor(isolate)->MarkWrapper(&(dst_object->As<v8::Value>()));
......
......@@ -117,6 +117,13 @@ class PLATFORM_EXPORT ScriptWrappableVisitor : public v8::EmbedderHeapTracer,
if (!src_object || !dst_object) {
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
// that this implicitly disables the write barrier when the GC is not
// active as object will not be marked in this case.
......@@ -124,8 +131,6 @@ class PLATFORM_EXPORT ScriptWrappableVisitor : public v8::EmbedderHeapTracer,
return;
}
const ThreadState* thread_state = ThreadState::Current();
DCHECK(thread_state);
// If the wrapper is already marked we can bail out here.
if (TraceTrait<T>::GetHeapObjectHeader(dst_object)->IsWrapperHeaderMarked())
return;
......
......@@ -123,6 +123,8 @@ ThreadState::ThreadState()
isolate_(nullptr),
trace_dom_wrappers_(nullptr),
invalidate_dead_objects_in_wrappers_marking_deque_(nullptr),
perform_cleanup_(nullptr),
wrapper_tracing_in_progress_(false),
#if defined(ADDRESS_SANITIZER)
asan_fake_stack_(__asan_get_current_fake_stack()),
#endif
......
......@@ -292,6 +292,11 @@ class PLATFORM_EXPORT ThreadState {
object_resurrection_forbidden_ = false;
}
bool WrapperTracingInProgress() const { return wrapper_tracing_in_progress_; }
void SetWrapperTracingInProgress(bool value) {
wrapper_tracing_in_progress_ = value;
}
class MainThreadGCForbiddenScope final {
STACK_ALLOCATED();
......@@ -679,6 +684,7 @@ class PLATFORM_EXPORT ThreadState {
void (*trace_dom_wrappers_)(v8::Isolate*, Visitor*);
void (*invalidate_dead_objects_in_wrappers_marking_deque_)(v8::Isolate*);
void (*perform_cleanup_)(v8::Isolate*);
bool wrapper_tracing_in_progress_;
#if defined(ADDRESS_SANITIZER)
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