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

Unified Diff: runtime/vm/thread_test.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/thread.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/thread_test.cc
diff --git a/runtime/vm/thread_test.cc b/runtime/vm/thread_test.cc
index f781783d8e43dd403a088228bc4248e126446c3d..c6339bd550224dc5d9624442d8d67649151ba6a4 100644
--- a/runtime/vm/thread_test.cc
+++ b/runtime/vm/thread_test.cc
@@ -129,9 +129,10 @@ class TaskWithZoneAllocation : public ThreadPool::Task {
a0->Add(true);
a1.Add(true);
}
- // Check that we can create handles (but not yet allocate heap objects).
- String& str = String::Handle(zone, foo_.raw());
- EXPECT(str.Equals("foo"));
+ // Check that we can create handles and allocate in old space.
+ String& str = String::Handle(zone, String::New("old", Heap::kOld));
+ EXPECT(str.Equals("old"));
+
const intptr_t unique_smi = id_ + 928327281;
Smi& smi = Smi::Handle(zone, Smi::New(unique_smi));
EXPECT(smi.Value() == unique_smi);
@@ -140,6 +141,22 @@ class TaskWithZoneAllocation : public ThreadPool::Task {
// TODO(koda): Remove "->thread_registry()" after updating stack walker.
isolate_->thread_registry()->VisitObjectPointers(&counter);
EXPECT_EQ(1, counter.count());
+
+ char* unique_chars = zone->PrintToString("unique_str_%" Pd, id_);
+ String& unique_str = String::Handle(zone);
+ {
+ // String::New may create additional handles in the topmost scope that
+ // we don't want to count, so wrap this in its own scope.
+ HANDLESCOPE(thread);
+ unique_str = String::New(unique_chars, Heap::kOld);
+ }
+ EXPECT(unique_str.Equals(unique_chars));
+ ObjectCounter str_counter(isolate_, &unique_str);
+ // Ensure that our particular zone is visited.
+ // TODO(koda): Remove "->thread_registry()" after updating stack walker.
+ isolate_->thread_registry()->VisitObjectPointers(&str_counter);
+ // We should visit the string object exactly once.
+ EXPECT_EQ(1, str_counter.count());
}
Thread::ExitIsolateAsHelper();
{
@@ -164,7 +181,8 @@ TEST_CASE(ManyTasksWithZones) {
bool done[kTaskCount];
Isolate* isolate = Thread::Current()->isolate();
String& foo = String::Handle(String::New("foo"));
-
+ EXPECT(isolate->heap()->GrowthControlState());
+ isolate->heap()->DisableGrowthControl();
for (int i = 0; i < kTaskCount; i++) {
done[i] = false;
Dart::thread_pool()->Run(
« no previous file with comments | « runtime/vm/thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698