V8 Project
assert-scope.h
Go to the documentation of this file.
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
3 // found in the LICENSE file.
4 
5 #ifndef V8_ASSERT_SCOPE_H_
6 #define V8_ASSERT_SCOPE_H_
7 
8 #include "include/v8stdint.h"
9 #include "src/base/macros.h"
10 
11 namespace v8 {
12 namespace internal {
13 
14 // Forward declarations.
15 class Isolate;
16 class PerThreadAssertData;
17 
18 
26 };
27 
28 
35 };
36 
37 
38 template <PerThreadAssertType kType, bool kAllow>
40  public:
43 
44  static bool IsAllowed();
45 
46  private:
47  PerThreadAssertData* data_;
48  bool old_state_;
49 
51 };
52 
53 
54 template <PerIsolateAssertType type, bool allow>
56  public:
57  explicit PerIsolateAssertScope(Isolate* isolate);
59 
60  static bool IsAllowed(Isolate* isolate);
61 
62  private:
63  class DataBit;
64 
67 
69 };
70 
71 
72 template <PerThreadAssertType type, bool allow>
73 #ifdef DEBUG
74 class PerThreadAssertScopeDebugOnly : public
75  PerThreadAssertScope<type, allow> {
76 #else
78  public:
80 #endif
81 };
82 
83 
84 template <PerIsolateAssertType type, bool allow>
85 #ifdef DEBUG
86 class PerIsolateAssertScopeDebugOnly : public
87  PerIsolateAssertScope<type, allow> {
88  public:
89  explicit PerIsolateAssertScopeDebugOnly(Isolate* isolate)
90  : PerIsolateAssertScope<type, allow>(isolate) { }
91 #else
93  public:
94  explicit PerIsolateAssertScopeDebugOnly(Isolate* isolate) { }
95 #endif
96 };
97 
98 // Per-thread assert scopes.
99 
100 // Scope to document where we do not expect handles to be created.
101 typedef PerThreadAssertScopeDebugOnly<HANDLE_ALLOCATION_ASSERT, false>
103 
104 // Scope to introduce an exception to DisallowHandleAllocation.
107 
108 // Scope to document where we do not expect any allocation and GC.
111 
112 // Scope to introduce an exception to DisallowHeapAllocation.
115 
116 // Scope to document where we do not expect any handle dereferences.
119 
120 // Scope to introduce an exception to DisallowHandleDereference.
123 
124 // Scope to document where we do not expect deferred handles to be dereferenced.
127 
128 // Scope to introduce an exception to DisallowDeferredHandleDereference.
131 
132 // Scope to document where we do not expect deferred handles to be dereferenced.
135 
136 // Scope to introduce an exception to DisallowDeferredHandleDereference.
139 
140 
141 // Per-isolate assert scopes.
142 
143 // Scope to document where we do not expect javascript execution.
146 
147 // Scope to introduce an exception to DisallowJavascriptExecution.
150 
151 // Scope in which javascript execution leads to exception being thrown.
154 
155 // Scope to introduce an exception to ThrowOnJavascriptExecution.
158 
159 // Scope to document where we do not expect an allocation failure.
162 
163 // Scope to introduce an exception to DisallowAllocationFailure.
166 
167 // Scope to document where we do not expect deoptimization.
170 
171 // Scope to introduce an exception to DisallowDeoptimization.
174 
175 // Scope to document where we do not expect deoptimization.
178 
179 // Scope to introduce an exception to DisallowDeoptimization.
182 } } // namespace v8::internal
183 
184 #endif // V8_ASSERT_SCOPE_H_
Isolate represents an isolated instance of the V8 engine.
Definition: v8.h:4356
static bool IsAllowed(Isolate *isolate)
DISALLOW_COPY_AND_ASSIGN(PerIsolateAssertScope)
DISALLOW_COPY_AND_ASSIGN(PerThreadAssertScope)
PerThreadAssertData * data_
Definition: assert-scope.h:47
PerThreadAssertScopeDebugOnly< HANDLE_ALLOCATION_ASSERT, true > AllowHandleAllocation
Definition: assert-scope.h:106
PerThreadAssertScopeDebugOnly< DEFERRED_HANDLE_DEREFERENCE_ASSERT, false > DisallowDeferredHandleDereference
Definition: assert-scope.h:126
PerThreadAssertScopeDebugOnly< CODE_DEPENDENCY_CHANGE_ASSERT, false > DisallowCodeDependencyChange
Definition: assert-scope.h:134
PerThreadAssertScopeDebugOnly< HEAP_ALLOCATION_ASSERT, false > DisallowHeapAllocation
Definition: assert-scope.h:110
PerIsolateAssertScope< JAVASCRIPT_EXECUTION_ASSERT, true > AllowJavascriptExecution
Definition: assert-scope.h:149
PerIsolateAssertScopeDebugOnly< DEOPTIMIZATION_ASSERT, false > DisallowDeoptimization
Definition: assert-scope.h:169
PerThreadAssertScopeDebugOnly< HEAP_ALLOCATION_ASSERT, true > AllowHeapAllocation
Definition: assert-scope.h:114
PerThreadAssertScopeDebugOnly< HANDLE_DEREFERENCE_ASSERT, true > AllowHandleDereference
Definition: assert-scope.h:122
@ CODE_DEPENDENCY_CHANGE_ASSERT
Definition: assert-scope.h:24
@ DEFERRED_HANDLE_DEREFERENCE_ASSERT
Definition: assert-scope.h:23
@ LAST_PER_THREAD_ASSERT_TYPE
Definition: assert-scope.h:25
@ HEAP_ALLOCATION_ASSERT
Definition: assert-scope.h:20
@ HANDLE_ALLOCATION_ASSERT
Definition: assert-scope.h:21
@ HANDLE_DEREFERENCE_ASSERT
Definition: assert-scope.h:22
PerIsolateAssertScope< JAVASCRIPT_EXECUTION_THROWS, false > ThrowOnJavascriptExecution
Definition: assert-scope.h:153
PerIsolateAssertScopeDebugOnly< ALLOCATION_FAILURE_ASSERT, false > DisallowAllocationFailure
Definition: assert-scope.h:161
PerThreadAssertScopeDebugOnly< CODE_DEPENDENCY_CHANGE_ASSERT, true > AllowCodeDependencyChange
Definition: assert-scope.h:138
PerIsolateAssertScope< JAVASCRIPT_EXECUTION_ASSERT, false > DisallowJavascriptExecution
Definition: assert-scope.h:145
@ DEOPTIMIZATION_ASSERT
Definition: assert-scope.h:33
@ JAVASCRIPT_EXECUTION_THROWS
Definition: assert-scope.h:31
@ JAVASCRIPT_EXECUTION_ASSERT
Definition: assert-scope.h:30
@ ALLOCATION_FAILURE_ASSERT
Definition: assert-scope.h:32
PerIsolateAssertScopeDebugOnly< COMPILATION_ASSERT, false > DisallowCompilation
Definition: assert-scope.h:177
PerThreadAssertScopeDebugOnly< HANDLE_DEREFERENCE_ASSERT, false > DisallowHandleDereference
Definition: assert-scope.h:118
PerIsolateAssertScopeDebugOnly< ALLOCATION_FAILURE_ASSERT, true > AllowAllocationFailure
Definition: assert-scope.h:165
PerIsolateAssertScopeDebugOnly< COMPILATION_ASSERT, true > AllowCompilation
Definition: assert-scope.h:181
PerThreadAssertScopeDebugOnly< HANDLE_ALLOCATION_ASSERT, false > DisallowHandleAllocation
Definition: assert-scope.h:102
PerIsolateAssertScopeDebugOnly< DEOPTIMIZATION_ASSERT, true > AllowDeoptimization
Definition: assert-scope.h:173
PerIsolateAssertScope< JAVASCRIPT_EXECUTION_THROWS, true > NoThrowOnJavascriptExecution
Definition: assert-scope.h:157
PerThreadAssertScopeDebugOnly< DEFERRED_HANDLE_DEREFERENCE_ASSERT, true > AllowDeferredHandleDereference
Definition: assert-scope.h:130
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20