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

Unified Diff: runtime/vm/dart_api_impl_test.cc

Issue 2041373004: Revert "Background finalization." (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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 | runtime/vm/dart_api_state.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl_test.cc
diff --git a/runtime/vm/dart_api_impl_test.cc b/runtime/vm/dart_api_impl_test.cc
index 2ab0656d87bdd4e945aa0c0591eb3f8dbac725df..fcc4e79cd8cc88cc39f412f13ed1490c827bd007 100644
--- a/runtime/vm/dart_api_impl_test.cc
+++ b/runtime/vm/dart_api_impl_test.cc
@@ -1206,28 +1206,6 @@ TEST_CASE(MalformedStringToUTF8) {
}
-// Helper class to ensure new gen GC is triggered without any side effects.
-// The normal call to CollectGarbage(Heap::kNew) could potentially trigger
-// an old gen collection if there is a promotion failure and this could
-// perturb the test.
-class GCTestHelper : public AllStatic {
- public:
- static void CollectNewSpace(Heap::ApiCallbacks api_callbacks) {
- bool invoke_api_callbacks = (api_callbacks == Heap::kInvokeApiCallbacks);
- Isolate::Current()->heap()->new_space()->Scavenge(invoke_api_callbacks);
- }
-
- static void WaitForFinalizationTasks() {
- Thread* thread = Thread::Current();
- Heap* heap = thread->isolate()->heap();
- MonitorLocker ml(heap->finalization_tasks_lock());
- while (heap->finalization_tasks() > 0) {
- ml.WaitWithSafepointCheck(thread);
- }
- }
-};
-
-
static void ExternalStringCallbackFinalizer(void* peer) {
*static_cast<int*>(peer) *= 2;
}
@@ -1264,11 +1242,9 @@ TEST_CASE(ExternalStringCallback) {
EXPECT_EQ(40, peer8);
EXPECT_EQ(41, peer16);
Isolate::Current()->heap()->CollectGarbage(Heap::kOld);
- GCTestHelper::WaitForFinalizationTasks();
EXPECT_EQ(40, peer8);
EXPECT_EQ(41, peer16);
Isolate::Current()->heap()->CollectGarbage(Heap::kNew);
- GCTestHelper::WaitForFinalizationTasks();
EXPECT_EQ(80, peer8);
EXPECT_EQ(82, peer16);
}
@@ -2405,10 +2381,8 @@ TEST_CASE(ExternalTypedDataCallback) {
TransitionNativeToVM transition(thread);
EXPECT(peer == 0);
Isolate::Current()->heap()->CollectGarbage(Heap::kOld);
- GCTestHelper::WaitForFinalizationTasks();
EXPECT(peer == 0);
Isolate::Current()->heap()->CollectGarbage(Heap::kNew);
- GCTestHelper::WaitForFinalizationTasks();
EXPECT(peer == 42);
}
}
@@ -2465,7 +2439,6 @@ TEST_CASE(Float32x4List) {
{
TransitionNativeToVM transition(thread);
Isolate::Current()->heap()->CollectGarbage(Heap::kNew);
- GCTestHelper::WaitForFinalizationTasks();
EXPECT(peer == 42);
}
}
@@ -2628,6 +2601,19 @@ UNIT_TEST_CASE(AssignToPersistentHandle) {
}
+// Helper class to ensure new gen GC is triggered without any side effects.
+// The normal call to CollectGarbage(Heap::kNew) could potentially trigger
+// an old gen collection if there is a promotion failure and this could
+// perturb the test.
+class GCTestHelper : public AllStatic {
+ public:
+ static void CollectNewSpace(Heap::ApiCallbacks api_callbacks) {
+ bool invoke_api_callbacks = (api_callbacks == Heap::kInvokeApiCallbacks);
+ Isolate::Current()->heap()->new_space()->Scavenge(invoke_api_callbacks);
+ }
+};
+
+
static Dart_Handle AsHandle(Dart_PersistentHandle weak) {
return Dart_HandleFromPersistent(weak);
}
@@ -2742,7 +2728,6 @@ TEST_CASE(WeakPersistentHandle) {
TransitionNativeToVM transition(thread);
// Garbage collect new space again.
GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks);
- GCTestHelper::WaitForFinalizationTasks();
}
{
@@ -2758,7 +2743,6 @@ TEST_CASE(WeakPersistentHandle) {
TransitionNativeToVM transition(thread);
// Garbage collect old space again.
Isolate::Current()->heap()->CollectGarbage(Heap::kOld);
- GCTestHelper::WaitForFinalizationTasks();
}
{
@@ -2803,7 +2787,6 @@ TEST_CASE(WeakPersistentHandleCallback) {
Isolate::Current()->heap()->CollectGarbage(Heap::kOld);
EXPECT(peer == 0);
GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks);
- GCTestHelper::WaitForFinalizationTasks();
EXPECT(peer == 42);
}
}
@@ -2830,7 +2813,6 @@ TEST_CASE(WeakPersistentHandleNoCallback) {
Isolate::Current()->heap()->CollectGarbage(Heap::kOld);
EXPECT(peer == 0);
GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks);
- GCTestHelper::WaitForFinalizationTasks();
EXPECT(peer == 0);
}
}
@@ -2891,7 +2873,6 @@ TEST_CASE(WeakPersistentHandleExternalAllocationSize) {
// Collect weakly referenced string, and promote strongly referenced string.
GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks);
GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks);
- GCTestHelper::WaitForFinalizationTasks();
EXPECT(heap->ExternalInWords(Heap::kNew) == 0);
EXPECT(heap->ExternalInWords(Heap::kOld) == kWeak2ExternalSize / kWordSize);
}
@@ -2902,7 +2883,6 @@ TEST_CASE(WeakPersistentHandleExternalAllocationSize) {
{
TransitionNativeToVM transition(thread);
Isolate::Current()->heap()->CollectGarbage(Heap::kOld);
- GCTestHelper::WaitForFinalizationTasks();
EXPECT(heap->ExternalInWords(Heap::kOld) == 0);
}
}
@@ -2948,7 +2928,6 @@ TEST_CASE(WeakPersistentHandleExternalAllocationSizeNewspaceGC) {
{
TransitionNativeToVM transition(thread);
Isolate::Current()->heap()->CollectGarbage(Heap::kOld);
- GCTestHelper::WaitForFinalizationTasks();
EXPECT(heap->ExternalInWords(Heap::kOld) == 0);
}
}
« no previous file with comments | « no previous file | runtime/vm/dart_api_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698