Commit 26372107 authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[CSA][cleanup] TNodify builtins numbers gen

TNodify related methods in CSA:
 * TaggedToWord32OrBigInt
 * TaggedToWord32OrBigIntWithFeedback
 * TaggedToWord32OrBigIntImpl

Remove Sloppy-ness in RelationalComparison

Bug: v8:6949
Change-Id: I970a40a424f6e8cdc45544eb79c95291a5a5a608
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1807362Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarMythri Alle <mythria@chromium.org>
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63861}
parent d7903dd3
This diff is collapsed.
......@@ -5629,48 +5629,43 @@ TNode<Float64T> CodeStubAssembler::TruncateTaggedToFloat64(
TNode<Word32T> CodeStubAssembler::TruncateTaggedToWord32(
SloppyTNode<Context> context, SloppyTNode<Object> value) {
VARIABLE(var_result, MachineRepresentation::kWord32);
TVARIABLE(Word32T, var_result);
Label done(this);
TaggedToWord32OrBigIntImpl<Object::Conversion::kToNumber>(context, value,
&done, &var_result);
BIND(&done);
return UncheckedCast<Word32T>(var_result.value());
return var_result.value();
}
// Truncate {value} to word32 and jump to {if_number} if it is a Number,
// or find that it is a BigInt and jump to {if_bigint}.
void CodeStubAssembler::TaggedToWord32OrBigInt(Node* context, Node* value,
Label* if_number,
Variable* var_word32,
Label* if_bigint,
Variable* var_bigint) {
void CodeStubAssembler::TaggedToWord32OrBigInt(
TNode<Context> context, TNode<Object> value, Label* if_number,
TVariable<Word32T>* var_word32, Label* if_bigint,
TVariable<Object>* var_maybe_bigint) {
TaggedToWord32OrBigIntImpl<Object::Conversion::kToNumeric>(
context, value, if_number, var_word32, if_bigint, var_bigint);
context, value, if_number, var_word32, if_bigint, var_maybe_bigint);
}
// Truncate {value} to word32 and jump to {if_number} if it is a Number,
// or find that it is a BigInt and jump to {if_bigint}. In either case,
// store the type feedback in {var_feedback}.
void CodeStubAssembler::TaggedToWord32OrBigIntWithFeedback(
Node* context, Node* value, Label* if_number, Variable* var_word32,
Label* if_bigint, Variable* var_bigint, Variable* var_feedback) {
TNode<Context> context, TNode<Object> value, Label* if_number,
TVariable<Word32T>* var_word32, Label* if_bigint,
TVariable<Object>* var_maybe_bigint, TVariable<Smi>* var_feedback) {
TaggedToWord32OrBigIntImpl<Object::Conversion::kToNumeric>(
context, value, if_number, var_word32, if_bigint, var_bigint,
context, value, if_number, var_word32, if_bigint, var_maybe_bigint,
var_feedback);
}
template <Object::Conversion conversion>
void CodeStubAssembler::TaggedToWord32OrBigIntImpl(
Node* context, Node* value, Label* if_number, Variable* var_word32,
Label* if_bigint, Variable* var_bigint, Variable* var_feedback) {
DCHECK(var_word32->rep() == MachineRepresentation::kWord32);
DCHECK(var_bigint == nullptr ||
var_bigint->rep() == MachineRepresentation::kTagged);
DCHECK(var_feedback == nullptr ||
var_feedback->rep() == MachineRepresentation::kTaggedSigned);
TNode<Context> context, TNode<Object> value, Label* if_number,
TVariable<Word32T>* var_word32, Label* if_bigint,
TVariable<Object>* var_maybe_bigint, TVariable<Smi>* var_feedback) {
// We might need to loop after conversion.
VARIABLE(var_value, MachineRepresentation::kTagged, value);
TVARIABLE(Object, var_value, value);
OverwriteFeedback(var_feedback, BinaryOperationFeedback::kNone);
Variable* loop_vars[] = {&var_value, var_feedback};
int num_vars =
......@@ -5685,12 +5680,13 @@ void CodeStubAssembler::TaggedToWord32OrBigIntImpl(
GotoIf(TaggedIsNotSmi(value), &not_smi);
// {value} is a Smi.
var_word32->Bind(SmiToInt32(value));
*var_word32 = SmiToInt32(CAST(value));
CombineFeedback(var_feedback, BinaryOperationFeedback::kSignedSmall);
Goto(if_number);
BIND(&not_smi);
TNode<Map> map = LoadMap(value);
TNode<HeapObject> value_heap_object = CAST(value);
TNode<Map> map = LoadMap(value_heap_object);
GotoIf(IsHeapNumberMap(map), &is_heap_number);
TNode<Uint16T> instance_type = LoadMapInstanceType(map);
if (conversion == Object::Conversion::kToNumeric) {
......@@ -5703,7 +5699,7 @@ void CodeStubAssembler::TaggedToWord32OrBigIntImpl(
// We do not require an Or with earlier feedback here because once we
// convert the value to a Numeric, we cannot reach this path. We can
// only reach this path on the first pass when the feedback is kNone.
CSA_ASSERT(this, SmiEqual(CAST(var_feedback->value()),
CSA_ASSERT(this, SmiEqual(var_feedback->value(),
SmiConstant(BinaryOperationFeedback::kNone)));
}
GotoIf(InstanceTypeEqual(instance_type, ODDBALL_TYPE), &is_oddball);
......@@ -5711,25 +5707,25 @@ void CodeStubAssembler::TaggedToWord32OrBigIntImpl(
auto builtin = conversion == Object::Conversion::kToNumeric
? Builtins::kNonNumberToNumeric
: Builtins::kNonNumberToNumber;
var_value.Bind(CallBuiltin(builtin, context, value));
var_value = CallBuiltin(builtin, context, value);
OverwriteFeedback(var_feedback, BinaryOperationFeedback::kAny);
Goto(&loop);
BIND(&is_oddball);
var_value.Bind(LoadObjectField(value, Oddball::kToNumberOffset));
var_value = LoadObjectField(value_heap_object, Oddball::kToNumberOffset);
OverwriteFeedback(var_feedback,
BinaryOperationFeedback::kNumberOrOddball);
Goto(&loop);
}
BIND(&is_heap_number);
var_word32->Bind(TruncateHeapNumberValueToWord32(CAST(value)));
*var_word32 = TruncateHeapNumberValueToWord32(CAST(value));
CombineFeedback(var_feedback, BinaryOperationFeedback::kNumber);
Goto(if_number);
if (conversion == Object::Conversion::kToNumeric) {
BIND(&is_bigint);
var_bigint->Bind(value);
*var_maybe_bigint = value;
CombineFeedback(var_feedback, BinaryOperationFeedback::kBigInt);
Goto(if_bigint);
}
......@@ -11547,8 +11543,8 @@ Operation Reverse(Operation op) {
} // anonymous namespace
TNode<Oddball> CodeStubAssembler::RelationalComparison(
Operation op, SloppyTNode<Object> left, SloppyTNode<Object> right,
SloppyTNode<Context> context, TVariable<Smi>* var_type_feedback) {
Operation op, TNode<Object> left, TNode<Object> right,
TNode<Context> context, TVariable<Smi>* var_type_feedback) {
Label return_true(this), return_false(this), do_float_comparison(this),
end(this);
TVARIABLE(Oddball, var_result); // Actually only "true" or "false".
......
......@@ -2305,12 +2305,16 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
SloppyTNode<Object> value);
TNode<Word32T> TruncateTaggedToWord32(SloppyTNode<Context> context,
SloppyTNode<Object> value);
void TaggedToWord32OrBigInt(Node* context, Node* value, Label* if_number,
Variable* var_word32, Label* if_bigint,
Variable* var_bigint);
void TaggedToWord32OrBigIntWithFeedback(
Node* context, Node* value, Label* if_number, Variable* var_word32,
Label* if_bigint, Variable* var_bigint, Variable* var_feedback);
void TaggedToWord32OrBigInt(TNode<Context> context, TNode<Object> value,
Label* if_number, TVariable<Word32T>* var_word32,
Label* if_bigint,
TVariable<Object>* var_maybe_bigint);
void TaggedToWord32OrBigIntWithFeedback(TNode<Context> context,
TNode<Object> value, Label* if_number,
TVariable<Word32T>* var_word32,
Label* if_bigint,
TVariable<Object>* var_maybe_bigint,
TVariable<Smi>* var_feedback);
// Truncate the floating point value of a HeapNumber to an Int32.
TNode<Int32T> TruncateHeapNumberValueToWord32(TNode<HeapNumber> object);
......@@ -3409,9 +3413,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
TNode<IntPtrT> end_offset, RootIndex root);
TNode<Oddball> RelationalComparison(
Operation op, SloppyTNode<Object> left, SloppyTNode<Object> right,
SloppyTNode<Context> context,
TVariable<Smi>* var_type_feedback = nullptr);
Operation op, TNode<Object> left, TNode<Object> right,
TNode<Context> context, TVariable<Smi>* var_type_feedback = nullptr);
void BranchIfNumberRelationalComparison(Operation op,
SloppyTNode<Number> left,
......@@ -3811,11 +3814,12 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
Variable* var_numeric, Variable* var_feedback);
template <Object::Conversion conversion>
void TaggedToWord32OrBigIntImpl(Node* context, Node* value, Label* if_number,
Variable* var_word32,
void TaggedToWord32OrBigIntImpl(TNode<Context> context, TNode<Object> value,
Label* if_number,
TVariable<Word32T>* var_word32,
Label* if_bigint = nullptr,
Variable* var_bigint = nullptr,
Variable* var_feedback = nullptr);
TVariable<Object>* var_maybe_bigint = nullptr,
TVariable<Smi>* var_feedback = nullptr);
private:
// Low-level accessors for Descriptor arrays.
......
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