Commit f118d952 authored by Choongwoo Han's avatar Choongwoo Han Committed by Commit Bot

[typedarray] Reduce generated code size of TA.map

We don't need to generate TypedArraySpeciesCreate code for each type
case because TypedArraySpeciesCreate also handles each case, so it
generates duplicated codes.  Thus, create a result object once before
switching to each type case.  Also, replace ToNumber with
ToNumber_Inline.

This CL saves about 8000 bytes of generated code size.

Change-Id: I014535b0ef4b3d2a50a37cdc2b6cb4e83f6c2f17
Reviewed-on: https://chromium-review.googlesource.com/910755Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51213}
parent 76a1003f
......@@ -340,7 +340,7 @@ Node* ArrayBuiltinsAssembler::FindProcessor(Node* k_value, Node* k) {
BIND(&fast);
// #sec-integerindexedelementset 3. Let numValue be ? ToNumber(value).
Node* num_value = ToNumber(context(), mapped_value);
Node* num_value = ToNumber_Inline(context(), mapped_value);
// The only way how this can bailout is because of a detached buffer.
EmitElementStore(a(), k, num_value, false, source_elements_kind_,
KeyedAccessStoreMode::STANDARD_STORE, &detached);
......@@ -524,6 +524,8 @@ Node* ArrayBuiltinsAssembler::FindProcessor(Node* k_value, Node* k) {
BIND(&distinguish_types);
generator(this);
if (direction == ForEachDirection::kForward) {
k_.Bind(SmiConstant(0));
} else {
......@@ -538,7 +540,6 @@ Node* ArrayBuiltinsAssembler::FindProcessor(Node* k_value, Node* k) {
Label done(this);
source_elements_kind_ = ElementsKindForInstanceType(
static_cast<InstanceType>(instance_types[i]));
generator(this);
// TODO(tebbi): Silently cancelling the loop on buffer detachment is a
// spec violation. Should go to &throw_detached and throw a TypeError
// instead.
......
......@@ -5623,8 +5623,8 @@ TNode<Numeric> CodeStubAssembler::NonNumberToNumeric(
return UncheckedCast<Numeric>(result);
}
TNode<Number> CodeStubAssembler::ToNumber_Inline(TNode<Context> context,
TNode<Object> input) {
TNode<Number> CodeStubAssembler::ToNumber_Inline(SloppyTNode<Context> context,
SloppyTNode<Object> input) {
TVARIABLE(Number, var_result);
Label end(this), not_smi(this, Label::kDeferred);
......
......@@ -1251,7 +1251,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
TNode<Number> ToNumber(
SloppyTNode<Context> context, SloppyTNode<Object> input,
BigIntHandling bigint_handling = BigIntHandling::kThrow);
TNode<Number> ToNumber_Inline(TNode<Context> context, TNode<Object> input);
TNode<Number> ToNumber_Inline(SloppyTNode<Context> context,
SloppyTNode<Object> input);
// Converts |input| to one of 2^32 integer values in the range 0 through
// 2^32-1, inclusive.
......
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