V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
builtins-typed-array-gen.h
1 // Copyright 2018 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_TYPED_ARRAY_GEN_H_
6 #define V8_BUILTINS_BUILTINS_TYPED_ARRAY_GEN_H_
7 
8 #include "src/code-stub-assembler.h"
9 
10 namespace v8 {
11 namespace internal {
12 
14  public:
16  : CodeStubAssembler(state) {}
17 
18  template <class... TArgs>
19  TNode<JSTypedArray> TypedArraySpeciesCreate(const char* method_name,
20  TNode<Context> context,
21  TNode<JSTypedArray> exemplar,
22  TArgs... args);
23 
24  TNode<JSTypedArray> TypedArraySpeciesCreateByLength(
25  TNode<Context> context, TNode<JSTypedArray> exemplar, TNode<Smi> len,
26  const char* method_name);
27 
28  void GenerateTypedArrayPrototypeIterationMethod(TNode<Context> context,
29  TNode<Object> receiver,
30  const char* method_name,
31  IterationKind iteration_kind);
32 
33  void ConstructByLength(TNode<Context> context, TNode<JSTypedArray> holder,
34  TNode<Object> length, TNode<Smi> element_size);
35  void ConstructByArrayBuffer(TNode<Context> context,
36  TNode<JSTypedArray> holder,
37  TNode<JSArrayBuffer> buffer,
38  TNode<Object> byte_offset, TNode<Object> length,
39  TNode<Smi> element_size);
40  void ConstructByTypedArray(TNode<Context> context, TNode<JSTypedArray> holder,
41  TNode<JSTypedArray> typed_array,
42  TNode<Smi> element_size);
43  void ConstructByArrayLike(TNode<Context> context, TNode<JSTypedArray> holder,
44  TNode<HeapObject> array_like,
45  TNode<Object> initial_length,
46  TNode<Smi> element_size,
47  TNode<JSReceiver> buffer_constructor);
48  void ConstructByIterable(TNode<Context> context, TNode<JSTypedArray> holder,
49  TNode<JSReceiver> iterable,
50  TNode<JSReceiver> iterator_fn,
51  TNode<Smi> element_size);
52 
53  void SetupTypedArray(TNode<JSTypedArray> holder, TNode<Smi> length,
54  TNode<UintPtrT> byte_offset,
55  TNode<UintPtrT> byte_length);
56  void AttachBuffer(TNode<JSTypedArray> holder, TNode<JSArrayBuffer> buffer,
57  TNode<Map> map, TNode<Smi> length,
58  TNode<Number> byte_offset);
59 
60  TNode<Map> LoadMapForType(TNode<JSTypedArray> array);
61  TNode<UintPtrT> CalculateExternalPointer(TNode<UintPtrT> backing_store,
62  TNode<Number> byte_offset);
63  Node* LoadDataPtr(Node* typed_array);
64  TNode<BoolT> ByteLengthIsValid(TNode<Number> byte_length);
65 
66  // Returns true if kind is either UINT8_ELEMENTS or UINT8_CLAMPED_ELEMENTS.
67  TNode<Word32T> IsUint8ElementsKind(TNode<Word32T> kind);
68 
69  // Returns true if kind is either BIGINT64_ELEMENTS or BIGUINT64_ELEMENTS.
70  TNode<Word32T> IsBigInt64ElementsKind(TNode<Word32T> kind);
71 
72  // Returns the byte size of an element for a TypedArray elements kind.
73  TNode<IntPtrT> GetTypedArrayElementSize(TNode<Word32T> elements_kind);
74 
75  TNode<JSArrayBuffer> LoadTypedArrayBuffer(TNode<JSTypedArray> typed_array) {
76  return LoadObjectField<JSArrayBuffer>(typed_array,
77  JSTypedArray::kBufferOffset);
78  }
79 
80  TNode<JSFunction> GetDefaultConstructor(TNode<Context> context,
81  TNode<JSTypedArray> exemplar);
82 
83  TNode<JSTypedArray> TypedArrayCreateByLength(TNode<Context> context,
84  TNode<Object> constructor,
85  TNode<Smi> len,
86  const char* method_name);
87 
88  void ThrowIfLengthLessThan(TNode<Context> context,
89  TNode<JSTypedArray> typed_array,
90  TNode<Smi> min_length);
91 
92  TNode<JSArrayBuffer> GetBuffer(TNode<Context> context,
93  TNode<JSTypedArray> array);
94 
95  TNode<JSTypedArray> ValidateTypedArray(TNode<Context> context,
96  TNode<Object> obj,
97  const char* method_name);
98 
99  // Fast path for setting a TypedArray (source) onto another TypedArray
100  // (target) at an element offset.
101  void SetTypedArraySource(TNode<Context> context, TNode<JSTypedArray> source,
102  TNode<JSTypedArray> target, TNode<IntPtrT> offset,
103  Label* call_runtime, Label* if_source_too_large);
104 
105  void SetJSArraySource(TNode<Context> context, TNode<JSArray> source,
106  TNode<JSTypedArray> target, TNode<IntPtrT> offset,
107  Label* call_runtime, Label* if_source_too_large);
108 
109  void CallCMemmove(TNode<IntPtrT> dest_ptr, TNode<IntPtrT> src_ptr,
110  TNode<IntPtrT> byte_length);
111 
112  void CallCCopyFastNumberJSArrayElementsToTypedArray(
113  TNode<Context> context, TNode<JSArray> source, TNode<JSTypedArray> dest,
114  TNode<IntPtrT> source_length, TNode<IntPtrT> offset);
115 
116  void CallCCopyTypedArrayElementsToTypedArray(TNode<JSTypedArray> source,
117  TNode<JSTypedArray> dest,
118  TNode<IntPtrT> source_length,
119  TNode<IntPtrT> offset);
120 
121  void CallCCopyTypedArrayElementsSlice(TNode<JSTypedArray> source,
122  TNode<JSTypedArray> dest,
123  TNode<IntPtrT> start,
124  TNode<IntPtrT> end);
125 
126  typedef std::function<void(ElementsKind, int, int)> TypedArraySwitchCase;
127 
128  void DispatchTypedArrayByElementsKind(
129  TNode<Word32T> elements_kind, const TypedArraySwitchCase& case_function);
130 };
131 
132 } // namespace internal
133 } // namespace v8
134 
135 #endif // V8_BUILTINS_BUILTINS_TYPED_ARRAY_GEN_H_
Definition: libplatform.h:13