V8 Project
v8::internal::FastElementsAccessor< FastElementsAccessorSubclass, KindTraits > Class Template Reference
+ Inheritance diagram for v8::internal::FastElementsAccessor< FastElementsAccessorSubclass, KindTraits >:
+ Collaboration diagram for v8::internal::FastElementsAccessor< FastElementsAccessorSubclass, KindTraits >:

Public Member Functions

 FastElementsAccessor (const char *name)
 
- 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)
 

Protected Types

typedef KindTraits::BackingStore BackingStore
 
- Protected Types inherited from v8::internal::ElementsAccessorBase< FastElementsAccessorSubclass, KindTraits >
typedef KindTraits ElementsTraits
 
typedef ElementsTraitsParam::BackingStore BackingStore
 

Protected Member Functions

virtual MaybeHandle< ObjectDelete (Handle< JSObject > obj, uint32_t key, JSReceiver::DeleteMode mode) FINAL OVERRIDE
 
- Protected Member Functions inherited from v8::internal::ElementsAccessorBase< FastElementsAccessorSubclass, KindTraits >
 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 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 Handle< ObjectSetLengthWithoutNormalize (Handle< FixedArrayBase > backing_store, Handle< JSArray > array, Handle< Object > length_object, uint32_t length)
 
static Handle< ObjectDeleteCommon (Handle< JSObject > obj, uint32_t key, JSReceiver::DeleteMode mode)
 
static bool HasElementImpl (Handle< Object > receiver, Handle< JSObject > holder, uint32_t key, Handle< FixedArrayBase > backing_store)
 
static void ValidateContents (Handle< JSObject > holder, int length)
 
- Static Protected Member Functions inherited from v8::internal::ElementsAccessorBase< FastElementsAccessorSubclass, KindTraits >
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)
 

Friends

class ElementsAccessorBase< FastElementsAccessorSubclass, KindTraits >
 
class SloppyArgumentsElementsAccessor
 

Additional Inherited Members

- 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 FastElementsAccessorSubclass, typename KindTraits>
class v8::internal::FastElementsAccessor< FastElementsAccessorSubclass, KindTraits >

Definition at line 873 of file elements.cc.

Member Typedef Documentation

◆ BackingStore

template<typename FastElementsAccessorSubclass , typename KindTraits >
typedef KindTraits::BackingStore v8::internal::FastElementsAccessor< FastElementsAccessorSubclass, KindTraits >::BackingStore
protected

Definition at line 883 of file elements.cc.

Constructor & Destructor Documentation

◆ FastElementsAccessor()

template<typename FastElementsAccessorSubclass , typename KindTraits >
v8::internal::FastElementsAccessor< FastElementsAccessorSubclass, KindTraits >::FastElementsAccessor ( const char *  name)
inlineexplicit

Definition at line 876 of file elements.cc.

877  : ElementsAccessorBase<FastElementsAccessorSubclass,
878  KindTraits>(name) {}
const char * name() const
Definition: elements.h:24

Member Function Documentation

◆ Delete()

template<typename FastElementsAccessorSubclass , typename KindTraits >
virtual MaybeHandle<Object> v8::internal::FastElementsAccessor< FastElementsAccessorSubclass, KindTraits >::Delete ( Handle< JSObject obj,
uint32_t  key,
JSReceiver::DeleteMode  mode 
)
inlineprotectedvirtual

Implements v8::internal::ElementsAccessorBase< FastElementsAccessorSubclass, KindTraits >.

Definition at line 995 of file elements.cc.

998  {
999  return DeleteCommon(obj, key, mode);
1000  }
static Handle< Object > DeleteCommon(Handle< JSObject > obj, uint32_t key, JSReceiver::DeleteMode mode)
Definition: elements.cc:936
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

References v8::internal::FastElementsAccessor< FastElementsAccessorSubclass, KindTraits >::DeleteCommon(), and mode().

+ Here is the call graph for this function:

◆ DeleteCommon()

template<typename FastElementsAccessorSubclass , typename KindTraits >
static Handle<Object> v8::internal::FastElementsAccessor< FastElementsAccessorSubclass, KindTraits >::DeleteCommon ( Handle< JSObject obj,
uint32_t  key,
JSReceiver::DeleteMode  mode 
)
inlinestaticprotected

Definition at line 936 of file elements.cc.

938  {
939  DCHECK(obj->HasFastSmiOrObjectElements() ||
940  obj->HasFastDoubleElements() ||
941  obj->HasFastArgumentsElements());
942  Isolate* isolate = obj->GetIsolate();
943  Heap* heap = obj->GetHeap();
944  Handle<FixedArrayBase> elements(obj->elements());
945  if (*elements == heap->empty_fixed_array()) {
946  return isolate->factory()->true_value();
947  }
948  Handle<BackingStore> backing_store = Handle<BackingStore>::cast(elements);
949  bool is_sloppy_arguments_elements_map =
950  backing_store->map() == heap->sloppy_arguments_elements_map();
951  if (is_sloppy_arguments_elements_map) {
952  backing_store = handle(
953  BackingStore::cast(Handle<FixedArray>::cast(backing_store)->get(1)),
954  isolate);
955  }
956  uint32_t length = static_cast<uint32_t>(
957  obj->IsJSArray()
958  ? Smi::cast(Handle<JSArray>::cast(obj)->length())->value()
959  : backing_store->length());
960  if (key < length) {
961  if (!is_sloppy_arguments_elements_map) {
962  ElementsKind kind = KindTraits::Kind;
965  }
966  if (IsFastSmiOrObjectElementsKind(KindTraits::Kind)) {
967  Handle<Object> writable = JSObject::EnsureWritableFastElements(obj);
968  backing_store = Handle<BackingStore>::cast(writable);
969  }
970  }
971  backing_store->set_the_hole(key);
972  // If an old space backing store is larger than a certain size and
973  // has too few used values, normalize it.
974  // To avoid doing the check on every delete we require at least
975  // one adjacent hole to the value being deleted.
976  const int kMinLengthForSparsenessCheck = 64;
977  if (backing_store->length() >= kMinLengthForSparsenessCheck &&
978  !heap->InNewSpace(*backing_store) &&
979  ((key > 0 && backing_store->is_the_hole(key - 1)) ||
980  (key + 1 < length && backing_store->is_the_hole(key + 1)))) {
981  int num_used = 0;
982  for (int i = 0; i < backing_store->length(); ++i) {
983  if (!backing_store->is_the_hole(i)) ++num_used;
984  // Bail out early if more than 1/4 is used.
985  if (4 * num_used > backing_store->length()) break;
986  }
987  if (4 * num_used <= backing_store->length()) {
989  }
990  }
991  }
992  return isolate->factory()->true_value();
993  }
static Handle< T > cast(Handle< S > that)
Definition: handles.h:116
static void TransitionElementsKind(Handle< JSObject > object, ElementsKind to_kind)
Definition: objects.cc:12706
static Handle< FixedArray > EnsureWritableFastElements(Handle< JSObject > object)
Definition: objects.cc:383
static Handle< SeededNumberDictionary > NormalizeElements(Handle< JSObject > object)
Definition: objects.cc:4459
#define DCHECK(condition)
Definition: logging.h:205
bool IsFastSmiOrObjectElementsKind(ElementsKind kind)
Handle< T > handle(T *t, Isolate *isolate)
Definition: handles.h:146
bool IsFastPackedElementsKind(ElementsKind kind)
ElementsKind GetHoleyElementsKind(ElementsKind packed_kind)

References v8::internal::Handle< T >::cast(), DCHECK, v8::internal::JSObject::EnsureWritableFastElements(), v8::internal::Isolate::factory(), v8::internal::GetHoleyElementsKind(), v8::internal::handle(), v8::internal::Heap::InNewSpace(), v8::internal::IsFastPackedElementsKind(), v8::internal::IsFastSmiOrObjectElementsKind(), v8::internal::ElementsAccessorBase< FastElementsAccessorSubclass, KindTraits >::kind(), v8::internal::JSObject::NormalizeElements(), and v8::internal::JSObject::TransitionElementsKind().

Referenced by v8::internal::FastElementsAccessor< FastElementsAccessorSubclass, KindTraits >::Delete(), and v8::internal::SloppyArgumentsElementsAccessor::Delete().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HasElementImpl()

template<typename FastElementsAccessorSubclass , typename KindTraits >
static bool v8::internal::FastElementsAccessor< FastElementsAccessorSubclass, KindTraits >::HasElementImpl ( Handle< Object receiver,
Handle< JSObject holder,
uint32_t  key,
Handle< FixedArrayBase backing_store 
)
inlinestaticprotected

Definition at line 1002 of file elements.cc.

1006  {
1007  if (key >= static_cast<uint32_t>(backing_store->length())) {
1008  return false;
1009  }
1010  return !Handle<BackingStore>::cast(backing_store)->is_the_hole(key);
1011  }

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

+ Here is the call graph for this function:

◆ SetLengthWithoutNormalize()

template<typename FastElementsAccessorSubclass , typename KindTraits >
static Handle<Object> v8::internal::FastElementsAccessor< FastElementsAccessorSubclass, KindTraits >::SetLengthWithoutNormalize ( Handle< FixedArrayBase backing_store,
Handle< JSArray array,
Handle< Object length_object,
uint32_t  length 
)
inlinestaticprotected

Definition at line 886 of file elements.cc.

890  {
891  Isolate* isolate = array->GetIsolate();
892  uint32_t old_capacity = backing_store->length();
893  Handle<Object> old_length(array->length(), isolate);
894  bool same_or_smaller_size = old_length->IsSmi() &&
895  static_cast<uint32_t>(Handle<Smi>::cast(old_length)->value()) >= length;
896  ElementsKind kind = array->GetElementsKind();
897 
898  if (!same_or_smaller_size && IsFastElementsKind(kind) &&
902  }
903 
904  // Check whether the backing store should be shrunk.
905  if (length <= old_capacity) {
906  if (array->HasFastSmiOrObjectElements()) {
907  backing_store = JSObject::EnsureWritableFastElements(array);
908  }
909  if (2 * length <= old_capacity) {
910  // If more than half the elements won't be used, trim the array.
911  if (length == 0) {
912  array->initialize_elements();
913  } else {
914  isolate->heap()->RightTrimFixedArray<Heap::FROM_MUTATOR>(
915  *backing_store, old_capacity - length);
916  }
917  } else {
918  // Otherwise, fill the unused tail with holes.
919  int old_length = FastD2IChecked(array->length()->Number());
920  for (int i = length; i < old_length; i++) {
921  Handle<BackingStore>::cast(backing_store)->set_the_hole(i);
922  }
923  }
924  return length_object;
925  }
926 
927  // Check whether the backing store should be expanded.
929  uint32_t new_capacity = length > min ? length : min;
930  FastElementsAccessorSubclass::SetFastElementsCapacityAndLength(
931  array, new_capacity, length);
933  return length_object;
934  }
static int NewElementsCapacity(int old_capacity)
Definition: objects.h:1911
static void ValidateElements(Handle< JSObject > object)
Definition: objects-inl.h:1561
bool IsFastHoleyElementsKind(ElementsKind kind)
static int min(int a, int b)
Definition: liveedit.cc:273
bool IsFastElementsKind(ElementsKind kind)
int FastD2IChecked(double x)
Definition: conversions.h:46

References v8::internal::Handle< T >::cast(), v8::internal::JSObject::EnsureWritableFastElements(), v8::internal::FastD2IChecked(), v8::internal::Heap::FROM_MUTATOR, v8::internal::GetHoleyElementsKind(), v8::internal::Isolate::heap(), v8::internal::IsFastElementsKind(), v8::internal::IsFastHoleyElementsKind(), v8::internal::ElementsAccessorBase< FastElementsAccessorSubclass, KindTraits >::kind(), v8::internal::min(), v8::internal::JSObject::NewElementsCapacity(), v8::internal::Heap::RightTrimFixedArray(), v8::internal::JSObject::TransitionElementsKind(), and v8::internal::JSObject::ValidateElements().

+ Here is the call graph for this function:

◆ ValidateContents()

template<typename FastElementsAccessorSubclass , typename KindTraits >
static void v8::internal::FastElementsAccessor< FastElementsAccessorSubclass, KindTraits >::ValidateContents ( Handle< JSObject holder,
int  length 
)
inlinestaticprotected

Definition at line 1013 of file elements.cc.

1013  {
1014 #if DEBUG
1015  Isolate* isolate = holder->GetIsolate();
1016  HandleScope scope(isolate);
1017  Handle<FixedArrayBase> elements(holder->elements(), isolate);
1018  Map* map = elements->map();
1019  DCHECK((IsFastSmiOrObjectElementsKind(KindTraits::Kind) &&
1020  (map == isolate->heap()->fixed_array_map() ||
1021  map == isolate->heap()->fixed_cow_array_map())) ||
1022  (IsFastDoubleElementsKind(KindTraits::Kind) ==
1023  ((map == isolate->heap()->fixed_array_map() && length == 0) ||
1024  map == isolate->heap()->fixed_double_array_map())));
1025  DisallowHeapAllocation no_gc;
1026  for (int i = 0; i < length; i++) {
1027  HandleScope scope(isolate);
1028  Handle<BackingStore> backing_store = Handle<BackingStore>::cast(elements);
1029  DCHECK((!IsFastSmiElementsKind(KindTraits::Kind) ||
1030  BackingStore::get(backing_store, i)->IsSmi()) ||
1031  (IsFastHoleyElementsKind(KindTraits::Kind) ==
1032  backing_store->is_the_hole(i)));
1033  }
1034 #endif
1035  }
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 map
PerThreadAssertScopeDebugOnly< HEAP_ALLOCATION_ASSERT, false > DisallowHeapAllocation
Definition: assert-scope.h:110
bool IsFastDoubleElementsKind(ElementsKind kind)
bool IsFastSmiElementsKind(ElementsKind kind)

References v8::internal::Handle< T >::cast(), DCHECK, v8::internal::Isolate::heap(), v8::internal::IsFastDoubleElementsKind(), v8::internal::IsFastHoleyElementsKind(), v8::internal::IsFastSmiElementsKind(), v8::internal::IsFastSmiOrObjectElementsKind(), and map.

+ Here is the call graph for this function:

Friends And Related Function Documentation

◆ ElementsAccessorBase< FastElementsAccessorSubclass, KindTraits >

template<typename FastElementsAccessorSubclass , typename KindTraits >
friend class ElementsAccessorBase< FastElementsAccessorSubclass, KindTraits >
friend

Definition at line 876 of file elements.cc.

◆ SloppyArgumentsElementsAccessor

template<typename FastElementsAccessorSubclass , typename KindTraits >
friend class SloppyArgumentsElementsAccessor
friend

Definition at line 881 of file elements.cc.


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