LCOV - code coverage report
Current view: top level - src/objects - embedder-data-array.h (source / functions) Hit Total Coverage
Test: app.info Lines: 1 1 100.0 %
Date: 2019-04-18 Functions: 0 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_EMBEDDER_DATA_ARRAY_H_
       6             : #define V8_OBJECTS_EMBEDDER_DATA_ARRAY_H_
       7             : 
       8             : #include "src/globals.h"
       9             : #include "src/maybe-handles.h"
      10             : #include "src/objects/heap-object.h"
      11             : #include "torque-generated/class-definitions-from-dsl.h"
      12             : 
      13             : // Has to be the last include (doesn't have include guards):
      14             : #include "src/objects/object-macros.h"
      15             : 
      16             : namespace v8 {
      17             : namespace internal {
      18             : 
      19             : // This is a storage array for embedder data fields stored in native context.
      20             : // It's basically an "array of EmbedderDataSlots".
      21             : // Note, if the pointer compression is enabled the embedder data slot also
      22             : // contains a raw data part in addition to tagged part.
      23             : class EmbedderDataArray : public HeapObject {
      24             :  public:
      25             :   // [length]: length of the array in an embedder data slots.
      26             :   V8_INLINE int length() const;
      27             :   V8_INLINE void set_length(int value);
      28             : 
      29             :   DECL_CAST(EmbedderDataArray)
      30             : 
      31             :   DEFINE_FIELD_OFFSET_CONSTANTS(HeapObject::kHeaderSize,
      32             :                                 TORQUE_GENERATED_EMBEDDER_DATA_ARRAY_FIELDS)
      33             :   // TODO(v8:8989): [torque] Support marker constants.
      34             :   static const int kHeaderSize = kSize;
      35             : 
      36             :   // Garbage collection support.
      37             :   static constexpr int SizeFor(int length) {
      38      635988 :     return kHeaderSize + length * kEmbedderDataSlotSize;
      39             :   }
      40             : 
      41             :   // Returns a grown copy if the index is bigger than the array's length.
      42             :   static Handle<EmbedderDataArray> EnsureCapacity(
      43             :       Isolate* isolate, Handle<EmbedderDataArray> array, int index);
      44             : 
      45             :   // Code Generation support.
      46             :   static constexpr int OffsetOfElementAt(int index) { return SizeFor(index); }
      47             : 
      48             :   // Address of the first slot.
      49             :   V8_INLINE Address slots_start();
      50             : 
      51             :   // Address of the one past last slot.
      52             :   V8_INLINE Address slots_end();
      53             : 
      54             :   // Dispatched behavior.
      55             :   DECL_PRINTER(EmbedderDataArray)
      56             :   DECL_VERIFIER(EmbedderDataArray)
      57             : 
      58             :   class BodyDescriptor;
      59             : 
      60             :   static const int kMaxSize = kMaxRegularHeapObjectSize;
      61             :   static constexpr int kMaxLength =
      62             :       (kMaxSize - kHeaderSize) / kEmbedderDataSlotSize;
      63             : 
      64             :  private:
      65             :   STATIC_ASSERT(kHeaderSize == Internals::kFixedArrayHeaderSize);
      66             : 
      67             :   OBJECT_CONSTRUCTORS(EmbedderDataArray, HeapObject);
      68             : };
      69             : 
      70             : }  // namespace internal
      71             : }  // namespace v8
      72             : 
      73             : #include "src/objects/object-macros-undef.h"
      74             : 
      75             : #endif  // V8_OBJECTS_EMBEDDER_DATA_ARRAY_H_

Generated by: LCOV version 1.10