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( ...@@ -5629,48 +5629,43 @@ TNode<Float64T> CodeStubAssembler::TruncateTaggedToFloat64(
TNode<Word32T> CodeStubAssembler::TruncateTaggedToWord32( TNode<Word32T> CodeStubAssembler::TruncateTaggedToWord32(
SloppyTNode<Context> context, SloppyTNode<Object> value) { SloppyTNode<Context> context, SloppyTNode<Object> value) {
VARIABLE(var_result, MachineRepresentation::kWord32); TVARIABLE(Word32T, var_result);
Label done(this); Label done(this);
TaggedToWord32OrBigIntImpl<Object::Conversion::kToNumber>(context, value, TaggedToWord32OrBigIntImpl<Object::Conversion::kToNumber>(context, value,
&done, &var_result); &done, &var_result);
BIND(&done); 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, // 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}. // or find that it is a BigInt and jump to {if_bigint}.
void CodeStubAssembler::TaggedToWord32OrBigInt(Node* context, Node* value, void CodeStubAssembler::TaggedToWord32OrBigInt(
Label* if_number, TNode<Context> context, TNode<Object> value, Label* if_number,
Variable* var_word32, TVariable<Word32T>* var_word32, Label* if_bigint,
Label* if_bigint, TVariable<Object>* var_maybe_bigint) {
Variable* var_bigint) {
TaggedToWord32OrBigIntImpl<Object::Conversion::kToNumeric>( 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, // 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, // or find that it is a BigInt and jump to {if_bigint}. In either case,
// store the type feedback in {var_feedback}. // store the type feedback in {var_feedback}.
void CodeStubAssembler::TaggedToWord32OrBigIntWithFeedback( void CodeStubAssembler::TaggedToWord32OrBigIntWithFeedback(
Node* context, Node* value, Label* if_number, Variable* var_word32, TNode<Context> context, TNode<Object> value, Label* if_number,
Label* if_bigint, Variable* var_bigint, Variable* var_feedback) { TVariable<Word32T>* var_word32, Label* if_bigint,
TVariable<Object>* var_maybe_bigint, TVariable<Smi>* var_feedback) {
TaggedToWord32OrBigIntImpl<Object::Conversion::kToNumeric>( 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); var_feedback);
} }
template <Object::Conversion conversion> template <Object::Conversion conversion>
void CodeStubAssembler::TaggedToWord32OrBigIntImpl( void CodeStubAssembler::TaggedToWord32OrBigIntImpl(
Node* context, Node* value, Label* if_number, Variable* var_word32, TNode<Context> context, TNode<Object> value, Label* if_number,
Label* if_bigint, Variable* var_bigint, Variable* var_feedback) { TVariable<Word32T>* var_word32, Label* if_bigint,
DCHECK(var_word32->rep() == MachineRepresentation::kWord32); TVariable<Object>* var_maybe_bigint, TVariable<Smi>* var_feedback) {
DCHECK(var_bigint == nullptr ||
var_bigint->rep() == MachineRepresentation::kTagged);
DCHECK(var_feedback == nullptr ||
var_feedback->rep() == MachineRepresentation::kTaggedSigned);
// We might need to loop after conversion. // We might need to loop after conversion.
VARIABLE(var_value, MachineRepresentation::kTagged, value); TVARIABLE(Object, var_value, value);
OverwriteFeedback(var_feedback, BinaryOperationFeedback::kNone); OverwriteFeedback(var_feedback, BinaryOperationFeedback::kNone);
Variable* loop_vars[] = {&var_value, var_feedback}; Variable* loop_vars[] = {&var_value, var_feedback};
int num_vars = int num_vars =
...@@ -5685,12 +5680,13 @@ void CodeStubAssembler::TaggedToWord32OrBigIntImpl( ...@@ -5685,12 +5680,13 @@ void CodeStubAssembler::TaggedToWord32OrBigIntImpl(
GotoIf(TaggedIsNotSmi(value), &not_smi); GotoIf(TaggedIsNotSmi(value), &not_smi);
// {value} is a Smi. // {value} is a Smi.
var_word32->Bind(SmiToInt32(value)); *var_word32 = SmiToInt32(CAST(value));
CombineFeedback(var_feedback, BinaryOperationFeedback::kSignedSmall); CombineFeedback(var_feedback, BinaryOperationFeedback::kSignedSmall);
Goto(if_number); Goto(if_number);
BIND(&not_smi); 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); GotoIf(IsHeapNumberMap(map), &is_heap_number);
TNode<Uint16T> instance_type = LoadMapInstanceType(map); TNode<Uint16T> instance_type = LoadMapInstanceType(map);
if (conversion == Object::Conversion::kToNumeric) { if (conversion == Object::Conversion::kToNumeric) {
...@@ -5703,7 +5699,7 @@ void CodeStubAssembler::TaggedToWord32OrBigIntImpl( ...@@ -5703,7 +5699,7 @@ void CodeStubAssembler::TaggedToWord32OrBigIntImpl(
// We do not require an Or with earlier feedback here because once we // 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 // 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. // 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))); SmiConstant(BinaryOperationFeedback::kNone)));
} }
GotoIf(InstanceTypeEqual(instance_type, ODDBALL_TYPE), &is_oddball); GotoIf(InstanceTypeEqual(instance_type, ODDBALL_TYPE), &is_oddball);
...@@ -5711,25 +5707,25 @@ void CodeStubAssembler::TaggedToWord32OrBigIntImpl( ...@@ -5711,25 +5707,25 @@ void CodeStubAssembler::TaggedToWord32OrBigIntImpl(
auto builtin = conversion == Object::Conversion::kToNumeric auto builtin = conversion == Object::Conversion::kToNumeric
? Builtins::kNonNumberToNumeric ? Builtins::kNonNumberToNumeric
: Builtins::kNonNumberToNumber; : Builtins::kNonNumberToNumber;
var_value.Bind(CallBuiltin(builtin, context, value)); var_value = CallBuiltin(builtin, context, value);
OverwriteFeedback(var_feedback, BinaryOperationFeedback::kAny); OverwriteFeedback(var_feedback, BinaryOperationFeedback::kAny);
Goto(&loop); Goto(&loop);
BIND(&is_oddball); BIND(&is_oddball);
var_value.Bind(LoadObjectField(value, Oddball::kToNumberOffset)); var_value = LoadObjectField(value_heap_object, Oddball::kToNumberOffset);
OverwriteFeedback(var_feedback, OverwriteFeedback(var_feedback,
BinaryOperationFeedback::kNumberOrOddball); BinaryOperationFeedback::kNumberOrOddball);
Goto(&loop); Goto(&loop);
} }
BIND(&is_heap_number); BIND(&is_heap_number);
var_word32->Bind(TruncateHeapNumberValueToWord32(CAST(value))); *var_word32 = TruncateHeapNumberValueToWord32(CAST(value));
CombineFeedback(var_feedback, BinaryOperationFeedback::kNumber); CombineFeedback(var_feedback, BinaryOperationFeedback::kNumber);
Goto(if_number); Goto(if_number);
if (conversion == Object::Conversion::kToNumeric) { if (conversion == Object::Conversion::kToNumeric) {
BIND(&is_bigint); BIND(&is_bigint);
var_bigint->Bind(value); *var_maybe_bigint = value;
CombineFeedback(var_feedback, BinaryOperationFeedback::kBigInt); CombineFeedback(var_feedback, BinaryOperationFeedback::kBigInt);
Goto(if_bigint); Goto(if_bigint);
} }
...@@ -11547,8 +11543,8 @@ Operation Reverse(Operation op) { ...@@ -11547,8 +11543,8 @@ Operation Reverse(Operation op) {
} // anonymous namespace } // anonymous namespace
TNode<Oddball> CodeStubAssembler::RelationalComparison( TNode<Oddball> CodeStubAssembler::RelationalComparison(
Operation op, SloppyTNode<Object> left, SloppyTNode<Object> right, Operation op, TNode<Object> left, TNode<Object> right,
SloppyTNode<Context> context, TVariable<Smi>* var_type_feedback) { TNode<Context> context, TVariable<Smi>* var_type_feedback) {
Label return_true(this), return_false(this), do_float_comparison(this), Label return_true(this), return_false(this), do_float_comparison(this),
end(this); end(this);
TVARIABLE(Oddball, var_result); // Actually only "true" or "false". TVARIABLE(Oddball, var_result); // Actually only "true" or "false".
......
...@@ -2305,12 +2305,16 @@ class V8_EXPORT_PRIVATE CodeStubAssembler ...@@ -2305,12 +2305,16 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
SloppyTNode<Object> value); SloppyTNode<Object> value);
TNode<Word32T> TruncateTaggedToWord32(SloppyTNode<Context> context, TNode<Word32T> TruncateTaggedToWord32(SloppyTNode<Context> context,
SloppyTNode<Object> value); SloppyTNode<Object> value);
void TaggedToWord32OrBigInt(Node* context, Node* value, Label* if_number, void TaggedToWord32OrBigInt(TNode<Context> context, TNode<Object> value,
Variable* var_word32, Label* if_bigint, Label* if_number, TVariable<Word32T>* var_word32,
Variable* var_bigint); Label* if_bigint,
void TaggedToWord32OrBigIntWithFeedback( TVariable<Object>* var_maybe_bigint);
Node* context, Node* value, Label* if_number, Variable* var_word32, void TaggedToWord32OrBigIntWithFeedback(TNode<Context> context,
Label* if_bigint, Variable* var_bigint, Variable* var_feedback); 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. // Truncate the floating point value of a HeapNumber to an Int32.
TNode<Int32T> TruncateHeapNumberValueToWord32(TNode<HeapNumber> object); TNode<Int32T> TruncateHeapNumberValueToWord32(TNode<HeapNumber> object);
...@@ -3409,9 +3413,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler ...@@ -3409,9 +3413,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
TNode<IntPtrT> end_offset, RootIndex root); TNode<IntPtrT> end_offset, RootIndex root);
TNode<Oddball> RelationalComparison( TNode<Oddball> RelationalComparison(
Operation op, SloppyTNode<Object> left, SloppyTNode<Object> right, Operation op, TNode<Object> left, TNode<Object> right,
SloppyTNode<Context> context, TNode<Context> context, TVariable<Smi>* var_type_feedback = nullptr);
TVariable<Smi>* var_type_feedback = nullptr);
void BranchIfNumberRelationalComparison(Operation op, void BranchIfNumberRelationalComparison(Operation op,
SloppyTNode<Number> left, SloppyTNode<Number> left,
...@@ -3811,11 +3814,12 @@ class V8_EXPORT_PRIVATE CodeStubAssembler ...@@ -3811,11 +3814,12 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
Variable* var_numeric, Variable* var_feedback); Variable* var_numeric, Variable* var_feedback);
template <Object::Conversion conversion> template <Object::Conversion conversion>
void TaggedToWord32OrBigIntImpl(Node* context, Node* value, Label* if_number, void TaggedToWord32OrBigIntImpl(TNode<Context> context, TNode<Object> value,
Variable* var_word32, Label* if_number,
TVariable<Word32T>* var_word32,
Label* if_bigint = nullptr, Label* if_bigint = nullptr,
Variable* var_bigint = nullptr, TVariable<Object>* var_maybe_bigint = nullptr,
Variable* var_feedback = nullptr); TVariable<Smi>* var_feedback = nullptr);
private: private:
// Low-level accessors for Descriptor arrays. // 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