Commit d74199d5 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[bigint] Resolve a few minor TODOs.

R=jkummerow@chromium.org

Bug: v8:6791
Change-Id: I55c11c1328c92983286a8173795ce38f0b1e9e8e
TBR: yangguo@chromium.org
Reviewed-on: https://chromium-review.googlesource.com/735322Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48897}
parent d8fbe426
...@@ -532,11 +532,11 @@ class ArrayBuiltinCodeStubAssembler : public CodeStubAssembler { ...@@ -532,11 +532,11 @@ class ArrayBuiltinCodeStubAssembler : public CodeStubAssembler {
{ {
if (direction == ForEachDirection::kForward) { if (direction == ForEachDirection::kForward) {
// 8. Repeat, while k < len // 8. Repeat, while k < len
GotoIfNumberGreaterThanOrEqual(k(), len_, &after_loop); GotoIfNumericGreaterThanOrEqual(k(), len_, &after_loop);
} else { } else {
// OR // OR
// 10. Repeat, while k >= 0 // 10. Repeat, while k >= 0
GotoIfNumberGreaterThanOrEqual(SmiConstant(-1), k(), &after_loop); GotoIfNumericGreaterThanOrEqual(SmiConstant(-1), k(), &after_loop);
} }
Label done_element(this, &to_); Label done_element(this, &to_);
...@@ -1301,7 +1301,7 @@ TF_BUILTIN(FastArraySlice, FastArraySliceCodeStubAssembler) { ...@@ -1301,7 +1301,7 @@ TF_BUILTIN(FastArraySlice, FastArraySliceCodeStubAssembler) {
// else let k be min(relativeStart, len.value()). // else let k be min(relativeStart, len.value()).
VARIABLE(k, MachineRepresentation::kTagged); VARIABLE(k, MachineRepresentation::kTagged);
Label relative_start_positive(this), relative_start_done(this); Label relative_start_positive(this), relative_start_done(this);
GotoIfNumberGreaterThanOrEqual(relative_start, SmiConstant(0), GotoIfNumericGreaterThanOrEqual(relative_start, SmiConstant(0),
&relative_start_positive); &relative_start_positive);
k.Bind(NumberMax(NumberAdd(len.value(), relative_start), NumberConstant(0))); k.Bind(NumberMax(NumberAdd(len.value(), relative_start), NumberConstant(0)));
Goto(&relative_start_done); Goto(&relative_start_done);
...@@ -1328,7 +1328,7 @@ TF_BUILTIN(FastArraySlice, FastArraySliceCodeStubAssembler) { ...@@ -1328,7 +1328,7 @@ TF_BUILTIN(FastArraySlice, FastArraySliceCodeStubAssembler) {
// else let final be min(relativeEnd, len). // else let final be min(relativeEnd, len).
VARIABLE(final, MachineRepresentation::kTagged); VARIABLE(final, MachineRepresentation::kTagged);
Label relative_end_positive(this), relative_end_done(this); Label relative_end_positive(this), relative_end_done(this);
GotoIfNumberGreaterThanOrEqual(relative_end.value(), NumberConstant(0), GotoIfNumericGreaterThanOrEqual(relative_end.value(), NumberConstant(0),
&relative_end_positive); &relative_end_positive);
final.Bind(NumberMax(NumberAdd(len.value(), relative_end.value()), final.Bind(NumberMax(NumberAdd(len.value(), relative_end.value()),
NumberConstant(0))); NumberConstant(0)));
...@@ -1367,7 +1367,7 @@ TF_BUILTIN(FastArraySlice, FastArraySliceCodeStubAssembler) { ...@@ -1367,7 +1367,7 @@ TF_BUILTIN(FastArraySlice, FastArraySliceCodeStubAssembler) {
BIND(&loop); BIND(&loop);
{ {
// 15. Repeat, while k < final // 15. Repeat, while k < final
GotoIfNumberGreaterThanOrEqual(k.value(), final.value(), &after_loop); GotoIfNumericGreaterThanOrEqual(k.value(), final.value(), &after_loop);
Node* p_k = k.value(); // ToString(context, k.value()) is no-op Node* p_k = k.value(); // ToString(context, k.value()) is no-op
...@@ -2371,10 +2371,16 @@ void ArrayIncludesIndexofAssembler::Generate(SearchVariant variant) { ...@@ -2371,10 +2371,16 @@ void ArrayIncludesIndexofAssembler::Generate(SearchVariant variant) {
{ {
GotoIfNot(UintPtrLessThan(index_var.value(), array_length), GotoIfNot(UintPtrLessThan(index_var.value(), array_length),
&return_not_found); &return_not_found);
Node* element_k = LoadFixedArrayElement(elements, index_var.value()); Node* element_k = LoadFixedArrayElement(elements, index_var.value());
TNode<Object> result = CallRuntime(Runtime::kBigIntEqual, context, Label continue_loop(this);
GotoIf(TaggedIsSmi(element_k), &continue_loop);
GotoIfNot(IsBigInt(element_k), &continue_loop);
TNode<Object> result = CallRuntime(Runtime::kBigIntEqualToBigInt, context,
search_element, element_k); search_element, element_k);
GotoIf(WordEqual(result, TrueConstant()), &return_found); Branch(WordEqual(result, TrueConstant()), &return_found, &continue_loop);
BIND(&continue_loop);
Increment(&index_var); Increment(&index_var);
Goto(&bigint_loop); Goto(&bigint_loop);
} }
...@@ -2782,7 +2788,7 @@ TF_BUILTIN(ArrayIteratorPrototypeNext, CodeStubAssembler) { ...@@ -2782,7 +2788,7 @@ TF_BUILTIN(ArrayIteratorPrototypeNext, CodeStubAssembler) {
length = var_length.value(); length = var_length.value();
} }
GotoIfNumberGreaterThanOrEqual(index, length, &set_done); GotoIfNumericGreaterThanOrEqual(index, length, &set_done);
StoreObjectField(iterator, JSArrayIterator::kNextIndexOffset, StoreObjectField(iterator, JSArrayIterator::kNextIndexOffset,
NumberInc(index)); NumberInc(index));
......
...@@ -640,8 +640,8 @@ void CollectionsBuiltinsAssembler::SameValueZeroBigInt(Node* key, ...@@ -640,8 +640,8 @@ void CollectionsBuiltinsAssembler::SameValueZeroBigInt(Node* key,
GotoIf(TaggedIsSmi(candidate_key), if_not_same); GotoIf(TaggedIsSmi(candidate_key), if_not_same);
GotoIfNot(IsBigInt(candidate_key), if_not_same); GotoIfNot(IsBigInt(candidate_key), if_not_same);
Branch(WordEqual(CallRuntime(Runtime::kBigIntEqual, NoContextConstant(), key, Branch(WordEqual(CallRuntime(Runtime::kBigIntEqualToBigInt,
candidate_key), NoContextConstant(), key, candidate_key),
TrueConstant()), TrueConstant()),
if_same, if_not_same); if_same, if_not_same);
} }
......
...@@ -546,8 +546,8 @@ TNode<Object> CodeStubAssembler::NumberMax(SloppyTNode<Object> a, ...@@ -546,8 +546,8 @@ TNode<Object> CodeStubAssembler::NumberMax(SloppyTNode<Object> a,
// TODO(danno): This could be optimized by specifically handling smi cases. // TODO(danno): This could be optimized by specifically handling smi cases.
VARIABLE(result, MachineRepresentation::kTagged); VARIABLE(result, MachineRepresentation::kTagged);
Label done(this), greater_than_equal_a(this), greater_than_equal_b(this); Label done(this), greater_than_equal_a(this), greater_than_equal_b(this);
GotoIfNumberGreaterThanOrEqual(a, b, &greater_than_equal_a); GotoIfNumericGreaterThanOrEqual(a, b, &greater_than_equal_a);
GotoIfNumberGreaterThanOrEqual(b, a, &greater_than_equal_b); GotoIfNumericGreaterThanOrEqual(b, a, &greater_than_equal_b);
result.Bind(NanConstant()); result.Bind(NanConstant());
Goto(&done); Goto(&done);
BIND(&greater_than_equal_a); BIND(&greater_than_equal_a);
...@@ -565,8 +565,8 @@ TNode<Object> CodeStubAssembler::NumberMin(SloppyTNode<Object> a, ...@@ -565,8 +565,8 @@ TNode<Object> CodeStubAssembler::NumberMin(SloppyTNode<Object> a,
// TODO(danno): This could be optimized by specifically handling smi cases. // TODO(danno): This could be optimized by specifically handling smi cases.
VARIABLE(result, MachineRepresentation::kTagged); VARIABLE(result, MachineRepresentation::kTagged);
Label done(this), greater_than_equal_a(this), greater_than_equal_b(this); Label done(this), greater_than_equal_a(this), greater_than_equal_b(this);
GotoIfNumberGreaterThanOrEqual(a, b, &greater_than_equal_a); GotoIfNumericGreaterThanOrEqual(a, b, &greater_than_equal_a);
GotoIfNumberGreaterThanOrEqual(b, a, &greater_than_equal_b); GotoIfNumericGreaterThanOrEqual(b, a, &greater_than_equal_b);
result.Bind(NanConstant()); result.Bind(NanConstant());
Goto(&done); Goto(&done);
BIND(&greater_than_equal_a); BIND(&greater_than_equal_a);
...@@ -4387,11 +4387,12 @@ Node* CodeStubAssembler::IsNumberArrayIndex(Node* number) { ...@@ -4387,11 +4387,12 @@ Node* CodeStubAssembler::IsNumberArrayIndex(Node* number) {
Label check_upper_bound(this), check_is_integer(this), out(this), Label check_upper_bound(this), check_is_integer(this), out(this),
return_false(this); return_false(this);
GotoIfNumberGreaterThanOrEqual(number, NumberConstant(0), &check_upper_bound); GotoIfNumericGreaterThanOrEqual(number, NumberConstant(0),
&check_upper_bound);
Goto(&return_false); Goto(&return_false);
BIND(&check_upper_bound); BIND(&check_upper_bound);
GotoIfNumberGreaterThanOrEqual(number, NumberConstant(kMaxUInt32), GotoIfNumericGreaterThanOrEqual(number, NumberConstant(kMaxUInt32),
&return_false); &return_false);
Goto(&check_is_integer); Goto(&check_is_integer);
...@@ -8196,8 +8197,7 @@ void CodeStubAssembler::BranchIfNumericRelationalComparison( ...@@ -8196,8 +8197,7 @@ void CodeStubAssembler::BranchIfNumericRelationalComparison(
} }
} }
// TODO(neis): Rename to GotoIfNumeric...? void CodeStubAssembler::GotoIfNumericGreaterThanOrEqual(Node* lhs, Node* rhs,
void CodeStubAssembler::GotoIfNumberGreaterThanOrEqual(Node* lhs, Node* rhs,
Label* if_true) { Label* if_true) {
Label if_false(this); Label if_false(this);
BranchIfNumericRelationalComparison( BranchIfNumericRelationalComparison(
...@@ -8973,8 +8973,8 @@ Node* CodeStubAssembler::Equal(Node* left, Node* right, Node* context, ...@@ -8973,8 +8973,8 @@ Node* CodeStubAssembler::Equal(Node* left, Node* right, Node* context,
BIND(&if_right_bigint); BIND(&if_right_bigint);
{ {
result.Bind(CallRuntime(Runtime::kBigIntEqual, NoContextConstant(), result.Bind(CallRuntime(Runtime::kBigIntEqualToBigInt,
left, right)); NoContextConstant(), left, right));
Goto(&end); Goto(&end);
} }
...@@ -9147,7 +9147,7 @@ Node* CodeStubAssembler::StrictEqual(Node* lhs, Node* rhs, ...@@ -9147,7 +9147,7 @@ Node* CodeStubAssembler::StrictEqual(Node* lhs, Node* rhs,
// } // }
// } else if (lhs->IsBigInt()) { // } else if (lhs->IsBigInt()) {
// if (rhs->IsBigInt()) { // if (rhs->IsBigInt()) {
// return %BigIntEqual(lhs, rhs); // return %BigIntEqualToBigInt(lhs, rhs);
// } else { // } else {
// return false; // return false;
// } // }
...@@ -9331,7 +9331,7 @@ Node* CodeStubAssembler::StrictEqual(Node* lhs, Node* rhs, ...@@ -9331,7 +9331,7 @@ Node* CodeStubAssembler::StrictEqual(Node* lhs, Node* rhs,
WordEqual(var_type_feedback->value(), WordEqual(var_type_feedback->value(),
SmiConstant(CompareOperationFeedback::kAny))); SmiConstant(CompareOperationFeedback::kAny)));
} }
result.Bind(CallRuntime(Runtime::kBigIntEqual, result.Bind(CallRuntime(Runtime::kBigIntEqualToBigInt,
NoContextConstant(), lhs, rhs)); NoContextConstant(), lhs, rhs));
Goto(&end); Goto(&end);
} }
...@@ -9516,8 +9516,8 @@ void CodeStubAssembler::BranchIfSameValue(Node* lhs, Node* rhs, Label* if_true, ...@@ -9516,8 +9516,8 @@ void CodeStubAssembler::BranchIfSameValue(Node* lhs, Node* rhs, Label* if_true,
BIND(&if_lhsisbigint); BIND(&if_lhsisbigint);
{ {
GotoIfNot(IsBigInt(rhs), if_false); GotoIfNot(IsBigInt(rhs), if_false);
Node* const result = Node* const result = CallRuntime(Runtime::kBigIntEqualToBigInt,
CallRuntime(Runtime::kBigIntEqual, NoContextConstant(), lhs, rhs); NoContextConstant(), lhs, rhs);
Branch(IsTrue(result), if_true, if_false); Branch(IsTrue(result), if_true, if_false);
} }
} }
......
...@@ -1735,7 +1735,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { ...@@ -1735,7 +1735,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
Branch(IsAccessorPair(value), if_accessor_pair, if_not_accessor_pair); Branch(IsAccessorPair(value), if_accessor_pair, if_not_accessor_pair);
} }
void GotoIfNumberGreaterThanOrEqual(Node* lhs, Node* rhs, Label* if_false); void GotoIfNumericGreaterThanOrEqual(Node* lhs, Node* rhs, Label* if_false);
Node* Equal(Node* lhs, Node* rhs, Node* context, Node* Equal(Node* lhs, Node* rhs, Node* context,
Variable* var_type_feedback = nullptr); Variable* var_type_feedback = nullptr);
......
...@@ -293,7 +293,7 @@ bool IntrinsicHasNoSideEffect(Runtime::FunctionId id) { ...@@ -293,7 +293,7 @@ bool IntrinsicHasNoSideEffect(Runtime::FunctionId id) {
V(SubString) \ V(SubString) \
V(RegExpInternalReplace) \ V(RegExpInternalReplace) \
/* BigInts */ \ /* BigInts */ \
V(BigIntEqual) \ V(BigIntEqualToBigInt) \
V(BigIntToBoolean) \ V(BigIntToBoolean) \
/* Literals */ \ /* Literals */ \
V(CreateArrayLiteral) \ V(CreateArrayLiteral) \
......
...@@ -37,16 +37,13 @@ RUNTIME_FUNCTION(Runtime_BigIntCompareToNumber) { ...@@ -37,16 +37,13 @@ RUNTIME_FUNCTION(Runtime_BigIntCompareToNumber) {
return *isolate->factory()->ToBoolean(result); return *isolate->factory()->ToBoolean(result);
} }
RUNTIME_FUNCTION(Runtime_BigIntEqual) { RUNTIME_FUNCTION(Runtime_BigIntEqualToBigInt) {
SealHandleScope shs(isolate); SealHandleScope shs(isolate);
DCHECK_EQ(2, args.length()); DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0); CONVERT_ARG_HANDLE_CHECKED(BigInt, lhs, 0);
CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1); CONVERT_ARG_HANDLE_CHECKED(BigInt, rhs, 1);
bool result = lhs->IsBigInt() && rhs->IsBigInt() && bool result = BigInt::EqualToBigInt(*lhs, *rhs);
BigInt::EqualToBigInt(BigInt::cast(*lhs), BigInt::cast(*rhs));
return *isolate->factory()->ToBoolean(result); return *isolate->factory()->ToBoolean(result);
// TODO(neis): Remove IsBigInt checks?
// TODO(neis): Rename to BigIntEqualToBigInt.
} }
RUNTIME_FUNCTION(Runtime_BigIntEqualToNumber) { RUNTIME_FUNCTION(Runtime_BigIntEqualToNumber) {
......
...@@ -73,7 +73,7 @@ namespace internal { ...@@ -73,7 +73,7 @@ namespace internal {
F(BigIntBinaryOp, 3, 1) \ F(BigIntBinaryOp, 3, 1) \
F(BigIntCompareToBigInt, 3, 1) \ F(BigIntCompareToBigInt, 3, 1) \
F(BigIntCompareToNumber, 3, 1) \ F(BigIntCompareToNumber, 3, 1) \
F(BigIntEqual, 2, 1) \ F(BigIntEqualToBigInt, 2, 1) \
F(BigIntEqualToNumber, 2, 1) \ F(BigIntEqualToNumber, 2, 1) \
F(BigIntEqualToString, 2, 1) \ F(BigIntEqualToString, 2, 1) \
F(BigIntToBoolean, 1, 1) \ F(BigIntToBoolean, 1, 1) \
......
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