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

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: state is now bool 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..18a2cf351b33f1eb2886fe8b8658519159a445b1 100644
--- a/src/heap-inl.h
+++ b/src/heap-inl.h
@@ -650,6 +650,10 @@ inline bool Heap::allow_allocation(bool new_state) {
return old;
}
+inline void Heap::set_allow_allocation(bool allocation_allowed) {
+ allocation_allowed_ = allocation_allowed;
+}
+
#endif
@@ -864,33 +868,36 @@ DisallowAllocationFailure::~DisallowAllocationFailure() {
#ifdef DEBUG
-AssertNoAllocation::AssertNoAllocation() {
- Isolate* isolate = ISOLATE;
- active_ = !isolate->optimizing_compiler_thread()->IsOptimizerThread();
- if (active_) {
- old_state_ = isolate->heap()->allow_allocation(false);
+bool EnterAllocationScope(Isolate* isolate, bool allow_allocation) {
+ bool active = !isolate->optimizing_compiler_thread()->IsOptimizerThread();
+ bool last_state = isolate->heap()->IsAllocationAllowed();
+ if (active) {
+ isolate->heap()->set_allow_allocation(allow_allocation);
}
+ return last_state;
}
-AssertNoAllocation::~AssertNoAllocation() {
- if (active_) HEAP->allow_allocation(old_state_);
+void ExitAllocationScope(Isolate* isolate, bool last_state) {
+ isolate->heap()->set_allow_allocation(last_state);
}
-DisableAssertNoAllocation::DisableAssertNoAllocation() {
- Isolate* isolate = ISOLATE;
- active_ = !isolate->optimizing_compiler_thread()->IsOptimizerThread();
- if (active_) {
- old_state_ = isolate->heap()->allow_allocation(true);
- }
+AssertNoAllocation::AssertNoAllocation()
+ : last_state_(EnterAllocationScope(ISOLATE, false)) {
}
+AssertNoAllocation::~AssertNoAllocation() {
+ ExitAllocationScope(ISOLATE, last_state_);
+}
-DisableAssertNoAllocation::~DisableAssertNoAllocation() {
- if (active_) HEAP->allow_allocation(old_state_);
+DisableAssertNoAllocation::DisableAssertNoAllocation()
+ : last_state_(EnterAllocationScope(ISOLATE, true)) {
}
+DisableAssertNoAllocation::~DisableAssertNoAllocation() {
+ ExitAllocationScope(ISOLATE, last_state_);
+}
#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