v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
builtins-iterator-gen.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_BUILTINS_BUILTINS_ITERATOR_GEN_H_
6#define V8_BUILTINS_BUILTINS_ITERATOR_GEN_H_
7
10
11namespace v8 {
12namespace internal {
13
14class GrowableFixedArray;
15
17 public:
20
21 using IteratorRecord = TorqueStructIteratorRecord;
22
23 // Returns object[Symbol.iterator].
25
26 // https://tc39.github.io/ecma262/#sec-getiterator --- never used for
27 // @@asyncIterator.
31
32 // https://tc39.github.io/ecma262/#sec-iteratorstep
33 // If the iterator is done, goto {if_done}, otherwise returns an iterator
34 // result.
35 // `fast_iterator_result_map` refers to the map for the JSIteratorResult
36 // object, loaded from the native context.
38 TNode<Context> context, const IteratorRecord& iterator, Label* if_done,
39 std::optional<TNode<Map>> fast_iterator_result_map = std::nullopt);
41 TNode<Context> context, const IteratorRecord& iterator,
42 std::optional<TNode<Map>> fast_iterator_result_map, Label* if_done) {
43 return IteratorStep(context, iterator, if_done, fast_iterator_result_map);
44 }
45
46 // https://tc39.es/ecma262/#sec-iteratorcomplete
48 TNode<Context> context, const TNode<JSAnyNotSmi> iterator, Label* if_done,
49 std::optional<TNode<Map>> fast_iterator_result_map = std::nullopt);
51 const TNode<JSAnyNotSmi> iterator,
52 std::optional<TNode<Map>> fast_iterator_result_map,
53 Label* if_done) {
54 return IteratorComplete(context, iterator, if_done,
55 fast_iterator_result_map);
56 }
57
58 // https://tc39.github.io/ecma262/#sec-iteratorvalue
59 // Return the `value` field from an iterator.
60 // `fast_iterator_result_map` refers to the map for the JSIteratorResult
61 // object, loaded from the native context.
64 std::optional<TNode<Map>> fast_iterator_result_map = std::nullopt);
65
66 void Iterate(TNode<Context> context, TNode<JSAny> iterable,
67 std::function<void(TNode<Object>)> func,
68 std::initializer_list<compiler::CodeAssemblerVariable*>
69 merged_variables = {});
70 void Iterate(TNode<Context> context, TNode<JSAny> iterable,
71 TNode<Object> iterable_fn,
72 std::function<void(TNode<Object>)> func,
73 std::initializer_list<compiler::CodeAssemblerVariable*>
74 merged_variables = {});
75
76 // #sec-iterabletolist
77 // Build a JSArray by iterating over {iterable} using {iterator_fn},
78 // following the ECMAscript operation with the same name.
79 TNode<JSArray> IterableToList(TNode<Context> context, TNode<JSAny> iterable,
80 TNode<Object> iterator_fn);
81
82 TNode<FixedArray> IterableToFixedArray(TNode<Context> context,
83 TNode<JSAny> iterable,
84 TNode<Object> iterator_fn);
85
86 void FillFixedArrayFromIterable(TNode<Context> context, TNode<JSAny> iterable,
87 TNode<Object> iterator_fn,
88 GrowableFixedArray* values);
89
90 // Currently at https://tc39.github.io/proposal-intl-list-format/
91 // #sec-createstringlistfromiterable
92 TNode<FixedArray> StringListFromIterable(TNode<Context> context,
93 TNode<JSAny> iterable);
94
95 void FastIterableToList(TNode<Context> context, TNode<JSAny> iterable,
96 TVariable<JSArray>* var_result, Label* slow);
97 TNode<JSArray> FastIterableToList(TNode<Context> context,
98 TNode<JSAny> iterable, Label* slow);
99};
100
101} // namespace internal
102} // namespace v8
103
104#endif // V8_BUILTINS_BUILTINS_ITERATOR_GEN_H_
void IteratorComplete(TNode< Context > context, const TNode< JSAnyNotSmi > iterator, std::optional< TNode< Map > > fast_iterator_result_map, Label *if_done)
TNode< JSReceiver > IteratorStep(TNode< Context > context, const IteratorRecord &iterator, std::optional< TNode< Map > > fast_iterator_result_map, Label *if_done)
IteratorBuiltinsAssembler(compiler::CodeAssemblerState *state)
TNode< JSReceiver > IteratorStep(TNode< Context > context, const IteratorRecord &iterator, Label *if_done, std::optional< TNode< Map > > fast_iterator_result_map=std::nullopt)
void Iterate(TNode< Context > context, TNode< JSAny > iterable, std::function< void(TNode< Object >)> func, std::initializer_list< compiler::CodeAssemblerVariable * > merged_variables={})
TNode< JSArray > IterableToList(TNode< Context > context, TNode< JSAny > iterable, TNode< Object > iterator_fn)
void FastIterableToList(TNode< Context > context, TNode< JSAny > iterable, TVariable< JSArray > *var_result, Label *slow)
TNode< FixedArray > IterableToFixedArray(TNode< Context > context, TNode< JSAny > iterable, TNode< Object > iterator_fn)
void IteratorComplete(TNode< Context > context, const TNode< JSAnyNotSmi > iterator, Label *if_done, std::optional< TNode< Map > > fast_iterator_result_map=std::nullopt)
TNode< JSAny > IteratorValue(TNode< Context > context, TNode< JSReceiver > result, std::optional< TNode< Map > > fast_iterator_result_map=std::nullopt)
void FillFixedArrayFromIterable(TNode< Context > context, TNode< JSAny > iterable, TNode< Object > iterator_fn, GrowableFixedArray *values)
TNode< JSAny > GetIteratorMethod(TNode< Context > context, TNode< JSAny >)
TNode< FixedArray > StringListFromIterable(TNode< Context > context, TNode< JSAny > iterable)
IteratorRecord GetIterator(TNode< Context > context, TNode< JSAny > object)
ZoneVector< RpoNumber > & result
compiler::TypedCodeAssemblerVariable< T > TVariable
Symbol method