[csa] ChangeUint32ToTagged doesn't need to double-check for overflow.
Bug: v8:8015 Change-Id: Iabb051be94768e5ca570a8fa5128a3dbf66065da Reviewed-on: https://chromium-review.googlesource.com/1221194 Commit-Queue: Benedikt Meurer <bmeurer@chromium.org> Reviewed-by: Tobias Tebbi <tebbi@chromium.org> Cr-Commit-Position: refs/heads/master@{#55829}
This commit is contained in:
parent
c97cb459d0
commit
3c082741a4
@ -5044,28 +5044,13 @@ TNode<Number> CodeStubAssembler::ChangeUint32ToTagged(
|
||||
if_join(this);
|
||||
TVARIABLE(Number, var_result);
|
||||
// If {value} > 2^31 - 1, we need to store it in a HeapNumber.
|
||||
Branch(Uint32LessThan(Int32Constant(Smi::kMaxValue), value), &if_overflow,
|
||||
Branch(Uint32LessThan(Uint32Constant(Smi::kMaxValue), value), &if_overflow,
|
||||
&if_not_overflow);
|
||||
|
||||
BIND(&if_not_overflow);
|
||||
{
|
||||
if (SmiValuesAre32Bits()) {
|
||||
var_result =
|
||||
SmiTag(ReinterpretCast<IntPtrT>(ChangeUint32ToUint64(value)));
|
||||
} else {
|
||||
DCHECK(SmiValuesAre31Bits());
|
||||
// If tagging {value} results in an overflow, we need to use a HeapNumber
|
||||
// to represent it.
|
||||
// TODO(tebbi): This overflow can never happen.
|
||||
TNode<PairT<Int32T, BoolT>> pair = Int32AddWithOverflow(
|
||||
UncheckedCast<Int32T>(value), UncheckedCast<Int32T>(value));
|
||||
TNode<BoolT> overflow = Projection<1>(pair);
|
||||
GotoIf(overflow, &if_overflow);
|
||||
|
||||
TNode<IntPtrT> almost_tagged_value =
|
||||
ChangeInt32ToIntPtr(Projection<0>(pair));
|
||||
var_result = BitcastWordToTaggedSigned(almost_tagged_value);
|
||||
}
|
||||
// The {value} is definitely in valid Smi range.
|
||||
var_result = SmiTag(Signed(ChangeUint32ToWord(value)));
|
||||
}
|
||||
Goto(&if_join);
|
||||
|
||||
|
@ -698,6 +698,9 @@ class V8_EXPORT_PRIVATE CodeAssembler {
|
||||
TNode<Int32T> Int32Constant(int32_t value);
|
||||
TNode<Int64T> Int64Constant(int64_t value);
|
||||
TNode<IntPtrT> IntPtrConstant(intptr_t value);
|
||||
TNode<Uint32T> Uint32Constant(uint32_t value) {
|
||||
return Unsigned(Int32Constant(bit_cast<int32_t>(value)));
|
||||
}
|
||||
TNode<Number> NumberConstant(double value);
|
||||
TNode<Smi> SmiConstant(Smi* value);
|
||||
TNode<Smi> SmiConstant(int value);
|
||||
|
Loading…
Reference in New Issue
Block a user