diff options
author | Michaël Zasso <targos@protonmail.com> | 2017-06-06 10:28:14 +0200 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2017-06-07 10:33:31 +0200 |
commit | 3dc8c3bed4cf3a77607edbb0b015e33f8b60fc09 (patch) | |
tree | 9dee56e142638b34f1eccbd0ad88c3bce5377c29 /deps/v8/src/global-handles.h | |
parent | 91a1bbe3055a660194ca4d403795aa0c03e9d056 (diff) | |
download | android-node-v8-3dc8c3bed4cf3a77607edbb0b015e33f8b60fc09.tar.gz android-node-v8-3dc8c3bed4cf3a77607edbb0b015e33f8b60fc09.tar.bz2 android-node-v8-3dc8c3bed4cf3a77607edbb0b015e33f8b60fc09.zip |
deps: update V8 to 5.9.211.32
PR-URL: https://github.com/nodejs/node/pull/13263
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Diffstat (limited to 'deps/v8/src/global-handles.h')
-rw-r--r-- | deps/v8/src/global-handles.h | 188 |
1 files changed, 29 insertions, 159 deletions
diff --git a/deps/v8/src/global-handles.h b/deps/v8/src/global-handles.h index 9c4ffb4f1a..000fc64ecd 100644 --- a/deps/v8/src/global-handles.h +++ b/deps/v8/src/global-handles.h @@ -5,6 +5,8 @@ #ifndef V8_GLOBAL_HANDLES_H_ #define V8_GLOBAL_HANDLES_H_ +#include <type_traits> + #include "include/v8.h" #include "include/v8-profiler.h" @@ -24,88 +26,16 @@ class ObjectVisitor; // At GC the destroyed global handles are removed from the free list // and deallocated. -// Data structures for tracking object groups and implicit references. - -// An object group is treated like a single JS object: if one of object in -// the group is alive, all objects in the same group are considered alive. -// An object group is used to simulate object relationship in a DOM tree. - -// An implicit references group consists of two parts: a parent object and a -// list of children objects. If the parent is alive, all the children are alive -// too. - -struct ObjectGroup { - explicit ObjectGroup(size_t length) - : info(NULL), length(length) { - DCHECK(length > 0); - objects = new Object**[length]; - } - ~ObjectGroup(); - - v8::RetainedObjectInfo* info; - Object*** objects; - size_t length; -}; - - -struct ImplicitRefGroup { - ImplicitRefGroup(HeapObject** parent, size_t length) - : parent(parent), length(length) { - DCHECK(length > 0); - children = new Object**[length]; - } - ~ImplicitRefGroup(); - - HeapObject** parent; - Object*** children; - size_t length; -}; - - -// For internal bookkeeping. -struct ObjectGroupConnection { - ObjectGroupConnection(UniqueId id, Object** object) - : id(id), object(object) {} - - bool operator==(const ObjectGroupConnection& other) const { - return id == other.id; - } - - bool operator<(const ObjectGroupConnection& other) const { - return id < other.id; - } - - UniqueId id; - Object** object; -}; - - -struct ObjectGroupRetainerInfo { - ObjectGroupRetainerInfo(UniqueId id, RetainedObjectInfo* info) - : id(id), info(info) {} - - bool operator==(const ObjectGroupRetainerInfo& other) const { - return id == other.id; - } - - bool operator<(const ObjectGroupRetainerInfo& other) const { - return id < other.id; - } - - UniqueId id; - RetainedObjectInfo* info; -}; - enum WeaknessType { // Embedder gets a handle to the dying object. FINALIZER_WEAK, // In the following cases, the embedder gets the parameter they passed in - // earlier, and 0 or 2 first internal fields. Note that the internal + // earlier, and 0 or 2 first embedder fields. Note that the internal // fields must contain aligned non-V8 pointers. Getting pointers to V8 // objects through this interface would be GC unsafe so in that case the // embedder gets a null pointer instead. PHANTOM_WEAK, - PHANTOM_WEAK_2_INTERNAL_FIELDS, + PHANTOM_WEAK_2_EMBEDDER_FIELDS, // The handle is automatically reset by the garbage collector when // the object is no longer reachable. PHANTOM_WEAK_RESET_HANDLE @@ -124,6 +54,14 @@ class GlobalHandles { // Creates a new global handle that is alive until Destroy is called. Handle<Object> Create(Object* value); + template <typename T> + Handle<T> Create(T* value) { + static_assert(std::is_base_of<Object, T>::value, "static type violation"); + // The compiler should only pick this method if T is not Object. + static_assert(!std::is_same<Object, T>::value, "compiler error"); + return Handle<T>::cast(Create(static_cast<Object*>(value))); + } + // Copy a global handle static Handle<Object> CopyGlobal(Object** location); @@ -170,7 +108,7 @@ class GlobalHandles { // Clear the weakness of a global handle. static void* ClearWeakness(Object** location); - // Mark the reference to this object independent of any object group. + // Mark the reference to this object independent. static void MarkIndependent(Object** location); static bool IsIndependent(Object** location); @@ -193,15 +131,15 @@ class GlobalHandles { void IterateAllRoots(ObjectVisitor* v); // Iterates over all handles that have embedder-assigned class ID. - void IterateAllRootsWithClassIds(ObjectVisitor* v); + void IterateAllRootsWithClassIds(v8::PersistentHandleVisitor* v); // Iterates over all handles in the new space that have embedder-assigned // class ID. - void IterateAllRootsInNewSpaceWithClassIds(ObjectVisitor* v); + void IterateAllRootsInNewSpaceWithClassIds(v8::PersistentHandleVisitor* v); // Iterate over all handles in the new space that are weak, unmodified // and have class IDs - void IterateWeakRootsInNewSpaceWithClassIds(ObjectVisitor* v); + void IterateWeakRootsInNewSpaceWithClassIds(v8::PersistentHandleVisitor* v); // Iterates over all weak roots in heap. void IterateWeakRoots(ObjectVisitor* v); @@ -240,55 +178,6 @@ class GlobalHandles { // unmodified void IdentifyWeakUnmodifiedObjects(WeakSlotCallback is_unmodified); - // Iterate over objects in object groups that have at least one object - // which requires visiting. The callback has to return true if objects - // can be skipped and false otherwise. - bool IterateObjectGroups(ObjectVisitor* v, WeakSlotCallbackWithHeap can_skip); - - // Print all objects in object groups - void PrintObjectGroups(); - - // Add an object group. - // Should be only used in GC callback function before a collection. - // All groups are destroyed after a garbage collection. - void AddObjectGroup(Object*** handles, - size_t length, - v8::RetainedObjectInfo* info); - - // Associates handle with the object group represented by id. - // Should be only used in GC callback function before a collection. - // All groups are destroyed after a garbage collection. - void SetObjectGroupId(Object** handle, UniqueId id); - - // Set RetainedObjectInfo for an object group. Should not be called more than - // once for a group. Should not be called for a group which contains no - // handles. - void SetRetainedObjectInfo(UniqueId id, RetainedObjectInfo* info); - - // Adds an implicit reference from a group to an object. Should be only used - // in GC callback function before a collection. All implicit references are - // destroyed after a mark-compact collection. - void SetReferenceFromGroup(UniqueId id, Object** child); - - // Adds an implicit reference from a parent object to a child object. Should - // be only used in GC callback function before a collection. All implicit - // references are destroyed after a mark-compact collection. - void SetReference(HeapObject** parent, Object** child); - - List<ObjectGroup*>* object_groups() { - ComputeObjectGroupsAndImplicitReferences(); - return &object_groups_; - } - - List<ImplicitRefGroup*>* implicit_ref_groups() { - ComputeObjectGroupsAndImplicitReferences(); - return &implicit_ref_groups_; - } - - // Remove bags, this should only happen after GC. - void RemoveObjectGroups(); - void RemoveImplicitRefGroups(); - // Tear down the global handle structure. void TearDown(); @@ -300,18 +189,14 @@ class GlobalHandles { #endif // DEBUG private: - explicit GlobalHandles(Isolate* isolate); - - // Migrates data from the internal representation (object_group_connections_, - // retainer_infos_ and implicit_ref_connections_) to the public and more - // efficient representation (object_groups_ and implicit_ref_groups_). - void ComputeObjectGroupsAndImplicitReferences(); - - // v8::internal::List is inefficient even for small number of elements, if we - // don't assign any initial capacity. - static const int kObjectGroupConnectionsCapacity = 20; - + // Internal node structures. + class Node; + class NodeBlock; + class NodeIterator; class PendingPhantomCallback; + class PendingPhantomCallbacksSecondPassTask; + + explicit GlobalHandles(Isolate* isolate); // Helpers for PostGarbageCollectionProcessing. static void InvokeSecondPassPhantomCallbacks( @@ -320,12 +205,8 @@ class GlobalHandles { int PostMarkSweepProcessing(int initial_post_gc_processing_count); int DispatchPendingPhantomCallbacks(bool synchronous_second_pass); void UpdateListOfNewSpaceNodes(); - - // Internal node structures. - class Node; - class NodeBlock; - class NodeIterator; - class PendingPhantomCallbacksSecondPassTask; + void ApplyPersistentHandleVisitor(v8::PersistentHandleVisitor* visitor, + Node* node); Isolate* isolate_; @@ -349,17 +230,6 @@ class GlobalHandles { size_t number_of_phantom_handle_resets_; - // Object groups and implicit references, public and more efficient - // representation. - List<ObjectGroup*> object_groups_; - List<ImplicitRefGroup*> implicit_ref_groups_; - - // Object groups and implicit references, temporary representation while - // constructing the groups. - List<ObjectGroupConnection> object_group_connections_; - List<ObjectGroupRetainerInfo> retainer_infos_; - List<ObjectGroupConnection> implicit_ref_connections_; - List<PendingPhantomCallback> pending_phantom_callbacks_; friend class Isolate; @@ -373,10 +243,10 @@ class GlobalHandles::PendingPhantomCallback { typedef v8::WeakCallbackInfo<void> Data; PendingPhantomCallback( Node* node, Data::Callback callback, void* parameter, - void* internal_fields[v8::kInternalFieldsInWeakCallback]) + void* embedder_fields[v8::kEmbedderFieldsInWeakCallback]) : node_(node), callback_(callback), parameter_(parameter) { - for (int i = 0; i < v8::kInternalFieldsInWeakCallback; ++i) { - internal_fields_[i] = internal_fields[i]; + for (int i = 0; i < v8::kEmbedderFieldsInWeakCallback; ++i) { + embedder_fields_[i] = embedder_fields[i]; } } @@ -389,7 +259,7 @@ class GlobalHandles::PendingPhantomCallback { Node* node_; Data::Callback callback_; void* parameter_; - void* internal_fields_[v8::kInternalFieldsInWeakCallback]; + void* embedder_fields_[v8::kEmbedderFieldsInWeakCallback]; }; |