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 // TODO(jochen): Remove this after the setting is turned on globally. | 5 // TODO(jochen): Remove this after the setting is turned on globally. |
6 #define V8_IMMINENT_DEPRECATION_WARNINGS | 6 #define V8_IMMINENT_DEPRECATION_WARNINGS |
7 | 7 |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "src/compiler/pipeline.h" | 10 #include "src/compiler/pipeline.h" |
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 | 782 |
783 BytecodeGraphTester tester(isolate, zone, script.start()); | 783 BytecodeGraphTester tester(isolate, zone, script.start()); |
784 auto callable = tester.GetCallable<Handle<Object>>(); | 784 auto callable = tester.GetCallable<Handle<Object>>(); |
785 Handle<Object> return_value = | 785 Handle<Object> return_value = |
786 callable(snippets[i].parameter(0)).ToHandleChecked(); | 786 callable(snippets[i].parameter(0)).ToHandleChecked(); |
787 CHECK(return_value->SameValue(*snippets[i].return_value())); | 787 CHECK(return_value->SameValue(*snippets[i].return_value())); |
788 } | 788 } |
789 } | 789 } |
790 | 790 |
791 | 791 |
| 792 TEST(BytecodeGraphBuilderCountOperation) { |
| 793 HandleAndZoneScope scope; |
| 794 Isolate* isolate = scope.main_isolate(); |
| 795 Zone* zone = scope.main_zone(); |
| 796 Factory* factory = isolate->factory(); |
| 797 |
| 798 ExpectedSnippet<1> snippets[] = { |
| 799 {"return ++p1;", |
| 800 {factory->NewNumberFromInt(11), factory->NewNumberFromInt(10)}}, |
| 801 {"return p1++;", |
| 802 {factory->NewNumberFromInt(10), factory->NewNumberFromInt(10)}}, |
| 803 {"return p1++ + 10;", |
| 804 {factory->NewHeapNumber(15.23), factory->NewHeapNumber(5.23)}}, |
| 805 {"return 20 + ++p1;", |
| 806 {factory->NewHeapNumber(27.23), factory->NewHeapNumber(6.23)}}, |
| 807 {"return --p1;", |
| 808 {factory->NewHeapNumber(9.8), factory->NewHeapNumber(10.8)}}, |
| 809 {"return p1--;", |
| 810 {factory->NewHeapNumber(10.8), factory->NewHeapNumber(10.8)}}, |
| 811 {"return p1-- + 10;", |
| 812 {factory->NewNumberFromInt(20), factory->NewNumberFromInt(10)}}, |
| 813 {"return 20 + --p1;", |
| 814 {factory->NewNumberFromInt(29), factory->NewNumberFromInt(10)}}, |
| 815 {"return p1.val--;", |
| 816 {factory->NewNumberFromInt(10), |
| 817 BytecodeGraphTester::NewObject("({val : 10})")}}, |
| 818 {"return ++p1['val'];", |
| 819 {factory->NewNumberFromInt(11), |
| 820 BytecodeGraphTester::NewObject("({val : 10})")}}, |
| 821 {"return ++p1[1];", |
| 822 {factory->NewNumberFromInt(11), |
| 823 BytecodeGraphTester::NewObject("({1 : 10})")}}, |
| 824 {" function inner() { return p1 } return --p1;", |
| 825 {factory->NewNumberFromInt(9), factory->NewNumberFromInt(10)}}, |
| 826 {" function inner() { return p1 } return p1--;", |
| 827 {factory->NewNumberFromInt(10), factory->NewNumberFromInt(10)}}, |
| 828 {"return ++p1;", |
| 829 {factory->nan_value(), factory->NewStringFromStaticChars("String")}}, |
| 830 }; |
| 831 |
| 832 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]); |
| 833 for (size_t i = 0; i < num_snippets; i++) { |
| 834 ScopedVector<char> script(1024); |
| 835 SNPrintF(script, "function %s(p1) { %s }\n%s({});", kFunctionName, |
| 836 snippets[i].code_snippet, kFunctionName); |
| 837 |
| 838 BytecodeGraphTester tester(isolate, zone, script.start()); |
| 839 auto callable = tester.GetCallable<Handle<Object>>(); |
| 840 Handle<Object> return_value = |
| 841 callable(snippets[i].parameter(0)).ToHandleChecked(); |
| 842 CHECK(return_value->SameValue(*snippets[i].return_value())); |
| 843 } |
| 844 } |
| 845 |
| 846 |
792 TEST(BytecodeGraphBuilderDelete) { | 847 TEST(BytecodeGraphBuilderDelete) { |
793 HandleAndZoneScope scope; | 848 HandleAndZoneScope scope; |
794 Isolate* isolate = scope.main_isolate(); | 849 Isolate* isolate = scope.main_isolate(); |
795 Zone* zone = scope.main_zone(); | 850 Zone* zone = scope.main_zone(); |
796 Factory* factory = isolate->factory(); | 851 Factory* factory = isolate->factory(); |
797 | 852 |
798 ExpectedSnippet<1> snippets[] = { | 853 ExpectedSnippet<1> snippets[] = { |
799 {"return delete p1.val;", | 854 {"return delete p1.val;", |
800 {factory->true_value(), BytecodeGraphTester::NewObject("({val : 10})")}}, | 855 {factory->true_value(), BytecodeGraphTester::NewObject("({val : 10})")}}, |
801 {"delete p1.val; return p1.val;", | 856 {"delete p1.val; return p1.val;", |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 auto callable = tester.GetCallable<Handle<Object>>("f"); | 1182 auto callable = tester.GetCallable<Handle<Object>>("f"); |
1128 Handle<Object> return_value = | 1183 Handle<Object> return_value = |
1129 callable(snippets[i].parameter(0)).ToHandleChecked(); | 1184 callable(snippets[i].parameter(0)).ToHandleChecked(); |
1130 CHECK(return_value->SameValue(*snippets[i].return_value())); | 1185 CHECK(return_value->SameValue(*snippets[i].return_value())); |
1131 } | 1186 } |
1132 } | 1187 } |
1133 | 1188 |
1134 } // namespace compiler | 1189 } // namespace compiler |
1135 } // namespace internal | 1190 } // namespace internal |
1136 } // namespace v8 | 1191 } // namespace v8 |
OLD | NEW |