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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 231053003: 1. Provide a framework to traverse persistent prolog weak handles. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 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_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.cc
===================================================================
--- runtime/vm/dart_api_impl.cc (revision 34879)
+++ runtime/vm/dart_api_impl.cc (working copy)
@@ -816,6 +816,52 @@
}
+class PrologueWeakVisitor : public HandleVisitor {
+ public:
+ PrologueWeakVisitor(Isolate* isolate,
+ Dart_GcPrologueWeakHandleCallback callback)
+ : HandleVisitor(isolate),
+ callback_(callback) {
+ }
+
+ void VisitHandle(uword addr) {
+ NoGCScope no_gc;
+ FinalizablePersistentHandle* handle =
+ reinterpret_cast<FinalizablePersistentHandle*>(addr);
+ RawObject* raw_obj = handle->raw();
+ if (raw_obj->IsHeapObject()) {
+ ASSERT(handle->IsPrologueWeakPersistent());
+ ReusableInstanceHandleScope reused_instance_handle(isolate());
+ Instance& instance = reused_instance_handle.Handle();
+ instance ^= reinterpret_cast<RawInstance*>(handle->raw());
+ intptr_t num_native_fields = instance.NumNativeFields();
+ intptr_t* native_fields = instance.NativeFieldsDataAddr();
+ if (native_fields != NULL) {
+ callback_(isolate()->init_callback_data(),
+ reinterpret_cast<Dart_WeakPersistentHandle>(addr),
+ num_native_fields,
+ native_fields);
+ }
+ }
+ }
+
+ private:
+ Dart_GcPrologueWeakHandleCallback callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(PrologueWeakVisitor);
+};
+
+
+DART_EXPORT Dart_Handle Dart_VisitPrologueWeakHandles(
+ Dart_GcPrologueWeakHandleCallback callback) {
+ Isolate* isolate = Isolate::Current();
+ CHECK_ISOLATE(isolate);
+ PrologueWeakVisitor visitor(isolate, callback);
+ isolate->VisitPrologueWeakPersistentHandles(&visitor);
+ return Api::Success();
+}
+
+
// --- Initialization and Globals ---
DART_EXPORT const char* Dart_VersionString() {
@@ -3130,6 +3176,7 @@
if (result.IsError()) {
return Api::NewHandle(isolate, result.raw());
}
+
if (constructor.IsConstructor()) {
ASSERT(result.IsNull());
} else {
@@ -3872,8 +3919,7 @@
intptr_t value) {
Isolate* isolate = Isolate::Current();
DARTSCOPE(isolate);
- ReusableObjectHandleScope reused_obj_handle(isolate);
- const Instance& instance = Api::UnwrapInstanceHandle(reused_obj_handle, obj);
+ const Instance& instance = Api::UnwrapInstanceHandle(isolate, obj);
if (instance.IsNull()) {
RETURN_TYPE_ERROR(isolate, obj, Instance);
}
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/dart_api_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698