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

Side by Side Diff: test/cctest/interpreter/test-interpreter.cc

Issue 1414193006: [Interpreter] Removes unnecessary jumps and dead code from If and loops. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Adds a test for generating JumpIfToBoolean for If statement. The earlier tests were optimized out b… Created 5 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/interpreter/test-bytecode-generator.cc ('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 // 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
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
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
OLDNEW
« no previous file with comments | « test/cctest/interpreter/test-bytecode-generator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698