Commit ca1508fc authored by Daniel Clifford's avatar Daniel Clifford Committed by Commit Bot

Refactor ArrayBuiltinsAssembler to split into a header and source file

This makes the ArrayBuiltinsAssembler consistent with the StringBuiltinsAssembler
and paves the way for tools that expect the assemblers to have a common structure.

Change-Id: I7470fc2cf144f9cc2fdbcee99b31daed267550be
Reviewed-on: https://chromium-review.googlesource.com/889933Reviewed-by: 's avatarMichael Stanton <mvstanton@chromium.org>
Commit-Queue: Daniel Clifford <danno@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50920}
parent ff394b44
......@@ -1018,6 +1018,7 @@ v8_source_set("v8_initializers") {
"src/builtins/builtins-arguments-gen.cc",
"src/builtins/builtins-arguments-gen.h",
"src/builtins/builtins-array-gen.cc",
"src/builtins/builtins-array-gen.h",
"src/builtins/builtins-async-function-gen.cc",
"src/builtins/builtins-async-gen.cc",
"src/builtins/builtins-async-gen.h",
......
......@@ -153,6 +153,7 @@
'../src/builtins/builtins-arguments-gen.cc',
'../src/builtins/builtins-arguments-gen.h',
'../src/builtins/builtins-array-gen.cc',
'../src/builtins/builtins-array-gen.h',
'../src/builtins/builtins-async-function-gen.cc',
'../src/builtins/builtins-async-gen.cc',
'../src/builtins/builtins-async-gen.h',
......
This diff is collapsed.
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_BUILTINS_BUILTINS_ARRAY_GEN_H_
#define V8_BUILTINS_BUILTINS_ARRAY_GEN_H_
#include "src/code-stub-assembler.h"
namespace v8 {
namespace internal {
class ArrayBuiltinsAssembler : public CodeStubAssembler {
public:
explicit ArrayBuiltinsAssembler(compiler::CodeAssemblerState* state);
typedef std::function<void(ArrayBuiltinsAssembler* masm)>
BuiltinResultGenerator;
typedef std::function<Node*(ArrayBuiltinsAssembler* masm, Node* k_value,
Node* k)>
CallResultProcessor;
typedef std::function<void(ArrayBuiltinsAssembler* masm)> PostLoopAction;
enum class MissingPropertyMode { kSkip, kUseUndefined };
void FindResultGenerator();
Node* FindProcessor(Node* k_value, Node* k);
void FindIndexResultGenerator();
Node* FindIndexProcessor(Node* k_value, Node* k);
void ForEachResultGenerator();
Node* ForEachProcessor(Node* k_value, Node* k);
void SomeResultGenerator();
Node* SomeProcessor(Node* k_value, Node* k);
void EveryResultGenerator();
Node* EveryProcessor(Node* k_value, Node* k);
void ReduceResultGenerator();
Node* ReduceProcessor(Node* k_value, Node* k);
void ReducePostLoopAction();
void FilterResultGenerator();
Node* FilterProcessor(Node* k_value, Node* k);
void MapResultGenerator();
void TypedArrayMapResultGenerator();
Node* SpecCompliantMapProcessor(Node* k_value, Node* k);
Node* FastMapProcessor(Node* k_value, Node* k);
// See tc39.github.io/ecma262/#sec-%typedarray%.prototype.map.
Node* TypedArrayMapProcessor(Node* k_value, Node* k);
void NullPostLoopAction();
protected:
Node* context() { return context_; }
Node* receiver() { return receiver_; }
Node* new_target() { return new_target_; }
Node* argc() { return argc_; }
Node* o() { return o_; }
Node* len() { return len_; }
Node* callbackfn() { return callbackfn_; }
Node* this_arg() { return this_arg_; }
Node* k() { return k_.value(); }
Node* a() { return a_.value(); }
void ReturnFromBuiltin(Node* value);
void InitIteratingArrayBuiltinBody(Node* context, Node* receiver,
Node* callbackfn, Node* this_arg,
Node* new_target, Node* argc);
void GenerateIteratingArrayBuiltinBody(
const char* name, const BuiltinResultGenerator& generator,
const CallResultProcessor& processor, const PostLoopAction& action,
const Callable& slow_case_continuation,
MissingPropertyMode missing_property_mode,
ForEachDirection direction = ForEachDirection::kForward);
void InitIteratingArrayBuiltinLoopContinuation(Node* context, Node* receiver,
Node* callbackfn,
Node* this_arg, Node* a,
Node* o, Node* initial_k,
Node* len, Node* to);
void GenerateIteratingTypedArrayBuiltinBody(
const char* name, const BuiltinResultGenerator& generator,
const CallResultProcessor& processor, const PostLoopAction& action,
ForEachDirection direction = ForEachDirection::kForward);
void GenerateIteratingArrayBuiltinLoopContinuation(
const CallResultProcessor& processor, const PostLoopAction& action,
MissingPropertyMode missing_property_mode,
ForEachDirection direction = ForEachDirection::kForward);
private:
static ElementsKind ElementsKindForInstanceType(InstanceType type);
void VisitAllTypedArrayElements(Node* array_buffer,
const CallResultProcessor& processor,
Label* detached, ForEachDirection direction);
void VisitAllFastElementsOneKind(ElementsKind kind,
const CallResultProcessor& processor,
Label* array_changed, ParameterMode mode,
ForEachDirection direction,
MissingPropertyMode missing_property_mode);
void HandleFastElements(const CallResultProcessor& processor,
const PostLoopAction& action, Label* slow,
ForEachDirection direction,
MissingPropertyMode missing_property_mode);
// Perform ArraySpeciesCreate (ES6 #sec-arrayspeciescreate).
// This version is specialized to create a zero length array
// of the elements kind of the input array.
void GenerateArraySpeciesCreate();
// Perform ArraySpeciesCreate (ES6 #sec-arrayspeciescreate).
void GenerateArraySpeciesCreate(SloppyTNode<Smi> len);
Node* callbackfn_ = nullptr;
Node* o_ = nullptr;
Node* this_arg_ = nullptr;
Node* len_ = nullptr;
Node* context_ = nullptr;
Node* receiver_ = nullptr;
Node* new_target_ = nullptr;
Node* argc_ = nullptr;
Node* fast_typed_array_target_ = nullptr;
const char* name_ = nullptr;
Variable k_;
Variable a_;
Variable to_;
Label fully_spec_compliant_;
ElementsKind source_elements_kind_ = ElementsKind::NO_ELEMENTS;
};
} // namespace internal
} // namespace v8
#endif // V8_BUILTINS_BUILTINS_ARRAY_GEN_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment