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(rmcilroy): Remove this define after this flag is turned on globally | 5 // TODO(rmcilroy): Remove this define after this flag is turned on globally |
6 #define V8_IMMINENT_DEPRECATION_WARNINGS | 6 #define V8_IMMINENT_DEPRECATION_WARNINGS |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/execution.h" | 10 #include "src/execution.h" |
(...skipping 2559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2570 " b = b * 2;\n" | 2570 " b = b * 2;\n" |
2571 " --a;\n" | 2571 " --a;\n" |
2572 "} while(a);\n" | 2572 "} while(a);\n" |
2573 "return b;\n", | 2573 "return b;\n", |
2574 handle(Smi::FromInt(2), isolate)), | 2574 handle(Smi::FromInt(2), isolate)), |
2575 std::make_pair("var b = 1;\n" | 2575 std::make_pair("var b = 1;\n" |
2576 "for ( var a = 10; a > 0; a--) {\n" | 2576 "for ( var a = 10; a > 0; a--) {\n" |
2577 " b *= 2;\n" | 2577 " b *= 2;\n" |
2578 "}\n" | 2578 "}\n" |
2579 "return b;", | 2579 "return b;", |
2580 factory->NewHeapNumber(1024))}; | 2580 factory->NewHeapNumber(1024)), |
| 2581 std::make_pair("var a = 10; var b = 1;\n" |
| 2582 "while (false) {\n" |
| 2583 " b = b * 2;\n" |
| 2584 " a = a - 1;\n" |
| 2585 "}\n" |
| 2586 "return b;\n", |
| 2587 Handle<Object>(Smi::FromInt(1), isolate)), |
| 2588 std::make_pair("var a = 10; var b = 1;\n" |
| 2589 "while (true) {\n" |
| 2590 " b = b * 2;\n" |
| 2591 " a = a - 1;\n" |
| 2592 " if (a == 0) break;" |
| 2593 " continue;" |
| 2594 "}\n" |
| 2595 "return b;\n", |
| 2596 factory->NewHeapNumber(1024)), |
| 2597 std::make_pair("var a = 10; var b = 1;\n" |
| 2598 "do {\n" |
| 2599 " b = b * 2;\n" |
| 2600 " a = a - 1;\n" |
| 2601 " if (a == 0) break;" |
| 2602 "} while(true);\n" |
| 2603 "return b;\n", |
| 2604 factory->NewHeapNumber(1024)), |
| 2605 std::make_pair("var a = 10; var b = 1;\n" |
| 2606 "do {\n" |
| 2607 " b = b * 2;\n" |
| 2608 " a = a - 1;\n" |
| 2609 " if (a == 0) break;" |
| 2610 "} while(false);\n" |
| 2611 "return b;\n", |
| 2612 Handle<Object>(Smi::FromInt(2), isolate)), |
| 2613 std::make_pair("var a = 10; var b = 1;\n" |
| 2614 "for ( a = 1, b = 30; false; ) {\n" |
| 2615 " b = b * 2;\n" |
| 2616 "}\n" |
| 2617 "return b;\n", |
| 2618 Handle<Object>(Smi::FromInt(30), isolate))}; |
2581 | 2619 |
2582 for (size_t i = 0; i < arraysize(loops); i++) { | 2620 for (size_t i = 0; i < arraysize(loops); i++) { |
2583 std::string source(InterpreterTester::SourceForBody(loops[i].first)); | 2621 std::string source(InterpreterTester::SourceForBody(loops[i].first)); |
2584 InterpreterTester tester(handles.main_isolate(), source.c_str()); | 2622 InterpreterTester tester(handles.main_isolate(), source.c_str()); |
2585 auto callable = tester.GetCallable<>(); | 2623 auto callable = tester.GetCallable<>(); |
2586 | 2624 |
2587 Handle<i::Object> return_value = callable().ToHandleChecked(); | 2625 Handle<i::Object> return_value = callable().ToHandleChecked(); |
2588 CHECK(return_value->SameValue(*loops[i].second)); | 2626 CHECK(return_value->SameValue(*loops[i].second)); |
2589 } | 2627 } |
2590 } | 2628 } |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2856 auto callable = tester.GetCallable<>(); | 2894 auto callable = tester.GetCallable<>(); |
2857 | 2895 |
2858 Handle<i::Object> return_value = callable().ToHandleChecked(); | 2896 Handle<i::Object> return_value = callable().ToHandleChecked(); |
2859 CHECK(return_value->SameValue(*switch_ops[i].second)); | 2897 CHECK(return_value->SameValue(*switch_ops[i].second)); |
2860 } | 2898 } |
2861 } | 2899 } |
2862 | 2900 |
2863 } // namespace interpreter | 2901 } // namespace interpreter |
2864 } // namespace internal | 2902 } // namespace internal |
2865 } // namespace v8 | 2903 } // namespace v8 |
OLD | NEW |