Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(416)

Unified Diff: src/v8threads.cc

Issue 637263002: Fix data races and leaks related to v8::Lockers (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/isolate.h ('k') | test/cctest/test-lockers.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/v8threads.cc
diff --git a/src/v8threads.cc b/src/v8threads.cc
index a46b289ba1374b9e17dc3e18e823c86214784159..788786dbfdf683b9a2fea2120fcc6468d343145a 100644
--- a/src/v8threads.cc
+++ b/src/v8threads.cc
@@ -14,9 +14,13 @@
namespace v8 {
+namespace {
+
// Track whether this V8 instance has ever called v8::Locker. This allows the
// API code to verify that the lock is always held when V8 is being entered.
-bool Locker::active_ = false;
+base::Atomic32 g_locker_was_ever_used_ = 0;
+
+} // namespace
// Once the Locker is initialized, the current thread will be guaranteed to have
@@ -27,7 +31,7 @@ void Locker::Initialize(v8::Isolate* isolate) {
top_level_ = true;
isolate_ = reinterpret_cast<i::Isolate*>(isolate);
// Record that the Locker has been used at least once.
- active_ = true;
+ base::NoBarrier_Store(&g_locker_was_ever_used_, 1);
// Get the big lock if necessary.
if (!isolate_->thread_manager()->IsLockedByCurrentThread()) {
isolate_->thread_manager()->Lock();
@@ -64,7 +68,7 @@ bool Locker::IsLocked(v8::Isolate* isolate) {
bool Locker::IsActive() {
- return active_;
+ return !!base::NoBarrier_Load(&g_locker_was_ever_used_);
}
« no previous file with comments | « src/isolate.h ('k') | test/cctest/test-lockers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698