[cleanup][csa] TNodify CheckForCapacityGrow and type VARIABLEs
This CL types almost all remaining VARIABLEs. Only one remains (in PrepareValueForWriteToTypedArray) since it depends on a variable MachineRepresentation. Will be done in a follow-up. Bug: v8:6949 Change-Id: Icdec3d8fdc1459c0b35fc3d1f7e8816981bbccba Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2282594 Reviewed-by: Dan Elphick <delphick@chromium.org> Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org> Cr-Commit-Position: refs/heads/master@{#68709}
This commit is contained in:
parent
b7512d3409
commit
ad29219533
@ -6995,7 +6995,7 @@ TNode<Number> CodeStubAssembler::ToUint32(SloppyTNode<Context> context,
|
|||||||
|
|
||||||
Label out(this);
|
Label out(this);
|
||||||
|
|
||||||
VARIABLE(var_result, MachineRepresentation::kTagged, input);
|
TVARIABLE(Object, var_result, input);
|
||||||
|
|
||||||
// Early exit for positive smis.
|
// Early exit for positive smis.
|
||||||
{
|
{
|
||||||
@ -7007,7 +7007,7 @@ TNode<Number> CodeStubAssembler::ToUint32(SloppyTNode<Context> context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const TNode<Number> number = ToNumber(context, input);
|
const TNode<Number> number = ToNumber(context, input);
|
||||||
var_result.Bind(number);
|
var_result = number;
|
||||||
|
|
||||||
// Perhaps we have a positive smi now.
|
// Perhaps we have a positive smi now.
|
||||||
{
|
{
|
||||||
@ -7023,7 +7023,7 @@ TNode<Number> CodeStubAssembler::ToUint32(SloppyTNode<Context> context,
|
|||||||
{
|
{
|
||||||
const TNode<Int32T> uint32_value = SmiToInt32(CAST(number));
|
const TNode<Int32T> uint32_value = SmiToInt32(CAST(number));
|
||||||
TNode<Float64T> float64_value = ChangeUint32ToFloat64(uint32_value);
|
TNode<Float64T> float64_value = ChangeUint32ToFloat64(uint32_value);
|
||||||
var_result.Bind(AllocateHeapNumberWithValue(float64_value));
|
var_result = AllocateHeapNumberWithValue(float64_value);
|
||||||
Goto(&out);
|
Goto(&out);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7075,13 +7075,13 @@ TNode<Number> CodeStubAssembler::ToUint32(SloppyTNode<Context> context,
|
|||||||
x = Float64Mod(x, float_two_32);
|
x = Float64Mod(x, float_two_32);
|
||||||
|
|
||||||
const TNode<Number> result = ChangeFloat64ToTagged(x);
|
const TNode<Number> result = ChangeFloat64ToTagged(x);
|
||||||
var_result.Bind(result);
|
var_result = result;
|
||||||
Goto(&out);
|
Goto(&out);
|
||||||
}
|
}
|
||||||
|
|
||||||
BIND(&return_zero);
|
BIND(&return_zero);
|
||||||
{
|
{
|
||||||
var_result.Bind(SmiConstant(0));
|
var_result = SmiConstant(0);
|
||||||
Goto(&out);
|
Goto(&out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7092,14 +7092,14 @@ TNode<Number> CodeStubAssembler::ToUint32(SloppyTNode<Context> context,
|
|||||||
|
|
||||||
TNode<String> CodeStubAssembler::ToString_Inline(SloppyTNode<Context> context,
|
TNode<String> CodeStubAssembler::ToString_Inline(SloppyTNode<Context> context,
|
||||||
SloppyTNode<Object> input) {
|
SloppyTNode<Object> input) {
|
||||||
VARIABLE(var_result, MachineRepresentation::kTagged, input);
|
TVARIABLE(Object, var_result, input);
|
||||||
Label stub_call(this, Label::kDeferred), out(this);
|
Label stub_call(this, Label::kDeferred), out(this);
|
||||||
|
|
||||||
GotoIf(TaggedIsSmi(input), &stub_call);
|
GotoIf(TaggedIsSmi(input), &stub_call);
|
||||||
Branch(IsString(CAST(input)), &out, &stub_call);
|
Branch(IsString(CAST(input)), &out, &stub_call);
|
||||||
|
|
||||||
BIND(&stub_call);
|
BIND(&stub_call);
|
||||||
var_result.Bind(CallBuiltin(Builtins::kToString, context, input));
|
var_result = CallBuiltin(Builtins::kToString, context, input);
|
||||||
Goto(&out);
|
Goto(&out);
|
||||||
|
|
||||||
BIND(&out);
|
BIND(&out);
|
||||||
@ -9543,7 +9543,7 @@ Node* CodeStubAssembler::PrepareValueForWriteToTypedArray(
|
|||||||
}
|
}
|
||||||
|
|
||||||
VARIABLE(var_result, rep);
|
VARIABLE(var_result, rep);
|
||||||
VARIABLE(var_input, MachineRepresentation::kTagged, input);
|
TVARIABLE(Object, var_input, input);
|
||||||
Label done(this, &var_result), if_smi(this), if_heapnumber_or_oddball(this),
|
Label done(this, &var_result), if_smi(this), if_heapnumber_or_oddball(this),
|
||||||
convert(this), loop(this, &var_input);
|
convert(this), loop(this, &var_input);
|
||||||
Goto(&loop);
|
Goto(&loop);
|
||||||
@ -9552,16 +9552,17 @@ Node* CodeStubAssembler::PrepareValueForWriteToTypedArray(
|
|||||||
// We can handle both HeapNumber and Oddball here, since Oddball has the
|
// We can handle both HeapNumber and Oddball here, since Oddball has the
|
||||||
// same layout as the HeapNumber for the HeapNumber::value field. This
|
// same layout as the HeapNumber for the HeapNumber::value field. This
|
||||||
// way we can also properly optimize stores of oddballs to typed arrays.
|
// way we can also properly optimize stores of oddballs to typed arrays.
|
||||||
GotoIf(IsHeapNumber(CAST(var_input.value())), &if_heapnumber_or_oddball);
|
TNode<HeapObject> heap_object = CAST(var_input.value());
|
||||||
|
GotoIf(IsHeapNumber(heap_object), &if_heapnumber_or_oddball);
|
||||||
STATIC_ASSERT_FIELD_OFFSETS_EQUAL(HeapNumber::kValueOffset,
|
STATIC_ASSERT_FIELD_OFFSETS_EQUAL(HeapNumber::kValueOffset,
|
||||||
Oddball::kToNumberRawOffset);
|
Oddball::kToNumberRawOffset);
|
||||||
Branch(HasInstanceType(var_input.value(), ODDBALL_TYPE),
|
Branch(HasInstanceType(heap_object, ODDBALL_TYPE), &if_heapnumber_or_oddball,
|
||||||
&if_heapnumber_or_oddball, &convert);
|
&convert);
|
||||||
|
|
||||||
BIND(&if_heapnumber_or_oddball);
|
BIND(&if_heapnumber_or_oddball);
|
||||||
{
|
{
|
||||||
TNode<Float64T> value = UncheckedCast<Float64T>(LoadObjectField(
|
TNode<Float64T> value =
|
||||||
var_input.value(), HeapNumber::kValueOffset, MachineType::Float64()));
|
LoadObjectField<Float64T>(heap_object, HeapNumber::kValueOffset);
|
||||||
if (rep == MachineRepresentation::kWord32) {
|
if (rep == MachineRepresentation::kWord32) {
|
||||||
if (elements_kind == UINT8_CLAMPED_ELEMENTS) {
|
if (elements_kind == UINT8_CLAMPED_ELEMENTS) {
|
||||||
var_result.Bind(Float64ToUint8Clamped(value));
|
var_result.Bind(Float64ToUint8Clamped(value));
|
||||||
@ -9579,7 +9580,7 @@ Node* CodeStubAssembler::PrepareValueForWriteToTypedArray(
|
|||||||
|
|
||||||
BIND(&if_smi);
|
BIND(&if_smi);
|
||||||
{
|
{
|
||||||
TNode<Int32T> value = SmiToInt32(var_input.value());
|
TNode<Int32T> value = SmiToInt32(CAST(var_input.value()));
|
||||||
if (rep == MachineRepresentation::kFloat32) {
|
if (rep == MachineRepresentation::kFloat32) {
|
||||||
var_result.Bind(RoundInt32ToFloat32(value));
|
var_result.Bind(RoundInt32ToFloat32(value));
|
||||||
} else if (rep == MachineRepresentation::kFloat64) {
|
} else if (rep == MachineRepresentation::kFloat64) {
|
||||||
@ -9597,7 +9598,7 @@ Node* CodeStubAssembler::PrepareValueForWriteToTypedArray(
|
|||||||
|
|
||||||
BIND(&convert);
|
BIND(&convert);
|
||||||
{
|
{
|
||||||
var_input.Bind(CallBuiltin(Builtins::kNonNumberToNumber, context, input));
|
var_input = CallBuiltin(Builtins::kNonNumberToNumber, context, input);
|
||||||
Goto(&loop);
|
Goto(&loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9794,8 +9795,8 @@ void CodeStubAssembler::EmitElementStore(
|
|||||||
if (IsGrowStoreMode(store_mode) &&
|
if (IsGrowStoreMode(store_mode) &&
|
||||||
!(IsSealedElementsKind(elements_kind) ||
|
!(IsSealedElementsKind(elements_kind) ||
|
||||||
IsNonextensibleElementsKind(elements_kind))) {
|
IsNonextensibleElementsKind(elements_kind))) {
|
||||||
elements = CAST(CheckForCapacityGrow(object, elements, elements_kind,
|
elements = CheckForCapacityGrow(object, elements, elements_kind, length,
|
||||||
length, intptr_key, bailout));
|
intptr_key, bailout);
|
||||||
} else {
|
} else {
|
||||||
GotoIfNot(UintPtrLessThan(Unsigned(intptr_key), length), bailout);
|
GotoIfNot(UintPtrLessThan(Unsigned(intptr_key), length), bailout);
|
||||||
}
|
}
|
||||||
@ -9824,11 +9825,11 @@ void CodeStubAssembler::EmitElementStore(
|
|||||||
parameter_mode);
|
parameter_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
Node* CodeStubAssembler::CheckForCapacityGrow(
|
TNode<FixedArrayBase> CodeStubAssembler::CheckForCapacityGrow(
|
||||||
TNode<JSObject> object, TNode<FixedArrayBase> elements, ElementsKind kind,
|
TNode<JSObject> object, TNode<FixedArrayBase> elements, ElementsKind kind,
|
||||||
TNode<UintPtrT> length, TNode<IntPtrT> key, Label* bailout) {
|
TNode<UintPtrT> length, TNode<IntPtrT> key, Label* bailout) {
|
||||||
DCHECK(IsFastElementsKind(kind));
|
DCHECK(IsFastElementsKind(kind));
|
||||||
VARIABLE(checked_elements, MachineRepresentation::kTagged);
|
TVARIABLE(FixedArrayBase, checked_elements);
|
||||||
Label grow_case(this), no_grow_case(this), done(this),
|
Label grow_case(this), no_grow_case(this), done(this),
|
||||||
grow_bailout(this, Label::kDeferred);
|
grow_bailout(this, Label::kDeferred);
|
||||||
|
|
||||||
@ -9845,15 +9846,15 @@ Node* CodeStubAssembler::CheckForCapacityGrow(
|
|||||||
{
|
{
|
||||||
TNode<IntPtrT> current_capacity =
|
TNode<IntPtrT> current_capacity =
|
||||||
SmiUntag(LoadFixedArrayBaseLength(elements));
|
SmiUntag(LoadFixedArrayBaseLength(elements));
|
||||||
checked_elements.Bind(elements);
|
checked_elements = elements;
|
||||||
Label fits_capacity(this);
|
Label fits_capacity(this);
|
||||||
// If key is negative, we will notice in Runtime::kGrowArrayElements.
|
// If key is negative, we will notice in Runtime::kGrowArrayElements.
|
||||||
GotoIf(UintPtrLessThan(key, current_capacity), &fits_capacity);
|
GotoIf(UintPtrLessThan(key, current_capacity), &fits_capacity);
|
||||||
|
|
||||||
{
|
{
|
||||||
Node* new_elements = TryGrowElementsCapacity(
|
TNode<FixedArrayBase> new_elements = TryGrowElementsCapacity(
|
||||||
object, elements, kind, key, current_capacity, &grow_bailout);
|
object, elements, kind, key, current_capacity, &grow_bailout);
|
||||||
checked_elements.Bind(new_elements);
|
checked_elements = new_elements;
|
||||||
Goto(&fits_capacity);
|
Goto(&fits_capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9864,8 +9865,9 @@ Node* CodeStubAssembler::CheckForCapacityGrow(
|
|||||||
TNode<Object> maybe_elements = CallRuntime(
|
TNode<Object> maybe_elements = CallRuntime(
|
||||||
Runtime::kGrowArrayElements, NoContextConstant(), object, tagged_key);
|
Runtime::kGrowArrayElements, NoContextConstant(), object, tagged_key);
|
||||||
GotoIf(TaggedIsSmi(maybe_elements), bailout);
|
GotoIf(TaggedIsSmi(maybe_elements), bailout);
|
||||||
CSA_ASSERT(this, IsFixedArrayWithKind(CAST(maybe_elements), kind));
|
TNode<FixedArrayBase> new_elements = CAST(maybe_elements);
|
||||||
checked_elements.Bind(maybe_elements);
|
CSA_ASSERT(this, IsFixedArrayWithKind(new_elements, kind));
|
||||||
|
checked_elements = new_elements;
|
||||||
Goto(&fits_capacity);
|
Goto(&fits_capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9881,7 +9883,7 @@ Node* CodeStubAssembler::CheckForCapacityGrow(
|
|||||||
BIND(&no_grow_case);
|
BIND(&no_grow_case);
|
||||||
{
|
{
|
||||||
GotoIfNot(UintPtrLessThan(key, length), bailout);
|
GotoIfNot(UintPtrLessThan(key, length), bailout);
|
||||||
checked_elements.Bind(elements);
|
checked_elements = elements;
|
||||||
Goto(&done);
|
Goto(&done);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3317,10 +3317,9 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
|
|||||||
TNode<Context> context,
|
TNode<Context> context,
|
||||||
TVariable<Object>* maybe_converted_value = nullptr);
|
TVariable<Object>* maybe_converted_value = nullptr);
|
||||||
|
|
||||||
Node* CheckForCapacityGrow(TNode<JSObject> object,
|
TNode<FixedArrayBase> CheckForCapacityGrow(
|
||||||
TNode<FixedArrayBase> elements, ElementsKind kind,
|
TNode<JSObject> object, TNode<FixedArrayBase> elements, ElementsKind kind,
|
||||||
TNode<UintPtrT> length, TNode<IntPtrT> key,
|
TNode<UintPtrT> length, TNode<IntPtrT> key, Label* bailout);
|
||||||
Label* bailout);
|
|
||||||
|
|
||||||
TNode<FixedArrayBase> CopyElementsOnWrite(TNode<HeapObject> object,
|
TNode<FixedArrayBase> CopyElementsOnWrite(TNode<HeapObject> object,
|
||||||
TNode<FixedArrayBase> elements,
|
TNode<FixedArrayBase> elements,
|
||||||
|
Loading…
Reference in New Issue
Block a user