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

Unified Diff: src/assert-scope.h

Issue 396923002: Reduce amount of boilerplate in assert-scope.h (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/assert-scope.h
diff --git a/src/assert-scope.h b/src/assert-scope.h
index 82ba66505df363fc68c93abad5b10dc8b45abb9f..9937c1727c1f9bd8f64d89dd01ac9509015d8c5d 100644
--- a/src/assert-scope.h
+++ b/src/assert-scope.h
@@ -14,22 +14,43 @@ namespace internal {
class Isolate;
+#define PER_THREAD_ASSERT_LIST(V) \
+ V(HEAP_ALLOCATION_ASSERT, AllowHeapAllocation, DisallowHeapAllocation, \
+ DebugOnly) \
+ V(HANDLE_ALLOCATION_ASSERT, AllowHandleAllocation, DisallowHandleAllocation, \
+ DebugOnly) \
+ V(HANDLE_DEREFERENCE_ASSERT, AllowHandleDereference, \
+ DisallowHandleDereference, DebugOnly) \
+ V(DEFERRED_HANDLE_DEREFERENCE_ASSERT, AllowDeferredHandleDereference, \
+ DisallowDeferredHandleDereference, DebugOnly) \
+ V(CODE_DEPENDENCY_CHANGE_ASSERT, AllowCodeDependencyChange, \
+ DisallowCodeDependencyChange, DebugOnly)
+
+#define PER_ISOLATE_ASSERT_LIST(V) \
+ V(JAVASCRIPT_EXECUTION_ASSERT, AllowJavascriptExecution, \
+ DisallowJavascriptExecution, ReleaseAndDebug) \
+ V(JAVASCRIPT_EXECUTION_THROWS, NoThrowOnJavascriptExecution, \
+ ThrowOnJavascriptExecution, ReleaseAndDebug) \
+ V(ALLOCATION_FAILURE_ASSERT, AllowAllocationFailure, \
+ DisallowAllocationFailure, DebugOnly) \
+ V(DEOPTIMIZATION_ASSERT, AllowDeoptimization, DisallowDeoptimization, \
+ DebugOnly) \
+ V(COMPILATION_ASSERT, AllowCompilation, DisallowCompilation, DebugOnly)
+
+
enum PerThreadAssertType {
- HEAP_ALLOCATION_ASSERT,
- HANDLE_ALLOCATION_ASSERT,
- HANDLE_DEREFERENCE_ASSERT,
- DEFERRED_HANDLE_DEREFERENCE_ASSERT,
- CODE_DEPENDENCY_CHANGE_ASSERT,
+#define V(NAME, PositiveName, NegativeName, BuildMode) NAME,
+ PER_THREAD_ASSERT_LIST(V)
+#undef V
LAST_PER_THREAD_ASSERT_TYPE
};
enum PerIsolateAssertType {
- JAVASCRIPT_EXECUTION_ASSERT,
- JAVASCRIPT_EXECUTION_THROWS,
- ALLOCATION_FAILURE_ASSERT,
- DEOPTIMIZATION_ASSERT,
- COMPILATION_ASSERT
+#define V(NAME, PositiveName, NegativeName, BuildMode) NAME,
+ PER_ISOLATE_ASSERT_LIST(V)
+#undef V
+ LAST_PER_ISOLATE_ASSERT_TYPE
};
@@ -178,90 +199,24 @@ class PerIsolateAssertScopeDebugOnly {
#endif
};
-// Per-thread assert scopes.
-
-// Scope to document where we do not expect handles to be created.
-typedef PerThreadAssertScopeDebugOnly<HANDLE_ALLOCATION_ASSERT, false>
- DisallowHandleAllocation;
-
-// Scope to introduce an exception to DisallowHandleAllocation.
-typedef PerThreadAssertScopeDebugOnly<HANDLE_ALLOCATION_ASSERT, true>
- AllowHandleAllocation;
-
-// Scope to document where we do not expect any allocation and GC.
-typedef PerThreadAssertScopeDebugOnly<HEAP_ALLOCATION_ASSERT, false>
- DisallowHeapAllocation;
-
-// Scope to introduce an exception to DisallowHeapAllocation.
-typedef PerThreadAssertScopeDebugOnly<HEAP_ALLOCATION_ASSERT, true>
- AllowHeapAllocation;
-
-// Scope to document where we do not expect any handle dereferences.
-typedef PerThreadAssertScopeDebugOnly<HANDLE_DEREFERENCE_ASSERT, false>
- DisallowHandleDereference;
-
-// Scope to introduce an exception to DisallowHandleDereference.
-typedef PerThreadAssertScopeDebugOnly<HANDLE_DEREFERENCE_ASSERT, true>
- AllowHandleDereference;
-
-// Scope to document where we do not expect deferred handles to be dereferenced.
-typedef PerThreadAssertScopeDebugOnly<DEFERRED_HANDLE_DEREFERENCE_ASSERT, false>
- DisallowDeferredHandleDereference;
-
-// Scope to introduce an exception to DisallowDeferredHandleDereference.
-typedef PerThreadAssertScopeDebugOnly<DEFERRED_HANDLE_DEREFERENCE_ASSERT, true>
- AllowDeferredHandleDereference;
-
-// Scope to document where we do not expect deferred handles to be dereferenced.
-typedef PerThreadAssertScopeDebugOnly<CODE_DEPENDENCY_CHANGE_ASSERT, false>
- DisallowCodeDependencyChange;
-
-// Scope to introduce an exception to DisallowDeferredHandleDereference.
-typedef PerThreadAssertScopeDebugOnly<CODE_DEPENDENCY_CHANGE_ASSERT, true>
- AllowCodeDependencyChange;
-
-
-// Per-isolate assert scopes.
-
-// Scope to document where we do not expect javascript execution.
-typedef PerIsolateAssertScope<JAVASCRIPT_EXECUTION_ASSERT, false>
- DisallowJavascriptExecution;
-
-// Scope to introduce an exception to DisallowJavascriptExecution.
-typedef PerIsolateAssertScope<JAVASCRIPT_EXECUTION_ASSERT, true>
- AllowJavascriptExecution;
-
-// Scope in which javascript execution leads to exception being thrown.
-typedef PerIsolateAssertScope<JAVASCRIPT_EXECUTION_THROWS, false>
- ThrowOnJavascriptExecution;
-
-// Scope to introduce an exception to ThrowOnJavascriptExecution.
-typedef PerIsolateAssertScope<JAVASCRIPT_EXECUTION_THROWS, true>
- NoThrowOnJavascriptExecution;
-
-// Scope to document where we do not expect an allocation failure.
-typedef PerIsolateAssertScopeDebugOnly<ALLOCATION_FAILURE_ASSERT, false>
- DisallowAllocationFailure;
-
-// Scope to introduce an exception to DisallowAllocationFailure.
-typedef PerIsolateAssertScopeDebugOnly<ALLOCATION_FAILURE_ASSERT, true>
- AllowAllocationFailure;
-
-// Scope to document where we do not expect deoptimization.
-typedef PerIsolateAssertScopeDebugOnly<DEOPTIMIZATION_ASSERT, false>
- DisallowDeoptimization;
-
-// Scope to introduce an exception to DisallowDeoptimization.
-typedef PerIsolateAssertScopeDebugOnly<DEOPTIMIZATION_ASSERT, true>
- AllowDeoptimization;
-
-// Scope to document where we do not expect deoptimization.
-typedef PerIsolateAssertScopeDebugOnly<COMPILATION_ASSERT, false>
- DisallowCompilation;
-// Scope to introduce an exception to DisallowDeoptimization.
-typedef PerIsolateAssertScopeDebugOnly<COMPILATION_ASSERT, true>
- AllowCompilation;
+// Define Per-thread assert scopes.
+#define PerThreadAssertScopeReleaseAndDebug PerThreadAssertScope
+#define V(NAME, PositiveName, NegativeName, BuildMode) \
+ typedef PerThreadAssertScope##BuildMode<NAME, false> NegativeName; \
+ typedef PerThreadAssertScope##BuildMode<NAME, true> PositiveName;
+PER_THREAD_ASSERT_LIST(V)
+#undef V
+#undef PerThreadAssertScopeReleaseAndDebug
+
+// Define Per-isolate assert scopes.
+#define PerIsolateAssertScopeReleaseAndDebug PerIsolateAssertScope
+#define V(NAME, PositiveName, NegativeName, BuildMode) \
+ typedef PerIsolateAssertScope##BuildMode<NAME, false> NegativeName; \
+ typedef PerIsolateAssertScope##BuildMode<NAME, true> PositiveName;
+PER_ISOLATE_ASSERT_LIST(V)
+#undef V
+#undef PerIsolateAssertScopeReleaseAndDebug
} } // namespace v8::internal
#endif // V8_ASSERT_SCOPE_H_
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698