summaryrefslogtreecommitdiff
path: root/deps/v8/src/assert-scope.h
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2013-07-02 17:11:31 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2013-07-06 16:53:06 +0200
commit704fd8f3745527fc080f96e54e5ec1857c505399 (patch)
treebff68e8a731f3618d3e8f1708aa9de194bc1f612 /deps/v8/src/assert-scope.h
parenteec43351c44c0bec31a83e1a28be15e30722936a (diff)
downloadnode-new-704fd8f3745527fc080f96e54e5ec1857c505399.tar.gz
v8: upgrade to v3.20.2
Diffstat (limited to 'deps/v8/src/assert-scope.h')
-rw-r--r--deps/v8/src/assert-scope.h29
1 files changed, 18 insertions, 11 deletions
diff --git a/deps/v8/src/assert-scope.h b/deps/v8/src/assert-scope.h
index e2ec542a77..13adbd0f9c 100644
--- a/deps/v8/src/assert-scope.h
+++ b/deps/v8/src/assert-scope.h
@@ -79,7 +79,11 @@ class PerThreadAssertScopeBase {
protected:
PerThreadAssertScopeBase() {
- data_ = AssertData();
+ data_ = GetAssertData();
+ if (data_ == NULL) {
+ data_ = new PerThreadAssertData();
+ SetThreadLocalData(data_);
+ }
data_->increment_level();
}
@@ -89,22 +93,22 @@ class PerThreadAssertScopeBase {
ASSERT(data_->get(static_cast<PerThreadAssertType>(i)));
}
delete data_;
- Thread::SetThreadLocal(thread_local_key, NULL);
+ SetThreadLocalData(NULL);
}
- static PerThreadAssertData* AssertData() {
- PerThreadAssertData* data = reinterpret_cast<PerThreadAssertData*>(
- Thread::GetThreadLocal(thread_local_key));
- if (data == NULL) {
- data = new PerThreadAssertData();
- Thread::SetThreadLocal(thread_local_key, data);
- }
- return data;
+ static PerThreadAssertData* GetAssertData() {
+ return reinterpret_cast<PerThreadAssertData*>(
+ Thread::GetThreadLocal(thread_local_key));
}
static Thread::LocalStorageKey thread_local_key;
PerThreadAssertData* data_;
friend class Isolate;
+
+ private:
+ static void SetThreadLocalData(PerThreadAssertData* data) {
+ Thread::SetThreadLocal(thread_local_key, data);
+ }
#endif // DEBUG
};
@@ -124,7 +128,10 @@ class PerThreadAssertScope : public PerThreadAssertScopeBase {
~PerThreadAssertScope() { data_->set(type, old_state_); }
- static bool IsAllowed() { return AssertData()->get(type); }
+ static bool IsAllowed() {
+ PerThreadAssertData* data = GetAssertData();
+ return data == NULL || data->get(type);
+ }
private:
bool old_state_;