Chromium Code Reviews| Index: src/builtins/builtins-array.cc |
| diff --git a/src/builtins/builtins-array.cc b/src/builtins/builtins-array.cc |
| index 137fa4d9dd674c5e4cff0dba6e3b39798b629fe2..9bcfb1e4e1351f65e3873a1b433022f08f59fbf2 100644 |
| --- a/src/builtins/builtins-array.cc |
| +++ b/src/builtins/builtins-array.cc |
| @@ -1685,14 +1685,12 @@ TF_BUILTIN(ArrayIncludes, CodeStubAssembler) { |
| Node* const start_from = Parameter(2); |
| Node* const context = Parameter(3 + 2); |
| - Variable len_var(this, MachineType::PointerRepresentation()), |
| - index_var(this, MachineType::PointerRepresentation()); |
| + Variable index_var(this, MachineType::PointerRepresentation()); |
| Label init_k(this), return_true(this), return_false(this), call_runtime(this); |
| Label init_len(this), select_loop(this); |
| index_var.Bind(IntPtrConstant(0)); |
| - len_var.Bind(IntPtrConstant(0)); |
| // Take slow path if not a JSArray, if retrieving elements requires |
| // traversing prototype, or if access checks are required. |
| @@ -1700,13 +1698,13 @@ TF_BUILTIN(ArrayIncludes, CodeStubAssembler) { |
| CodeStubAssembler::FastJSArrayAccessMode::INBOUNDS_READ, |
| &init_len, &call_runtime); |
| + Node* len = nullptr; |
|
vabr (Chromium)
2017/02/25 21:25:55
I tried to initialize |len| with LoadAndUntagObjec
Benedikt Meurer
2017/02/26 18:34:27
Just remove the { and } in 1704, and declare the N
vabr (Chromium)
2017/02/26 20:30:24
Done.
|
| Bind(&init_len); |
| { |
| - // Handle case where JSArray length is not an Smi in the runtime |
| - Node* len = LoadObjectField(array, JSArray::kLengthOffset); |
| - GotoIfNot(TaggedIsSmi(len), &call_runtime); |
| - |
| - len_var.Bind(SmiToWord(len)); |
| + // JSArray length is always an Smi for fast arrays. |
| + CSA_ASSERT(this, |
| + TaggedIsSmi(LoadObjectField(array, JSArray::kLengthOffset))); |
| + len = LoadAndUntagObjectField(array, JSArray::kLengthOffset); |
| GotoIf(IsUndefined(start_from), &select_loop); |
| @@ -1721,7 +1719,7 @@ TF_BUILTIN(ArrayIncludes, CodeStubAssembler) { |
| IntPtrGreaterThanOrEqual(untagged_start_from, IntPtrConstant(0)), |
| [=]() { return untagged_start_from; }, |
| [=]() { |
| - Node* const index = IntPtrAdd(len_var.value(), untagged_start_from); |
| + Node* const index = IntPtrAdd(len, untagged_start_from); |
| return SelectConstant(IntPtrLessThan(index, IntPtrConstant(0)), |
| IntPtrConstant(0), index, |
| MachineType::PointerRepresentation()); |
| @@ -1771,8 +1769,7 @@ TF_BUILTIN(ArrayIncludes, CodeStubAssembler) { |
| Bind(&ident_loop); |
| { |
| - GotoIfNot(UintPtrLessThan(index_var.value(), len_var.value()), |
| - &return_false); |
| + GotoIfNot(UintPtrLessThan(index_var.value(), len), &return_false); |
| Node* element_k = LoadFixedArrayElement(elements, index_var.value()); |
| GotoIf(WordEqual(element_k, search_element), &return_true); |
| @@ -1782,8 +1779,7 @@ TF_BUILTIN(ArrayIncludes, CodeStubAssembler) { |
| Bind(&undef_loop); |
| { |
| - GotoIfNot(UintPtrLessThan(index_var.value(), len_var.value()), |
| - &return_false); |
| + GotoIfNot(UintPtrLessThan(index_var.value(), len), &return_false); |
| Node* element_k = LoadFixedArrayElement(elements, index_var.value()); |
| GotoIf(WordEqual(element_k, UndefinedConstant()), &return_true); |
| GotoIf(WordEqual(element_k, TheHoleConstant()), &return_true); |
| @@ -1800,8 +1796,7 @@ TF_BUILTIN(ArrayIncludes, CodeStubAssembler) { |
| Bind(¬_nan_loop); |
| { |
| Label continue_loop(this), not_smi(this); |
| - GotoIfNot(UintPtrLessThan(index_var.value(), len_var.value()), |
| - &return_false); |
| + GotoIfNot(UintPtrLessThan(index_var.value(), len), &return_false); |
| Node* element_k = LoadFixedArrayElement(elements, index_var.value()); |
| GotoIfNot(TaggedIsSmi(element_k), ¬_smi); |
| Branch(Float64Equal(search_num.value(), SmiToFloat64(element_k)), |
| @@ -1820,8 +1815,7 @@ TF_BUILTIN(ArrayIncludes, CodeStubAssembler) { |
| Bind(&nan_loop); |
| { |
| Label continue_loop(this); |
| - GotoIfNot(UintPtrLessThan(index_var.value(), len_var.value()), |
| - &return_false); |
| + GotoIfNot(UintPtrLessThan(index_var.value(), len), &return_false); |
| Node* element_k = LoadFixedArrayElement(elements, index_var.value()); |
| GotoIf(TaggedIsSmi(element_k), &continue_loop); |
| GotoIfNot(IsHeapNumber(element_k), &continue_loop); |
| @@ -1837,8 +1831,7 @@ TF_BUILTIN(ArrayIncludes, CodeStubAssembler) { |
| Bind(&string_loop); |
| { |
| Label continue_loop(this); |
| - GotoIfNot(UintPtrLessThan(index_var.value(), len_var.value()), |
| - &return_false); |
| + GotoIfNot(UintPtrLessThan(index_var.value(), len), &return_false); |
| Node* element_k = LoadFixedArrayElement(elements, index_var.value()); |
| GotoIf(TaggedIsSmi(element_k), &continue_loop); |
| GotoIfNot(IsStringInstanceType(LoadInstanceType(element_k)), |
| @@ -1877,8 +1870,7 @@ TF_BUILTIN(ArrayIncludes, CodeStubAssembler) { |
| Bind(¬_nan_loop); |
| { |
| Label continue_loop(this); |
| - GotoIfNot(UintPtrLessThan(index_var.value(), len_var.value()), |
| - &return_false); |
| + GotoIfNot(UintPtrLessThan(index_var.value(), len), &return_false); |
| Node* element_k = LoadFixedDoubleArrayElement(elements, index_var.value(), |
| MachineType::Float64()); |
| Branch(Float64Equal(element_k, search_num.value()), &return_true, |
| @@ -1892,8 +1884,7 @@ TF_BUILTIN(ArrayIncludes, CodeStubAssembler) { |
| Bind(&nan_loop); |
| { |
| Label continue_loop(this); |
| - GotoIfNot(UintPtrLessThan(index_var.value(), len_var.value()), |
| - &return_false); |
| + GotoIfNot(UintPtrLessThan(index_var.value(), len), &return_false); |
| Node* element_k = LoadFixedDoubleArrayElement(elements, index_var.value(), |
| MachineType::Float64()); |
| BranchIfFloat64IsNaN(element_k, &return_true, &continue_loop); |
| @@ -1925,8 +1916,7 @@ TF_BUILTIN(ArrayIncludes, CodeStubAssembler) { |
| Bind(¬_nan_loop); |
| { |
| Label continue_loop(this); |
| - GotoIfNot(UintPtrLessThan(index_var.value(), len_var.value()), |
| - &return_false); |
| + GotoIfNot(UintPtrLessThan(index_var.value(), len), &return_false); |
| // Load double value or continue if it contains a double hole. |
| Node* element_k = LoadFixedDoubleArrayElement( |
| @@ -1944,8 +1934,7 @@ TF_BUILTIN(ArrayIncludes, CodeStubAssembler) { |
| Bind(&nan_loop); |
| { |
| Label continue_loop(this); |
| - GotoIfNot(UintPtrLessThan(index_var.value(), len_var.value()), |
| - &return_false); |
| + GotoIfNot(UintPtrLessThan(index_var.value(), len), &return_false); |
| // Load double value or continue if it contains a double hole. |
| Node* element_k = LoadFixedDoubleArrayElement( |
| @@ -1961,8 +1950,7 @@ TF_BUILTIN(ArrayIncludes, CodeStubAssembler) { |
| // Search for the Hole |
| Bind(&hole_loop); |
| { |
| - GotoIfNot(UintPtrLessThan(index_var.value(), len_var.value()), |
| - &return_false); |
| + GotoIfNot(UintPtrLessThan(index_var.value(), len), &return_false); |
| // Check if the element is a double hole, but don't load it. |
| LoadFixedDoubleArrayElement( |