| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 #include "src/base/macros.h" | 9 #include "src/base/macros.h" |
| 10 #include "src/globals.h" |
| 10 | 11 |
| 11 namespace v8 { | 12 namespace v8 { |
| 12 namespace internal { | 13 namespace internal { |
| 13 | 14 |
| 14 // Forward declarations. | 15 // Forward declarations. |
| 15 class Isolate; | 16 class Isolate; |
| 16 class PerThreadAssertData; | 17 class PerThreadAssertData; |
| 17 | 18 |
| 18 | 19 |
| 19 enum PerThreadAssertType { | 20 enum PerThreadAssertType { |
| 20 HEAP_ALLOCATION_ASSERT, | 21 HEAP_ALLOCATION_ASSERT, |
| 21 HANDLE_ALLOCATION_ASSERT, | 22 HANDLE_ALLOCATION_ASSERT, |
| 22 HANDLE_DEREFERENCE_ASSERT, | 23 HANDLE_DEREFERENCE_ASSERT, |
| 23 DEFERRED_HANDLE_DEREFERENCE_ASSERT, | 24 DEFERRED_HANDLE_DEREFERENCE_ASSERT, |
| 24 CODE_DEPENDENCY_CHANGE_ASSERT, | 25 CODE_DEPENDENCY_CHANGE_ASSERT, |
| 25 LAST_PER_THREAD_ASSERT_TYPE | 26 LAST_PER_THREAD_ASSERT_TYPE |
| 26 }; | 27 }; |
| 27 | 28 |
| 28 | 29 |
| 29 enum PerIsolateAssertType { | 30 enum PerIsolateAssertType { |
| 30 JAVASCRIPT_EXECUTION_ASSERT, | 31 JAVASCRIPT_EXECUTION_ASSERT, |
| 31 JAVASCRIPT_EXECUTION_THROWS, | 32 JAVASCRIPT_EXECUTION_THROWS, |
| 32 DEOPTIMIZATION_ASSERT, | 33 DEOPTIMIZATION_ASSERT, |
| 33 COMPILATION_ASSERT | 34 COMPILATION_ASSERT |
| 34 }; | 35 }; |
| 35 | 36 |
| 36 | |
| 37 template <PerThreadAssertType kType, bool kAllow> | 37 template <PerThreadAssertType kType, bool kAllow> |
| 38 class PerThreadAssertScope { | 38 class PerThreadAssertScope { |
| 39 public: | 39 public: |
| 40 PerThreadAssertScope(); | 40 V8_EXPORT_PRIVATE PerThreadAssertScope(); |
| 41 ~PerThreadAssertScope(); | 41 V8_EXPORT_PRIVATE ~PerThreadAssertScope(); |
| 42 | 42 |
| 43 static bool IsAllowed(); | 43 V8_EXPORT_PRIVATE static bool IsAllowed(); |
| 44 | 44 |
| 45 private: | 45 private: |
| 46 PerThreadAssertData* data_; | 46 PerThreadAssertData* data_; |
| 47 bool old_state_; | 47 bool old_state_; |
| 48 | 48 |
| 49 DISALLOW_COPY_AND_ASSIGN(PerThreadAssertScope); | 49 DISALLOW_COPY_AND_ASSIGN(PerThreadAssertScope); |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 | 52 |
| 53 template <PerIsolateAssertType type, bool allow> | 53 template <PerIsolateAssertType type, bool allow> |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 typedef PerIsolateAssertScopeDebugOnly<COMPILATION_ASSERT, false> | 167 typedef PerIsolateAssertScopeDebugOnly<COMPILATION_ASSERT, false> |
| 168 DisallowCompilation; | 168 DisallowCompilation; |
| 169 | 169 |
| 170 // Scope to introduce an exception to DisallowDeoptimization. | 170 // Scope to introduce an exception to DisallowDeoptimization. |
| 171 typedef PerIsolateAssertScopeDebugOnly<COMPILATION_ASSERT, true> | 171 typedef PerIsolateAssertScopeDebugOnly<COMPILATION_ASSERT, true> |
| 172 AllowCompilation; | 172 AllowCompilation; |
| 173 } // namespace internal | 173 } // namespace internal |
| 174 } // namespace v8 | 174 } // namespace v8 |
| 175 | 175 |
| 176 #endif // V8_ASSERT_SCOPE_H_ | 176 #endif // V8_ASSERT_SCOPE_H_ |
| OLD | NEW |