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