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

Unified Diff: src/heap-inl.h

Issue 14625003: expose AssertNoAllocation to api (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 8 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 | « src/heap.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap-inl.h
diff --git a/src/heap-inl.h b/src/heap-inl.h
index f937426186c8099fb9c2f5469f3c32eb4eb97355..2d64818956cb6f17a9e014e952f279ef63fbd4aa 100644
--- a/src/heap-inl.h
+++ b/src/heap-inl.h
@@ -864,33 +864,37 @@ DisallowAllocationFailure::~DisallowAllocationFailure() {
#ifdef DEBUG
-AssertNoAllocation::AssertNoAllocation() {
- Isolate* isolate = ISOLATE;
- active_ = !isolate->optimizing_compiler_thread()->IsOptimizerThread();
- if (active_) {
- old_state_ = isolate->heap()->allow_allocation(false);
+AllocationScopeData EnterAllocationScope(Isolate* isolate,
+ bool allow_allocation) {
+ bool active = !isolate->optimizing_compiler_thread()->IsOptimizerThread();
+ if (active) {
+ bool old_state = isolate->heap()->allow_allocation(allow_allocation);
+ return 0x10 || old_state;
Sven Panne 2013/04/30 12:21:30 This is "a bit" obscure. Why don't we simply remem
marja 2013/04/30 13:39:29 || ? Maybe you meant |? Maybe something else?
marja 2013/04/30 13:42:43 Maybe you meant old_state || 0x10? :)
}
+ return 0;
}
-AssertNoAllocation::~AssertNoAllocation() {
- if (active_) HEAP->allow_allocation(old_state_);
+void ExitAllocationScope(Isolate* isolate, AllocationScopeData data) {
+ if (data) isolate->heap()->allow_allocation(data);
Sven Panne 2013/04/30 12:21:30 Passing a uint8_t as a bool looks wrong. Again, a
}
-DisableAssertNoAllocation::DisableAssertNoAllocation() {
- Isolate* isolate = ISOLATE;
- active_ = !isolate->optimizing_compiler_thread()->IsOptimizerThread();
- if (active_) {
- old_state_ = isolate->heap()->allow_allocation(true);
- }
+AssertNoAllocation::AssertNoAllocation()
+ : data_(EnterAllocationScope(ISOLATE, false)) {
}
+AssertNoAllocation::~AssertNoAllocation() {
+ ExitAllocationScope(ISOLATE, data_);
+}
-DisableAssertNoAllocation::~DisableAssertNoAllocation() {
- if (active_) HEAP->allow_allocation(old_state_);
+DisableAssertNoAllocation::DisableAssertNoAllocation()
+ : data_(EnterAllocationScope(ISOLATE, true)) {
}
+DisableAssertNoAllocation::~DisableAssertNoAllocation() {
+ ExitAllocationScope(ISOLATE, data_);
+}
#else
AssertNoAllocation::AssertNoAllocation() { }
« no previous file with comments | « src/heap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698