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

Side by Side Diff: test/cctest/compiler/test-run-bytecode-graph-builder.cc

Issue 1524893003: [Interpreter] Add support for break statements in labelled blocks. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@oth-0009-phi
Patch Set: Rebase Created 5 years 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
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 #include <utility> 5 #include <utility>
6 6
7 #include "src/compiler/pipeline.h" 7 #include "src/compiler/pipeline.h"
8 #include "src/execution.h" 8 #include "src/execution.h"
9 #include "src/handles.h" 9 #include "src/handles.h"
10 #include "src/interpreter/bytecode-array-builder.h" 10 #include "src/interpreter/bytecode-array-builder.h"
(...skipping 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after
1665 BytecodeGraphTester tester(isolate, zone, script.start()); 1665 BytecodeGraphTester tester(isolate, zone, script.start());
1666 auto callable = tester.GetCallable<Handle<Object>, Handle<Object>>(); 1666 auto callable = tester.GetCallable<Handle<Object>, Handle<Object>>();
1667 Handle<Object> return_value = 1667 Handle<Object> return_value =
1668 callable(snippets[i].parameter(0), snippets[i].parameter(1)) 1668 callable(snippets[i].parameter(0), snippets[i].parameter(1))
1669 .ToHandleChecked(); 1669 .ToHandleChecked();
1670 CHECK(return_value->SameValue(*snippets[i].return_value())); 1670 CHECK(return_value->SameValue(*snippets[i].return_value()));
1671 } 1671 }
1672 } 1672 }
1673 1673
1674 1674
1675 TEST(BytecodeGraphBuilderBreakableBlocks) {
1676 HandleAndZoneScope scope;
1677 Isolate* isolate = scope.main_isolate();
1678 Zone* zone = scope.main_zone();
1679 Factory* factory = isolate->factory();
1680
1681 ExpectedSnippet<0> snippets[] = {
1682 {"var x = 0;\n"
1683 "my_heart: {\n"
1684 " x = x + 1;\n"
1685 " break my_heart;\n"
1686 " x = x + 2;\n"
1687 "}\n"
1688 "return x;\n",
1689 {factory->NewNumberFromInt(1)}},
1690 {"var sum = 0;\n"
1691 "outta_here: {\n"
1692 " for (var x = 0; x < 10; ++x) {\n"
1693 " for (var y = 0; y < 3; ++y) {\n"
1694 " ++sum;\n"
1695 " if (x + y == 12) { break outta_here; }\n"
1696 " }\n"
1697 " }\n"
1698 "}\n"
1699 "return sum;",
1700 {factory->NewNumber(30)}},
1701 };
1702
1703 for (size_t i = 0; i < arraysize(snippets); i++) {
1704 ScopedVector<char> script(1024);
1705 SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName,
1706 snippets[i].code_snippet, kFunctionName);
1707
1708 BytecodeGraphTester tester(isolate, zone, script.start());
1709 auto callable = tester.GetCallable<>();
1710 Handle<Object> return_value = callable().ToHandleChecked();
1711 CHECK(return_value->SameValue(*snippets[i].return_value()));
1712 }
1713 }
1714
1715
1675 TEST(BytecodeGraphBuilderWhile) { 1716 TEST(BytecodeGraphBuilderWhile) {
1676 HandleAndZoneScope scope; 1717 HandleAndZoneScope scope;
1677 Isolate* isolate = scope.main_isolate(); 1718 Isolate* isolate = scope.main_isolate();
1678 Zone* zone = scope.main_zone(); 1719 Zone* zone = scope.main_zone();
1679 Factory* factory = isolate->factory(); 1720 Factory* factory = isolate->factory();
1680 1721
1681 ExpectedSnippet<0> snippets[] = { 1722 ExpectedSnippet<0> snippets[] = {
1682 {"var x = 1; while (x < 1) { x *= 100; } return x;", 1723 {"var x = 1; while (x < 1) { x *= 100; } return x;",
1683 {factory->NewNumberFromInt(1)}}, 1724 {factory->NewNumberFromInt(1)}},
1684 {"var x = 1, y = 0; while (x < 7) { y += x * x; x += 1; } return y;", 1725 {"var x = 1, y = 0; while (x < 7) { y += x * x; x += 1; } return y;",
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1834 BytecodeGraphTester tester(isolate, zone, script.start()); 1875 BytecodeGraphTester tester(isolate, zone, script.start());
1835 auto callable = tester.GetCallable<>(); 1876 auto callable = tester.GetCallable<>();
1836 Handle<Object> return_value = callable().ToHandleChecked(); 1877 Handle<Object> return_value = callable().ToHandleChecked();
1837 CHECK(return_value->SameValue(*snippets[i].return_value())); 1878 CHECK(return_value->SameValue(*snippets[i].return_value()));
1838 } 1879 }
1839 } 1880 }
1840 1881
1841 } // namespace compiler 1882 } // namespace compiler
1842 } // namespace internal 1883 } // namespace internal
1843 } // namespace v8 1884 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/control-flow-builders.cc ('k') | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698