Commit ce96e422 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[cleanup] Spread more CSA helpers

- LoadJSArrayLength
- LoadStringLength
- LoadElements
- LoadFixedArrayBaseLength

Bug: v8:6921
Change-Id: I6bc72e99f4f8c993cb6923f19df1fbaec82881d0
Reviewed-on: https://chromium-review.googlesource.com/718199Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48530}
parent 39b2227b
......@@ -829,8 +829,7 @@ TF_BUILTIN(FastArrayPop, CodeStubAssembler) {
BIND(&fast);
{
CSA_ASSERT(this, TaggedIsPositiveSmi(
LoadObjectField(receiver, JSArray::kLengthOffset)));
CSA_ASSERT(this, TaggedIsPositiveSmi(LoadJSArrayLength(receiver)));
Node* length = LoadAndUntagObjectField(receiver, JSArray::kLengthOffset);
Label return_undefined(this), fast_elements(this);
GotoIf(IntPtrEqual(length, IntPtrConstant(0)), &return_undefined);
......@@ -1060,8 +1059,7 @@ TF_BUILTIN(FastArrayShift, CodeStubAssembler) {
BIND(&fast);
{
CSA_ASSERT(this, TaggedIsPositiveSmi(
LoadObjectField(receiver, JSArray::kLengthOffset)));
CSA_ASSERT(this, TaggedIsPositiveSmi(LoadJSArrayLength(receiver)));
Node* length = LoadAndUntagObjectField(receiver, JSArray::kLengthOffset);
Label return_undefined(this), fast_elements_tagged(this),
fast_elements_smi(this);
......@@ -2203,7 +2201,7 @@ TF_BUILTIN(ArrayIteratorPrototypeNext, CodeStubAssembler) {
CSA_ASSERT(this, Word32Equal(LoadMapInstanceType(array_map),
Int32Constant(JS_ARRAY_TYPE)));
Node* length = LoadObjectField(array, JSArray::kLengthOffset);
Node* length = LoadJSArrayLength(array);
CSA_ASSERT(this, TaggedIsSmi(length));
CSA_ASSERT(this, TaggedIsSmi(index));
......@@ -2309,7 +2307,7 @@ TF_BUILTIN(ArrayIteratorPrototypeNext, CodeStubAssembler) {
BIND(&if_isarray);
{
var_length.Bind(LoadObjectField(array, JSArray::kLengthOffset));
var_length.Bind(LoadJSArrayLength(array));
// Invalidate protector cell if needed
Branch(WordNotEqual(orig_map, UndefinedConstant()), &if_wasfastarray,
......
......@@ -165,8 +165,7 @@ void CallOrConstructBuiltinsAssembler::CallOrConstructWithArrayLike(
LoadObjectField(arguments_list, JSArgumentsObject::kLengthOffset);
Node* elements =
LoadObjectField(arguments_list, JSArgumentsObject::kElementsOffset);
Node* elements_length =
LoadObjectField(elements, FixedArray::kLengthOffset);
Node* elements_length = LoadFixedArrayBaseLength(elements);
GotoIfNot(WordEqual(length, elements_length), &if_runtime);
var_elements.Bind(elements);
var_length.Bind(SmiToWord32(length));
......
......@@ -754,7 +754,7 @@ TF_BUILTIN(OrderedHashTableHealIndex, CollectionsBuiltinsAssembler) {
Label return_index(this), return_zero(this);
// Check if we need to update the {index}.
GotoIfNot(SmiLessThan(SmiConstant(Smi::kZero), index), &return_zero);
GotoIfNot(SmiLessThan(SmiConstant(0), index), &return_zero);
// Check if the {table} was cleared.
Node* number_of_deleted_elements = LoadAndUntagObjectField(
......@@ -783,7 +783,7 @@ TF_BUILTIN(OrderedHashTableHealIndex, CollectionsBuiltinsAssembler) {
Return(var_index.value());
BIND(&return_zero);
Return(SmiConstant(Smi::kZero));
Return(SmiConstant(0));
}
template <typename TableType>
......
......@@ -31,7 +31,7 @@ TF_BUILTIN(CopyFastSmiOrObjectElements, CodeStubAssembler) {
Node* object = Parameter(Descriptor::kObject);
// Load the {object}s elements.
Node* source = LoadObjectField(object, JSObject::kElementsOffset);
Node* source = LoadElements(object);
ParameterMode mode = OptimalParameterMode();
Node* length = TaggedToParameter(LoadFixedArrayBaseLength(source), mode);
......
......@@ -188,7 +188,7 @@ TF_BUILTIN(ObjectKeys, ObjectBuiltinsAssembler) {
// Ensure that the {object} doesn't have any elements.
CSA_ASSERT(this, IsJSObjectMap(object_map));
Node* object_elements = LoadObjectField(object, JSObject::kElementsOffset);
Node* object_elements = LoadElements(object);
GotoIf(IsEmptyFixedArray(object_elements), &if_empty_elements);
Branch(IsEmptySlowElementDictionary(object_elements), &if_empty_elements,
&if_slow);
......
......@@ -653,7 +653,7 @@ TF_BUILTIN(StringPrototypeCharAt, CodeStubAssembler) {
GotoIfNot(TaggedIsSmi(position), &return_emptystring);
// Determine the actual length of the {receiver} String.
Node* receiver_length = LoadObjectField(receiver, String::kLengthOffset);
Node* receiver_length = LoadStringLength(receiver);
// Return "" if the Smi {position} is outside the bounds of the {receiver}.
Label if_positioninbounds(this);
......@@ -692,7 +692,7 @@ TF_BUILTIN(StringPrototypeCharCodeAt, CodeStubAssembler) {
GotoIfNot(TaggedIsSmi(position), &return_nan);
// Determine the actual length of the {receiver} String.
Node* receiver_length = LoadObjectField(receiver, String::kLengthOffset);
Node* receiver_length = LoadStringLength(receiver);
// Return NaN if the Smi {position} is outside the bounds of the {receiver}.
Label if_positioninbounds(this);
......@@ -726,7 +726,7 @@ TF_BUILTIN(StringPrototypeCodePointAt, StringBuiltinsAssembler) {
position =
ToInteger(context, position, CodeStubAssembler::kTruncateMinusZero);
GotoIfNot(TaggedIsSmi(position), &if_outofbounds);
Node* receiver_length = LoadObjectField(receiver, String::kLengthOffset);
Node* receiver_length = LoadStringLength(receiver);
Branch(SmiBelow(position, receiver_length), &if_inbounds, &if_outofbounds);
BIND(&if_inbounds);
......@@ -2213,7 +2213,7 @@ TF_BUILTIN(StringIteratorPrototypeNext, StringBuiltinsAssembler) {
Node* string = LoadObjectField(iterator, JSStringIterator::kStringOffset);
Node* position =
LoadObjectField(iterator, JSStringIterator::kNextIndexOffset);
Node* length = LoadObjectField(string, String::kLengthOffset);
Node* length = LoadStringLength(string);
Branch(SmiLessThan(position, length), &next_codepoint, &return_result);
......@@ -2223,7 +2223,7 @@ TF_BUILTIN(StringIteratorPrototypeNext, StringBuiltinsAssembler) {
Node* ch = LoadSurrogatePairAt(string, length, position, encoding);
Node* value = StringFromCodePoint(ch, encoding);
var_value.Bind(value);
Node* length = LoadObjectField(value, String::kLengthOffset);
Node* length = LoadStringLength(value);
StoreObjectFieldNoWriteBarrier(iterator, JSStringIterator::kNextIndexOffset,
SmiAdd(position, length));
var_done.Bind(BooleanConstant(false));
......
......@@ -7211,7 +7211,7 @@ void CodeStubAssembler::EmitElementStore(Node* object, Node* key, Node* value,
DCHECK(IsSmiOrObjectElementsKind(elements_kind) ||
IsDoubleElementsKind(elements_kind));
Node* length = is_jsarray ? LoadObjectField(object, JSArray::kLengthOffset)
Node* length = is_jsarray ? LoadJSArrayLength(object)
: LoadFixedArrayBaseLength(elements);
length = TaggedToParameter(length, parameter_mode);
......@@ -10239,9 +10239,8 @@ void CodeStubAssembler::CheckPrototypeEnumCache(Node* receiver,
// It might still be an empty JSArray.
GotoIfNot(IsJSArrayMap(object_map), if_slow);
Node* object_length = LoadObjectField(object, JSArray::kLengthOffset);
Branch(WordEqual(object_length, SmiConstant(Smi::kZero)), &if_no_elements,
if_slow);
Node* object_length = LoadJSArrayLength(object);
Branch(WordEqual(object_length, SmiConstant(0)), &if_no_elements, if_slow);
// Continue with the {object}s prototype.
BIND(&if_no_elements);
......@@ -10276,7 +10275,7 @@ Node* CodeStubAssembler::CheckEnumCache(Node* receiver, Label* if_empty,
Node* properties = LoadSlowProperties(receiver);
Node* length = LoadFixedArrayElement(
properties, NameDictionary::kNumberOfElementsIndex);
GotoIfNot(WordEqual(length, SmiConstant(Smi::kZero)), if_runtime);
GotoIfNot(WordEqual(length, SmiConstant(0)), if_runtime);
// Check that there are no elements on the {receiver} and its prototype
// chain. Given that we do not create an EnumCache for dict-mode objects,
// directly jump to {if_empty} if there are no elements and no properties
......
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