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

Unified Diff: src/objects.h

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/js/weak-collection.js ('k') | src/objects.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index b9366c18acbac87f4a19fb76d7b2e5197129b304..3fb56f68210421de1395011794a20029cdfd83cd 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -65,6 +65,7 @@
// - JSWeakCollection
// - JSWeakMap
// - JSWeakSet
+// - JSWeakRef
// - JSRegExp
// - JSFunction
// - JSGeneratorObject
@@ -399,7 +400,8 @@ const int kStubMinorKeyBits = kSmiValueSize - kStubMajorKeyBits - 1;
V(JS_SET_ITERATOR_TYPE) \
V(JS_MAP_ITERATOR_TYPE) \
V(JS_WEAK_MAP_TYPE) \
- V(JS_WEAK_SET_TYPE) \
+ V(JS_WEAK_SET_TYPE) \
+ V(JS_WEAK_REF_TYPE) \
V(JS_PROMISE_CAPABILITY_TYPE) \
V(JS_PROMISE_TYPE) \
V(JS_REGEXP_TYPE) \
@@ -750,6 +752,7 @@ enum InstanceType {
JS_MAP_ITERATOR_TYPE,
JS_WEAK_MAP_TYPE,
JS_WEAK_SET_TYPE,
+ JS_WEAK_REF_TYPE,
JS_PROMISE_CAPABILITY_TYPE,
JS_PROMISE_TYPE,
JS_REGEXP_TYPE,
@@ -878,6 +881,7 @@ V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
V(HANDLER_TABLE_SUB_TYPE) \
V(JS_COLLECTION_SUB_TYPE) \
V(JS_WEAK_COLLECTION_SUB_TYPE) \
+ V(JS_WEAK_REF_SUB_TYPE) \
V(MAP_CODE_CACHE_SUB_TYPE) \
V(NOSCRIPT_SHARED_FUNCTION_INFOS_SUB_TYPE) \
V(NUMBER_STRING_CACHE_SUB_TYPE) \
@@ -1066,6 +1070,7 @@ template <class C> inline bool Is(Object* obj);
V(JSWeakCollection) \
V(JSWeakMap) \
V(JSWeakSet) \
+ V(JSWeakRef) \
V(Map) \
V(MapCache) \
V(ModuleInfo) \
@@ -9367,6 +9372,48 @@ class JSWeakSet: public JSWeakCollection {
DISALLOW_IMPLICIT_CONSTRUCTORS(JSWeakSet);
};
+// The JSWeakRef describes EcmaScript Harmony weak refs
+class JSWeakRef: public JSObject {
+ public:
+ DECL_ACCESSORS(target, WeakCell)
+ DECL_ACCESSORS(executor, JSFunction)
+ DECL_ACCESSORS(holdings, Object)
+
+ DECL_INT_ACCESSORS(flags)
+ // marker to keep target alive until tick is over
+ DECL_BOOLEAN_ACCESSORS(held)
+ // declares that it needs to be executor'd
+ DECL_BOOLEAN_ACCESSORS(queued)
+
+ DECLARE_CAST(JSWeakRef)
+
+ // Dispatched behavior.
+ DECLARE_PRINTER(JSWeakRef)
+ DECLARE_VERIFIER(JSWeakRef)
+
+ static const int kTargetOffset = JSWeakCollection::kSize;
+ static const int kExecutorOffset = kTargetOffset + kPointerSize;
+ static const int kHoldingsOffset = kExecutorOffset + kPointerSize;
+ static const int kFlagsOffset = kHoldingsOffset + kPointerSize;
+ static const int kSize = kFlagsOffset + kPointerSize;
+
+ static const int kHeldBit = 0;
+ static const int kQueuedBit = 1;
+
+ static void Initialize(Handle<JSWeakRef> weak_ref,
+ Isolate* isolate,
+ Handle<JSObject> target,
+ Handle<JSFunction> executor,
+ Handle<Object> holdings);
+ static void Clear(Handle<JSWeakRef> weak_ref,
+ Isolate* isolate);
+ static Handle<HeapObject> Value(Handle<JSWeakRef> weak_ref,
+ Isolate* isolate);
+
+ private:
+ DISALLOW_IMPLICIT_CONSTRUCTORS(JSWeakRef);
+};
+
// Whether a JSArrayBuffer is a SharedArrayBuffer or not.
enum class SharedFlag { kNotShared, kShared };
« no previous file with comments | « src/js/weak-collection.js ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698