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

Side by Side Diff: src/objects.h

Issue 2915793002: [api] Prototype WeakRef implementation
Patch Set: Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « src/js/weak-collection.js ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_OBJECTS_H_ 5 #ifndef V8_OBJECTS_H_
6 #define V8_OBJECTS_H_ 6 #define V8_OBJECTS_H_
7 7
8 #include <iosfwd> 8 #include <iosfwd>
9 #include <memory> 9 #include <memory>
10 10
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 // - JSBoundFunction 58 // - JSBoundFunction
59 // - JSCollection 59 // - JSCollection
60 // - JSSet 60 // - JSSet
61 // - JSMap 61 // - JSMap
62 // - JSStringIterator 62 // - JSStringIterator
63 // - JSSetIterator 63 // - JSSetIterator
64 // - JSMapIterator 64 // - JSMapIterator
65 // - JSWeakCollection 65 // - JSWeakCollection
66 // - JSWeakMap 66 // - JSWeakMap
67 // - JSWeakSet 67 // - JSWeakSet
68 // - JSWeakRef
68 // - JSRegExp 69 // - JSRegExp
69 // - JSFunction 70 // - JSFunction
70 // - JSGeneratorObject 71 // - JSGeneratorObject
71 // - JSGlobalObject 72 // - JSGlobalObject
72 // - JSGlobalProxy 73 // - JSGlobalProxy
73 // - JSValue 74 // - JSValue
74 // - JSDate 75 // - JSDate
75 // - JSMessageObject 76 // - JSMessageObject
76 // - JSModuleNamespace 77 // - JSModuleNamespace
77 // - JSProxy 78 // - JSProxy
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 V(JS_MODULE_NAMESPACE_TYPE) \ 393 V(JS_MODULE_NAMESPACE_TYPE) \
393 V(JS_ARRAY_TYPE) \ 394 V(JS_ARRAY_TYPE) \
394 V(JS_ARRAY_BUFFER_TYPE) \ 395 V(JS_ARRAY_BUFFER_TYPE) \
395 V(JS_TYPED_ARRAY_TYPE) \ 396 V(JS_TYPED_ARRAY_TYPE) \
396 V(JS_DATA_VIEW_TYPE) \ 397 V(JS_DATA_VIEW_TYPE) \
397 V(JS_SET_TYPE) \ 398 V(JS_SET_TYPE) \
398 V(JS_MAP_TYPE) \ 399 V(JS_MAP_TYPE) \
399 V(JS_SET_ITERATOR_TYPE) \ 400 V(JS_SET_ITERATOR_TYPE) \
400 V(JS_MAP_ITERATOR_TYPE) \ 401 V(JS_MAP_ITERATOR_TYPE) \
401 V(JS_WEAK_MAP_TYPE) \ 402 V(JS_WEAK_MAP_TYPE) \
402 V(JS_WEAK_SET_TYPE) \ 403 V(JS_WEAK_SET_TYPE) \
404 V(JS_WEAK_REF_TYPE) \
403 V(JS_PROMISE_CAPABILITY_TYPE) \ 405 V(JS_PROMISE_CAPABILITY_TYPE) \
404 V(JS_PROMISE_TYPE) \ 406 V(JS_PROMISE_TYPE) \
405 V(JS_REGEXP_TYPE) \ 407 V(JS_REGEXP_TYPE) \
406 V(JS_ERROR_TYPE) \ 408 V(JS_ERROR_TYPE) \
407 V(JS_ASYNC_FROM_SYNC_ITERATOR_TYPE) \ 409 V(JS_ASYNC_FROM_SYNC_ITERATOR_TYPE) \
408 V(JS_STRING_ITERATOR_TYPE) \ 410 V(JS_STRING_ITERATOR_TYPE) \
409 \ 411 \
410 V(JS_TYPED_ARRAY_KEY_ITERATOR_TYPE) \ 412 V(JS_TYPED_ARRAY_KEY_ITERATOR_TYPE) \
411 V(JS_FAST_ARRAY_KEY_ITERATOR_TYPE) \ 413 V(JS_FAST_ARRAY_KEY_ITERATOR_TYPE) \
412 V(JS_GENERIC_ARRAY_KEY_ITERATOR_TYPE) \ 414 V(JS_GENERIC_ARRAY_KEY_ITERATOR_TYPE) \
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 JS_ARRAY_TYPE, 745 JS_ARRAY_TYPE,
744 JS_ARRAY_BUFFER_TYPE, 746 JS_ARRAY_BUFFER_TYPE,
745 JS_TYPED_ARRAY_TYPE, 747 JS_TYPED_ARRAY_TYPE,
746 JS_DATA_VIEW_TYPE, 748 JS_DATA_VIEW_TYPE,
747 JS_SET_TYPE, 749 JS_SET_TYPE,
748 JS_MAP_TYPE, 750 JS_MAP_TYPE,
749 JS_SET_ITERATOR_TYPE, 751 JS_SET_ITERATOR_TYPE,
750 JS_MAP_ITERATOR_TYPE, 752 JS_MAP_ITERATOR_TYPE,
751 JS_WEAK_MAP_TYPE, 753 JS_WEAK_MAP_TYPE,
752 JS_WEAK_SET_TYPE, 754 JS_WEAK_SET_TYPE,
755 JS_WEAK_REF_TYPE,
753 JS_PROMISE_CAPABILITY_TYPE, 756 JS_PROMISE_CAPABILITY_TYPE,
754 JS_PROMISE_TYPE, 757 JS_PROMISE_TYPE,
755 JS_REGEXP_TYPE, 758 JS_REGEXP_TYPE,
756 JS_ERROR_TYPE, 759 JS_ERROR_TYPE,
757 JS_ASYNC_FROM_SYNC_ITERATOR_TYPE, 760 JS_ASYNC_FROM_SYNC_ITERATOR_TYPE,
758 JS_STRING_ITERATOR_TYPE, 761 JS_STRING_ITERATOR_TYPE,
759 762
760 JS_TYPED_ARRAY_KEY_ITERATOR_TYPE, 763 JS_TYPED_ARRAY_KEY_ITERATOR_TYPE,
761 JS_FAST_ARRAY_KEY_ITERATOR_TYPE, 764 JS_FAST_ARRAY_KEY_ITERATOR_TYPE,
762 JS_GENERIC_ARRAY_KEY_ITERATOR_TYPE, 765 JS_GENERIC_ARRAY_KEY_ITERATOR_TYPE,
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 V(DEPENDENT_CODE_SUB_TYPE) \ 874 V(DEPENDENT_CODE_SUB_TYPE) \
872 V(DICTIONARY_ELEMENTS_SUB_TYPE) \ 875 V(DICTIONARY_ELEMENTS_SUB_TYPE) \
873 V(DICTIONARY_PROPERTIES_SUB_TYPE) \ 876 V(DICTIONARY_PROPERTIES_SUB_TYPE) \
874 V(EMPTY_PROPERTIES_DICTIONARY_SUB_TYPE) \ 877 V(EMPTY_PROPERTIES_DICTIONARY_SUB_TYPE) \
875 V(FAST_ELEMENTS_SUB_TYPE) \ 878 V(FAST_ELEMENTS_SUB_TYPE) \
876 V(FAST_PROPERTIES_SUB_TYPE) \ 879 V(FAST_PROPERTIES_SUB_TYPE) \
877 V(FAST_TEMPLATE_INSTANTIATIONS_CACHE_SUB_TYPE) \ 880 V(FAST_TEMPLATE_INSTANTIATIONS_CACHE_SUB_TYPE) \
878 V(HANDLER_TABLE_SUB_TYPE) \ 881 V(HANDLER_TABLE_SUB_TYPE) \
879 V(JS_COLLECTION_SUB_TYPE) \ 882 V(JS_COLLECTION_SUB_TYPE) \
880 V(JS_WEAK_COLLECTION_SUB_TYPE) \ 883 V(JS_WEAK_COLLECTION_SUB_TYPE) \
884 V(JS_WEAK_REF_SUB_TYPE) \
881 V(MAP_CODE_CACHE_SUB_TYPE) \ 885 V(MAP_CODE_CACHE_SUB_TYPE) \
882 V(NOSCRIPT_SHARED_FUNCTION_INFOS_SUB_TYPE) \ 886 V(NOSCRIPT_SHARED_FUNCTION_INFOS_SUB_TYPE) \
883 V(NUMBER_STRING_CACHE_SUB_TYPE) \ 887 V(NUMBER_STRING_CACHE_SUB_TYPE) \
884 V(OBJECT_TO_CODE_SUB_TYPE) \ 888 V(OBJECT_TO_CODE_SUB_TYPE) \
885 V(OPTIMIZED_CODE_LITERALS_SUB_TYPE) \ 889 V(OPTIMIZED_CODE_LITERALS_SUB_TYPE) \
886 V(OPTIMIZED_CODE_MAP_SUB_TYPE) \ 890 V(OPTIMIZED_CODE_MAP_SUB_TYPE) \
887 V(PROTOTYPE_USERS_SUB_TYPE) \ 891 V(PROTOTYPE_USERS_SUB_TYPE) \
888 V(REGEXP_MULTIPLE_CACHE_SUB_TYPE) \ 892 V(REGEXP_MULTIPLE_CACHE_SUB_TYPE) \
889 V(RETAINED_MAPS_SUB_TYPE) \ 893 V(RETAINED_MAPS_SUB_TYPE) \
890 V(SCOPE_INFO_SUB_TYPE) \ 894 V(SCOPE_INFO_SUB_TYPE) \
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 V(JSRegExp) \ 1063 V(JSRegExp) \
1060 V(JSSet) \ 1064 V(JSSet) \
1061 V(JSSetIterator) \ 1065 V(JSSetIterator) \
1062 V(JSSloppyArgumentsObject) \ 1066 V(JSSloppyArgumentsObject) \
1063 V(JSStringIterator) \ 1067 V(JSStringIterator) \
1064 V(JSTypedArray) \ 1068 V(JSTypedArray) \
1065 V(JSValue) \ 1069 V(JSValue) \
1066 V(JSWeakCollection) \ 1070 V(JSWeakCollection) \
1067 V(JSWeakMap) \ 1071 V(JSWeakMap) \
1068 V(JSWeakSet) \ 1072 V(JSWeakSet) \
1073 V(JSWeakRef) \
1069 V(Map) \ 1074 V(Map) \
1070 V(MapCache) \ 1075 V(MapCache) \
1071 V(ModuleInfo) \ 1076 V(ModuleInfo) \
1072 V(MutableHeapNumber) \ 1077 V(MutableHeapNumber) \
1073 V(Name) \ 1078 V(Name) \
1074 V(NativeContext) \ 1079 V(NativeContext) \
1075 V(NormalizedMapCache) \ 1080 V(NormalizedMapCache) \
1076 V(ObjectHashSet) \ 1081 V(ObjectHashSet) \
1077 V(ObjectHashTable) \ 1082 V(ObjectHashTable) \
1078 V(Oddball) \ 1083 V(Oddball) \
(...skipping 8281 matching lines...) Expand 10 before | Expand all | Expand 10 after
9360 DECLARE_CAST(JSWeakSet) 9365 DECLARE_CAST(JSWeakSet)
9361 9366
9362 // Dispatched behavior. 9367 // Dispatched behavior.
9363 DECLARE_PRINTER(JSWeakSet) 9368 DECLARE_PRINTER(JSWeakSet)
9364 DECLARE_VERIFIER(JSWeakSet) 9369 DECLARE_VERIFIER(JSWeakSet)
9365 9370
9366 private: 9371 private:
9367 DISALLOW_IMPLICIT_CONSTRUCTORS(JSWeakSet); 9372 DISALLOW_IMPLICIT_CONSTRUCTORS(JSWeakSet);
9368 }; 9373 };
9369 9374
9375 // The JSWeakRef describes EcmaScript Harmony weak refs
9376 class JSWeakRef: public JSObject {
9377 public:
9378 DECL_ACCESSORS(target, WeakCell)
9379 DECL_ACCESSORS(executor, JSFunction)
9380 DECL_ACCESSORS(holdings, Object)
9381
9382 DECL_INT_ACCESSORS(flags)
9383 // marker to keep target alive until tick is over
9384 DECL_BOOLEAN_ACCESSORS(held)
9385 // declares that it needs to be executor'd
9386 DECL_BOOLEAN_ACCESSORS(queued)
9387
9388 DECLARE_CAST(JSWeakRef)
9389
9390 // Dispatched behavior.
9391 DECLARE_PRINTER(JSWeakRef)
9392 DECLARE_VERIFIER(JSWeakRef)
9393
9394 static const int kTargetOffset = JSWeakCollection::kSize;
9395 static const int kExecutorOffset = kTargetOffset + kPointerSize;
9396 static const int kHoldingsOffset = kExecutorOffset + kPointerSize;
9397 static const int kFlagsOffset = kHoldingsOffset + kPointerSize;
9398 static const int kSize = kFlagsOffset + kPointerSize;
9399
9400 static const int kHeldBit = 0;
9401 static const int kQueuedBit = 1;
9402
9403 static void Initialize(Handle<JSWeakRef> weak_ref,
9404 Isolate* isolate,
9405 Handle<JSObject> target,
9406 Handle<JSFunction> executor,
9407 Handle<Object> holdings);
9408 static void Clear(Handle<JSWeakRef> weak_ref,
9409 Isolate* isolate);
9410 static Handle<HeapObject> Value(Handle<JSWeakRef> weak_ref,
9411 Isolate* isolate);
9412
9413 private:
9414 DISALLOW_IMPLICIT_CONSTRUCTORS(JSWeakRef);
9415 };
9416
9370 9417
9371 // Whether a JSArrayBuffer is a SharedArrayBuffer or not. 9418 // Whether a JSArrayBuffer is a SharedArrayBuffer or not.
9372 enum class SharedFlag { kNotShared, kShared }; 9419 enum class SharedFlag { kNotShared, kShared };
9373 9420
9374 9421
9375 class JSArrayBuffer: public JSObject { 9422 class JSArrayBuffer: public JSObject {
9376 public: 9423 public:
9377 // [backing_store]: backing memory for this array 9424 // [backing_store]: backing memory for this array
9378 DECL_ACCESSORS(backing_store, void) 9425 DECL_ACCESSORS(backing_store, void)
9379 9426
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after
10301 } 10348 }
10302 }; 10349 };
10303 10350
10304 10351
10305 } // NOLINT, false-positive due to second-order macros. 10352 } // NOLINT, false-positive due to second-order macros.
10306 } // NOLINT, false-positive due to second-order macros. 10353 } // NOLINT, false-positive due to second-order macros.
10307 10354
10308 #include "src/objects/object-macros-undef.h" 10355 #include "src/objects/object-macros-undef.h"
10309 10356
10310 #endif // V8_OBJECTS_H_ 10357 #endif // V8_OBJECTS_H_
OLDNEW
« 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