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