From 30de5494d5e93bb014c2bfdd9d3f85ff0e03a429 Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Mon, 17 Oct 2022 18:23:59 +0000 Subject: [PATCH] [vm] Rename Dart_NotifyDetach to Dart_NotifyDestroyed. To reflect its expected usage. TEST=ci Bug: https://github.com/flutter/flutter/issues/108601 Change-Id: I898e400d4a6c112130663a03354844cd82ed778c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264561 Reviewed-by: Siva Annamalai Commit-Queue: Ryan Macnak --- runtime/include/dart_api.h | 2 +- runtime/vm/dart_api_impl.cc | 4 ++-- runtime/vm/dart_api_impl_test.cc | 17 +++++++++-------- runtime/vm/heap/heap.cc | 10 +++++----- runtime/vm/heap/heap.h | 2 +- runtime/vm/heap/spaces.h | 2 +- 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/runtime/include/dart_api.h b/runtime/include/dart_api.h index f2b997bc041..741447a0677 100644 --- a/runtime/include/dart_api.h +++ b/runtime/include/dart_api.h @@ -1277,7 +1277,7 @@ DART_EXPORT void Dart_NotifyIdle(int64_t deadline); * * Requires there to be a current isolate. */ -DART_EXPORT void Dart_NotifyDetach(void); +DART_EXPORT void Dart_NotifyDestroyed(void); /** * Notifies the VM that the system is running low on memory. diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc index e4861195c3e..f5cd28d3673 100644 --- a/runtime/vm/dart_api_impl.cc +++ b/runtime/vm/dart_api_impl.cc @@ -1818,12 +1818,12 @@ DART_EXPORT void Dart_NotifyIdle(int64_t deadline) { T->isolate()->group()->idle_time_handler()->NotifyIdle(deadline); } -DART_EXPORT void Dart_NotifyDetach() { +DART_EXPORT void Dart_NotifyDestroyed() { Thread* T = Thread::Current(); CHECK_ISOLATE(T->isolate()); API_TIMELINE_BEGIN_END(T); TransitionNativeToVM transition(T); - T->heap()->NotifyDetach(); + T->heap()->NotifyDestroyed(); } DART_EXPORT void Dart_NotifyLowMemory() { diff --git a/runtime/vm/dart_api_impl_test.cc b/runtime/vm/dart_api_impl_test.cc index 0bab07f7b4c..2fbb0f594e2 100644 --- a/runtime/vm/dart_api_impl_test.cc +++ b/runtime/vm/dart_api_impl_test.cc @@ -10008,17 +10008,18 @@ void main() { EXPECT_VALID(result); } -static void NotifyDetachNative(Dart_NativeArguments args) { - Dart_NotifyDetach(); +static void NotifyDestroyedNative(Dart_NativeArguments args) { + Dart_NotifyDestroyed(); } -static Dart_NativeFunction NotifyDetach_native_lookup(Dart_Handle name, - int argument_count, - bool* auto_setup_scope) { - return NotifyDetachNative; +static Dart_NativeFunction NotifyDestroyed_native_lookup( + Dart_Handle name, + int argument_count, + bool* auto_setup_scope) { + return NotifyDestroyedNative; } -TEST_CASE(DartAPI_NotifyDetach) { +TEST_CASE(DartAPI_NotifyDestroyed) { const char* kScriptChars = R"( import 'dart:isolate'; @pragma("vm:external-name", "Test_nativeFunc") @@ -10035,7 +10036,7 @@ void main() { } })"; Dart_Handle lib = - TestCase::LoadTestScript(kScriptChars, &NotifyDetach_native_lookup); + TestCase::LoadTestScript(kScriptChars, &NotifyDestroyed_native_lookup); Dart_Handle result = Dart_Invoke(lib, NewString("main"), 0, NULL); EXPECT_VALID(result); } diff --git a/runtime/vm/heap/heap.cc b/runtime/vm/heap/heap.cc index c5a7f5d30f9..77288de3346 100644 --- a/runtime/vm/heap/heap.cc +++ b/runtime/vm/heap/heap.cc @@ -436,9 +436,9 @@ void Heap::NotifyIdle(int64_t deadline) { } } -void Heap::NotifyDetach() { - TIMELINE_FUNCTION_GC_DURATION(Thread::Current(), "NotifyDetach"); - CollectAllGarbage(GCReason::kDetach, /*compact=*/true); +void Heap::NotifyDestroyed() { + TIMELINE_FUNCTION_GC_DURATION(Thread::Current(), "NotifyDestroyed"); + CollectAllGarbage(GCReason::kDestroyed, /*compact=*/true); Page::ClearCache(); } @@ -878,8 +878,8 @@ const char* Heap::GCReasonToString(GCReason gc_reason) { return "external"; case GCReason::kIdle: return "idle"; - case GCReason::kDetach: - return "detach"; + case GCReason::kDestroyed: + return "destroyed"; case GCReason::kDebugging: return "debugging"; case GCReason::kCatchUp: diff --git a/runtime/vm/heap/heap.h b/runtime/vm/heap/heap.h index 9678357f97a..3ba52233ce4 100644 --- a/runtime/vm/heap/heap.h +++ b/runtime/vm/heap/heap.h @@ -108,7 +108,7 @@ class Heap { ObjectPtr FindObject(FindObjectVisitor* visitor); void NotifyIdle(int64_t deadline); - void NotifyDetach(); + void NotifyDestroyed(); Dart_PerformanceMode mode() const { return mode_; } Dart_PerformanceMode SetMode(Dart_PerformanceMode mode); diff --git a/runtime/vm/heap/spaces.h b/runtime/vm/heap/spaces.h index 16b5c89edc2..c3bc192ea96 100644 --- a/runtime/vm/heap/spaces.h +++ b/runtime/vm/heap/spaces.h @@ -46,7 +46,7 @@ enum class GCReason { kFull, // Heap::CollectAllGarbage kExternal, // Dart_NewFinalizableHandle Dart_NewWeakPersistentHandle kIdle, // Dart_NotifyIdle - kDetach, // Dart_NotifyDetach + kDestroyed, // Dart_NotifyDestroyed kDebugging, // service request, etc. kCatchUp, // End of ForceGrowthScope or Dart_PerformanceMode_Latency. };