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

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

Issue 2467513002: [builtins]: Uniformly push argument count in TF-generated builtins (Closed)
Patch Set: Fix windows build Created 4 years, 1 month 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 | « test/cctest/compiler/code-assembler-tester.h ('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/code-factory.h" 6 #include "src/code-factory.h"
7 #include "src/code-stub-assembler.h" 7 #include "src/code-stub-assembler.h"
8 #include "src/compiler/node.h" 8 #include "src/compiler/node.h"
9 #include "src/ic/stub-cache.h" 9 #include "src/ic/stub-cache.h"
10 #include "src/isolate.h" 10 #include "src/isolate.h"
(...skipping 1492 matching lines...) Expand 10 before | Expand all | Expand 10 after
1503 // Ensure we performed both kind of queries. 1503 // Ensure we performed both kind of queries.
1504 CHECK(queried_existing && queried_non_existing); 1504 CHECK(queried_existing && queried_non_existing);
1505 } 1505 }
1506 1506
1507 TEST(GotoIfException) { 1507 TEST(GotoIfException) {
1508 typedef CodeStubAssembler::Label Label; 1508 typedef CodeStubAssembler::Label Label;
1509 typedef CodeStubAssembler::Variable Variable; 1509 typedef CodeStubAssembler::Variable Variable;
1510 Isolate* isolate(CcTest::InitIsolateOnce()); 1510 Isolate* isolate(CcTest::InitIsolateOnce());
1511 1511
1512 const int kNumParams = 1; 1512 const int kNumParams = 1;
1513 CodeStubAssemblerTester m(isolate, kNumParams); 1513 // Emulate TFJ builtin
1514 CodeStubAssemblerTester m(isolate, kNumParams, Code::BUILTIN);
1514 1515
1515 Node* context = m.HeapConstant(Handle<Context>(isolate->native_context())); 1516 Node* context = m.HeapConstant(Handle<Context>(isolate->native_context()));
1516 Node* to_string_tag = 1517 Node* to_string_tag =
1517 m.HeapConstant(isolate->factory()->to_string_tag_symbol()); 1518 m.HeapConstant(isolate->factory()->to_string_tag_symbol());
1518 Variable exception(&m, MachineRepresentation::kTagged); 1519 Variable exception(&m, MachineRepresentation::kTagged);
1519 1520
1520 Label exception_handler(&m); 1521 Label exception_handler(&m);
1521 Callable to_string = CodeFactory::ToString(isolate); 1522 Callable to_string = CodeFactory::ToString(isolate);
1522 Node* string = m.CallStub(to_string, context, to_string_tag); 1523 Node* string = m.CallStub(to_string, context, to_string_tag);
1523 m.GotoIfException(string, &exception_handler, &exception); 1524 m.GotoIfException(string, &exception_handler, &exception);
1524 m.Return(string); 1525 m.Return(string);
1525 1526
1526 m.Bind(&exception_handler); 1527 m.Bind(&exception_handler);
1527 m.Return(exception.value()); 1528 m.Return(exception.value());
1528 1529
1529 Handle<Code> code = m.GenerateCode(); 1530 Handle<Code> code = m.GenerateCode();
1530 CHECK(!code.is_null()); 1531 CHECK(!code.is_null());
1531 1532
1532 // Emulate TFJ builtin
1533 code->set_flags(Code::ComputeFlags(Code::BUILTIN));
1534
1535 FunctionTester ft(code, kNumParams); 1533 FunctionTester ft(code, kNumParams);
1536 Handle<Object> result = ft.Call().ToHandleChecked(); 1534 Handle<Object> result = ft.Call().ToHandleChecked();
1537 1535
1538 // Should be a TypeError 1536 // Should be a TypeError
1539 CHECK(result->IsJSObject()); 1537 CHECK(result->IsJSObject());
1540 1538
1541 Handle<Object> constructor = 1539 Handle<Object> constructor =
1542 Object::GetPropertyOrElement(result, 1540 Object::GetPropertyOrElement(result,
1543 isolate->factory()->constructor_string()) 1541 isolate->factory()->constructor_string())
1544 .ToHandleChecked(); 1542 .ToHandleChecked();
1545 CHECK(constructor->SameValue(*isolate->type_error_function())); 1543 CHECK(constructor->SameValue(*isolate->type_error_function()));
1546 } 1544 }
1547 1545
1548 TEST(GotoIfExceptionMultiple) { 1546 TEST(GotoIfExceptionMultiple) {
1549 typedef CodeStubAssembler::Label Label; 1547 typedef CodeStubAssembler::Label Label;
1550 typedef CodeStubAssembler::Variable Variable; 1548 typedef CodeStubAssembler::Variable Variable;
1551 Isolate* isolate(CcTest::InitIsolateOnce()); 1549 Isolate* isolate(CcTest::InitIsolateOnce());
1552 1550
1553 const int kNumParams = 4; // receiver, first, second, third 1551 const int kNumParams = 4; // receiver, first, second, third
1554 CodeStubAssemblerTester m(isolate, kNumParams); 1552 // Emulate TFJ builtin
1553 CodeStubAssemblerTester m(isolate, kNumParams, Code::BUILTIN);
1555 1554
1556 Node* context = m.HeapConstant(Handle<Context>(isolate->native_context())); 1555 Node* context = m.HeapConstant(Handle<Context>(isolate->native_context()));
1557 Node* first_value = m.Parameter(0); 1556 Node* first_value = m.Parameter(0);
1558 Node* second_value = m.Parameter(1); 1557 Node* second_value = m.Parameter(1);
1559 Node* third_value = m.Parameter(2); 1558 Node* third_value = m.Parameter(2);
1560 1559
1561 Label exception_handler1(&m); 1560 Label exception_handler1(&m);
1562 Label exception_handler2(&m); 1561 Label exception_handler2(&m);
1563 Label exception_handler3(&m); 1562 Label exception_handler3(&m);
1564 Variable return_value(&m, MachineRepresentation::kWord32); 1563 Variable return_value(&m, MachineRepresentation::kWord32);
(...skipping 24 matching lines...) Expand all
1589 m.Return(m.SmiFromWord32( 1588 m.Return(m.SmiFromWord32(
1590 m.Word32And(return_value.value(), 1589 m.Word32And(return_value.value(),
1591 m.Word32Xor(m.Int32Constant(2), m.Int32Constant(-1))))); 1590 m.Word32Xor(m.Int32Constant(2), m.Int32Constant(-1)))));
1592 1591
1593 m.Bind(&exception_handler3); 1592 m.Bind(&exception_handler3);
1594 m.Return(error.value()); 1593 m.Return(error.value());
1595 1594
1596 Handle<Code> code = m.GenerateCode(); 1595 Handle<Code> code = m.GenerateCode();
1597 CHECK(!code.is_null()); 1596 CHECK(!code.is_null());
1598 1597
1599 // Emulate TFJ builtin
1600 code->set_flags(Code::ComputeFlags(Code::BUILTIN));
1601
1602 FunctionTester ft(code, kNumParams); 1598 FunctionTester ft(code, kNumParams);
1603 1599
1604 Handle<Object> result; 1600 Handle<Object> result;
1605 // First handler does not throw, returns result of first value 1601 // First handler does not throw, returns result of first value
1606 result = ft.Call(isolate->factory()->undefined_value(), 1602 result = ft.Call(isolate->factory()->undefined_value(),
1607 isolate->factory()->to_string_tag_symbol()) 1603 isolate->factory()->to_string_tag_symbol())
1608 .ToHandleChecked(); 1604 .ToHandleChecked();
1609 CHECK(String::cast(*result)->IsOneByteEqualTo(OneByteVector("undefined"))); 1605 CHECK(String::cast(*result)->IsOneByteEqualTo(OneByteVector("undefined")));
1610 1606
1611 // First handler returns a number 1607 // First handler returns a number
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1769 // passed in as a parameter to the function so that it can't be recongized as 1765 // passed in as a parameter to the function so that it can't be recongized as
1770 // a constant. 1766 // a constant.
1771 m.PopAndReturn(m.SmiUntag(m.Parameter(1)), m.SmiConstant(Smi::FromInt(1234))); 1767 m.PopAndReturn(m.SmiUntag(m.Parameter(1)), m.SmiConstant(Smi::FromInt(1234)));
1772 1768
1773 Handle<Code> code = m.GenerateCode(); 1769 Handle<Code> code = m.GenerateCode();
1774 CHECK(!code.is_null()); 1770 CHECK(!code.is_null());
1775 1771
1776 FunctionTester ft(code, kNumParams); 1772 FunctionTester ft(code, kNumParams);
1777 Handle<Object> result; 1773 Handle<Object> result;
1778 for (int test_count = 0; test_count < 100; ++test_count) { 1774 for (int test_count = 0; test_count < 100; ++test_count) {
1779 result = 1775 result = ft.Call(isolate->factory()->undefined_value(),
1780 ft.Call(isolate->factory()->undefined_value(), 1776 Handle<Smi>(Smi::FromInt(1234), isolate),
1781 Handle<Smi>(Smi::FromInt(1234), isolate), 1777 isolate->factory()->undefined_value(),
1782 isolate->factory()->undefined_value(), 1778 Handle<Smi>(Smi::FromInt(kNumProgramaticParams), isolate))
1783 Handle<Smi>(Smi::FromInt(kNumProgramaticParams * kPointerSize), 1779 .ToHandleChecked();
1784 isolate))
1785 .ToHandleChecked();
1786 CHECK_EQ(1234, Handle<Smi>::cast(result)->value()); 1780 CHECK_EQ(1234, Handle<Smi>::cast(result)->value());
1787 } 1781 }
1788 } 1782 }
1789 1783
1790 } // namespace internal 1784 } // namespace internal
1791 } // namespace v8 1785 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/compiler/code-assembler-tester.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698