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

Unified Diff: src/factory.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/factory.h ('k') | src/flag-definitions.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index 7d8198cb7bc03f5e7a26246437777b682bd26d7b..727591f5a5fdc65e9fc3a6690c574165ba046a19 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -932,6 +932,32 @@ Handle<JSPromise> Factory::NewJSPromise() {
return promise;
}
+void Factory::InitJSWeakRef(
+ Handle<JSWeakRef> weak_ref,
+ Handle<JSObject> target,
+ Handle<JSFunction> executor,
+ Handle<Object> holdings
+) {
+ Handle<JSFunction> constructor(
+ isolate()->native_context()->js_weak_ref_fun(), isolate());
+ DCHECK(constructor->has_initial_map());
+ Handle<Map> map(constructor->initial_map(), isolate());
+
+ DCHECK(!map->is_prototype_map());
+
+ weak_ref->set_target(*NewWeakCell(target));
+ weak_ref->set_executor(*executor);
+ weak_ref->set_holdings(*holdings);
+ weak_ref->set_held(false);
+ weak_ref->set_queued(false);
+
+ Handle<FixedArray> refs(isolate()->heap()->weak_refs(), isolate());
+ int num_refs = refs->length();
+ refs = isolate()->factory()->CopyFixedArrayAndGrow(refs, 1);
+ isolate()->heap()->set_weak_refs(*refs);
+ refs->set(num_refs, *weak_ref);
+}
+
Handle<Context> Factory::NewNativeContext() {
Handle<FixedArray> array =
NewFixedArray(Context::NATIVE_CONTEXT_SLOTS, TENURED);
« no previous file with comments | « src/factory.h ('k') | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698