OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_ASSERT_SCOPE_H_ | 5 #ifndef V8_ASSERT_SCOPE_H_ |
6 #define V8_ASSERT_SCOPE_H_ | 6 #define V8_ASSERT_SCOPE_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/platform.h" | 9 #include "src/base/platform/platform.h" |
10 #include "src/utils.h" | 10 #include "src/utils.h" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 | 14 |
15 class Isolate; | 15 class Isolate; |
16 | 16 |
17 enum PerThreadAssertType { | 17 enum PerThreadAssertType { |
18 HEAP_ALLOCATION_ASSERT, | 18 HEAP_ALLOCATION_ASSERT, |
19 HANDLE_ALLOCATION_ASSERT, | 19 HANDLE_ALLOCATION_ASSERT, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 if (!data_->decrement_level()) return; | 74 if (!data_->decrement_level()) return; |
75 for (int i = 0; i < LAST_PER_THREAD_ASSERT_TYPE; i++) { | 75 for (int i = 0; i < LAST_PER_THREAD_ASSERT_TYPE; i++) { |
76 ASSERT(data_->get(static_cast<PerThreadAssertType>(i))); | 76 ASSERT(data_->get(static_cast<PerThreadAssertType>(i))); |
77 } | 77 } |
78 delete data_; | 78 delete data_; |
79 SetThreadLocalData(NULL); | 79 SetThreadLocalData(NULL); |
80 } | 80 } |
81 | 81 |
82 static PerThreadAssertData* GetAssertData() { | 82 static PerThreadAssertData* GetAssertData() { |
83 return reinterpret_cast<PerThreadAssertData*>( | 83 return reinterpret_cast<PerThreadAssertData*>( |
84 Thread::GetThreadLocal(thread_local_key)); | 84 base::Thread::GetThreadLocal(thread_local_key)); |
85 } | 85 } |
86 | 86 |
87 static Thread::LocalStorageKey thread_local_key; | 87 static base::Thread::LocalStorageKey thread_local_key; |
88 PerThreadAssertData* data_; | 88 PerThreadAssertData* data_; |
89 friend class Isolate; | 89 friend class Isolate; |
90 | 90 |
91 private: | 91 private: |
92 static void SetThreadLocalData(PerThreadAssertData* data) { | 92 static void SetThreadLocalData(PerThreadAssertData* data) { |
93 Thread::SetThreadLocal(thread_local_key, data); | 93 base::Thread::SetThreadLocal(thread_local_key, data); |
94 } | 94 } |
95 }; | 95 }; |
96 | 96 |
97 | 97 |
98 template <PerThreadAssertType type, bool allow> | 98 template <PerThreadAssertType type, bool allow> |
99 class PerThreadAssertScope : public PerThreadAssertScopeBase { | 99 class PerThreadAssertScope : public PerThreadAssertScopeBase { |
100 public: | 100 public: |
101 PerThreadAssertScope() { | 101 PerThreadAssertScope() { |
102 old_state_ = data_->get(type); | 102 old_state_ = data_->get(type); |
103 data_->set(type, allow); | 103 data_->set(type, allow); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 typedef PerIsolateAssertScopeDebugOnly<DEOPTIMIZATION_ASSERT, false> | 250 typedef PerIsolateAssertScopeDebugOnly<DEOPTIMIZATION_ASSERT, false> |
251 DisallowDeoptimization; | 251 DisallowDeoptimization; |
252 | 252 |
253 // Scope to introduce an exception to DisallowDeoptimization. | 253 // Scope to introduce an exception to DisallowDeoptimization. |
254 typedef PerIsolateAssertScopeDebugOnly<DEOPTIMIZATION_ASSERT, true> | 254 typedef PerIsolateAssertScopeDebugOnly<DEOPTIMIZATION_ASSERT, true> |
255 AllowDeoptimization; | 255 AllowDeoptimization; |
256 | 256 |
257 } } // namespace v8::internal | 257 } } // namespace v8::internal |
258 | 258 |
259 #endif // V8_ASSERT_SCOPE_H_ | 259 #endif // V8_ASSERT_SCOPE_H_ |
OLD | NEW |