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

Unified Diff: runtime/vm/heap.cc

Issue 1250463004: Migrate NoSafepointScope; add constrained concurrent allocation to unit test (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Assert current thread is mutator; add shared assertion macro. Created 5 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 | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/heap_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/heap.cc
diff --git a/runtime/vm/heap.cc b/runtime/vm/heap.cc
index 06da6f1b769e653b405668e7bc2c97ef8f770160..a5900b68681655bd28ac06223aecf9a760458e3a 100644
--- a/runtime/vm/heap.cc
+++ b/runtime/vm/heap.cc
@@ -74,7 +74,9 @@ Heap::~Heap() {
uword Heap::AllocateNew(intptr_t size) {
- ASSERT(isolate()->no_safepoint_scope_depth() == 0);
+ ASSERT(Thread::Current()->no_safepoint_scope_depth() == 0);
+ // Currently, only the Dart thread may allocate in new space.
+ isolate()->AssertCurrentThreadIsMutator();
uword addr = new_space_.TryAllocate(size);
if (addr == 0) {
CollectGarbage(kNew);
@@ -88,7 +90,13 @@ uword Heap::AllocateNew(intptr_t size) {
uword Heap::AllocateOld(intptr_t size, HeapPage::PageType type) {
- ASSERT(isolate()->no_safepoint_scope_depth() == 0);
+ ASSERT(Thread::Current()->no_safepoint_scope_depth() == 0);
+#if defined(DEBUG)
+ // Currently, allocation from non-Dart threads must not trigger GC.
+ if (GrowthControlState()) {
+ isolate()->AssertCurrentThreadIsMutator();
+ }
+#endif
uword addr = old_space_.TryAllocate(size, type);
if (addr != 0) {
return addr;
@@ -149,7 +157,7 @@ uword Heap::AllocateOld(intptr_t size, HeapPage::PageType type) {
uword Heap::AllocatePretenured(intptr_t size) {
- ASSERT(isolate()->no_safepoint_scope_depth() == 0);
+ ASSERT(Thread::Current()->no_safepoint_scope_depth() == 0);
uword addr = old_space_.TryAllocateDataBump(size, PageSpace::kControlGrowth);
if (addr != 0) return addr;
return AllocateOld(size, HeapPage::kData);
@@ -157,7 +165,7 @@ uword Heap::AllocatePretenured(intptr_t size) {
void Heap::AllocateExternal(intptr_t size, Space space) {
- ASSERT(isolate()->no_safepoint_scope_depth() == 0);
+ ASSERT(Thread::Current()->no_safepoint_scope_depth() == 0);
if (space == kNew) {
new_space_.AllocateExternal(size);
if (new_space_.ExternalInWords() > (FLAG_new_gen_ext_limit * MBInWords)) {
@@ -759,13 +767,13 @@ void Heap::PrintStats() {
#if defined(DEBUG)
-NoSafepointScope::NoSafepointScope() : StackResource(Isolate::Current()) {
- isolate()->IncrementNoSafepointScopeDepth();
+NoSafepointScope::NoSafepointScope() : StackResource(Thread::Current()) {
+ thread()->IncrementNoSafepointScopeDepth();
}
NoSafepointScope::~NoSafepointScope() {
- isolate()->DecrementNoSafepointScopeDepth();
+ thread()->DecrementNoSafepointScopeDepth();
}
#endif // defined(DEBUG)
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/heap_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698