diff options
Diffstat (limited to 'deps/v8/src/builtins/builtins-array-gen.cc')
-rw-r--r-- | deps/v8/src/builtins/builtins-array-gen.cc | 1150 |
1 files changed, 35 insertions, 1115 deletions
diff --git a/deps/v8/src/builtins/builtins-array-gen.cc b/deps/v8/src/builtins/builtins-array-gen.cc index db58ecf152..7dfe705811 100644 --- a/deps/v8/src/builtins/builtins-array-gen.cc +++ b/deps/v8/src/builtins/builtins-array-gen.cc @@ -12,8 +12,10 @@ #include "src/code-stub-assembler.h" #include "src/frame-constants.h" #include "src/heap/factory-inl.h" +#include "src/objects/allocation-site-inl.h" #include "src/objects/arguments-inl.h" #include "src/objects/property-cell.h" +#include "torque-generated/builtins-typed-array-createtypedarray-from-dsl-gen.h" namespace v8 { namespace internal { @@ -59,16 +61,6 @@ Node* ArrayBuiltinsAssembler::FindProcessor(Node* k_value, Node* k) { return a(); } - void ArrayBuiltinsAssembler::ForEachResultGenerator() { - a_.Bind(UndefinedConstant()); - } - - Node* ArrayBuiltinsAssembler::ForEachProcessor(Node* k_value, Node* k) { - CallJS(CodeFactory::Call(isolate()), context(), callbackfn(), this_arg(), - k_value, k, o()); - return a(); - } - void ArrayBuiltinsAssembler::SomeResultGenerator() { a_.Bind(FalseConstant()); } @@ -99,46 +91,15 @@ Node* ArrayBuiltinsAssembler::FindProcessor(Node* k_value, Node* k) { return a(); } - void ArrayBuiltinsAssembler::ReduceResultGenerator() { - return a_.Bind(this_arg()); - } - - Node* ArrayBuiltinsAssembler::ReduceProcessor(Node* k_value, Node* k) { - VARIABLE(result, MachineRepresentation::kTagged); - Label done(this, {&result}), initial(this); - GotoIf(WordEqual(a(), TheHoleConstant()), &initial); - result.Bind(CallJS(CodeFactory::Call(isolate()), context(), callbackfn(), - UndefinedConstant(), a(), k_value, k, o())); - Goto(&done); - - BIND(&initial); - result.Bind(k_value); - Goto(&done); - - BIND(&done); - return result.value(); - } - - void ArrayBuiltinsAssembler::ReducePostLoopAction() { - Label ok(this); - GotoIf(WordNotEqual(a(), TheHoleConstant()), &ok); - ThrowTypeError(context(), MessageTemplate::kReduceNoInitial); - BIND(&ok); - } - - void ArrayBuiltinsAssembler::MapResultGenerator() { - GenerateArraySpeciesCreate(len_); - } - void ArrayBuiltinsAssembler::TypedArrayMapResultGenerator() { // 6. Let A be ? TypedArraySpeciesCreate(O, len). TNode<JSTypedArray> original_array = CAST(o()); TNode<Smi> length = CAST(len_); const char* method_name = "%TypedArray%.prototype.map"; - TypedArrayBuiltinsAssembler typedarray_asm(state()); + TypedArrayCreatetypedarrayBuiltinsFromDSLAssembler typedarray_asm(state()); TNode<JSTypedArray> a = typedarray_asm.TypedArraySpeciesCreateByLength( - context(), original_array, length, method_name); + context(), method_name, original_array, length); // In the Spec and our current implementation, the length check is already // performed in TypedArraySpeciesCreate. CSA_ASSERT(this, SmiLessThanOrEqual(CAST(len_), LoadJSTypedArrayLength(a))); @@ -148,120 +109,6 @@ Node* ArrayBuiltinsAssembler::FindProcessor(Node* k_value, Node* k) { a_.Bind(a); } - Node* ArrayBuiltinsAssembler::SpecCompliantMapProcessor(Node* k_value, - Node* k) { - // i. Let kValue be ? Get(O, Pk). Performed by the caller of - // SpecCompliantMapProcessor. - // ii. Let mapped_value be ? Call(callbackfn, T, kValue, k, O). - Node* mapped_value = CallJS(CodeFactory::Call(isolate()), context(), - callbackfn(), this_arg(), k_value, k, o()); - - // iii. Perform ? CreateDataPropertyOrThrow(A, Pk, mapped_value). - CallRuntime(Runtime::kCreateDataProperty, context(), a(), k, mapped_value); - return a(); - } - - Node* ArrayBuiltinsAssembler::FastMapProcessor(Node* k_value, Node* k) { - // i. Let kValue be ? Get(O, Pk). Performed by the caller of - // FastMapProcessor. - // ii. Let mapped_value be ? Call(callbackfn, T, kValue, k, O). - Node* mapped_value = CallJS(CodeFactory::Call(isolate()), context(), - callbackfn(), this_arg(), k_value, k, o()); - - // mode is SMI_PARAMETERS because k has tagged representation. - ParameterMode mode = SMI_PARAMETERS; - Label runtime(this), finished(this); - Label transition_pre(this), transition_smi_fast(this), - transition_smi_double(this); - Label array_not_smi(this), array_fast(this), array_double(this); - - TNode<Int32T> kind = LoadElementsKind(a()); - Node* elements = LoadElements(a()); - GotoIf(IsElementsKindGreaterThan(kind, HOLEY_SMI_ELEMENTS), &array_not_smi); - TryStoreArrayElement(HOLEY_SMI_ELEMENTS, mode, &transition_pre, elements, k, - mapped_value); - Goto(&finished); - - BIND(&transition_pre); - { - // array is smi. Value is either tagged or a heap number. - CSA_ASSERT(this, TaggedIsNotSmi(mapped_value)); - GotoIf(IsHeapNumberMap(LoadMap(mapped_value)), &transition_smi_double); - Goto(&transition_smi_fast); - } - - BIND(&array_not_smi); - { - Branch(IsElementsKindGreaterThan(kind, HOLEY_ELEMENTS), &array_double, - &array_fast); - } - - BIND(&transition_smi_fast); - { - // iii. Perform ? CreateDataPropertyOrThrow(A, Pk, mapped_value). - Node* const native_context = LoadNativeContext(context()); - Node* const fast_map = LoadContextElement( - native_context, Context::JS_ARRAY_HOLEY_ELEMENTS_MAP_INDEX); - - // Since this transition is only a map change, just do it right here. - // Since a() doesn't have an allocation site, it's safe to do the - // map store directly, otherwise I'd call TransitionElementsKind(). - StoreMap(a(), fast_map); - Goto(&array_fast); - } - - BIND(&array_fast); - { - TryStoreArrayElement(HOLEY_ELEMENTS, mode, &runtime, elements, k, - mapped_value); - Goto(&finished); - } - - BIND(&transition_smi_double); - { - // iii. Perform ? CreateDataPropertyOrThrow(A, Pk, mapped_value). - Node* const native_context = LoadNativeContext(context()); - Node* const double_map = LoadContextElement( - native_context, Context::JS_ARRAY_HOLEY_DOUBLE_ELEMENTS_MAP_INDEX); - - const ElementsKind kFromKind = HOLEY_SMI_ELEMENTS; - const ElementsKind kToKind = HOLEY_DOUBLE_ELEMENTS; - - Label transition_in_runtime(this, Label::kDeferred); - TransitionElementsKind(a(), double_map, kFromKind, kToKind, - &transition_in_runtime); - Goto(&array_double); - - BIND(&transition_in_runtime); - CallRuntime(Runtime::kTransitionElementsKind, context(), a(), double_map); - Goto(&array_double); - } - - BIND(&array_double); - { - // TODO(mvstanton): If we use a variable for elements and bind it - // appropriately, we can avoid an extra load of elements by binding the - // value only after a transition from smi to double. - elements = LoadElements(a()); - // If the mapped_value isn't a number, this will bail out to the runtime - // to make the transition. - TryStoreArrayElement(HOLEY_DOUBLE_ELEMENTS, mode, &runtime, elements, k, - mapped_value); - Goto(&finished); - } - - BIND(&runtime); - { - // iii. Perform ? CreateDataPropertyOrThrow(A, Pk, mapped_value). - CallRuntime(Runtime::kCreateDataProperty, context(), a(), k, - mapped_value); - Goto(&finished); - } - - BIND(&finished); - return a(); - } - // See tc39.github.io/ecma262/#sec-%typedarray%.prototype.map. Node* ArrayBuiltinsAssembler::TypedArrayMapProcessor(Node* k_value, Node* k) { // 8. c. Let mapped_value be ? Call(callbackfn, T, « kValue, k, O »). @@ -350,97 +197,6 @@ Node* ArrayBuiltinsAssembler::FindProcessor(Node* k_value, Node* k) { argc_ = argc; } - void ArrayBuiltinsAssembler::GenerateIteratingArrayBuiltinBody( - const char* name, const BuiltinResultGenerator& generator, - const CallResultProcessor& processor, const PostLoopAction& action, - const Callable& slow_case_continuation, - MissingPropertyMode missing_property_mode, ForEachDirection direction) { - Label non_array(this), array_changes(this, {&k_, &a_, &to_}); - - // TODO(danno): Seriously? Do we really need to throw the exact error - // message on null and undefined so that the webkit tests pass? - Label throw_null_undefined_exception(this, Label::kDeferred); - GotoIf(IsNullOrUndefined(receiver()), &throw_null_undefined_exception); - - // By the book: taken directly from the ECMAScript 2015 specification - - // 1. Let O be ToObject(this value). - // 2. ReturnIfAbrupt(O) - o_ = ToObject_Inline(context(), receiver()); - - // 3. Let len be ToLength(Get(O, "length")). - // 4. ReturnIfAbrupt(len). - TVARIABLE(Number, merged_length); - Label has_length(this, &merged_length), not_js_array(this); - GotoIf(DoesntHaveInstanceType(o(), JS_ARRAY_TYPE), ¬_js_array); - merged_length = LoadJSArrayLength(CAST(o())); - Goto(&has_length); - - BIND(¬_js_array); - { - Node* len_property = - GetProperty(context(), o(), isolate()->factory()->length_string()); - merged_length = ToLength_Inline(context(), len_property); - Goto(&has_length); - } - BIND(&has_length); - { - len_ = merged_length.value(); - - // 5. If IsCallable(callbackfn) is false, throw a TypeError exception. - Label type_exception(this, Label::kDeferred); - Label done(this); - GotoIf(TaggedIsSmi(callbackfn()), &type_exception); - Branch(IsCallableMap(LoadMap(callbackfn())), &done, &type_exception); - - BIND(&throw_null_undefined_exception); - ThrowTypeError(context(), MessageTemplate::kCalledOnNullOrUndefined, - name); - - BIND(&type_exception); - ThrowTypeError(context(), MessageTemplate::kCalledNonCallable, - callbackfn()); - - BIND(&done); - } - - // 6. If thisArg was supplied, let T be thisArg; else let T be undefined. - // [Already done by the arguments adapter] - - if (direction == ForEachDirection::kForward) { - // 7. Let k be 0. - k_.Bind(SmiConstant(0)); - } else { - k_.Bind(NumberDec(len())); - } - - generator(this); - - HandleFastElements(processor, action, &fully_spec_compliant_, direction, - missing_property_mode); - - BIND(&fully_spec_compliant_); - - Node* result = - CallStub(slow_case_continuation, context(), receiver(), callbackfn(), - this_arg(), a_.value(), o(), k_.value(), len(), to_.value()); - ReturnFromBuiltin(result); - } - - void ArrayBuiltinsAssembler::InitIteratingArrayBuiltinLoopContinuation( - TNode<Context> context, TNode<Object> receiver, Node* callbackfn, - Node* this_arg, Node* a, TNode<JSReceiver> o, Node* initial_k, - TNode<Number> len, Node* to) { - context_ = context; - this_arg_ = this_arg; - callbackfn_ = callbackfn; - a_.Bind(a); - k_.Bind(initial_k); - o_ = o; - len_ = len; - to_.Bind(to); - } - void ArrayBuiltinsAssembler::GenerateIteratingTypedArrayBuiltinBody( const char* name, const BuiltinResultGenerator& generator, const CallResultProcessor& processor, const PostLoopAction& action, @@ -485,9 +241,9 @@ Node* ArrayBuiltinsAssembler::FindProcessor(Node* k_value, Node* k) { TYPED_ARRAYS(INSTANCE_TYPE) #undef INSTANCE_TYPE }; - std::vector<Label> labels; + std::list<Label> labels; for (size_t i = 0; i < instance_types.size(); ++i) { - labels.push_back(Label(this)); + labels.emplace_back(this); } std::vector<Label*> label_ptrs; for (Label& label : labels) { @@ -508,8 +264,9 @@ Node* ArrayBuiltinsAssembler::FindProcessor(Node* k_value, Node* k) { Switch(instance_type, &unexpected_instance_type, instance_types.data(), label_ptrs.data(), labels.size()); - for (size_t i = 0; i < labels.size(); ++i) { - BIND(&labels[i]); + size_t i = 0; + for (auto it = labels.begin(); it != labels.end(); ++i, ++it) { + BIND(&*it); Label done(this); source_elements_kind_ = ElementsKindForInstanceType( static_cast<InstanceType>(instance_types[i])); @@ -526,65 +283,6 @@ Node* ArrayBuiltinsAssembler::FindProcessor(Node* k_value, Node* k) { } } - void ArrayBuiltinsAssembler::GenerateIteratingArrayBuiltinLoopContinuation( - const CallResultProcessor& processor, const PostLoopAction& action, - MissingPropertyMode missing_property_mode, ForEachDirection direction) { - Label loop(this, {&k_, &a_, &to_}); - Label after_loop(this); - Goto(&loop); - BIND(&loop); - { - if (direction == ForEachDirection::kForward) { - // 8. Repeat, while k < len - GotoIfNumberGreaterThanOrEqual(k(), len_, &after_loop); - } else { - // OR - // 10. Repeat, while k >= 0 - GotoIfNumberGreaterThanOrEqual(SmiConstant(-1), k(), &after_loop); - } - - Label done_element(this, &to_); - // a. Let Pk be ToString(k). - // k() is guaranteed to be a positive integer, hence ToString is - // side-effect free and HasProperty/GetProperty do the conversion inline. - CSA_ASSERT(this, IsSafeInteger(k())); - - if (missing_property_mode == MissingPropertyMode::kSkip) { - // b. Let kPresent be HasProperty(O, Pk). - // c. ReturnIfAbrupt(kPresent). - TNode<Oddball> k_present = - HasProperty(context(), o(), k(), kHasProperty); - - // d. If kPresent is true, then - GotoIf(IsFalse(k_present), &done_element); - } - - // i. Let kValue be Get(O, Pk). - // ii. ReturnIfAbrupt(kValue). - Node* k_value = GetProperty(context(), o(), k()); - - // iii. Let funcResult be Call(callbackfn, T, «kValue, k, O»). - // iv. ReturnIfAbrupt(funcResult). - a_.Bind(processor(this, k_value, k())); - Goto(&done_element); - - BIND(&done_element); - - if (direction == ForEachDirection::kForward) { - // e. Increase k by 1. - k_.Bind(NumberInc(k())); - } else { - // e. Decrease k by 1. - k_.Bind(NumberDec(k())); - } - Goto(&loop); - } - BIND(&after_loop); - - action(this); - Return(a_.value()); - } - ElementsKind ArrayBuiltinsAssembler::ElementsKindForInstanceType( InstanceType type) { switch (type) { @@ -632,133 +330,6 @@ Node* ArrayBuiltinsAssembler::FindProcessor(Node* k_value, Node* k) { advance_mode); } - void ArrayBuiltinsAssembler::VisitAllFastElementsOneKind( - ElementsKind kind, const CallResultProcessor& processor, - Label* array_changed, ParameterMode mode, ForEachDirection direction, - MissingPropertyMode missing_property_mode, TNode<Smi> length) { - Comment("begin VisitAllFastElementsOneKind"); - // We only use this kind of processing if the no-elements protector is - // in place at the start. We'll continue checking during array iteration. - CSA_ASSERT(this, Word32BinaryNot(IsNoElementsProtectorCellInvalid())); - VARIABLE(original_map, MachineRepresentation::kTagged); - original_map.Bind(LoadMap(o())); - VariableList list({&original_map, &a_, &k_, &to_}, zone()); - Node* start = IntPtrOrSmiConstant(0, mode); - Node* end = TaggedToParameter(length, mode); - IndexAdvanceMode advance_mode = direction == ForEachDirection::kReverse - ? IndexAdvanceMode::kPre - : IndexAdvanceMode::kPost; - if (direction == ForEachDirection::kReverse) std::swap(start, end); - BuildFastLoop( - list, start, end, - [=, &original_map](Node* index) { - k_.Bind(ParameterToTagged(index, mode)); - Label one_element_done(this), hole_element(this), - process_element(this); - - // Check if o's map has changed during the callback. If so, we have to - // fall back to the slower spec implementation for the rest of the - // iteration. - Node* o_map = LoadMap(o()); - GotoIf(WordNotEqual(o_map, original_map.value()), array_changed); - - TNode<JSArray> o_array = CAST(o()); - // Check if o's length has changed during the callback and if the - // index is now out of range of the new length. - GotoIf(SmiGreaterThanOrEqual(CAST(k_.value()), - CAST(LoadJSArrayLength(o_array))), - array_changed); - - // Re-load the elements array. If may have been resized. - Node* elements = LoadElements(o_array); - - // Fast case: load the element directly from the elements FixedArray - // and call the callback if the element is not the hole. - DCHECK(kind == PACKED_ELEMENTS || kind == PACKED_DOUBLE_ELEMENTS); - int base_size = kind == PACKED_ELEMENTS - ? FixedArray::kHeaderSize - : (FixedArray::kHeaderSize - kHeapObjectTag); - Node* offset = ElementOffsetFromIndex(index, kind, mode, base_size); - VARIABLE(value, MachineRepresentation::kTagged); - if (kind == PACKED_ELEMENTS) { - value.Bind(LoadObjectField(elements, offset)); - GotoIf(WordEqual(value.value(), TheHoleConstant()), &hole_element); - } else { - Node* double_value = - LoadDoubleWithHoleCheck(elements, offset, &hole_element); - value.Bind(AllocateHeapNumberWithValue(double_value)); - } - Goto(&process_element); - - BIND(&hole_element); - if (missing_property_mode == MissingPropertyMode::kSkip) { - // The NoElementsProtectorCell could go invalid during callbacks. - Branch(IsNoElementsProtectorCellInvalid(), array_changed, - &one_element_done); - } else { - value.Bind(UndefinedConstant()); - Goto(&process_element); - } - BIND(&process_element); - { - a_.Bind(processor(this, value.value(), k())); - Goto(&one_element_done); - } - BIND(&one_element_done); - }, - 1, mode, advance_mode); - Comment("end VisitAllFastElementsOneKind"); - } - - void ArrayBuiltinsAssembler::HandleFastElements( - const CallResultProcessor& processor, const PostLoopAction& action, - Label* slow, ForEachDirection direction, - MissingPropertyMode missing_property_mode) { - Label switch_on_elements_kind(this), fast_elements(this), - maybe_double_elements(this), fast_double_elements(this); - - Comment("begin HandleFastElements"); - // Non-smi lengths must use the slow path. - GotoIf(TaggedIsNotSmi(len()), slow); - - BranchIfFastJSArray(o(), context(), - &switch_on_elements_kind, slow); - - BIND(&switch_on_elements_kind); - TNode<Smi> smi_len = CAST(len()); - // Select by ElementsKind - Node* kind = LoadElementsKind(o()); - Branch(IsElementsKindGreaterThan(kind, HOLEY_ELEMENTS), - &maybe_double_elements, &fast_elements); - - ParameterMode mode = OptimalParameterMode(); - BIND(&fast_elements); - { - VisitAllFastElementsOneKind(PACKED_ELEMENTS, processor, slow, mode, - direction, missing_property_mode, smi_len); - - action(this); - - // No exception, return success - ReturnFromBuiltin(a_.value()); - } - - BIND(&maybe_double_elements); - Branch(IsElementsKindGreaterThan(kind, HOLEY_DOUBLE_ELEMENTS), slow, - &fast_double_elements); - - BIND(&fast_double_elements); - { - VisitAllFastElementsOneKind(PACKED_DOUBLE_ELEMENTS, processor, slow, mode, - direction, missing_property_mode, smi_len); - - action(this); - - // No exception, return success - ReturnFromBuiltin(a_.value()); - } - } - // Perform ArraySpeciesCreate (ES6 #sec-arrayspeciescreate). void ArrayBuiltinsAssembler::GenerateArraySpeciesCreate(TNode<Number> len) { Label runtime(this, Label::kDeferred), done(this); @@ -1201,199 +772,6 @@ TF_BUILTIN(CloneFastJSArrayFillingHoles, ArrayBuiltinsAssembler) { HoleConversionMode::kConvertToUndefined)); } -TF_BUILTIN(ArrayFindLoopContinuation, ArrayBuiltinsAssembler) { - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver)); - Node* callbackfn = Parameter(Descriptor::kCallbackFn); - Node* this_arg = Parameter(Descriptor::kThisArg); - Node* array = Parameter(Descriptor::kArray); - TNode<JSReceiver> object = CAST(Parameter(Descriptor::kObject)); - Node* initial_k = Parameter(Descriptor::kInitialK); - TNode<Number> len = CAST(Parameter(Descriptor::kLength)); - Node* to = Parameter(Descriptor::kTo); - - InitIteratingArrayBuiltinLoopContinuation(context, receiver, callbackfn, - this_arg, array, object, initial_k, - len, to); - - GenerateIteratingArrayBuiltinLoopContinuation( - &ArrayBuiltinsAssembler::FindProcessor, - &ArrayBuiltinsAssembler::NullPostLoopAction, - MissingPropertyMode::kUseUndefined, ForEachDirection::kForward); -} - -// Continuation that is called after an eager deoptimization from TF (ex. the -// array changes during iteration). -TF_BUILTIN(ArrayFindLoopEagerDeoptContinuation, ArrayBuiltinsAssembler) { - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver)); - Node* callbackfn = Parameter(Descriptor::kCallbackFn); - Node* this_arg = Parameter(Descriptor::kThisArg); - Node* initial_k = Parameter(Descriptor::kInitialK); - TNode<Number> len = CAST(Parameter(Descriptor::kLength)); - - Return(CallBuiltin(Builtins::kArrayFindLoopContinuation, context, receiver, - callbackfn, this_arg, UndefinedConstant(), receiver, - initial_k, len, UndefinedConstant())); -} - -// Continuation that is called after a lazy deoptimization from TF (ex. the -// callback function is no longer callable). -TF_BUILTIN(ArrayFindLoopLazyDeoptContinuation, ArrayBuiltinsAssembler) { - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver)); - Node* callbackfn = Parameter(Descriptor::kCallbackFn); - Node* this_arg = Parameter(Descriptor::kThisArg); - Node* initial_k = Parameter(Descriptor::kInitialK); - TNode<Number> len = CAST(Parameter(Descriptor::kLength)); - - Return(CallBuiltin(Builtins::kArrayFindLoopContinuation, context, receiver, - callbackfn, this_arg, UndefinedConstant(), receiver, - initial_k, len, UndefinedConstant())); -} - -// Continuation that is called after a lazy deoptimization from TF that happens -// right after the callback and it's returned value must be handled before -// iteration continues. -TF_BUILTIN(ArrayFindLoopAfterCallbackLazyDeoptContinuation, - ArrayBuiltinsAssembler) { - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver)); - Node* callbackfn = Parameter(Descriptor::kCallbackFn); - Node* this_arg = Parameter(Descriptor::kThisArg); - Node* initial_k = Parameter(Descriptor::kInitialK); - TNode<Number> len = CAST(Parameter(Descriptor::kLength)); - Node* found_value = Parameter(Descriptor::kFoundValue); - Node* is_found = Parameter(Descriptor::kIsFound); - - // This custom lazy deopt point is right after the callback. find() needs - // to pick up at the next step, which is returning the element if the callback - // value is truthy. Otherwise, continue the search by calling the - // continuation. - Label if_true(this), if_false(this); - BranchIfToBooleanIsTrue(is_found, &if_true, &if_false); - BIND(&if_true); - Return(found_value); - BIND(&if_false); - Return(CallBuiltin(Builtins::kArrayFindLoopContinuation, context, receiver, - callbackfn, this_arg, UndefinedConstant(), receiver, - initial_k, len, UndefinedConstant())); -} - -// ES #sec-get-%typedarray%.prototype.find -TF_BUILTIN(ArrayPrototypeFind, ArrayBuiltinsAssembler) { - TNode<IntPtrT> argc = - ChangeInt32ToIntPtr(Parameter(Descriptor::kJSActualArgumentsCount)); - CodeStubArguments args(this, argc); - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = args.GetReceiver(); - Node* callbackfn = args.GetOptionalArgumentValue(0); - Node* this_arg = args.GetOptionalArgumentValue(1); - - InitIteratingArrayBuiltinBody(context, receiver, callbackfn, this_arg, argc); - - GenerateIteratingArrayBuiltinBody( - "Array.prototype.find", &ArrayBuiltinsAssembler::FindResultGenerator, - &ArrayBuiltinsAssembler::FindProcessor, - &ArrayBuiltinsAssembler::NullPostLoopAction, - Builtins::CallableFor(isolate(), Builtins::kArrayFindLoopContinuation), - MissingPropertyMode::kUseUndefined, ForEachDirection::kForward); -} - -TF_BUILTIN(ArrayFindIndexLoopContinuation, ArrayBuiltinsAssembler) { - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver)); - Node* callbackfn = Parameter(Descriptor::kCallbackFn); - Node* this_arg = Parameter(Descriptor::kThisArg); - Node* array = Parameter(Descriptor::kArray); - TNode<JSReceiver> object = CAST(Parameter(Descriptor::kObject)); - Node* initial_k = Parameter(Descriptor::kInitialK); - TNode<Number> len = CAST(Parameter(Descriptor::kLength)); - Node* to = Parameter(Descriptor::kTo); - - InitIteratingArrayBuiltinLoopContinuation(context, receiver, callbackfn, - this_arg, array, object, initial_k, - len, to); - - GenerateIteratingArrayBuiltinLoopContinuation( - &ArrayBuiltinsAssembler::FindIndexProcessor, - &ArrayBuiltinsAssembler::NullPostLoopAction, - MissingPropertyMode::kUseUndefined, ForEachDirection::kForward); -} - -TF_BUILTIN(ArrayFindIndexLoopEagerDeoptContinuation, ArrayBuiltinsAssembler) { - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver)); - Node* callbackfn = Parameter(Descriptor::kCallbackFn); - Node* this_arg = Parameter(Descriptor::kThisArg); - Node* initial_k = Parameter(Descriptor::kInitialK); - TNode<Number> len = CAST(Parameter(Descriptor::kLength)); - - Return(CallBuiltin(Builtins::kArrayFindIndexLoopContinuation, context, - receiver, callbackfn, this_arg, SmiConstant(-1), receiver, - initial_k, len, UndefinedConstant())); -} - -TF_BUILTIN(ArrayFindIndexLoopLazyDeoptContinuation, ArrayBuiltinsAssembler) { - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver)); - Node* callbackfn = Parameter(Descriptor::kCallbackFn); - Node* this_arg = Parameter(Descriptor::kThisArg); - Node* initial_k = Parameter(Descriptor::kInitialK); - TNode<Number> len = CAST(Parameter(Descriptor::kLength)); - - Return(CallBuiltin(Builtins::kArrayFindIndexLoopContinuation, context, - receiver, callbackfn, this_arg, SmiConstant(-1), receiver, - initial_k, len, UndefinedConstant())); -} - -TF_BUILTIN(ArrayFindIndexLoopAfterCallbackLazyDeoptContinuation, - ArrayBuiltinsAssembler) { - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver)); - Node* callbackfn = Parameter(Descriptor::kCallbackFn); - Node* this_arg = Parameter(Descriptor::kThisArg); - Node* initial_k = Parameter(Descriptor::kInitialK); - TNode<Number> len = CAST(Parameter(Descriptor::kLength)); - Node* found_value = Parameter(Descriptor::kFoundValue); - Node* is_found = Parameter(Descriptor::kIsFound); - - // This custom lazy deopt point is right after the callback. find() needs - // to pick up at the next step, which is returning the element if the callback - // value is truthy. Otherwise, continue the search by calling the - // continuation. - Label if_true(this), if_false(this); - BranchIfToBooleanIsTrue(is_found, &if_true, &if_false); - BIND(&if_true); - Return(found_value); - BIND(&if_false); - Return(CallBuiltin(Builtins::kArrayFindIndexLoopContinuation, context, - receiver, callbackfn, this_arg, SmiConstant(-1), receiver, - initial_k, len, UndefinedConstant())); -} - -// ES #sec-get-%typedarray%.prototype.findIndex -TF_BUILTIN(ArrayPrototypeFindIndex, ArrayBuiltinsAssembler) { - TNode<IntPtrT> argc = - ChangeInt32ToIntPtr(Parameter(Descriptor::kJSActualArgumentsCount)); - CodeStubArguments args(this, argc); - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = args.GetReceiver(); - Node* callbackfn = args.GetOptionalArgumentValue(0); - Node* this_arg = args.GetOptionalArgumentValue(1); - - InitIteratingArrayBuiltinBody(context, receiver, callbackfn, this_arg, argc); - - GenerateIteratingArrayBuiltinBody( - "Array.prototype.findIndex", - &ArrayBuiltinsAssembler::FindIndexResultGenerator, - &ArrayBuiltinsAssembler::FindIndexProcessor, - &ArrayBuiltinsAssembler::NullPostLoopAction, - Builtins::CallableFor(isolate(), - Builtins::kArrayFindIndexLoopContinuation), - MissingPropertyMode::kUseUndefined, ForEachDirection::kForward); -} - class ArrayPopulatorAssembler : public CodeStubAssembler { public: explicit ArrayPopulatorAssembler(compiler::CodeAssemblerState* state) @@ -1707,104 +1085,6 @@ TF_BUILTIN(TypedArrayPrototypeFindIndex, ArrayBuiltinsAssembler) { &ArrayBuiltinsAssembler::NullPostLoopAction); } -TF_BUILTIN(TypedArrayPrototypeForEach, ArrayBuiltinsAssembler) { - TNode<IntPtrT> argc = - ChangeInt32ToIntPtr(Parameter(Descriptor::kJSActualArgumentsCount)); - CodeStubArguments args(this, argc); - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = args.GetReceiver(); - Node* callbackfn = args.GetOptionalArgumentValue(0); - Node* this_arg = args.GetOptionalArgumentValue(1); - - InitIteratingArrayBuiltinBody(context, receiver, callbackfn, this_arg, argc); - - GenerateIteratingTypedArrayBuiltinBody( - "%TypedArray%.prototype.forEach", - &ArrayBuiltinsAssembler::ForEachResultGenerator, - &ArrayBuiltinsAssembler::ForEachProcessor, - &ArrayBuiltinsAssembler::NullPostLoopAction); -} - -TF_BUILTIN(ArraySomeLoopLazyDeoptContinuation, ArrayBuiltinsAssembler) { - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver)); - Node* callbackfn = Parameter(Descriptor::kCallbackFn); - Node* this_arg = Parameter(Descriptor::kThisArg); - Node* initial_k = Parameter(Descriptor::kInitialK); - TNode<Number> len = CAST(Parameter(Descriptor::kLength)); - Node* result = Parameter(Descriptor::kResult); - - // This custom lazy deopt point is right after the callback. every() needs - // to pick up at the next step, which is either continuing to the next - // array element or returning false if {result} is false. - Label true_continue(this), false_continue(this); - - // iii. If selected is true, then... - BranchIfToBooleanIsTrue(result, &true_continue, &false_continue); - BIND(&true_continue); - { Return(TrueConstant()); } - BIND(&false_continue); - { - // Increment k. - initial_k = NumberInc(initial_k); - - Return(CallBuiltin(Builtins::kArraySomeLoopContinuation, context, receiver, - callbackfn, this_arg, FalseConstant(), receiver, - initial_k, len, UndefinedConstant())); - } -} - -TF_BUILTIN(ArraySomeLoopEagerDeoptContinuation, ArrayBuiltinsAssembler) { - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver)); - Node* callbackfn = Parameter(Descriptor::kCallbackFn); - Node* this_arg = Parameter(Descriptor::kThisArg); - Node* initial_k = Parameter(Descriptor::kInitialK); - TNode<Number> len = CAST(Parameter(Descriptor::kLength)); - - Return(CallBuiltin(Builtins::kArraySomeLoopContinuation, context, receiver, - callbackfn, this_arg, FalseConstant(), receiver, initial_k, - len, UndefinedConstant())); -} - -TF_BUILTIN(ArraySomeLoopContinuation, ArrayBuiltinsAssembler) { - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver)); - Node* callbackfn = Parameter(Descriptor::kCallbackFn); - Node* this_arg = Parameter(Descriptor::kThisArg); - Node* array = Parameter(Descriptor::kArray); - TNode<JSReceiver> object = CAST(Parameter(Descriptor::kObject)); - Node* initial_k = Parameter(Descriptor::kInitialK); - TNode<Number> len = CAST(Parameter(Descriptor::kLength)); - Node* to = Parameter(Descriptor::kTo); - - InitIteratingArrayBuiltinLoopContinuation(context, receiver, callbackfn, - this_arg, array, object, initial_k, - len, to); - - GenerateIteratingArrayBuiltinLoopContinuation( - &ArrayBuiltinsAssembler::SomeProcessor, - &ArrayBuiltinsAssembler::NullPostLoopAction, MissingPropertyMode::kSkip); -} - -TF_BUILTIN(ArraySome, ArrayBuiltinsAssembler) { - TNode<IntPtrT> argc = - ChangeInt32ToIntPtr(Parameter(Descriptor::kJSActualArgumentsCount)); - CodeStubArguments args(this, argc); - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = args.GetReceiver(); - Node* callbackfn = args.GetOptionalArgumentValue(0); - Node* this_arg = args.GetOptionalArgumentValue(1); - - InitIteratingArrayBuiltinBody(context, receiver, callbackfn, this_arg, argc); - - GenerateIteratingArrayBuiltinBody( - "Array.prototype.some", &ArrayBuiltinsAssembler::SomeResultGenerator, - &ArrayBuiltinsAssembler::SomeProcessor, - &ArrayBuiltinsAssembler::NullPostLoopAction, - Builtins::CallableFor(isolate(), Builtins::kArraySomeLoopContinuation), - MissingPropertyMode::kSkip); -} TF_BUILTIN(TypedArrayPrototypeSome, ArrayBuiltinsAssembler) { TNode<IntPtrT> argc = @@ -1824,87 +1104,6 @@ TF_BUILTIN(TypedArrayPrototypeSome, ArrayBuiltinsAssembler) { &ArrayBuiltinsAssembler::NullPostLoopAction); } -TF_BUILTIN(ArrayEveryLoopLazyDeoptContinuation, ArrayBuiltinsAssembler) { - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver)); - Node* callbackfn = Parameter(Descriptor::kCallbackFn); - Node* this_arg = Parameter(Descriptor::kThisArg); - Node* initial_k = Parameter(Descriptor::kInitialK); - TNode<Number> len = CAST(Parameter(Descriptor::kLength)); - Node* result = Parameter(Descriptor::kResult); - - // This custom lazy deopt point is right after the callback. every() needs - // to pick up at the next step, which is either continuing to the next - // array element or returning false if {result} is false. - Label true_continue(this), false_continue(this); - - // iii. If selected is true, then... - BranchIfToBooleanIsTrue(result, &true_continue, &false_continue); - BIND(&true_continue); - { - // Increment k. - initial_k = NumberInc(initial_k); - - Return(CallBuiltin(Builtins::kArrayEveryLoopContinuation, context, receiver, - callbackfn, this_arg, TrueConstant(), receiver, - initial_k, len, UndefinedConstant())); - } - BIND(&false_continue); - { Return(FalseConstant()); } -} - -TF_BUILTIN(ArrayEveryLoopEagerDeoptContinuation, ArrayBuiltinsAssembler) { - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver)); - Node* callbackfn = Parameter(Descriptor::kCallbackFn); - Node* this_arg = Parameter(Descriptor::kThisArg); - Node* initial_k = Parameter(Descriptor::kInitialK); - TNode<Number> len = CAST(Parameter(Descriptor::kLength)); - - Return(CallBuiltin(Builtins::kArrayEveryLoopContinuation, context, receiver, - callbackfn, this_arg, TrueConstant(), receiver, initial_k, - len, UndefinedConstant())); -} - -TF_BUILTIN(ArrayEveryLoopContinuation, ArrayBuiltinsAssembler) { - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver)); - Node* callbackfn = Parameter(Descriptor::kCallbackFn); - Node* this_arg = Parameter(Descriptor::kThisArg); - Node* array = Parameter(Descriptor::kArray); - TNode<JSReceiver> object = CAST(Parameter(Descriptor::kObject)); - Node* initial_k = Parameter(Descriptor::kInitialK); - TNode<Number> len = CAST(Parameter(Descriptor::kLength)); - Node* to = Parameter(Descriptor::kTo); - - InitIteratingArrayBuiltinLoopContinuation(context, receiver, callbackfn, - this_arg, array, object, initial_k, - len, to); - - GenerateIteratingArrayBuiltinLoopContinuation( - &ArrayBuiltinsAssembler::EveryProcessor, - &ArrayBuiltinsAssembler::NullPostLoopAction, MissingPropertyMode::kSkip); -} - -TF_BUILTIN(ArrayEvery, ArrayBuiltinsAssembler) { - TNode<IntPtrT> argc = - ChangeInt32ToIntPtr(Parameter(Descriptor::kJSActualArgumentsCount)); - CodeStubArguments args(this, argc); - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = args.GetReceiver(); - Node* callbackfn = args.GetOptionalArgumentValue(0); - Node* this_arg = args.GetOptionalArgumentValue(1); - - InitIteratingArrayBuiltinBody(context, receiver, callbackfn, this_arg, argc); - - GenerateIteratingArrayBuiltinBody( - "Array.prototype.every", &ArrayBuiltinsAssembler::EveryResultGenerator, - &ArrayBuiltinsAssembler::EveryProcessor, - &ArrayBuiltinsAssembler::NullPostLoopAction, - Builtins::CallableFor(isolate(), Builtins::kArrayEveryLoopContinuation), - MissingPropertyMode::kSkip); -} - TF_BUILTIN(TypedArrayPrototypeEvery, ArrayBuiltinsAssembler) { TNode<IntPtrT> argc = ChangeInt32ToIntPtr(Parameter(Descriptor::kJSActualArgumentsCount)); @@ -1923,289 +1122,6 @@ TF_BUILTIN(TypedArrayPrototypeEvery, ArrayBuiltinsAssembler) { &ArrayBuiltinsAssembler::NullPostLoopAction); } -TF_BUILTIN(ArrayReduceLoopContinuation, ArrayBuiltinsAssembler) { - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver)); - Node* callbackfn = Parameter(Descriptor::kCallbackFn); - Node* this_arg = Parameter(Descriptor::kThisArg); - Node* accumulator = Parameter(Descriptor::kAccumulator); - TNode<JSReceiver> object = CAST(Parameter(Descriptor::kObject)); - Node* initial_k = Parameter(Descriptor::kInitialK); - TNode<Number> len = CAST(Parameter(Descriptor::kLength)); - Node* to = Parameter(Descriptor::kTo); - - InitIteratingArrayBuiltinLoopContinuation(context, receiver, callbackfn, - this_arg, accumulator, object, - initial_k, len, to); - - GenerateIteratingArrayBuiltinLoopContinuation( - &ArrayBuiltinsAssembler::ReduceProcessor, - &ArrayBuiltinsAssembler::ReducePostLoopAction, - MissingPropertyMode::kSkip); -} - -TF_BUILTIN(ArrayReducePreLoopEagerDeoptContinuation, ArrayBuiltinsAssembler) { - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver)); - Node* callbackfn = Parameter(Descriptor::kCallbackFn); - TNode<Number> len = CAST(Parameter(Descriptor::kLength)); - - // Simulate starting the loop at 0, but ensuring that the accumulator is - // the hole. The continuation stub will search for the initial non-hole - // element, rightly throwing an exception if not found. - Return(CallBuiltin(Builtins::kArrayReduceLoopContinuation, context, receiver, - callbackfn, UndefinedConstant(), TheHoleConstant(), - receiver, SmiConstant(0), len, UndefinedConstant())); -} - -TF_BUILTIN(ArrayReduceLoopEagerDeoptContinuation, ArrayBuiltinsAssembler) { - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver)); - Node* callbackfn = Parameter(Descriptor::kCallbackFn); - Node* accumulator = Parameter(Descriptor::kAccumulator); - Node* initial_k = Parameter(Descriptor::kInitialK); - TNode<Number> len = CAST(Parameter(Descriptor::kLength)); - - Return(CallBuiltin(Builtins::kArrayReduceLoopContinuation, context, receiver, - callbackfn, UndefinedConstant(), accumulator, receiver, - initial_k, len, UndefinedConstant())); -} - -TF_BUILTIN(ArrayReduceLoopLazyDeoptContinuation, ArrayBuiltinsAssembler) { - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver)); - Node* callbackfn = Parameter(Descriptor::kCallbackFn); - Node* initial_k = Parameter(Descriptor::kInitialK); - TNode<Number> len = CAST(Parameter(Descriptor::kLength)); - Node* result = Parameter(Descriptor::kResult); - - Return(CallBuiltin(Builtins::kArrayReduceLoopContinuation, context, receiver, - callbackfn, UndefinedConstant(), result, receiver, - initial_k, len, UndefinedConstant())); -} - -TF_BUILTIN(ArrayReduce, ArrayBuiltinsAssembler) { - TNode<IntPtrT> argc = - ChangeInt32ToIntPtr(Parameter(Descriptor::kJSActualArgumentsCount)); - CodeStubArguments args(this, argc); - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = args.GetReceiver(); - Node* callbackfn = args.GetOptionalArgumentValue(0); - Node* initial_value = args.GetOptionalArgumentValue(1, TheHoleConstant()); - - InitIteratingArrayBuiltinBody(context, receiver, callbackfn, initial_value, - argc); - - GenerateIteratingArrayBuiltinBody( - "Array.prototype.reduce", &ArrayBuiltinsAssembler::ReduceResultGenerator, - &ArrayBuiltinsAssembler::ReduceProcessor, - &ArrayBuiltinsAssembler::ReducePostLoopAction, - Builtins::CallableFor(isolate(), Builtins::kArrayReduceLoopContinuation), - MissingPropertyMode::kSkip); -} - -TF_BUILTIN(TypedArrayPrototypeReduce, ArrayBuiltinsAssembler) { - TNode<IntPtrT> argc = - ChangeInt32ToIntPtr(Parameter(Descriptor::kJSActualArgumentsCount)); - CodeStubArguments args(this, argc); - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = args.GetReceiver(); - Node* callbackfn = args.GetOptionalArgumentValue(0); - Node* initial_value = args.GetOptionalArgumentValue(1, TheHoleConstant()); - - InitIteratingArrayBuiltinBody(context, receiver, callbackfn, initial_value, - argc); - - GenerateIteratingTypedArrayBuiltinBody( - "%TypedArray%.prototype.reduce", - &ArrayBuiltinsAssembler::ReduceResultGenerator, - &ArrayBuiltinsAssembler::ReduceProcessor, - &ArrayBuiltinsAssembler::ReducePostLoopAction); -} - -TF_BUILTIN(ArrayReduceRightLoopContinuation, ArrayBuiltinsAssembler) { - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver)); - Node* callbackfn = Parameter(Descriptor::kCallbackFn); - Node* this_arg = Parameter(Descriptor::kThisArg); - Node* accumulator = Parameter(Descriptor::kAccumulator); - TNode<JSReceiver> object = CAST(Parameter(Descriptor::kObject)); - Node* initial_k = Parameter(Descriptor::kInitialK); - TNode<Number> len = CAST(Parameter(Descriptor::kLength)); - Node* to = Parameter(Descriptor::kTo); - - InitIteratingArrayBuiltinLoopContinuation(context, receiver, callbackfn, - this_arg, accumulator, object, - initial_k, len, to); - - GenerateIteratingArrayBuiltinLoopContinuation( - &ArrayBuiltinsAssembler::ReduceProcessor, - &ArrayBuiltinsAssembler::ReducePostLoopAction, MissingPropertyMode::kSkip, - ForEachDirection::kReverse); -} - -TF_BUILTIN(ArrayReduceRightPreLoopEagerDeoptContinuation, - ArrayBuiltinsAssembler) { - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver)); - Node* callbackfn = Parameter(Descriptor::kCallbackFn); - TNode<Smi> len = CAST(Parameter(Descriptor::kLength)); - - // Simulate starting the loop at 0, but ensuring that the accumulator is - // the hole. The continuation stub will search for the initial non-hole - // element, rightly throwing an exception if not found. - Return(CallBuiltin(Builtins::kArrayReduceRightLoopContinuation, context, - receiver, callbackfn, UndefinedConstant(), - TheHoleConstant(), receiver, SmiSub(len, SmiConstant(1)), - len, UndefinedConstant())); -} - -TF_BUILTIN(ArrayReduceRightLoopEagerDeoptContinuation, ArrayBuiltinsAssembler) { - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver)); - Node* callbackfn = Parameter(Descriptor::kCallbackFn); - Node* accumulator = Parameter(Descriptor::kAccumulator); - Node* initial_k = Parameter(Descriptor::kInitialK); - TNode<Number> len = CAST(Parameter(Descriptor::kLength)); - - Return(CallBuiltin(Builtins::kArrayReduceRightLoopContinuation, context, - receiver, callbackfn, UndefinedConstant(), accumulator, - receiver, initial_k, len, UndefinedConstant())); -} - -TF_BUILTIN(ArrayReduceRightLoopLazyDeoptContinuation, ArrayBuiltinsAssembler) { - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver)); - Node* callbackfn = Parameter(Descriptor::kCallbackFn); - Node* initial_k = Parameter(Descriptor::kInitialK); - TNode<Number> len = CAST(Parameter(Descriptor::kLength)); - Node* result = Parameter(Descriptor::kResult); - - Return(CallBuiltin(Builtins::kArrayReduceRightLoopContinuation, context, - receiver, callbackfn, UndefinedConstant(), result, - receiver, initial_k, len, UndefinedConstant())); -} - -TF_BUILTIN(ArrayReduceRight, ArrayBuiltinsAssembler) { - TNode<IntPtrT> argc = - ChangeInt32ToIntPtr(Parameter(Descriptor::kJSActualArgumentsCount)); - CodeStubArguments args(this, argc); - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = args.GetReceiver(); - Node* callbackfn = args.GetOptionalArgumentValue(0); - Node* initial_value = args.GetOptionalArgumentValue(1, TheHoleConstant()); - - InitIteratingArrayBuiltinBody(context, receiver, callbackfn, initial_value, - argc); - - GenerateIteratingArrayBuiltinBody( - "Array.prototype.reduceRight", - &ArrayBuiltinsAssembler::ReduceResultGenerator, - &ArrayBuiltinsAssembler::ReduceProcessor, - &ArrayBuiltinsAssembler::ReducePostLoopAction, - Builtins::CallableFor(isolate(), - Builtins::kArrayReduceRightLoopContinuation), - MissingPropertyMode::kSkip, ForEachDirection::kReverse); -} - -TF_BUILTIN(TypedArrayPrototypeReduceRight, ArrayBuiltinsAssembler) { - TNode<IntPtrT> argc = - ChangeInt32ToIntPtr(Parameter(Descriptor::kJSActualArgumentsCount)); - CodeStubArguments args(this, argc); - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = args.GetReceiver(); - Node* callbackfn = args.GetOptionalArgumentValue(0); - Node* initial_value = args.GetOptionalArgumentValue(1, TheHoleConstant()); - - InitIteratingArrayBuiltinBody(context, receiver, callbackfn, initial_value, - argc); - - GenerateIteratingTypedArrayBuiltinBody( - "%TypedArray%.prototype.reduceRight", - &ArrayBuiltinsAssembler::ReduceResultGenerator, - &ArrayBuiltinsAssembler::ReduceProcessor, - &ArrayBuiltinsAssembler::ReducePostLoopAction, - ForEachDirection::kReverse); -} - -TF_BUILTIN(ArrayMapLoopContinuation, ArrayBuiltinsAssembler) { - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver)); - Node* callbackfn = Parameter(Descriptor::kCallbackFn); - Node* this_arg = Parameter(Descriptor::kThisArg); - Node* array = Parameter(Descriptor::kArray); - TNode<JSReceiver> object = CAST(Parameter(Descriptor::kObject)); - Node* initial_k = Parameter(Descriptor::kInitialK); - TNode<Number> len = CAST(Parameter(Descriptor::kLength)); - Node* to = Parameter(Descriptor::kTo); - - InitIteratingArrayBuiltinLoopContinuation(context, receiver, callbackfn, - this_arg, array, object, initial_k, - len, to); - - GenerateIteratingArrayBuiltinLoopContinuation( - &ArrayBuiltinsAssembler::SpecCompliantMapProcessor, - &ArrayBuiltinsAssembler::NullPostLoopAction, MissingPropertyMode::kSkip); -} - -TF_BUILTIN(ArrayMapLoopEagerDeoptContinuation, ArrayBuiltinsAssembler) { - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver)); - Node* callbackfn = Parameter(Descriptor::kCallbackFn); - Node* this_arg = Parameter(Descriptor::kThisArg); - Node* array = Parameter(Descriptor::kArray); - Node* initial_k = Parameter(Descriptor::kInitialK); - TNode<Number> len = CAST(Parameter(Descriptor::kLength)); - - Return(CallBuiltin(Builtins::kArrayMapLoopContinuation, context, receiver, - callbackfn, this_arg, array, receiver, initial_k, len, - UndefinedConstant())); -} - -TF_BUILTIN(ArrayMapLoopLazyDeoptContinuation, ArrayBuiltinsAssembler) { - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver)); - Node* callbackfn = Parameter(Descriptor::kCallbackFn); - Node* this_arg = Parameter(Descriptor::kThisArg); - Node* array = Parameter(Descriptor::kArray); - Node* initial_k = Parameter(Descriptor::kInitialK); - TNode<Number> len = CAST(Parameter(Descriptor::kLength)); - Node* result = Parameter(Descriptor::kResult); - - // This custom lazy deopt point is right after the callback. map() needs - // to pick up at the next step, which is setting the callback result in - // the output array. After incrementing k, we can glide into the loop - // continuation builtin. - - // iii. Perform ? CreateDataPropertyOrThrow(A, Pk, mappedValue). - CallRuntime(Runtime::kCreateDataProperty, context, array, initial_k, result); - // Then we have to increment k before going on. - initial_k = NumberInc(initial_k); - - Return(CallBuiltin(Builtins::kArrayMapLoopContinuation, context, receiver, - callbackfn, this_arg, array, receiver, initial_k, len, - UndefinedConstant())); -} - -TF_BUILTIN(ArrayMap, ArrayBuiltinsAssembler) { - TNode<IntPtrT> argc = - ChangeInt32ToIntPtr(Parameter(Descriptor::kJSActualArgumentsCount)); - CodeStubArguments args(this, argc); - TNode<Context> context = CAST(Parameter(Descriptor::kContext)); - TNode<Object> receiver = args.GetReceiver(); - Node* callbackfn = args.GetOptionalArgumentValue(0); - Node* this_arg = args.GetOptionalArgumentValue(1); - - InitIteratingArrayBuiltinBody(context, receiver, callbackfn, this_arg, argc); - - GenerateIteratingArrayBuiltinBody( - "Array.prototype.map", &ArrayBuiltinsAssembler::MapResultGenerator, - &ArrayBuiltinsAssembler::FastMapProcessor, - &ArrayBuiltinsAssembler::NullPostLoopAction, - Builtins::CallableFor(isolate(), Builtins::kArrayMapLoopContinuation), - MissingPropertyMode::kSkip); -} - TF_BUILTIN(TypedArrayPrototypeMap, ArrayBuiltinsAssembler) { TNode<IntPtrT> argc = ChangeInt32ToIntPtr(Parameter(Descriptor::kJSActualArgumentsCount)); @@ -2447,7 +1363,8 @@ void ArrayIncludesIndexofAssembler::GenerateSmiOrObject( { GotoIfNot(UintPtrLessThan(index_var.value(), array_length_untagged), &return_not_found); - Node* element_k = LoadFixedArrayElement(CAST(elements), index_var.value()); + Node* element_k = + UnsafeLoadFixedArrayElement(CAST(elements), index_var.value()); GotoIf(WordEqual(element_k, search_element), &return_found); Increment(&index_var); @@ -2459,7 +1376,8 @@ void ArrayIncludesIndexofAssembler::GenerateSmiOrObject( GotoIfNot(UintPtrLessThan(index_var.value(), array_length_untagged), &return_not_found); - Node* element_k = LoadFixedArrayElement(CAST(elements), index_var.value()); + Node* element_k = + UnsafeLoadFixedArrayElement(CAST(elements), index_var.value()); GotoIf(IsUndefined(element_k), &return_found); GotoIf(IsTheHole(element_k), &return_found); @@ -2479,7 +1397,7 @@ void ArrayIncludesIndexofAssembler::GenerateSmiOrObject( GotoIfNot(UintPtrLessThan(index_var.value(), array_length_untagged), &return_not_found); Node* element_k = - LoadFixedArrayElement(CAST(elements), index_var.value()); + UnsafeLoadFixedArrayElement(CAST(elements), index_var.value()); GotoIfNot(TaggedIsSmi(element_k), ¬_smi); Branch(Float64Equal(search_num.value(), SmiToFloat64(element_k)), &return_found, &continue_loop); @@ -2501,7 +1419,7 @@ void ArrayIncludesIndexofAssembler::GenerateSmiOrObject( GotoIfNot(UintPtrLessThan(index_var.value(), array_length_untagged), &return_not_found); Node* element_k = - LoadFixedArrayElement(CAST(elements), index_var.value()); + UnsafeLoadFixedArrayElement(CAST(elements), index_var.value()); GotoIf(TaggedIsSmi(element_k), &continue_loop); GotoIfNot(IsHeapNumber(CAST(element_k)), &continue_loop); BranchIfFloat64IsNaN(LoadHeapNumberValue(element_k), &return_found, @@ -2524,7 +1442,8 @@ void ArrayIncludesIndexofAssembler::GenerateSmiOrObject( BIND(&next_iteration); GotoIfNot(UintPtrLessThan(index_var.value(), array_length_untagged), &return_not_found); - Node* element_k = LoadFixedArrayElement(CAST(elements), index_var.value()); + Node* element_k = + UnsafeLoadFixedArrayElement(CAST(elements), index_var.value()); GotoIf(TaggedIsSmi(element_k), &continue_loop); GotoIf(WordEqual(search_element_string, element_k), &return_found); Node* element_k_type = LoadInstanceType(element_k); @@ -2552,7 +1471,8 @@ void ArrayIncludesIndexofAssembler::GenerateSmiOrObject( GotoIfNot(UintPtrLessThan(index_var.value(), array_length_untagged), &return_not_found); - Node* element_k = LoadFixedArrayElement(CAST(elements), index_var.value()); + Node* element_k = + UnsafeLoadFixedArrayElement(CAST(elements), index_var.value()); Label continue_loop(this); GotoIf(TaggedIsSmi(element_k), &continue_loop); GotoIfNot(IsBigInt(CAST(element_k)), &continue_loop); @@ -3620,39 +2540,39 @@ TF_BUILTIN(ArrayNArgumentsConstructor, ArrayBuiltinsAssembler) { // The ArrayNoArgumentConstructor builtin family. GENERATE_ARRAY_CTOR(NoArgument, PackedSmi, PACKED_SMI_ELEMENTS, DontOverride, - DONT_OVERRIDE); + DONT_OVERRIDE) GENERATE_ARRAY_CTOR(NoArgument, HoleySmi, HOLEY_SMI_ELEMENTS, DontOverride, - DONT_OVERRIDE); + DONT_OVERRIDE) GENERATE_ARRAY_CTOR(NoArgument, PackedSmi, PACKED_SMI_ELEMENTS, - DisableAllocationSites, DISABLE_ALLOCATION_SITES); + DisableAllocationSites, DISABLE_ALLOCATION_SITES) GENERATE_ARRAY_CTOR(NoArgument, HoleySmi, HOLEY_SMI_ELEMENTS, - DisableAllocationSites, DISABLE_ALLOCATION_SITES); + DisableAllocationSites, DISABLE_ALLOCATION_SITES) GENERATE_ARRAY_CTOR(NoArgument, Packed, PACKED_ELEMENTS, DisableAllocationSites, - DISABLE_ALLOCATION_SITES); + DISABLE_ALLOCATION_SITES) GENERATE_ARRAY_CTOR(NoArgument, Holey, HOLEY_ELEMENTS, DisableAllocationSites, - DISABLE_ALLOCATION_SITES); + DISABLE_ALLOCATION_SITES) GENERATE_ARRAY_CTOR(NoArgument, PackedDouble, PACKED_DOUBLE_ELEMENTS, - DisableAllocationSites, DISABLE_ALLOCATION_SITES); + DisableAllocationSites, DISABLE_ALLOCATION_SITES) GENERATE_ARRAY_CTOR(NoArgument, HoleyDouble, HOLEY_DOUBLE_ELEMENTS, - DisableAllocationSites, DISABLE_ALLOCATION_SITES); + DisableAllocationSites, DISABLE_ALLOCATION_SITES) // The ArraySingleArgumentConstructor builtin family. GENERATE_ARRAY_CTOR(SingleArgument, PackedSmi, PACKED_SMI_ELEMENTS, - DontOverride, DONT_OVERRIDE); + DontOverride, DONT_OVERRIDE) GENERATE_ARRAY_CTOR(SingleArgument, HoleySmi, HOLEY_SMI_ELEMENTS, DontOverride, - DONT_OVERRIDE); + DONT_OVERRIDE) GENERATE_ARRAY_CTOR(SingleArgument, PackedSmi, PACKED_SMI_ELEMENTS, - DisableAllocationSites, DISABLE_ALLOCATION_SITES); + DisableAllocationSites, DISABLE_ALLOCATION_SITES) GENERATE_ARRAY_CTOR(SingleArgument, HoleySmi, HOLEY_SMI_ELEMENTS, - DisableAllocationSites, DISABLE_ALLOCATION_SITES); + DisableAllocationSites, DISABLE_ALLOCATION_SITES) GENERATE_ARRAY_CTOR(SingleArgument, Packed, PACKED_ELEMENTS, - DisableAllocationSites, DISABLE_ALLOCATION_SITES); + DisableAllocationSites, DISABLE_ALLOCATION_SITES) GENERATE_ARRAY_CTOR(SingleArgument, Holey, HOLEY_ELEMENTS, - DisableAllocationSites, DISABLE_ALLOCATION_SITES); + DisableAllocationSites, DISABLE_ALLOCATION_SITES) GENERATE_ARRAY_CTOR(SingleArgument, PackedDouble, PACKED_DOUBLE_ELEMENTS, - DisableAllocationSites, DISABLE_ALLOCATION_SITES); + DisableAllocationSites, DISABLE_ALLOCATION_SITES) GENERATE_ARRAY_CTOR(SingleArgument, HoleyDouble, HOLEY_DOUBLE_ELEMENTS, - DisableAllocationSites, DISABLE_ALLOCATION_SITES); + DisableAllocationSites, DISABLE_ALLOCATION_SITES) #undef GENERATE_ARRAY_CTOR |