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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 9605033: Implement a garbage collection prologue and epilogue callback mechanism. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix grammar Created 8 years, 9 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/include/dart_api.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl.cc
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
index 048ee57d4f133bcb0d51319acf39d03b9c3eb074..e57ee6a93f9adc79b551871645476009cedf3b10 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -490,6 +490,72 @@ DART_EXPORT Dart_Handle Dart_NewWeakReferenceSet(Dart_Handle* keys,
return Api::Success();
}
+
+// --- Garbage Collection Callbacks --
+
+
+DART_EXPORT Dart_Handle Dart_AddGcPrologueCallback(
+ Dart_GcPrologueCallback callback) {
+ Isolate* isolate = Isolate::Current();
+ CHECK_ISOLATE(isolate);
+ GcPrologueCallbacks& callbacks = isolate->gc_prologue_callbacks();
+ if (callbacks.Contains(callback)) {
+ return Api::NewError(
+ "%s permits only one instance of 'callback' to be present in the "
+ "prologue callback list.",
+ CURRENT_FUNC);
+ }
+ callbacks.Add(callback);
+ return Api::Success();
+}
+
+
+DART_EXPORT Dart_Handle Dart_RemoveGcPrologueCallback(
+ Dart_GcPrologueCallback callback) {
+ Isolate* isolate = Isolate::Current();
+ CHECK_ISOLATE(isolate);
+ GcPrologueCallbacks& callbacks = isolate->gc_prologue_callbacks();
+ if (!callbacks.Contains(callback)) {
+ return Api::NewError(
+ "%s expects 'callback' to be present in the prologue callback list.",
+ CURRENT_FUNC);
+ }
+ callbacks.Remove(callback);
+ return Api::Success();
+}
+
+
+DART_EXPORT Dart_Handle Dart_AddGcEpilogueCallback(
+ Dart_GcEpilogueCallback callback) {
+ Isolate* isolate = Isolate::Current();
+ CHECK_ISOLATE(isolate);
+ GcEpilogueCallbacks& callbacks = isolate->gc_epilogue_callbacks();
+ if (callbacks.Contains(callback)) {
+ return Api::NewError(
+ "%s permits only one instance of 'callback' to be present in the "
+ "epilogue callback list.",
+ CURRENT_FUNC);
+ }
+ callbacks.Add(callback);
+ return Api::Success();
+}
+
+
+DART_EXPORT Dart_Handle Dart_RemoveGcEpilogueCallback(
+ Dart_GcEpilogueCallback callback) {
+ Isolate* isolate = Isolate::Current();
+ CHECK_ISOLATE(isolate);
+ GcEpilogueCallbacks& callbacks = isolate->gc_epilogue_callbacks();
+ if (!callbacks.Contains(callback)) {
+ return Api::NewError(
+ "%s expects 'callback' to be present in the epilogue callback list.",
+ CURRENT_FUNC);
+ }
+ callbacks.Remove(callback);
+ return Api::Success();
+}
+
+
// --- Initialization and Globals ---
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698