v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
js-array-inl.h
Go to the documentation of this file.
1// Copyright 2017 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_JS_ARRAY_INL_H_
6#define V8_OBJECTS_JS_ARRAY_INL_H_
7
9// Include the non-inl header before the rest of the headers.
10
11#include "src/objects/objects-inl.h" // Needed for write barriers
12
13// Has to be the last include (doesn't have include guards):
15
16namespace v8 {
17namespace internal {
18
19#include "torque-generated/src/objects/js-array-tq-inl.inc"
20
22TQ_OBJECT_CONSTRUCTORS_IMPL(JSArrayIterator)
23TQ_OBJECT_CONSTRUCTORS_IMPL(TemplateLiteralObject)
24
26 return TaggedField<Number, kLengthOffset>::load(cage_base, *this);
27}
28
30 // Note the relaxed atomic store.
32 CONDITIONAL_WRITE_BARRIER(*this, kLengthOffset, value, mode);
33}
34
39
41 // Don't need a write barrier for a Smi.
43}
44
48
51 EnsureCanContainElements(array, storage, storage->length(),
53#ifdef DEBUG
55 Tagged<Map> map = storage->map();
56 if (map == roots.fixed_double_array_map()) {
57 DCHECK(IsDoubleElementsKind(array->GetElementsKind()));
58 } else {
59 DCHECK_NE(map, roots.fixed_double_array_map());
60 if (IsSmiElementsKind(array->GetElementsKind())) {
61 auto elems = Cast<FixedArray>(storage);
62 Tagged<Object> the_hole = roots.the_hole_value();
63 for (int i = 0; i < elems->length(); i++) {
64 Tagged<Object> candidate = elems->get(i);
65 DCHECK(IsSmi(candidate) || candidate == the_hole);
66 }
67 } else {
68 DCHECK(IsObjectElementsKind(array->GetElementsKind()));
69 }
70 }
71#endif // DEBUG
72 array->set_elements(*storage);
73 array->set_length(Smi::FromInt(storage->length()));
74}
75
77 return map()->prototype() == *isolate->initial_array_prototype();
78}
79
80SMI_ACCESSORS(JSArrayIterator, raw_kind, kKindOffset)
81
83 return static_cast<IterationKind>(raw_kind());
84}
85
87 set_raw_kind(static_cast<int>(kind));
88}
89
90} // namespace internal
91} // namespace v8
92
94
95#endif // V8_OBJECTS_JS_ARRAY_INL_H_
Builtins::Kind kind
Definition builtins.cc:40
void set_kind(IterationKind kind)
IterationKind kind() const
bool SetLengthWouldNormalize(uint32_t new_length)
Definition objects.cc:4891
void set_length(Tagged< Number > value, ReleaseStoreTag tag, WriteBarrierMode mode=UPDATE_WRITE_BARRIER)=delete
Tagged< Number > length(PtrComprCageBase cage_base, AcquireLoadTag tag) const =delete
static void SetContent(DirectHandle< JSArray > array, DirectHandle< FixedArrayBase > storage)
bool HasArrayPrototype(Isolate *isolate)
static constexpr uint32_t kMaxFastArrayLength
Definition js-array.h:136
static constexpr Tagged< Smi > FromInt(int value)
Definition smi.h:38
static PtrType load(Tagged< HeapObject > host, int offset=0)
static void Relaxed_Store(Tagged< HeapObject > host, PtrType value)
static PtrType Relaxed_Load(Tagged< HeapObject > host, int offset=0)
std::map< const std::string, const std::string > map
@ ALLOW_COPIED_DOUBLE_ELEMENTS
Definition objects.h:874
@ SKIP_WRITE_BARRIER
Definition objects.h:52
ReadOnlyRoots GetReadOnlyRoots()
Definition roots-inl.h:86
Tagged(T object) -> Tagged< T >
constexpr bool IsSmiElementsKind(ElementsKind kind)
V8_INLINE constexpr bool IsSmi(TaggedImpl< kRefType, StorageType > obj)
Definition objects.h:665
constexpr bool IsObjectElementsKind(ElementsKind kind)
constexpr bool IsDoubleElementsKind(ElementsKind kind)
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
Definition casting.h:150
#define TQ_OBJECT_CONSTRUCTORS_IMPL(Type)
#define SMI_ACCESSORS(holder, name, offset)
#define CONDITIONAL_WRITE_BARRIER(object, offset, value, mode)
#define DEF_GETTER(Camel, Lower, Bit)
#define DCHECK_NE(v1, v2)
Definition logging.h:486
#define DCHECK(condition)
Definition logging.h:482