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

Unified Diff: src/runtime/runtime-collections.cc

Issue 2915793002: [api] Prototype WeakRef implementation
Patch Set: Created 3 years, 7 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 | « src/runtime/runtime.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-collections.cc
diff --git a/src/runtime/runtime-collections.cc b/src/runtime/runtime-collections.cc
index 214ce1c4e6cf590b3d54fb237a8b51758c44a764..97c7a0b5e88c99b47c0f7498ac822ae3f79beddb 100644
--- a/src/runtime/runtime-collections.cc
+++ b/src/runtime/runtime-collections.cc
@@ -325,5 +325,33 @@ RUNTIME_FUNCTION(Runtime_GetWeakSetValues) {
CHECK(max_values >= 0);
return *JSWeakCollection::GetEntries(holder, max_values);
}
+
+RUNTIME_FUNCTION(Runtime_WeakRefInitialize) {
+ HandleScope scope(isolate);
+ DCHECK_EQ(3, args.length());
+ CONVERT_ARG_HANDLE_CHECKED(JSWeakRef, weak_ref, 0);
+ CONVERT_ARG_HANDLE_CHECKED(JSObject, target, 1);
+ CONVERT_ARG_HANDLE_CHECKED(JSFunction, executor, 2);
+ CONVERT_ARG_HANDLE_CHECKED(Object, holdings, 3);
+ JSWeakRef::Initialize(weak_ref, isolate, target, executor, holdings);
+ return *weak_ref;
+}
+
+RUNTIME_FUNCTION(Runtime_WeakRefValue) {
+ HandleScope scope(isolate);
+ DCHECK_EQ(1, args.length());
+ CONVERT_ARG_HANDLE_CHECKED(JSWeakRef, weak_ref, 0);
+ Handle<Object> value = JSWeakRef::Value(weak_ref, isolate);
+ weak_ref->set_held(true);
+ return *value;
+}
+
+RUNTIME_FUNCTION(Runtime_WeakRefClear) {
+ HandleScope scope(isolate);
+ DCHECK_EQ(1, args.length());
+ CONVERT_ARG_HANDLE_CHECKED(JSWeakRef, weak_ref, 0);
+ JSWeakRef::Clear(weak_ref, isolate);
+ return isolate->heap()->undefined_value();
+}
} // namespace internal
} // namespace v8
« no previous file with comments | « src/runtime/runtime.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698