LCOV - code coverage report
Current view: top level - src/builtins - builtins-array-gen.h (source / functions) Hit Total Coverage
Test: app.info Lines: 6 6 100.0 %
Date: 2019-04-17 Functions: 2 2 100.0 %

          Line data    Source code
       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 "src/code-stub-assembler.h"
       9             : 
      10             : namespace v8 {
      11             : namespace internal {
      12             : 
      13        3136 : class ArrayBuiltinsAssembler : public CodeStubAssembler {
      14             :  public:
      15             :   explicit ArrayBuiltinsAssembler(compiler::CodeAssemblerState* state);
      16             : 
      17             :   typedef std::function<void(ArrayBuiltinsAssembler* masm)>
      18             :       BuiltinResultGenerator;
      19             : 
      20             :   typedef std::function<Node*(ArrayBuiltinsAssembler* masm, Node* k_value,
      21             :                               Node* k)>
      22             :       CallResultProcessor;
      23             : 
      24             :   typedef std::function<void(ArrayBuiltinsAssembler* masm)> PostLoopAction;
      25             : 
      26             :   void FindResultGenerator();
      27             : 
      28             :   Node* FindProcessor(Node* k_value, Node* k);
      29             : 
      30             :   void FindIndexResultGenerator();
      31             : 
      32             :   Node* FindIndexProcessor(Node* k_value, Node* k);
      33             : 
      34             :   void ForEachResultGenerator();
      35             : 
      36             :   Node* ForEachProcessor(Node* k_value, Node* k);
      37             : 
      38             :   void SomeResultGenerator();
      39             : 
      40             :   Node* SomeProcessor(Node* k_value, Node* k);
      41             : 
      42             :   void EveryResultGenerator();
      43             : 
      44             :   Node* EveryProcessor(Node* k_value, Node* k);
      45             : 
      46             :   void ReduceResultGenerator();
      47             : 
      48             :   Node* ReduceProcessor(Node* k_value, Node* k);
      49             : 
      50             :   void ReducePostLoopAction();
      51             : 
      52             :   void TypedArrayMapResultGenerator();
      53             : 
      54             :   Node* SpecCompliantMapProcessor(Node* k_value, Node* k);
      55             : 
      56             :   Node* FastMapProcessor(Node* k_value, Node* k);
      57             : 
      58             :   // See tc39.github.io/ecma262/#sec-%typedarray%.prototype.map.
      59             :   Node* TypedArrayMapProcessor(Node* k_value, Node* k);
      60             : 
      61             :   void NullPostLoopAction();
      62             : 
      63             :   // Uses memset to effectively initialize the given FixedArray with Smi zeroes.
      64             :   void FillFixedArrayWithSmiZero(TNode<FixedArray> array,
      65             :                                  TNode<Smi> smi_length);
      66             : 
      67         224 :   TNode<String> CallJSArrayArrayJoinConcatToSequentialString(
      68             :       TNode<FixedArray> fixed_array, TNode<IntPtrT> length, TNode<String> sep,
      69             :       TNode<String> dest) {
      70             :     TNode<ExternalReference> func = ExternalConstant(
      71         224 :         ExternalReference::jsarray_array_join_concat_to_sequential_string());
      72             :     TNode<ExternalReference> isolate_ptr =
      73         224 :         ExternalConstant(ExternalReference::isolate_address(isolate()));
      74             :     return UncheckedCast<String>(
      75             :         CallCFunction(func,
      76             :                       MachineType::AnyTagged(),  // <return> String
      77             :                       std::make_pair(MachineType::Pointer(), isolate_ptr),
      78             :                       std::make_pair(MachineType::AnyTagged(), fixed_array),
      79             :                       std::make_pair(MachineType::IntPtr(), length),
      80             :                       std::make_pair(MachineType::AnyTagged(), sep),
      81         224 :                       std::make_pair(MachineType::AnyTagged(), dest)));
      82             :   }
      83             : 
      84             :  protected:
      85             :   TNode<Context> context() { return context_; }
      86             :   TNode<Object> receiver() { return receiver_; }
      87             :   TNode<IntPtrT> argc() { return argc_; }
      88             :   TNode<JSReceiver> o() { return o_; }
      89             :   TNode<Number> len() { return len_; }
      90             :   Node* callbackfn() { return callbackfn_; }
      91             :   Node* this_arg() { return this_arg_; }
      92             :   TNode<Number> k() { return CAST(k_.value()); }
      93        1848 :   Node* a() { return a_.value(); }
      94             : 
      95             :   void ReturnFromBuiltin(Node* value);
      96             : 
      97             :   void InitIteratingArrayBuiltinBody(TNode<Context> context,
      98             :                                      TNode<Object> receiver, Node* callbackfn,
      99             :                                      Node* this_arg, TNode<IntPtrT> argc);
     100             : 
     101             :   void GenerateIteratingTypedArrayBuiltinBody(
     102             :       const char* name, const BuiltinResultGenerator& generator,
     103             :       const CallResultProcessor& processor, const PostLoopAction& action,
     104             :       ForEachDirection direction = ForEachDirection::kForward);
     105             : 
     106             :   void TailCallArrayConstructorStub(
     107             :       const Callable& callable, TNode<Context> context,
     108             :       TNode<JSFunction> target, TNode<HeapObject> allocation_site_or_undefined,
     109             :       TNode<Int32T> argc);
     110             : 
     111             :   void GenerateDispatchToArrayStub(
     112             :       TNode<Context> context, TNode<JSFunction> target, TNode<Int32T> argc,
     113             :       AllocationSiteOverrideMode mode,
     114             :       TNode<AllocationSite> allocation_site = TNode<AllocationSite>());
     115             : 
     116             :   void CreateArrayDispatchNoArgument(
     117             :       TNode<Context> context, TNode<JSFunction> target, TNode<Int32T> argc,
     118             :       AllocationSiteOverrideMode mode,
     119             :       TNode<AllocationSite> allocation_site = TNode<AllocationSite>());
     120             : 
     121             :   void CreateArrayDispatchSingleArgument(
     122             :       TNode<Context> context, TNode<JSFunction> target, TNode<Int32T> argc,
     123             :       AllocationSiteOverrideMode mode,
     124             :       TNode<AllocationSite> allocation_site = TNode<AllocationSite>());
     125             : 
     126             :   void GenerateConstructor(Node* context, Node* array_function, Node* array_map,
     127             :                            Node* array_size, Node* allocation_site,
     128             :                            ElementsKind elements_kind, AllocationSiteMode mode);
     129             :   void GenerateArrayNoArgumentConstructor(ElementsKind kind,
     130             :                                           AllocationSiteOverrideMode mode);
     131             :   void GenerateArraySingleArgumentConstructor(ElementsKind kind,
     132             :                                               AllocationSiteOverrideMode mode);
     133             :   void GenerateArrayNArgumentsConstructor(
     134             :       TNode<Context> context, TNode<JSFunction> target,
     135             :       TNode<Object> new_target, TNode<Int32T> argc,
     136             :       TNode<HeapObject> maybe_allocation_site);
     137             : 
     138             :  private:
     139             :   static ElementsKind ElementsKindForInstanceType(InstanceType type);
     140             : 
     141             :   void VisitAllTypedArrayElements(Node* array_buffer,
     142             :                                   const CallResultProcessor& processor,
     143             :                                   Label* detached, ForEachDirection direction,
     144             :                                   TNode<JSTypedArray> typed_array);
     145             : 
     146             :   // Perform ArraySpeciesCreate (ES6 #sec-arrayspeciescreate).
     147             :   // This version is specialized to create a zero length array
     148             :   // of the elements kind of the input array.
     149             :   void GenerateArraySpeciesCreate();
     150             : 
     151             :   // Perform ArraySpeciesCreate (ES6 #sec-arrayspeciescreate).
     152             :   void GenerateArraySpeciesCreate(TNode<Number> len);
     153             : 
     154             :   Node* callbackfn_ = nullptr;
     155             :   TNode<JSReceiver> o_;
     156             :   Node* this_arg_ = nullptr;
     157             :   TNode<Number> len_;
     158             :   TNode<Context> context_;
     159             :   TNode<Object> receiver_;
     160             :   TNode<IntPtrT> argc_;
     161             :   Node* fast_typed_array_target_ = nullptr;
     162             :   const char* name_ = nullptr;
     163             :   Variable k_;
     164             :   Variable a_;
     165             :   Variable to_;
     166             :   Label fully_spec_compliant_;
     167             :   ElementsKind source_elements_kind_ = ElementsKind::NO_ELEMENTS;
     168             : };
     169             : 
     170             : }  // namespace internal
     171             : }  // namespace v8
     172             : 
     173             : #endif  // V8_BUILTINS_BUILTINS_ARRAY_GEN_H_

Generated by: LCOV version 1.10