V8 Project
v8::internal::ElementsAccessorBase< ElementsAccessorSubclass, ElementsTraitsParam > Class Template Referenceabstract
+ Inheritance diagram for v8::internal::ElementsAccessorBase< ElementsAccessorSubclass, ElementsTraitsParam >:
+ Collaboration diagram for v8::internal::ElementsAccessorBase< ElementsAccessorSubclass, ElementsTraitsParam >:

Protected Types

typedef ElementsTraitsParam ElementsTraits
 
typedef ElementsTraitsParam::BackingStore BackingStore
 

Protected Member Functions

 ElementsAccessorBase (const char *name)
 
virtual ElementsKind kind () const FINAL OVERRIDE
 
virtual void Validate (Handle< JSObject > holder) FINAL OVERRIDE
 
virtual bool HasElement (Handle< Object > receiver, Handle< JSObject > holder, uint32_t key, Handle< FixedArrayBase > backing_store) FINAL OVERRIDE
 
virtual MUST_USE_RESULT MaybeHandle< ObjectGet (Handle< Object > receiver, Handle< JSObject > holder, uint32_t key, Handle< FixedArrayBase > backing_store) FINAL OVERRIDE
 
virtual MUST_USE_RESULT PropertyAttributes GetAttributes (Handle< Object > receiver, Handle< JSObject > holder, uint32_t key, Handle< FixedArrayBase > backing_store) FINAL OVERRIDE
 
virtual MUST_USE_RESULT MaybeHandle< AccessorPairGetAccessorPair (Handle< Object > receiver, Handle< JSObject > holder, uint32_t key, Handle< FixedArrayBase > backing_store) FINAL OVERRIDE
 
virtual MUST_USE_RESULT MaybeHandle< ObjectSetLength (Handle< JSArray > array, Handle< Object > length) FINAL OVERRIDE
 
virtual void SetCapacityAndLength (Handle< JSArray > array, int capacity, int length) FINAL OVERRIDE
 
virtual MUST_USE_RESULT MaybeHandle< ObjectDelete (Handle< JSObject > obj, uint32_t key, JSReceiver::DeleteMode mode) OVERRIDE=0
 
virtual void CopyElements (Handle< FixedArrayBase > from, uint32_t from_start, ElementsKind from_kind, Handle< FixedArrayBase > to, uint32_t to_start, int copy_size) FINAL OVERRIDE
 
virtual void CopyElements (JSObject *from_holder, uint32_t from_start, ElementsKind from_kind, Handle< FixedArrayBase > to, uint32_t to_start, int copy_size) FINAL OVERRIDE
 
virtual MaybeHandle< FixedArrayAddElementsToFixedArray (Handle< Object > receiver, Handle< JSObject > holder, Handle< FixedArray > to, Handle< FixedArrayBase > from) FINAL OVERRIDE
 
virtual uint32_t GetCapacity (Handle< FixedArrayBase > backing_store) FINAL OVERRIDE
 
virtual uint32_t GetKeyForIndex (Handle< FixedArrayBase > backing_store, uint32_t index) FINAL OVERRIDE
 

Static Protected Member Functions

static void ValidateContents (Handle< JSObject > holder, int length)
 
static void ValidateImpl (Handle< JSObject > holder)
 
static bool HasElementImpl (Handle< Object > receiver, Handle< JSObject > holder, uint32_t key, Handle< FixedArrayBase > backing_store)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetImpl (Handle< Object > receiver, Handle< JSObject > obj, uint32_t key, Handle< FixedArrayBase > backing_store)
 
static MUST_USE_RESULT PropertyAttributes GetAttributesImpl (Handle< Object > receiver, Handle< JSObject > obj, uint32_t key, Handle< FixedArrayBase > backing_store)
 
static MUST_USE_RESULT MaybeHandle< AccessorPairGetAccessorPairImpl (Handle< Object > receiver, Handle< JSObject > obj, uint32_t key, Handle< FixedArrayBase > backing_store)
 
static MUST_USE_RESULT MaybeHandle< ObjectSetLengthImpl (Handle< JSObject > obj, Handle< Object > length, Handle< FixedArrayBase > backing_store)
 
static void SetFastElementsCapacityAndLength (Handle< JSObject > obj, int capacity, int length)
 
static void CopyElementsImpl (FixedArrayBase *from, uint32_t from_start, FixedArrayBase *to, ElementsKind from_kind, uint32_t to_start, int packed_size, int copy_size)
 
static uint32_t GetCapacityImpl (Handle< FixedArrayBase > backing_store)
 
static uint32_t GetKeyForIndexImpl (Handle< FixedArrayBase > backing_store, uint32_t index)
 

Private Member Functions

 DISALLOW_COPY_AND_ASSIGN (ElementsAccessorBase)
 

Additional Inherited Members

- Public Member Functions inherited from v8::internal::ElementsAccessor
 ElementsAccessor (const char *name)
 
virtual ~ElementsAccessor ()
 
const char * name () const
 
bool HasElement (Handle< Object > receiver, Handle< JSObject > holder, uint32_t key)
 
MUST_USE_RESULT MaybeHandle< ObjectGet (Handle< Object > receiver, Handle< JSObject > holder, uint32_t key)
 
MUST_USE_RESULT PropertyAttributes GetAttributes (Handle< Object > receiver, Handle< JSObject > holder, uint32_t key)
 
MUST_USE_RESULT MaybeHandle< AccessorPairGetAccessorPair (Handle< Object > receiver, Handle< JSObject > holder, uint32_t key)
 
void CopyElements (Handle< JSObject > from_holder, Handle< FixedArrayBase > to, ElementsKind from_kind)
 
MUST_USE_RESULT MaybeHandle< FixedArrayAddElementsToFixedArray (Handle< Object > receiver, Handle< JSObject > holder, Handle< FixedArray > to)
 
- Static Public Member Functions inherited from v8::internal::ElementsAccessor
static ElementsAccessorForKind (ElementsKind elements_kind)
 
static ElementsAccessorForArray (Handle< FixedArrayBase > array)
 
static void InitializeOncePerProcess ()
 
static void TearDown ()
 
- Static Public Attributes inherited from v8::internal::ElementsAccessor
static const int kCopyToEnd = -1
 
static const int kCopyToEndAndInitializeToHole = -2
 

Detailed Description

template<typename ElementsAccessorSubclass, typename ElementsTraitsParam>
class v8::internal::ElementsAccessorBase< ElementsAccessorSubclass, ElementsTraitsParam >

Definition at line 555 of file elements.cc.

Member Typedef Documentation

◆ BackingStore

template<typename ElementsAccessorSubclass , typename ElementsTraitsParam >
typedef ElementsTraitsParam::BackingStore v8::internal::ElementsAccessorBase< ElementsAccessorSubclass, ElementsTraitsParam >::BackingStore
protected

Definition at line 561 of file elements.cc.

◆ ElementsTraits

template<typename ElementsAccessorSubclass , typename ElementsTraitsParam >
typedef ElementsTraitsParam v8::internal::ElementsAccessorBase< ElementsAccessorSubclass, ElementsTraitsParam >::ElementsTraits
protected

Definition at line 560 of file elements.cc.

Constructor & Destructor Documentation

◆ ElementsAccessorBase()

template<typename ElementsAccessorSubclass , typename ElementsTraitsParam >
v8::internal::ElementsAccessorBase< ElementsAccessorSubclass, ElementsTraitsParam >::ElementsAccessorBase ( const char *  name)
inlineexplicitprotected

Definition at line 557 of file elements.cc.

558  : ElementsAccessor(name) { }
const char * name() const
Definition: elements.h:24
ElementsAccessor(const char *name)
Definition: elements.h:20

Member Function Documentation

◆ AddElementsToFixedArray()

template<typename ElementsAccessorSubclass , typename ElementsTraitsParam >
virtual MaybeHandle<FixedArray> v8::internal::ElementsAccessorBase< ElementsAccessorSubclass, ElementsTraitsParam >::AddElementsToFixedArray ( Handle< Object receiver,
Handle< JSObject holder,
Handle< FixedArray to,
Handle< FixedArrayBase from 
)
inlineprotectedvirtual

Implements v8::internal::ElementsAccessor.

Definition at line 768 of file elements.cc.

772  {
773  int len0 = to->length();
774 #ifdef ENABLE_SLOW_DCHECKS
776  for (int i = 0; i < len0; i++) {
777  DCHECK(!to->get(i)->IsTheHole());
778  }
779  }
780 #endif
781 
782  // Optimize if 'other' is empty.
783  // We cannot optimize if 'this' is empty, as other may have holes.
784  uint32_t len1 = ElementsAccessorSubclass::GetCapacityImpl(from);
785  if (len1 == 0) return to;
786 
787  Isolate* isolate = from->GetIsolate();
788 
789  // Compute how many elements are not in other.
790  uint32_t extra = 0;
791  for (uint32_t y = 0; y < len1; y++) {
792  uint32_t key = ElementsAccessorSubclass::GetKeyForIndexImpl(from, y);
793  if (ElementsAccessorSubclass::HasElementImpl(
794  receiver, holder, key, from)) {
795  Handle<Object> value;
797  isolate, value,
798  ElementsAccessorSubclass::GetImpl(receiver, holder, key, from),
799  FixedArray);
800 
801  DCHECK(!value->IsTheHole());
802  if (!HasKey(to, value)) {
803  extra++;
804  }
805  }
806  }
807 
808  if (extra == 0) return to;
809 
810  // Allocate the result
811  Handle<FixedArray> result = isolate->factory()->NewFixedArray(len0 + extra);
812 
813  // Fill in the content
814  {
816  WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc);
817  for (int i = 0; i < len0; i++) {
818  Object* e = to->get(i);
819  DCHECK(e->IsString() || e->IsNumber());
820  result->set(i, e, mode);
821  }
822  }
823  // Fill in the extra values.
824  uint32_t index = 0;
825  for (uint32_t y = 0; y < len1; y++) {
826  uint32_t key =
827  ElementsAccessorSubclass::GetKeyForIndexImpl(from, y);
828  if (ElementsAccessorSubclass::HasElementImpl(
829  receiver, holder, key, from)) {
830  Handle<Object> value;
832  isolate, value,
833  ElementsAccessorSubclass::GetImpl(receiver, holder, key, from),
834  FixedArray);
835  if (!value->IsTheHole() && !HasKey(to, value)) {
836  result->set(len0 + index, *value);
837  index++;
838  }
839  }
840  }
841  DCHECK(extra == index);
842  return result;
843  }
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in only print modified registers Trace simulator debug messages Implied by trace sim abort randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot A filename with extra code to be included in the A file to write the raw snapshot bytes to(mksnapshot only)") DEFINE_STRING(raw_context_file
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long mode(MIPS only)") DEFINE_BOOL(enable_always_align_csp
#define ASSIGN_RETURN_ON_EXCEPTION(isolate, dst, call, T)
Definition: isolate.h:135
#define DCHECK(condition)
Definition: logging.h:205
PerThreadAssertScopeDebugOnly< HEAP_ALLOCATION_ASSERT, false > DisallowHeapAllocation
Definition: assert-scope.h:110
static bool HasKey(Handle< FixedArray > array, Handle< Object > key_handle)
Definition: elements.cc:126
kSerializedDataOffset Object
Definition: objects-inl.h:5322
const bool FLAG_enable_slow_asserts
Definition: checks.h:31

References ASSIGN_RETURN_ON_EXCEPTION, DCHECK, v8::internal::Isolate::factory(), v8::internal::FLAG_enable_slow_asserts, v8::internal::HasKey(), mode(), to(), and v8::base::internal::y.

+ Here is the call graph for this function:

◆ CopyElements() [1/2]

template<typename ElementsAccessorSubclass , typename ElementsTraitsParam >
virtual void v8::internal::ElementsAccessorBase< ElementsAccessorSubclass, ElementsTraitsParam >::CopyElements ( Handle< FixedArrayBase from,
uint32_t  from_start,
ElementsKind  from_kind,
Handle< FixedArrayBase to,
uint32_t  to_start,
int  copy_size 
)
inlineprotectedvirtual

Implements v8::internal::ElementsAccessor.

Definition at line 718 of file elements.cc.

724  {
725  DCHECK(!from.is_null());
726  // NOTE: the ElementsAccessorSubclass::CopyElementsImpl() methods
727  // violate the handlified function signature convention:
728  // raw pointer parameters in the function that allocates. This is done
729  // intentionally to avoid ArrayConcat() builtin performance degradation.
730  // See the comment in another ElementsAccessorBase::CopyElements() for
731  // details.
732  ElementsAccessorSubclass::CopyElementsImpl(*from, from_start, *to,
733  from_kind, to_start,
734  kPackedSizeNotKnown, copy_size);
735  }
static const int kPackedSizeNotKnown
Definition: elements.cc:55

References DCHECK, v8::internal::kPackedSizeNotKnown, and to().

+ Here is the call graph for this function:

◆ CopyElements() [2/2]

template<typename ElementsAccessorSubclass , typename ElementsTraitsParam >
virtual void v8::internal::ElementsAccessorBase< ElementsAccessorSubclass, ElementsTraitsParam >::CopyElements ( JSObject from_holder,
uint32_t  from_start,
ElementsKind  from_kind,
Handle< FixedArrayBase to,
uint32_t  to_start,
int  copy_size 
)
inlineprotectedvirtual

Implements v8::internal::ElementsAccessor.

Definition at line 737 of file elements.cc.

743  {
744  int packed_size = kPackedSizeNotKnown;
745  bool is_packed = IsFastPackedElementsKind(from_kind) &&
746  from_holder->IsJSArray();
747  if (is_packed) {
748  packed_size =
749  Smi::cast(JSArray::cast(from_holder)->length())->value();
750  if (copy_size >= 0 && packed_size > copy_size) {
751  packed_size = copy_size;
752  }
753  }
754  FixedArrayBase* from = from_holder->elements();
755  // NOTE: the ElementsAccessorSubclass::CopyElementsImpl() methods
756  // violate the handlified function signature convention:
757  // raw pointer parameters in the function that allocates. This is done
758  // intentionally to avoid ArrayConcat() builtin performance degradation.
759  //
760  // Details: The idea is that allocations actually happen only in case of
761  // copying from object with fast double elements to object with object
762  // elements. In all the other cases there are no allocations performed and
763  // handle creation causes noticeable performance degradation of the builtin.
764  ElementsAccessorSubclass::CopyElementsImpl(
765  from, from_start, *to, from_kind, to_start, packed_size, copy_size);
766  }
bool IsFastPackedElementsKind(ElementsKind kind)

References v8::internal::IsFastPackedElementsKind(), v8::internal::kPackedSizeNotKnown, and to().

+ Here is the call graph for this function:

◆ CopyElementsImpl()

template<typename ElementsAccessorSubclass , typename ElementsTraitsParam >
static void v8::internal::ElementsAccessorBase< ElementsAccessorSubclass, ElementsTraitsParam >::CopyElementsImpl ( FixedArrayBase from,
uint32_t  from_start,
FixedArrayBase to,
ElementsKind  from_kind,
uint32_t  to_start,
int  packed_size,
int  copy_size 
)
inlinestaticprotected

Definition at line 711 of file elements.cc.

714  {
715  UNREACHABLE();
716  }
#define UNREACHABLE()
Definition: logging.h:30

References UNREACHABLE.

◆ Delete()

template<typename ElementsAccessorSubclass , typename ElementsTraitsParam >
virtual MUST_USE_RESULT MaybeHandle<Object> v8::internal::ElementsAccessorBase< ElementsAccessorSubclass, ElementsTraitsParam >::Delete ( Handle< JSObject obj,
uint32_t  key,
JSReceiver::DeleteMode  mode 
)
protectedpure virtual

◆ DISALLOW_COPY_AND_ASSIGN()

template<typename ElementsAccessorSubclass , typename ElementsTraitsParam >
v8::internal::ElementsAccessorBase< ElementsAccessorSubclass, ElementsTraitsParam >::DISALLOW_COPY_AND_ASSIGN ( ElementsAccessorBase< ElementsAccessorSubclass, ElementsTraitsParam >  )
private

◆ Get()

template<typename ElementsAccessorSubclass , typename ElementsTraitsParam >
virtual MUST_USE_RESULT MaybeHandle<Object> v8::internal::ElementsAccessorBase< ElementsAccessorSubclass, ElementsTraitsParam >::Get ( Handle< Object receiver,
Handle< JSObject holder,
uint32_t  key,
Handle< FixedArrayBase backing_store 
)
inlineprotectedvirtual

Implements v8::internal::ElementsAccessor.

Definition at line 609 of file elements.cc.

613  {
614  if (!IsExternalArrayElementsKind(ElementsTraits::Kind) &&
615  FLAG_trace_js_array_abuse) {
616  CheckArrayAbuse(holder, "elements read", key);
617  }
618 
619  if (IsExternalArrayElementsKind(ElementsTraits::Kind) &&
620  FLAG_trace_external_array_abuse) {
621  CheckArrayAbuse(holder, "external elements read", key);
622  }
623 
624  return ElementsAccessorSubclass::GetImpl(
625  receiver, holder, key, backing_store);
626  }
bool IsExternalArrayElementsKind(ElementsKind kind)
Definition: elements-kind.h:95
void CheckArrayAbuse(Handle< JSObject > obj, const char *op, uint32_t key, bool allow_appending)
Definition: elements.cc:496

References v8::internal::CheckArrayAbuse(), and v8::internal::IsExternalArrayElementsKind().

+ Here is the call graph for this function:

◆ GetAccessorPair()

template<typename ElementsAccessorSubclass , typename ElementsTraitsParam >
virtual MUST_USE_RESULT MaybeHandle<AccessorPair> v8::internal::ElementsAccessorBase< ElementsAccessorSubclass, ElementsTraitsParam >::GetAccessorPair ( Handle< Object receiver,
Handle< JSObject holder,
uint32_t  key,
Handle< FixedArrayBase backing_store 
)
inlineprotectedvirtual

Implements v8::internal::ElementsAccessor.

Definition at line 662 of file elements.cc.

666  {
667  return ElementsAccessorSubclass::GetAccessorPairImpl(
668  receiver, holder, key, backing_store);
669  }

◆ GetAccessorPairImpl()

template<typename ElementsAccessorSubclass , typename ElementsTraitsParam >
static MUST_USE_RESULT MaybeHandle<AccessorPair> v8::internal::ElementsAccessorBase< ElementsAccessorSubclass, ElementsTraitsParam >::GetAccessorPairImpl ( Handle< Object receiver,
Handle< JSObject obj,
uint32_t  key,
Handle< FixedArrayBase backing_store 
)
inlinestaticprotected

Definition at line 671 of file elements.cc.

675  {
676  return MaybeHandle<AccessorPair>();
677  }

◆ GetAttributes()

template<typename ElementsAccessorSubclass , typename ElementsTraitsParam >
virtual MUST_USE_RESULT PropertyAttributes v8::internal::ElementsAccessorBase< ElementsAccessorSubclass, ElementsTraitsParam >::GetAttributes ( Handle< Object receiver,
Handle< JSObject holder,
uint32_t  key,
Handle< FixedArrayBase backing_store 
)
inlineprotectedvirtual

Implements v8::internal::ElementsAccessor.

Definition at line 640 of file elements.cc.

644  {
645  return ElementsAccessorSubclass::GetAttributesImpl(
646  receiver, holder, key, backing_store);
647  }

◆ GetAttributesImpl()

template<typename ElementsAccessorSubclass , typename ElementsTraitsParam >
static MUST_USE_RESULT PropertyAttributes v8::internal::ElementsAccessorBase< ElementsAccessorSubclass, ElementsTraitsParam >::GetAttributesImpl ( Handle< Object receiver,
Handle< JSObject obj,
uint32_t  key,
Handle< FixedArrayBase backing_store 
)
inlinestaticprotected

Definition at line 649 of file elements.cc.

653  {
654  if (key >= ElementsAccessorSubclass::GetCapacityImpl(backing_store)) {
655  return ABSENT;
656  }
657  return
658  Handle<BackingStore>::cast(backing_store)->is_the_hole(key)
659  ? ABSENT : NONE;
660  }
static Handle< T > cast(Handle< S > that)
Definition: handles.h:116
@ ABSENT
@ NONE

References ABSENT, v8::internal::Handle< T >::cast(), and NONE.

+ Here is the call graph for this function:

◆ GetCapacity()

template<typename ElementsAccessorSubclass , typename ElementsTraitsParam >
virtual uint32_t v8::internal::ElementsAccessorBase< ElementsAccessorSubclass, ElementsTraitsParam >::GetCapacity ( Handle< FixedArrayBase backing_store)
inlineprotectedvirtual

Implements v8::internal::ElementsAccessor.

Definition at line 850 of file elements.cc.

851  {
852  return ElementsAccessorSubclass::GetCapacityImpl(backing_store);
853  }

◆ GetCapacityImpl()

template<typename ElementsAccessorSubclass , typename ElementsTraitsParam >
static uint32_t v8::internal::ElementsAccessorBase< ElementsAccessorSubclass, ElementsTraitsParam >::GetCapacityImpl ( Handle< FixedArrayBase backing_store)
inlinestaticprotected

Definition at line 846 of file elements.cc.

846  {
847  return backing_store->length();
848  }

◆ GetImpl()

template<typename ElementsAccessorSubclass , typename ElementsTraitsParam >
static MUST_USE_RESULT MaybeHandle<Object> v8::internal::ElementsAccessorBase< ElementsAccessorSubclass, ElementsTraitsParam >::GetImpl ( Handle< Object receiver,
Handle< JSObject obj,
uint32_t  key,
Handle< FixedArrayBase backing_store 
)
inlinestaticprotected

Definition at line 628 of file elements.cc.

632  {
633  if (key < ElementsAccessorSubclass::GetCapacityImpl(backing_store)) {
634  return BackingStore::get(Handle<BackingStore>::cast(backing_store), key);
635  } else {
636  return backing_store->GetIsolate()->factory()->the_hole_value();
637  }
638  }

◆ GetKeyForIndex()

template<typename ElementsAccessorSubclass , typename ElementsTraitsParam >
virtual uint32_t v8::internal::ElementsAccessorBase< ElementsAccessorSubclass, ElementsTraitsParam >::GetKeyForIndex ( Handle< FixedArrayBase backing_store,
uint32_t  index 
)
inlineprotectedvirtual

Implements v8::internal::ElementsAccessor.

Definition at line 860 of file elements.cc.

861  {
862  return ElementsAccessorSubclass::GetKeyForIndexImpl(backing_store, index);
863  }

◆ GetKeyForIndexImpl()

template<typename ElementsAccessorSubclass , typename ElementsTraitsParam >
static uint32_t v8::internal::ElementsAccessorBase< ElementsAccessorSubclass, ElementsTraitsParam >::GetKeyForIndexImpl ( Handle< FixedArrayBase backing_store,
uint32_t  index 
)
inlinestaticprotected

Definition at line 855 of file elements.cc.

856  {
857  return index;
858  }

◆ HasElement()

template<typename ElementsAccessorSubclass , typename ElementsTraitsParam >
virtual bool v8::internal::ElementsAccessorBase< ElementsAccessorSubclass, ElementsTraitsParam >::HasElement ( Handle< Object receiver,
Handle< JSObject holder,
uint32_t  key,
Handle< FixedArrayBase backing_store 
)
inlineprotectedvirtual

Implements v8::internal::ElementsAccessor.

Definition at line 600 of file elements.cc.

604  {
605  return ElementsAccessorSubclass::HasElementImpl(
606  receiver, holder, key, backing_store);
607  }

◆ HasElementImpl()

template<typename ElementsAccessorSubclass , typename ElementsTraitsParam >
static bool v8::internal::ElementsAccessorBase< ElementsAccessorSubclass, ElementsTraitsParam >::HasElementImpl ( Handle< Object receiver,
Handle< JSObject holder,
uint32_t  key,
Handle< FixedArrayBase backing_store 
)
inlinestaticprotected

Definition at line 592 of file elements.cc.

595  {
596  return ElementsAccessorSubclass::GetAttributesImpl(
597  receiver, holder, key, backing_store) != ABSENT;
598  }

References ABSENT.

◆ kind()

template<typename ElementsAccessorSubclass , typename ElementsTraitsParam >
virtual ElementsKind v8::internal::ElementsAccessorBase< ElementsAccessorSubclass, ElementsTraitsParam >::kind ( ) const
inlineprotectedvirtual

Implements v8::internal::ElementsAccessor.

Definition at line 563 of file elements.cc.

563  {
564  return ElementsTraits::Kind;
565  }

◆ SetCapacityAndLength()

template<typename ElementsAccessorSubclass , typename ElementsTraitsParam >
virtual void v8::internal::ElementsAccessorBase< ElementsAccessorSubclass, ElementsTraitsParam >::SetCapacityAndLength ( Handle< JSArray array,
int  capacity,
int  length 
)
inlineprotectedvirtual

Implements v8::internal::ElementsAccessor.

Definition at line 691 of file elements.cc.

694  {
695  ElementsAccessorSubclass::
696  SetFastElementsCapacityAndLength(array, capacity, length);
697  }

◆ SetFastElementsCapacityAndLength()

template<typename ElementsAccessorSubclass , typename ElementsTraitsParam >
static void v8::internal::ElementsAccessorBase< ElementsAccessorSubclass, ElementsTraitsParam >::SetFastElementsCapacityAndLength ( Handle< JSObject obj,
int  capacity,
int  length 
)
inlinestaticprotected

Definition at line 699 of file elements.cc.

702  {
703  UNIMPLEMENTED();
704  }
#define UNIMPLEMENTED()
Definition: logging.h:28

References UNIMPLEMENTED.

◆ SetLength()

template<typename ElementsAccessorSubclass , typename ElementsTraitsParam >
virtual MUST_USE_RESULT MaybeHandle<Object> v8::internal::ElementsAccessorBase< ElementsAccessorSubclass, ElementsTraitsParam >::SetLength ( Handle< JSArray array,
Handle< Object length 
)
inlineprotectedvirtual

Implements v8::internal::ElementsAccessor.

Definition at line 679 of file elements.cc.

681  {
682  return ElementsAccessorSubclass::SetLengthImpl(
683  array, length, handle(array->elements()));
684  }
Handle< T > handle(T *t, Isolate *isolate)
Definition: handles.h:146

References v8::internal::handle().

+ Here is the call graph for this function:

◆ SetLengthImpl()

template<typename ElementsAccessorSubclass , typename ElementsKindTraits >
MUST_USE_RESULT MaybeHandle< Object > v8::internal::ElementsAccessorBase< ElementsAccessorSubclass, ElementsKindTraits >::SetLengthImpl ( Handle< JSObject obj,
Handle< Object length,
Handle< FixedArrayBase backing_store 
)
staticprotected

Definition at line 1762 of file elements.cc.

1765  {
1766  Isolate* isolate = obj->GetIsolate();
1767  Handle<JSArray> array = Handle<JSArray>::cast(obj);
1768 
1769  // Fast case: The new length fits into a Smi.
1770  Handle<Object> smi_length;
1771 
1772  if (Object::ToSmi(isolate, length).ToHandle(&smi_length) &&
1773  smi_length->IsSmi()) {
1774  const int value = Handle<Smi>::cast(smi_length)->value();
1775  if (value >= 0) {
1776  Handle<Object> new_length = ElementsAccessorSubclass::
1777  SetLengthWithoutNormalize(backing_store, array, smi_length, value);
1778  DCHECK(!new_length.is_null());
1779 
1780  // even though the proposed length was a smi, new_length could
1781  // still be a heap number because SetLengthWithoutNormalize doesn't
1782  // allow the array length property to drop below the index of
1783  // non-deletable elements.
1784  DCHECK(new_length->IsSmi() || new_length->IsHeapNumber() ||
1785  new_length->IsUndefined());
1786  if (new_length->IsSmi()) {
1787  array->set_length(*Handle<Smi>::cast(new_length));
1788  return array;
1789  } else if (new_length->IsHeapNumber()) {
1790  array->set_length(*new_length);
1791  return array;
1792  }
1793  } else {
1794  return ThrowArrayLengthRangeError(isolate);
1795  }
1796  }
1797 
1798  // Slow case: The new length does not fit into a Smi or conversion
1799  // to slow elements is needed for other reasons.
1800  if (length->IsNumber()) {
1801  uint32_t value;
1802  if (length->ToArrayIndex(&value)) {
1803  Handle<SeededNumberDictionary> dictionary =
1805  DCHECK(!dictionary.is_null());
1806 
1807  Handle<Object> new_length = DictionaryElementsAccessor::
1808  SetLengthWithoutNormalize(dictionary, array, length, value);
1809  DCHECK(!new_length.is_null());
1810 
1811  DCHECK(new_length->IsNumber());
1812  array->set_length(*new_length);
1813  return array;
1814  } else {
1815  return ThrowArrayLengthRangeError(isolate);
1816  }
1817  }
1818 
1819  // Fall-back case: The new length is not a number so make the array
1820  // size one and set only element to length.
1821  Handle<FixedArray> new_backing_store = isolate->factory()->NewFixedArray(1);
1822  new_backing_store->set(0, *length);
1823  JSArray::SetContent(array, new_backing_store);
1824  return array;
1825 }
static Handle< Object > SetLengthWithoutNormalize(Handle< FixedArrayBase > store, Handle< JSArray > array, Handle< Object > length_object, uint32_t length)
Definition: elements.cc:1366
static void SetContent(Handle< JSArray > array, Handle< FixedArrayBase > storage)
Definition: objects-inl.h:6986
static Handle< SeededNumberDictionary > NormalizeElements(Handle< JSObject > object)
Definition: objects.cc:4459
static MUST_USE_RESULT MaybeHandle< Smi > ToSmi(Isolate *isolate, Handle< Object > object)
Definition: objects-inl.h:1081
static MUST_USE_RESULT MaybeHandle< Object > ThrowArrayLengthRangeError(Isolate *isolate)
Definition: elements.cc:143

References v8::internal::Handle< T >::cast(), DCHECK, v8::internal::Isolate::factory(), v8::internal::Handle< T >::is_null(), v8::internal::JSObject::NormalizeElements(), v8::internal::JSArray::SetContent(), v8::internal::DictionaryElementsAccessor::SetLengthWithoutNormalize(), v8::internal::ThrowArrayLengthRangeError(), and v8::internal::Object::ToSmi().

+ Here is the call graph for this function:

◆ Validate()

template<typename ElementsAccessorSubclass , typename ElementsTraitsParam >
virtual void v8::internal::ElementsAccessorBase< ElementsAccessorSubclass, ElementsTraitsParam >::Validate ( Handle< JSObject holder)
inlineprotectedvirtual

Implements v8::internal::ElementsAccessor.

Definition at line 587 of file elements.cc.

587  {
589  ElementsAccessorSubclass::ValidateImpl(holder);
590  }

◆ ValidateContents()

template<typename ElementsAccessorSubclass , typename ElementsTraitsParam >
static void v8::internal::ElementsAccessorBase< ElementsAccessorSubclass, ElementsTraitsParam >::ValidateContents ( Handle< JSObject holder,
int  length 
)
inlinestaticprotected

Definition at line 567 of file elements.cc.

567  {
568  }

◆ ValidateImpl()

template<typename ElementsAccessorSubclass , typename ElementsTraitsParam >
static void v8::internal::ElementsAccessorBase< ElementsAccessorSubclass, ElementsTraitsParam >::ValidateImpl ( Handle< JSObject holder)
inlinestaticprotected

Definition at line 570 of file elements.cc.

570  {
571  Handle<FixedArrayBase> fixed_array_base(holder->elements());
572  if (!fixed_array_base->IsHeapObject()) return;
573  // Arrays that have been shifted in place can't be verified.
574  if (fixed_array_base->IsFiller()) return;
575  int length = 0;
576  if (holder->IsJSArray()) {
577  Object* length_obj = Handle<JSArray>::cast(holder)->length();
578  if (length_obj->IsSmi()) {
579  length = Smi::cast(length_obj)->value();
580  }
581  } else {
582  length = fixed_array_base->length();
583  }
584  ElementsAccessorSubclass::ValidateContents(holder, length);
585  }

References v8::internal::Handle< T >::cast().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: