v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
js-collection-iterator.h
Go to the documentation of this file.
1
// Copyright 2019 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_COLLECTION_ITERATOR_H_
6
#define V8_OBJECTS_JS_COLLECTION_ITERATOR_H_
7
8
#include "
src/common/globals.h
"
9
#include "
src/objects/js-objects.h
"
10
#include "
src/objects/objects.h
"
11
#include "
src/objects/smi.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
#include "torque-generated/src/objects/js-collection-iterator-tq.inc"
20
21
class
JSCollectionIterator
22
:
public
TorqueGeneratedJSCollectionIterator<JSCollectionIterator,
23
JSObject> {
24
public
:
25
void
JSCollectionIteratorPrint
(std::ostream& os,
const
char
* name);
26
27
TQ_OBJECT_CONSTRUCTORS
(
JSCollectionIterator
)
28
};
29
30
// OrderedHashTableIterator is an iterator that iterates over the keys and
31
// values of an OrderedHashTable.
32
//
33
// The iterator has a reference to the underlying OrderedHashTable data,
34
// [table], as well as the current [index] the iterator is at.
35
//
36
// When the OrderedHashTable is rehashed it adds a reference from the old table
37
// to the new table as well as storing enough data about the changes so that the
38
// iterator [index] can be adjusted accordingly.
39
//
40
// When the [Next] result from the iterator is requested, the iterator checks if
41
// there is a newer table that it needs to transition to.
42
template
<
class
Derived,
class
TableType>
43
class
OrderedHashTableIterator
:
public
JSCollectionIterator
{
44
public
:
45
// Whether the iterator has more elements. This needs to be called before
46
// calling |CurrentKey| and/or |CurrentValue|.
47
bool
HasMore
();
48
49
// Move the index forward one.
50
void
MoveNext
() { set_index(
Smi::FromInt
(
Smi::ToInt
(
index
()) + 1)); }
51
52
// Returns the current key of the iterator. This should only be called when
53
// |HasMore| returns true.
54
inline
Tagged<Object>
CurrentKey
();
55
56
private
:
57
// Transitions the iterator to the non obsolete backing store. This is a NOP
58
// if the [table] is not obsolete.
59
void
Transition
();
60
61
OBJECT_CONSTRUCTORS
(
OrderedHashTableIterator
,
JSCollectionIterator
);
62
};
63
64
}
// namespace internal
65
}
// namespace v8
66
67
#include "
src/objects/object-macros-undef.h
"
68
69
#endif
// V8_OBJECTS_JS_COLLECTION_ITERATOR_H_
v8::internal::JSCollectionIterator
Definition
js-collection-iterator.h:23
v8::internal::JSCollectionIterator::JSCollectionIteratorPrint
void JSCollectionIteratorPrint(std::ostream &os, const char *name)
v8::internal::OrderedHashTableIterator
Definition
js-collection-iterator.h:43
v8::internal::OrderedHashTableIterator::CurrentKey
Tagged< Object > CurrentKey()
Definition
ordered-hash-table-inl.h:190
v8::internal::OrderedHashTableIterator::MoveNext
void MoveNext()
Definition
js-collection-iterator.h:50
v8::internal::OrderedHashTableIterator::HasMore
bool HasMore()
Definition
ordered-hash-table.cc:1490
v8::internal::OrderedHashTableIterator::Transition
void Transition()
Definition
ordered-hash-table.cc:1457
v8::internal::OrderedHashTableIterator::OBJECT_CONSTRUCTORS
OBJECT_CONSTRUCTORS(OrderedHashTableIterator, JSCollectionIterator)
v8::internal::Smi::ToInt
static constexpr int ToInt(const Tagged< Object > object)
Definition
smi.h:33
v8::internal::Smi::FromInt
static constexpr Tagged< Smi > FromInt(int value)
Definition
smi.h:38
v8::internal::Tagged
Definition
waiter-queue-node.h:21
globals.h
js-objects.h
v8::internal::index
int index
Definition
heap-snapshot-generator.cc:1670
v8::internal::internal
internal
Definition
wasm-objects-inl.h:458
v8
Definition
api-arguments-inl.h:19
object-macros-undef.h
object-macros.h
TQ_OBJECT_CONSTRUCTORS
#define TQ_OBJECT_CONSTRUCTORS(Type)
Definition
object-macros.h:984
objects.h
smi.h
src
objects
js-collection-iterator.h
Generated on Sun Apr 6 2025 21:08:55 for v8 by
1.12.0