v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
builtins-array-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_ARRAY_GEN_H_
6#define V8_BUILTINS_BUILTINS_ARRAY_GEN_H_
7
8#include <optional>
9
10#include "src/codegen/code-factory.h" // for enum AllocationSiteOverrideMode
12
13namespace v8 {
14namespace internal {
15
17 public:
19
21 std::function<void(ArrayBuiltinsAssembler* masm)>;
22
23 using CallResultProcessor = std::function<TNode<JSAny>(
25
27
28 // See tc39.github.io/ecma262/#sec-%typedarray%.prototype.map.
30
32 TNode<FixedArray> fixed_array, TNode<IntPtrT> length, TNode<String> sep,
33 TNode<String> dest) {
35 ExternalReference::jsarray_array_join_concat_to_sequential_string());
36 TNode<ExternalReference> isolate_ptr =
39 CallCFunction(func,
40 MachineType::AnyTagged(), // <return> String
41 std::make_pair(MachineType::Pointer(), isolate_ptr),
42 std::make_pair(MachineType::AnyTagged(), fixed_array),
43 std::make_pair(MachineType::IntPtr(), length),
44 std::make_pair(MachineType::AnyTagged(), sep),
45 std::make_pair(MachineType::AnyTagged(), dest)));
46 }
47
48 protected:
52 TNode<JSReceiver> o() { return o_; }
53 TNode<UintPtrT> len() { return len_; }
56 TNode<UintPtrT> k() { return k_.value(); }
57 TNode<JSAny> a() { return a_.value(); }
58
60
66
68 const char* name, const BuiltinResultGenerator& generator,
69 const CallResultProcessor& processor,
71
73 const Callable& callable, TNode<Context> context,
74 TNode<JSFunction> target, TNode<HeapObject> allocation_site_or_undefined,
76
80 std::optional<TNode<AllocationSite>> allocation_site = std::nullopt);
81
85 std::optional<TNode<AllocationSite>> allocation_site);
86
90 std::optional<TNode<AllocationSite>> allocation_site);
91
93 TNode<JSAnyNotSmi> array_function,
94 TNode<Map> array_map, TNode<Object> array_size,
95 TNode<HeapObject> allocation_site,
96 ElementsKind elements_kind, AllocationSiteMode mode);
102 TNode<Context> context, TNode<JSFunction> target,
104 TNode<HeapObject> maybe_allocation_site);
105
106 private:
108 const CallResultProcessor& processor,
110 TNode<JSTypedArray> typed_array);
111
120 const char* name_ = nullptr;
125};
126
128 public:
146
164
179};
180
181} // namespace internal
182} // namespace v8
183
184#endif // V8_BUILTINS_BUILTINS_ARRAY_GEN_H_
Builtins::Kind kind
Definition builtins.cc:40
void GenerateArrayNArgumentsConstructor(TNode< Context > context, TNode< JSFunction > target, TNode< Object > new_target, TNode< Int32T > argc, TNode< HeapObject > maybe_allocation_site)
void ReturnFromBuiltin(TNode< Object > value)
TNode< String > CallJSArrayArrayJoinConcatToSequentialString(TNode< FixedArray > fixed_array, TNode< IntPtrT > length, TNode< String > sep, TNode< String > dest)
std::function< void(ArrayBuiltinsAssembler *masm)> BuiltinResultGenerator
ArrayBuiltinsAssembler(compiler::CodeAssemblerState *state)
TNode< JSAny > TypedArrayMapProcessor(TNode< Object > k_value, TNode< UintPtrT > k)
void InitIteratingArrayBuiltinBody(TNode< Context > context, TNode< JSAny > receiver, TNode< Object > callbackfn, TNode< JSAny > this_arg, TNode< IntPtrT > argc)
void GenerateIteratingTypedArrayBuiltinBody(const char *name, const BuiltinResultGenerator &generator, const CallResultProcessor &processor, ForEachDirection direction=ForEachDirection::kForward)
void GenerateDispatchToArrayStub(TNode< Context > context, TNode< JSFunction > target, TNode< Int32T > argc, AllocationSiteOverrideMode mode, std::optional< TNode< AllocationSite > > allocation_site=std::nullopt)
void GenerateConstructor(TNode< Context > context, TNode< JSAnyNotSmi > array_function, TNode< Map > array_map, TNode< Object > array_size, TNode< HeapObject > allocation_site, ElementsKind elements_kind, AllocationSiteMode mode)
void CreateArrayDispatchSingleArgument(TNode< Context > context, TNode< JSFunction > target, TNode< Int32T > argc, AllocationSiteOverrideMode mode, std::optional< TNode< AllocationSite > > allocation_site)
void GenerateArraySingleArgumentConstructor(ElementsKind kind, AllocationSiteOverrideMode mode)
void TailCallArrayConstructorStub(const Callable &callable, TNode< Context > context, TNode< JSFunction > target, TNode< HeapObject > allocation_site_or_undefined, TNode< Int32T > argc)
std::function< TNode< JSAny >( ArrayBuiltinsAssembler *masm, TNode< Object > k_value, TNode< UintPtrT > k)> CallResultProcessor
void GenerateArrayNoArgumentConstructor(ElementsKind kind, AllocationSiteOverrideMode mode)
void CreateArrayDispatchNoArgument(TNode< Context > context, TNode< JSFunction > target, TNode< Int32T > argc, AllocationSiteOverrideMode mode, std::optional< TNode< AllocationSite > > allocation_site)
void VisitAllTypedArrayElements(TNode< JSArrayBuffer > array_buffer, const CallResultProcessor &processor, ForEachDirection direction, TNode< JSTypedArray > typed_array)
static V8_EXPORT_PRIVATE ExternalReference isolate_address()
static constexpr MachineType Pointer()
static constexpr MachineType AnyTagged()
static constexpr MachineType IntPtr()
TNode< T > UncheckedCast(Node *value)
TNode< ExternalReference > ExternalConstant(ExternalReference address)
Node * CallCFunction(Node *function, std::optional< MachineType > return_type, CArgs... cargs)
DirectHandle< Object > new_target
Definition execution.cc:75
ArrayReduceDirection direction