LCOV - code coverage report
Current view: top level - src/objects - prototype-info.h (source / functions) Hit Total Coverage
Test: app.info Lines: 1 1 100.0 %
Date: 2019-01-20 Functions: 1 1 100.0 %

          Line data    Source code
       1             : // Copyright 2018 the V8 project authors. All rights reserved.
       2             : // Use of this source code is governed by a BSD-style license that can be
       3             : // found in the LICENSE file.
       4             : 
       5             : #ifndef V8_OBJECTS_PROTOTYPE_INFO_H_
       6             : #define V8_OBJECTS_PROTOTYPE_INFO_H_
       7             : 
       8             : #include "src/objects.h"
       9             : #include "src/objects/fixed-array.h"
      10             : #include "src/objects/struct.h"
      11             : 
      12             : // Has to be the last include (doesn't have include guards):
      13             : #include "src/objects/object-macros.h"
      14             : 
      15             : namespace v8 {
      16             : namespace internal {
      17             : 
      18             : // Container for metadata stored on each prototype map.
      19             : class PrototypeInfo : public Struct {
      20             :  public:
      21             :   static const int UNREGISTERED = -1;
      22             : 
      23             :   // [module_namespace]: A backpointer to JSModuleNamespace from its
      24             :   // PrototypeInfo (or undefined). This field is only used for JSModuleNamespace
      25             :   // maps.  TODO(jkummerow): Figure out if there's a way to store the namespace
      26             :   // pointer elsewhere to save memory.
      27             :   DECL_ACCESSORS(module_namespace, Object)
      28             : 
      29             :   // [prototype_users]: WeakArrayList containing weak references to maps using
      30             :   // this prototype, or Smi(0) if uninitialized.
      31             :   DECL_ACCESSORS(prototype_users, Object)
      32             : 
      33             :   // [object_create_map]: A field caching the map for Object.create(prototype).
      34             :   static inline void SetObjectCreateMap(Handle<PrototypeInfo> info,
      35             :                                         Handle<Map> map);
      36             :   inline Map ObjectCreateMap();
      37             :   inline bool HasObjectCreateMap();
      38             : 
      39             :   // [registry_slot]: Slot in prototype's user registry where this user
      40             :   // is stored. Returns UNREGISTERED if this prototype has not been registered.
      41             :   inline int registry_slot() const;
      42             :   inline void set_registry_slot(int slot);
      43             : 
      44             :   // [bit_field]
      45             :   inline int bit_field() const;
      46             :   inline void set_bit_field(int bit_field);
      47             : 
      48             :   DECL_BOOLEAN_ACCESSORS(should_be_fast_map)
      49             : 
      50             :   DECL_CAST(PrototypeInfo)
      51             : 
      52             :   // Dispatched behavior.
      53             :   DECL_PRINTER(PrototypeInfo)
      54             :   DECL_VERIFIER(PrototypeInfo)
      55             : 
      56             : // Layout description.
      57             : #define PROTOTYPE_INFO_FIELDS(V)           \
      58             :   V(kJSModuleNamespaceOffset, kTaggedSize) \
      59             :   V(kPrototypeUsersOffset, kTaggedSize)    \
      60             :   V(kRegistrySlotOffset, kTaggedSize)      \
      61             :   V(kValidityCellOffset, kTaggedSize)      \
      62             :   V(kObjectCreateMapOffset, kTaggedSize)   \
      63             :   V(kBitFieldOffset, kTaggedSize)          \
      64             :   /* Total size. */                        \
      65             :   V(kSize, 0)
      66             : 
      67             :   DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize, PROTOTYPE_INFO_FIELDS)
      68             : #undef PROTOTYPE_INFO_FIELDS
      69             : 
      70             :   // Bit field usage.
      71             :   static const int kShouldBeFastBit = 0;
      72             : 
      73             :   class BodyDescriptor;
      74             : 
      75             :  private:
      76             :   DECL_ACCESSORS(object_create_map, MaybeObject)
      77             : 
      78     3672388 :   OBJECT_CONSTRUCTORS(PrototypeInfo, Struct);
      79             : };
      80             : 
      81             : // A growing array with an additional API for marking slots "empty". When adding
      82             : // new elements, we reuse the empty slots instead of growing the array.
      83             : class PrototypeUsers : public WeakArrayList {
      84             :  public:
      85             :   static Handle<WeakArrayList> Add(Isolate* isolate,
      86             :                                    Handle<WeakArrayList> array,
      87             :                                    Handle<Map> value, int* assigned_index);
      88             : 
      89             :   static inline void MarkSlotEmpty(WeakArrayList array, int index);
      90             : 
      91             :   // The callback is called when a weak pointer to HeapObject "object" is moved
      92             :   // from index "from_index" to index "to_index" during compaction. The callback
      93             :   // must not cause GC.
      94             :   typedef void (*CompactionCallback)(HeapObject object, int from_index,
      95             :                                      int to_index);
      96             :   static WeakArrayList Compact(Handle<WeakArrayList> array, Heap* heap,
      97             :                                CompactionCallback callback,
      98             :                                PretenureFlag pretenure = NOT_TENURED);
      99             : 
     100             : #ifdef VERIFY_HEAP
     101             :   static void Verify(WeakArrayList array);
     102             : #endif  // VERIFY_HEAP
     103             : 
     104             :   static const int kEmptySlotIndex = 0;
     105             :   static const int kFirstIndex = 1;
     106             : 
     107             :   static const int kNoEmptySlotsMarker = 0;
     108             : 
     109             :  private:
     110             :   static inline Smi empty_slot_index(WeakArrayList array);
     111             :   static inline void set_empty_slot_index(WeakArrayList array, int index);
     112             : 
     113             :   static void IsSlotEmpty(WeakArrayList array, int index);
     114             : 
     115             :   DISALLOW_IMPLICIT_CONSTRUCTORS(PrototypeUsers);
     116             : };
     117             : 
     118             : }  // namespace internal
     119             : }  // namespace v8
     120             : 
     121             : #include "src/objects/object-macros-undef.h"
     122             : 
     123             : #endif  // V8_OBJECTS_PROTOTYPE_INFO_H_

Generated by: LCOV version 1.10