OLD | NEW |
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 1650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1661 ft.Call(handle(object->map()), handle(object->properties()), | 1661 ft.Call(handle(object->map()), handle(object->properties()), |
1662 handle(object->elements())) | 1662 handle(object->elements())) |
1663 .ToHandleChecked()); | 1663 .ToHandleChecked()); |
1664 VERIFY(result, object->map(), object->properties(), object->elements()); | 1664 VERIFY(result, object->map(), object->properties(), object->elements()); |
1665 #ifdef VERIFY_HEAP | 1665 #ifdef VERIFY_HEAP |
1666 isolate->heap()->Verify(); | 1666 isolate->heap()->Verify(); |
1667 #endif | 1667 #endif |
1668 } | 1668 } |
1669 } | 1669 } |
1670 | 1670 |
| 1671 TEST(PopAndReturnConstant) { |
| 1672 Isolate* isolate(CcTest::InitIsolateOnce()); |
| 1673 |
| 1674 const int kNumParams = 4; |
| 1675 const int kNumProgramaticParams = 2; |
| 1676 CodeStubAssemblerTester m(isolate, kNumParams - kNumProgramaticParams); |
| 1677 |
| 1678 // Call a function that return |kNumProgramaticParams| parameters in addition |
| 1679 // to those specified by the static descriptor. |kNumProgramaticParams| is |
| 1680 // specified as a constant. |
| 1681 m.PopAndReturn(m.Int32Constant(kNumProgramaticParams), |
| 1682 m.SmiConstant(Smi::FromInt(1234))); |
| 1683 |
| 1684 Handle<Code> code = m.GenerateCode(); |
| 1685 CHECK(!code.is_null()); |
| 1686 |
| 1687 FunctionTester ft(code, kNumParams); |
| 1688 Handle<Object> result; |
| 1689 for (int test_count = 0; test_count < 100; ++test_count) { |
| 1690 result = ft.Call(isolate->factory()->undefined_value(), |
| 1691 Handle<Smi>(Smi::FromInt(1234), isolate), |
| 1692 isolate->factory()->undefined_value(), |
| 1693 isolate->factory()->undefined_value()) |
| 1694 .ToHandleChecked(); |
| 1695 CHECK_EQ(1234, Handle<Smi>::cast(result)->value()); |
| 1696 } |
| 1697 } |
| 1698 |
| 1699 TEST(PopAndReturnVariable) { |
| 1700 Isolate* isolate(CcTest::InitIsolateOnce()); |
| 1701 |
| 1702 const int kNumParams = 4; |
| 1703 const int kNumProgramaticParams = 2; |
| 1704 CodeStubAssemblerTester m(isolate, kNumParams - kNumProgramaticParams); |
| 1705 |
| 1706 // Call a function that return |kNumProgramaticParams| parameters in addition |
| 1707 // to those specified by the static descriptor. |kNumProgramaticParams| is |
| 1708 // passed in as a parameter to the function so that it can't be recongized as |
| 1709 // a constant. |
| 1710 m.PopAndReturn(m.SmiUntag(m.Parameter(1)), m.SmiConstant(Smi::FromInt(1234))); |
| 1711 |
| 1712 Handle<Code> code = m.GenerateCode(); |
| 1713 CHECK(!code.is_null()); |
| 1714 |
| 1715 FunctionTester ft(code, kNumParams); |
| 1716 Handle<Object> result; |
| 1717 for (int test_count = 0; test_count < 100; ++test_count) { |
| 1718 result = |
| 1719 ft.Call(isolate->factory()->undefined_value(), |
| 1720 Handle<Smi>(Smi::FromInt(1234), isolate), |
| 1721 isolate->factory()->undefined_value(), |
| 1722 Handle<Smi>(Smi::FromInt(kNumProgramaticParams * kPointerSize), |
| 1723 isolate)) |
| 1724 .ToHandleChecked(); |
| 1725 CHECK_EQ(1234, Handle<Smi>::cast(result)->value()); |
| 1726 } |
| 1727 } |
| 1728 |
1671 } // namespace internal | 1729 } // namespace internal |
1672 } // namespace v8 | 1730 } // namespace v8 |
OLD | NEW |