Commit 9af1556f authored by Peter Marshall's avatar Peter Marshall Committed by Commit Bot

[cleanup] Add CSA types to ToSmiLength and callers.

Bug: v8:7310
Change-Id: Ic9c96708d6f6319d71b7e3ecae5434fb1e8eb504
Reviewed-on: https://chromium-review.googlesource.com/928767
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51462}
parent aaa78c33
......@@ -562,7 +562,7 @@ void TypedArrayBuiltinsAssembler::ConstructByArrayLike(
Label invalid_length(this), fill(this), fast_copy(this), done(this);
// The caller has looked up length on array_like, which is observable.
Node* length = ToSmiLength(initial_length, context, &invalid_length);
TNode<Smi> length = ToSmiLength(initial_length, context, &invalid_length);
CallBuiltin(Builtins::kTypedArrayInitialize, context, holder, length,
element_size, initialize);
......@@ -1746,9 +1746,9 @@ TF_BUILTIN(TypedArrayFrom, TypedArrayBuiltinsAssembler) {
final_source = CAST(source);
// 10. Let len be ? ToLength(? Get(arrayLike, "length")).
Node* raw_length =
GetProperty(context, final_source.value(), LengthStringConstant());
final_length = CAST(ToSmiLength(raw_length, context, &if_length_not_smi));
TNode<Object> raw_length = CAST(
GetProperty(context, final_source.value(), LengthStringConstant()));
final_length = ToSmiLength(raw_length, context, &if_length_not_smi);
Goto(&create_typed_array);
BIND(&if_length_not_smi);
......
......@@ -6143,30 +6143,42 @@ Node* CodeStubAssembler::ToSmiIndex(Node* const input, Node* const context,
return result.value();
}
Node* CodeStubAssembler::ToSmiLength(Node* input, Node* const context,
Label* range_error) {
VARIABLE(result, MachineRepresentation::kTagged, input);
Label to_integer(this), negative_check(this), return_zero(this), done(this);
Branch(TaggedIsSmi(result.value()), &negative_check, &to_integer);
TNode<Smi> CodeStubAssembler::ToSmiLength(TNode<Object> input,
TNode<Context> context,
Label* range_error) {
TVARIABLE(Smi, result);
Label to_integer(this), if_issmi(this), negative_check(this),
heap_number_negative_check(this), return_zero(this), done(this);
Branch(TaggedIsSmi(input), &if_issmi, &to_integer);
BIND(&to_integer);
result.Bind(ToInteger_Inline(CAST(context), CAST(result.value()),
CodeStubAssembler::kTruncateMinusZero));
GotoIf(TaggedIsSmi(result.value()), &negative_check);
// result.value() can still be a negative HeapNumber here.
Branch(IsTrue(CallBuiltin(Builtins::kLessThan, context, result.value(),
SmiConstant(0))),
&return_zero, range_error);
{
TNode<Number> integer_input =
ToInteger_Inline(context, input, CodeStubAssembler::kTruncateMinusZero);
GotoIfNot(TaggedIsSmi(integer_input), &heap_number_negative_check);
result = CAST(integer_input);
Goto(&negative_check);
// integer_input can still be a negative HeapNumber here.
BIND(&heap_number_negative_check);
TNode<HeapNumber> heap_number_input = CAST(integer_input);
Branch(IsTrue(CallBuiltin(Builtins::kLessThan, context, heap_number_input,
SmiConstant(0))),
&return_zero, range_error);
}
BIND(&if_issmi);
result = CAST(input);
Goto(&negative_check);
BIND(&negative_check);
Branch(SmiLessThan(result.value(), SmiConstant(0)), &return_zero, &done);
BIND(&return_zero);
result.Bind(SmiConstant(0));
result = SmiConstant(0);
Goto(&done);
BIND(&done);
CSA_SLOW_ASSERT(this, TaggedIsSmi(result.value()));
return result.value();
}
......
......@@ -1293,7 +1293,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
Node* ToSmiIndex(Node* const input, Node* const context, Label* range_error);
// ES6 7.1.15 ToLength, but jumps to range_error if the result is not a Smi.
Node* ToSmiLength(Node* input, Node* const context, Label* range_error);
TNode<Smi> ToSmiLength(TNode<Object> input, TNode<Context> context,
Label* range_error);
// ES6 7.1.15 ToLength, but with inlined fast path.
Node* ToLength_Inline(Node* const context, Node* const input);
......
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