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

Unified Diff: src/objects.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/objects.h ('k') | src/objects-body-descriptors-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index bc43b28fbf4998c305766f408ae3a0fa47a6cd54..3a01f281dc564a2b41396cfb8848d020214b9cd8 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -2697,6 +2697,10 @@ void JSObject::JSObjectShortPrint(StringStream* accumulator) {
accumulator->Add("<JSWeakSet>");
break;
}
+ case JS_WEAK_REF_TYPE: {
+ accumulator->Add("<JSWeakRef>");
+ break;
+ }
case JS_REGEXP_TYPE: {
accumulator->Add("<JSRegExp");
JSRegExp* regexp = JSRegExp::cast(this);
@@ -12789,6 +12793,7 @@ bool CanSubclassHaveInobjectProperties(InstanceType instance_type) {
case JS_VALUE_TYPE:
case JS_WEAK_MAP_TYPE:
case JS_WEAK_SET_TYPE:
+ case JS_WEAK_REF_TYPE:
return true;
case BYTECODE_ARRAY_TYPE:
@@ -19200,6 +19205,31 @@ Handle<JSArray> JSWeakCollection::GetEntries(Handle<JSWeakCollection> holder,
return isolate->factory()->NewJSArrayWithElements(entries);
}
+void JSWeakRef::Initialize(Handle<JSWeakRef> weak_ref,
+ Isolate* isolate,
+ Handle<JSObject> target,
+ Handle<JSFunction> executor,
+ Handle<Object> holdings) {
+ isolate->factory()->InitJSWeakRef(weak_ref, target, executor, holdings);
+}
+
+Handle<HeapObject> JSWeakRef::Value(Handle<JSWeakRef> weak_ref,
+ Isolate* isolate) {
+ if (weak_ref->target() == nullptr || weak_ref->target()->cleared()) {
+ return isolate->factory()->null_value();
+ }
+ weak_ref->set_held(true);
+ return Handle<HeapObject>(
+ reinterpret_cast<HeapObject*>(weak_ref->target()->value()));
+}
+
+void JSWeakRef::Clear(Handle<JSWeakRef> weak_ref,
+ Isolate* isolate) {
+ weak_ref->set_executor(nullptr);
+ weak_ref->set_holdings(nullptr);
+ weak_ref->set_target(nullptr);
+}
+
// Check if there is a break point at this source position.
bool DebugInfo::HasBreakPoint(int source_position) {
// Get the break point info object for this code offset.
« no previous file with comments | « src/objects.h ('k') | src/objects-body-descriptors-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698