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

Side by Side Diff: test/cctest/test-code-stub-assembler.cc

Issue 2661483002: [csa] Make argc parameter to CodeStubArguments constructor use ParameterMode (Closed)
Patch Set: Fix build Created 3 years, 10 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 | « src/code-stub-assembler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/base/utils/random-number-generator.h" 5 #include "src/base/utils/random-number-generator.h"
6 #include "src/builtins/builtins-promise.h" 6 #include "src/builtins/builtins-promise.h"
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/code-stub-assembler.h" 8 #include "src/code-stub-assembler.h"
9 #include "src/compiler/node.h" 9 #include "src/compiler/node.h"
10 #include "src/isolate.h" 10 #include "src/isolate.h"
(...skipping 1488 matching lines...) Expand 10 before | Expand all | Expand 10 after
1499 Handle<SeqTwoByteString>::cast(string2)->GetChars()[4]); 1499 Handle<SeqTwoByteString>::cast(string2)->GetChars()[4]);
1500 } 1500 }
1501 1501
1502 TEST(Arguments) { 1502 TEST(Arguments) {
1503 Isolate* isolate(CcTest::InitIsolateOnce()); 1503 Isolate* isolate(CcTest::InitIsolateOnce());
1504 1504
1505 const int kNumParams = 4; 1505 const int kNumParams = 4;
1506 CodeAssemblerTester data(isolate, kNumParams); 1506 CodeAssemblerTester data(isolate, kNumParams);
1507 CodeStubAssembler m(data.state()); 1507 CodeStubAssembler m(data.state());
1508 1508
1509 CodeStubArguments arguments(&m, m.Int32Constant(3)); 1509 CodeStubArguments arguments(&m, m.IntPtrConstant(3));
1510 1510
1511 CSA_ASSERT( 1511 CSA_ASSERT(
1512 &m, m.WordEqual(arguments.AtIndex(0), m.SmiConstant(Smi::FromInt(12)))); 1512 &m, m.WordEqual(arguments.AtIndex(0), m.SmiConstant(Smi::FromInt(12))));
1513 CSA_ASSERT( 1513 CSA_ASSERT(
1514 &m, m.WordEqual(arguments.AtIndex(1), m.SmiConstant(Smi::FromInt(13)))); 1514 &m, m.WordEqual(arguments.AtIndex(1), m.SmiConstant(Smi::FromInt(13))));
1515 CSA_ASSERT( 1515 CSA_ASSERT(
1516 &m, m.WordEqual(arguments.AtIndex(2), m.SmiConstant(Smi::FromInt(14)))); 1516 &m, m.WordEqual(arguments.AtIndex(2), m.SmiConstant(Smi::FromInt(14))));
1517 1517
1518 m.Return(arguments.GetReceiver()); 1518 m.Return(arguments.GetReceiver());
1519 1519
1520 Handle<Code> code = data.GenerateCode(); 1520 Handle<Code> code = data.GenerateCode();
1521 CHECK(!code.is_null()); 1521 CHECK(!code.is_null());
1522 1522
1523 FunctionTester ft(code, kNumParams); 1523 FunctionTester ft(code, kNumParams);
1524 Handle<Object> result = ft.Call(isolate->factory()->undefined_value(), 1524 Handle<Object> result = ft.Call(isolate->factory()->undefined_value(),
1525 Handle<Smi>(Smi::FromInt(12), isolate), 1525 Handle<Smi>(Smi::FromInt(12), isolate),
1526 Handle<Smi>(Smi::FromInt(13), isolate), 1526 Handle<Smi>(Smi::FromInt(13), isolate),
1527 Handle<Smi>(Smi::FromInt(14), isolate)) 1527 Handle<Smi>(Smi::FromInt(14), isolate))
1528 .ToHandleChecked(); 1528 .ToHandleChecked();
1529 CHECK_EQ(*isolate->factory()->undefined_value(), *result); 1529 CHECK_EQ(*isolate->factory()->undefined_value(), *result);
1530 } 1530 }
1531 1531
1532 TEST(ArgumentsForEach) { 1532 TEST(ArgumentsForEach) {
1533 Isolate* isolate(CcTest::InitIsolateOnce()); 1533 Isolate* isolate(CcTest::InitIsolateOnce());
1534 1534
1535 const int kNumParams = 4; 1535 const int kNumParams = 4;
1536 CodeAssemblerTester data(isolate, kNumParams); 1536 CodeAssemblerTester data(isolate, kNumParams);
1537 CodeStubAssembler m(data.state()); 1537 CodeStubAssembler m(data.state());
1538 1538
1539 CodeStubArguments arguments(&m, m.Int32Constant(3)); 1539 CodeStubArguments arguments(&m, m.IntPtrConstant(3));
1540 1540
1541 CodeAssemblerVariable sum(&m, MachineRepresentation::kTagged); 1541 CodeAssemblerVariable sum(&m, MachineRepresentation::kTagged);
1542 CodeAssemblerVariableList list({&sum}, m.zone()); 1542 CodeAssemblerVariableList list({&sum}, m.zone());
1543 1543
1544 sum.Bind(m.SmiConstant(0)); 1544 sum.Bind(m.SmiConstant(0));
1545 1545
1546 arguments.ForEach( 1546 arguments.ForEach(
1547 list, [&m, &sum](Node* arg) { sum.Bind(m.SmiAdd(sum.value(), arg)); }); 1547 list, [&m, &sum](Node* arg) { sum.Bind(m.SmiAdd(sum.value(), arg)); });
1548 1548
1549 m.Return(sum.value()); 1549 m.Return(sum.value());
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1609 typedef CodeAssemblerVariable Variable; 1609 typedef CodeAssemblerVariable Variable;
1610 typedef CodeAssemblerLabel Label; 1610 typedef CodeAssemblerLabel Label;
1611 Handle<JSArray> array = isolate->factory()->NewJSArray( 1611 Handle<JSArray> array = isolate->factory()->NewJSArray(
1612 kind_, 2, initial_size, INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE); 1612 kind_, 2, initial_size, INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE);
1613 JSObject::SetElement(isolate, array, 0, 1613 JSObject::SetElement(isolate, array, 0,
1614 Handle<Smi>(Smi::FromInt(1), isolate), SLOPPY) 1614 Handle<Smi>(Smi::FromInt(1), isolate), SLOPPY)
1615 .Check(); 1615 .Check();
1616 JSObject::SetElement(isolate, array, 1, 1616 JSObject::SetElement(isolate, array, 1,
1617 Handle<Smi>(Smi::FromInt(2), isolate), SLOPPY) 1617 Handle<Smi>(Smi::FromInt(2), isolate), SLOPPY)
1618 .Check(); 1618 .Check();
1619 CodeStubArguments args(this, Int32Constant(kNumParams)); 1619 CodeStubArguments args(this, IntPtrConstant(kNumParams));
1620 Variable arg_index(this, MachineType::PointerRepresentation()); 1620 Variable arg_index(this, MachineType::PointerRepresentation());
1621 Label bailout(this); 1621 Label bailout(this);
1622 arg_index.Bind(IntPtrConstant(0)); 1622 arg_index.Bind(IntPtrConstant(0));
1623 Node* length = BuildAppendJSArray( 1623 Node* length = BuildAppendJSArray(
1624 kind_, HeapConstant(Handle<HeapObject>(isolate->context(), isolate)), 1624 kind_, HeapConstant(Handle<HeapObject>(isolate->context(), isolate)),
1625 HeapConstant(array), args, arg_index, &bailout); 1625 HeapConstant(array), args, arg_index, &bailout);
1626 Return(length); 1626 Return(length);
1627 1627
1628 Bind(&bailout); 1628 Bind(&bailout);
1629 Return(SmiTag(IntPtrAdd(arg_index.value(), IntPtrConstant(2)))); 1629 Return(SmiTag(IntPtrAdd(arg_index.value(), IntPtrConstant(2))));
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
2455 m.Return(m.SmiConstant(0)); 2455 m.Return(m.SmiConstant(0));
2456 2456
2457 Handle<Code> code = data.GenerateCode(); 2457 Handle<Code> code = data.GenerateCode();
2458 CHECK(!code.is_null()); 2458 CHECK(!code.is_null());
2459 FunctionTester ft(code, kNumParams); 2459 FunctionTester ft(code, kNumParams);
2460 CHECK_EQ(1, Handle<Smi>::cast(ft.Call().ToHandleChecked())->value()); 2460 CHECK_EQ(1, Handle<Smi>::cast(ft.Call().ToHandleChecked())->value());
2461 } 2461 }
2462 2462
2463 } // namespace internal 2463 } // namespace internal
2464 } // namespace v8 2464 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stub-assembler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698