OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/v8.h" | 5 #include "src/v8.h" |
6 #include "test/cctest/cctest.h" | 6 #include "test/cctest/cctest.h" |
7 | 7 |
8 #include "src/compiler/common-operator.h" | 8 #include "src/compiler/common-operator.h" |
9 #include "src/compiler/generic-node-inl.h" | 9 #include "src/compiler/generic-node-inl.h" |
10 #include "src/compiler/generic-node.h" | 10 #include "src/compiler/generic-node.h" |
(...skipping 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1709 v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE); | 1709 v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE); |
1710 return isolate->factory()->NewFunctionFromSharedFunctionInfo( | 1710 return isolate->factory()->NewFunctionFromSharedFunctionInfo( |
1711 shared_function, isolate->native_context()); | 1711 shared_function, isolate->native_context()); |
1712 } | 1712 } |
1713 | 1713 |
1714 | 1714 |
1715 TEST(BuildScheduleTrivialLazyDeoptCall) { | 1715 TEST(BuildScheduleTrivialLazyDeoptCall) { |
1716 HandleAndZoneScope scope; | 1716 HandleAndZoneScope scope; |
1717 Isolate* isolate = scope.main_isolate(); | 1717 Isolate* isolate = scope.main_isolate(); |
1718 Graph graph(scope.main_zone()); | 1718 Graph graph(scope.main_zone()); |
1719 CommonOperatorBuilder common_builder(scope.main_zone()); | 1719 CommonOperatorBuilder common(scope.main_zone()); |
1720 JSOperatorBuilder js_builder(scope.main_zone()); | 1720 JSOperatorBuilder js_builder(scope.main_zone()); |
1721 | 1721 |
1722 InitializedHandleScope handles; | 1722 InitializedHandleScope handles; |
1723 Handle<JSFunction> function = Compile("m()"); | 1723 Handle<JSFunction> function = Compile("m()"); |
1724 CompilationInfoWithZone info(function); | 1724 CompilationInfoWithZone info(function); |
1725 Linkage linkage(&info); | 1725 Linkage linkage(&info); |
1726 | 1726 |
1727 // Manually transcribed code for: | 1727 // Manually transcribed code for: |
1728 // function turbo_fan_test() { | 1728 // function turbo_fan_test() { |
1729 // m(); | 1729 // m(); |
(...skipping 24 matching lines...) Expand all Loading... |
1754 // ^ // | 1754 // ^ // |
1755 // | // | 1755 // | // |
1756 // End // | 1756 // End // |
1757 | 1757 |
1758 Handle<Object> undef_object = | 1758 Handle<Object> undef_object = |
1759 Handle<Object>(isolate->heap()->undefined_value(), isolate); | 1759 Handle<Object>(isolate->heap()->undefined_value(), isolate); |
1760 PrintableUnique<Object> undef_constant = | 1760 PrintableUnique<Object> undef_constant = |
1761 PrintableUnique<Object>::CreateUninitialized(scope.main_zone(), | 1761 PrintableUnique<Object>::CreateUninitialized(scope.main_zone(), |
1762 undef_object); | 1762 undef_object); |
1763 | 1763 |
1764 Node* undef_node = graph.NewNode(common_builder.HeapConstant(undef_constant)); | 1764 Node* undef_node = graph.NewNode(common.HeapConstant(undef_constant)); |
1765 | 1765 |
1766 Node* start_node = graph.NewNode(common_builder.Start(0)); | 1766 Node* start_node = graph.NewNode(common.Start(0)); |
1767 | 1767 |
1768 CallDescriptor* descriptor = linkage.GetJSCallDescriptor(0); | 1768 CallDescriptor* descriptor = linkage.GetJSCallDescriptor(0); |
1769 Node* call_node = graph.NewNode(common_builder.Call(descriptor), | 1769 Node* call_node = graph.NewNode(common.Call(descriptor), |
1770 undef_node, // function | 1770 undef_node, // function |
1771 undef_node, // context | 1771 undef_node, // context |
1772 start_node, // effect | 1772 start_node, // effect |
1773 start_node); // control | 1773 start_node); // control |
1774 | 1774 |
1775 Node* cont_node = graph.NewNode(common_builder.Continuation(), call_node); | 1775 Node* cont_node = graph.NewNode(common.Continuation(), call_node); |
1776 Node* lazy_deopt_node = | 1776 Node* lazy_deopt_node = graph.NewNode(common.LazyDeoptimization(), call_node); |
1777 graph.NewNode(common_builder.LazyDeoptimization(), call_node); | |
1778 | 1777 |
1779 FrameStateDescriptor stateDescriptor(BailoutId(1234)); | 1778 Node* parameters = graph.NewNode(common.StateValues(1), undef_node); |
1780 Node* state_node = graph.NewNode(common_builder.FrameState(stateDescriptor)); | 1779 Node* locals = graph.NewNode(common.StateValues(0)); |
| 1780 Node* stack = graph.NewNode(common.StateValues(0)); |
1781 | 1781 |
1782 Node* return_node = graph.NewNode(common_builder.Return(), | 1782 Node* state_node = graph.NewNode(common.FrameState(BailoutId(1234)), |
| 1783 parameters, locals, stack); |
| 1784 |
| 1785 Node* return_node = graph.NewNode(common.Return(), |
1783 undef_node, // return value | 1786 undef_node, // return value |
1784 call_node, // effect | 1787 call_node, // effect |
1785 cont_node); // control | 1788 cont_node); // control |
1786 Node* deoptimization_node = graph.NewNode(common_builder.Deoptimize(), | 1789 Node* deoptimization_node = graph.NewNode(common.Deoptimize(), |
1787 state_node, // deopt environment | 1790 state_node, // deopt environment |
1788 call_node, // effect | 1791 call_node, // effect |
1789 lazy_deopt_node); // control | 1792 lazy_deopt_node); // control |
1790 | 1793 |
1791 Node* merge_node = | 1794 Node* merge_node = |
1792 graph.NewNode(common_builder.Merge(2), return_node, deoptimization_node); | 1795 graph.NewNode(common.Merge(2), return_node, deoptimization_node); |
1793 | 1796 |
1794 Node* end_node = graph.NewNode(common_builder.End(), merge_node); | 1797 Node* end_node = graph.NewNode(common.End(), merge_node); |
1795 | 1798 |
1796 graph.SetStart(start_node); | 1799 graph.SetStart(start_node); |
1797 graph.SetEnd(end_node); | 1800 graph.SetEnd(end_node); |
1798 | 1801 |
1799 PrintGraph(&graph); | 1802 PrintGraph(&graph); |
1800 | 1803 |
1801 Scheduler scheduler(scope.main_zone()); | 1804 Scheduler scheduler(scope.main_zone()); |
1802 Schedule* schedule = scheduler.NewSchedule(&graph); | 1805 Schedule* schedule = scheduler.NewSchedule(&graph); |
1803 | 1806 |
1804 PrintSchedule(schedule); | 1807 PrintSchedule(schedule); |
(...skipping 12 matching lines...) Expand all Loading... |
1817 CHECK_NE(deopt_block, call_block); | 1820 CHECK_NE(deopt_block, call_block); |
1818 // The call node finishes its own basic block. | 1821 // The call node finishes its own basic block. |
1819 CHECK_EQ(BasicBlock::kCall, call_block->control_); | 1822 CHECK_EQ(BasicBlock::kCall, call_block->control_); |
1820 CHECK_EQ(call_node, call_block->control_input_); | 1823 CHECK_EQ(call_node, call_block->control_input_); |
1821 // The lazy deopt block is deferred. | 1824 // The lazy deopt block is deferred. |
1822 CHECK(deopt_block->deferred_); | 1825 CHECK(deopt_block->deferred_); |
1823 CHECK(!call_block->deferred_); | 1826 CHECK(!call_block->deferred_); |
1824 CHECK(!cont_block->deferred_); | 1827 CHECK(!cont_block->deferred_); |
1825 // The lazy deopt block contains framestate + bailout (and nothing else). | 1828 // The lazy deopt block contains framestate + bailout (and nothing else). |
1826 CHECK_EQ(deoptimization_node, deopt_block->control_input_); | 1829 CHECK_EQ(deoptimization_node, deopt_block->control_input_); |
1827 CHECK_EQ(2, static_cast<int>(deopt_block->nodes_.size())); | 1830 CHECK_EQ(5, static_cast<int>(deopt_block->nodes_.size())); |
1828 CHECK_EQ(lazy_deopt_node, deopt_block->nodes_[0]); | 1831 CHECK_EQ(lazy_deopt_node, deopt_block->nodes_[0]); |
1829 CHECK_EQ(state_node, deopt_block->nodes_[1]); | 1832 CHECK_EQ(IrOpcode::kStateValues, deopt_block->nodes_[1]->op()->opcode()); |
| 1833 CHECK_EQ(IrOpcode::kStateValues, deopt_block->nodes_[2]->op()->opcode()); |
| 1834 CHECK_EQ(IrOpcode::kStateValues, deopt_block->nodes_[3]->op()->opcode()); |
| 1835 CHECK_EQ(state_node, deopt_block->nodes_[4]); |
1830 } | 1836 } |
1831 | 1837 |
1832 #endif | 1838 #endif |
OLD | NEW |