Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/builtins/builtins-array-gen.cc

Issue 2873653002: [array] Don't adapt arguments for ArrayIndexOf and ArrayIncludes (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/builtins/builtins-definitions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 the V8 project authors. All rights reserved. 1 // Copyright 2017 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/builtins/builtins-utils-gen.h" 5 #include "src/builtins/builtins-utils-gen.h"
6 #include "src/builtins/builtins.h" 6 #include "src/builtins/builtins.h"
7 #include "src/code-stub-assembler.h" 7 #include "src/code-stub-assembler.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 1337 matching lines...) Expand 10 before | Expand all | Expand 10 after
1348 Return(BooleanConstant(true)); 1348 Return(BooleanConstant(true));
1349 1349
1350 BIND(&return_false); 1350 BIND(&return_false);
1351 Return(BooleanConstant(false)); 1351 Return(BooleanConstant(false));
1352 1352
1353 BIND(&call_runtime); 1353 BIND(&call_runtime);
1354 Return(CallRuntime(Runtime::kArrayIsArray, context, object)); 1354 Return(CallRuntime(Runtime::kArrayIsArray, context, object));
1355 } 1355 }
1356 1356
1357 TF_BUILTIN(ArrayIncludes, CodeStubAssembler) { 1357 TF_BUILTIN(ArrayIncludes, CodeStubAssembler) {
1358 Node* const array = Parameter(Descriptor::kReceiver); 1358 const int kSearchElementArg = 0;
1359 Node* const search_element = Parameter(Descriptor::kSearchElement); 1359 const int kFromIndexArg = 1;
1360 Node* const start_from = Parameter(Descriptor::kFromIndex); 1360
1361 Node* const context = Parameter(Descriptor::kContext); 1361 Node* argc =
1362 ChangeInt32ToIntPtr(Parameter(BuiltinDescriptor::kArgumentsCount));
1363 CodeStubArguments args(this, argc);
1364
1365 Node* array = args.GetReceiver();
1366 Node* search_element =
1367 args.GetOptionalArgumentValue(kSearchElementArg, UndefinedConstant());
1368 Node* start_from =
1369 args.GetOptionalArgumentValue(kFromIndexArg, UndefinedConstant());
1370 Node* const context = Parameter(BuiltinDescriptor::kContext);
1362 1371
1363 VARIABLE(index_var, MachineType::PointerRepresentation()); 1372 VARIABLE(index_var, MachineType::PointerRepresentation());
1364 1373
1365 Label init_k(this), return_true(this), return_false(this), call_runtime(this); 1374 Label init_k(this), return_true(this), return_false(this), call_runtime(this);
1366 Label init_len(this), select_loop(this); 1375 Label init_len(this), select_loop(this);
1367 1376
1368 index_var.Bind(IntPtrConstant(0)); 1377 index_var.Bind(IntPtrConstant(0));
1369 1378
1370 // Take slow path if not a JSArray, if retrieving elements requires 1379 // Take slow path if not a JSArray, if retrieving elements requires
1371 // traversing prototype, or if access checks are required. 1380 // traversing prototype, or if access checks are required.
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 LoadFixedDoubleArrayElement(elements, index_var.value(), 1635 LoadFixedDoubleArrayElement(elements, index_var.value(),
1627 MachineType::None(), 0, INTPTR_PARAMETERS, 1636 MachineType::None(), 0, INTPTR_PARAMETERS,
1628 &return_true); 1637 &return_true);
1629 1638
1630 index_var.Bind(IntPtrAdd(index_var.value(), IntPtrConstant(1))); 1639 index_var.Bind(IntPtrAdd(index_var.value(), IntPtrConstant(1)));
1631 Goto(&hole_loop); 1640 Goto(&hole_loop);
1632 } 1641 }
1633 } 1642 }
1634 1643
1635 BIND(&return_true); 1644 BIND(&return_true);
1636 Return(TrueConstant()); 1645 args.PopAndReturn(TrueConstant());
1637 1646
1638 BIND(&return_false); 1647 BIND(&return_false);
1639 Return(FalseConstant()); 1648 args.PopAndReturn(FalseConstant());
1640 1649
1641 BIND(&call_runtime); 1650 BIND(&call_runtime);
1642 Return(CallRuntime(Runtime::kArrayIncludes_Slow, context, array, 1651 args.PopAndReturn(CallRuntime(Runtime::kArrayIncludes_Slow, context, array,
1643 search_element, start_from)); 1652 search_element, start_from));
1644 } 1653 }
1645 1654
1646 TF_BUILTIN(ArrayIndexOf, CodeStubAssembler) { 1655 TF_BUILTIN(ArrayIndexOf, CodeStubAssembler) {
1647 Node* array = Parameter(Descriptor::kReceiver); 1656 const int kSearchElementArg = 0;
1648 Node* search_element = Parameter(Descriptor::kSearchElement); 1657 const int kFromIndexArg = 1;
1649 Node* start_from = Parameter(Descriptor::kFromIndex); 1658
1650 Node* context = Parameter(Descriptor::kContext); 1659 Node* argc =
1660 ChangeInt32ToIntPtr(Parameter(BuiltinDescriptor::kArgumentsCount));
1661 CodeStubArguments args(this, argc);
1662
1663 Node* array = args.GetReceiver();
1664 Node* search_element =
1665 args.GetOptionalArgumentValue(kSearchElementArg, UndefinedConstant());
1666 Node* start_from =
1667 args.GetOptionalArgumentValue(kFromIndexArg, UndefinedConstant());
1668 Node* context = Parameter(BuiltinDescriptor::kContext);
1651 1669
1652 Node* intptr_zero = IntPtrConstant(0); 1670 Node* intptr_zero = IntPtrConstant(0);
1653 Node* intptr_one = IntPtrConstant(1); 1671 Node* intptr_one = IntPtrConstant(1);
1654 1672
1655 VARIABLE(len_var, MachineType::PointerRepresentation()); 1673 VARIABLE(len_var, MachineType::PointerRepresentation());
1656 VARIABLE(index_var, MachineType::PointerRepresentation()); 1674 VARIABLE(index_var, MachineType::PointerRepresentation());
1657 VARIABLE(start_from_var, MachineType::PointerRepresentation()); 1675 VARIABLE(start_from_var, MachineType::PointerRepresentation());
1658 1676
1659 Label init_k(this), return_found(this), return_not_found(this), 1677 Label init_k(this), return_found(this), return_not_found(this),
1660 call_runtime(this); 1678 call_runtime(this);
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1891 1909
1892 Branch(Float64Equal(element_k, search_num.value()), &return_found, 1910 Branch(Float64Equal(element_k, search_num.value()), &return_found,
1893 &continue_loop); 1911 &continue_loop);
1894 BIND(&continue_loop); 1912 BIND(&continue_loop);
1895 index_var.Bind(IntPtrAdd(index_var.value(), intptr_one)); 1913 index_var.Bind(IntPtrAdd(index_var.value(), intptr_one));
1896 Goto(&not_nan_loop); 1914 Goto(&not_nan_loop);
1897 } 1915 }
1898 } 1916 }
1899 1917
1900 BIND(&return_found); 1918 BIND(&return_found);
1901 Return(SmiTag(index_var.value())); 1919 args.PopAndReturn(SmiTag(index_var.value()));
1902 1920
1903 BIND(&return_not_found); 1921 BIND(&return_not_found);
1904 Return(NumberConstant(-1)); 1922 args.PopAndReturn(NumberConstant(-1));
1905 1923
1906 BIND(&call_runtime); 1924 BIND(&call_runtime);
1907 Return(CallRuntime(Runtime::kArrayIndexOf, context, array, search_element, 1925 args.PopAndReturn(CallRuntime(Runtime::kArrayIndexOf, context, array,
1908 start_from)); 1926 search_element, start_from));
1909 } 1927 }
1910 1928
1911 class ArrayPrototypeIterationAssembler : public CodeStubAssembler { 1929 class ArrayPrototypeIterationAssembler : public CodeStubAssembler {
1912 public: 1930 public:
1913 explicit ArrayPrototypeIterationAssembler(compiler::CodeAssemblerState* state) 1931 explicit ArrayPrototypeIterationAssembler(compiler::CodeAssemblerState* state)
1914 : CodeStubAssembler(state) {} 1932 : CodeStubAssembler(state) {}
1915 1933
1916 protected: 1934 protected:
1917 void Generate_ArrayPrototypeIterationMethod(Node* context, Node* receiver, 1935 void Generate_ArrayPrototypeIterationMethod(Node* context, Node* receiver,
1918 IterationKind iteration_kind) { 1936 IterationKind iteration_kind) {
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
2382 { 2400 {
2383 Node* message = SmiConstant(MessageTemplate::kDetachedOperation); 2401 Node* message = SmiConstant(MessageTemplate::kDetachedOperation);
2384 CallRuntime(Runtime::kThrowTypeError, context, message, 2402 CallRuntime(Runtime::kThrowTypeError, context, message,
2385 HeapConstant(operation)); 2403 HeapConstant(operation));
2386 Unreachable(); 2404 Unreachable();
2387 } 2405 }
2388 } 2406 }
2389 2407
2390 } // namespace internal 2408 } // namespace internal
2391 } // namespace v8 2409 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/builtins/builtins-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698