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

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

Issue 1531693002: [Interpreter] Implement ForIn in bytecode graph builder. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@oth-0009-phi
Patch Set: Minor clean-up/simplication in Runtime_InterpreterForInPrepare. 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
« no previous file with comments | « src/runtime/runtime-interpreter.cc ('k') | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | 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 #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 1862 matching lines...) Expand 10 before | Expand all | Expand 10 after
1873 SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName, 1873 SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName,
1874 snippets[i].code_snippet, kFunctionName); 1874 snippets[i].code_snippet, kFunctionName);
1875 1875
1876 BytecodeGraphTester tester(isolate, zone, script.start()); 1876 BytecodeGraphTester tester(isolate, zone, script.start());
1877 auto callable = tester.GetCallable<>(); 1877 auto callable = tester.GetCallable<>();
1878 Handle<Object> return_value = callable().ToHandleChecked(); 1878 Handle<Object> return_value = callable().ToHandleChecked();
1879 CHECK(return_value->SameValue(*snippets[i].return_value())); 1879 CHECK(return_value->SameValue(*snippets[i].return_value()));
1880 } 1880 }
1881 } 1881 }
1882 1882
1883
1884 TEST(BytecodeGraphBuilderForIn) {
1885 HandleAndZoneScope scope;
1886 Isolate* isolate = scope.main_isolate();
1887 Zone* zone = scope.main_zone();
1888 Factory* factory = isolate->factory();
1889 ExpectedSnippet<0> snippets[] = {
1890 {"var sum = 0;\n"
1891 "var empty = null;\n"
1892 "for (var x in empty) { sum++; }\n"
1893 "return sum;",
1894 {factory->NewNumberFromInt(0)}},
1895 {"var sum = 100;\n"
1896 "var empty = 1;\n"
1897 "for (var x in empty) { sum++; }\n"
1898 "return sum;",
1899 {factory->NewNumberFromInt(100)}},
1900 {"for (var x in [ 10, 20, 30 ]) {}\n"
1901 "return 2;",
1902 {factory->NewNumberFromInt(2)}},
1903 {"var last = 0;\n"
1904 "for (var x in [ 10, 20, 30 ]) {\n"
1905 " last = x;\n"
1906 "}\n"
1907 "return +last;",
1908 {factory->NewNumberFromInt(2)}},
1909 {"var first = -1;\n"
1910 "for (var x in [ 10, 20, 30 ]) {\n"
1911 " first = +x;\n"
1912 " if (first > 0) break;\n"
1913 "}\n"
1914 "return first;",
1915 {factory->NewNumberFromInt(1)}},
1916 {"var first = -1;\n"
1917 "for (var x in [ 10, 20, 30 ]) {\n"
1918 " if (first >= 0) continue;\n"
1919 " first = x;\n"
1920 "}\n"
1921 "return +first;",
1922 {factory->NewNumberFromInt(0)}},
1923 {"var sum = 0;\n"
1924 "for (var x in [ 10, 20, 30 ]) {\n"
1925 " for (var y in [ 11, 22, 33, 44, 55, 66, 77 ]) {\n"
1926 " sum += 1;\n"
1927 " }\n"
1928 "}\n"
1929 "return sum;",
1930 {factory->NewNumberFromInt(21)}},
1931 {"var sum = 0;\n"
1932 "for (var x in [ 10, 20, 30 ]) {\n"
1933 " for (var y in [ 11, 22, 33, 44, 55, 66, 77 ]) {\n"
1934 " if (sum == 7) break;\n"
1935 " if (sum == 6) continue;\n"
1936 " sum += 1;\n"
1937 " }\n"
1938 "}\n"
1939 "return sum;",
1940 {factory->NewNumberFromInt(6)}},
1941 };
1942
1943 for (size_t i = 0; i < arraysize(snippets); i++) {
1944 ScopedVector<char> script(1024);
1945 SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName,
1946 snippets[i].code_snippet, kFunctionName);
1947
1948 BytecodeGraphTester tester(isolate, zone, script.start());
1949 auto callable = tester.GetCallable<>();
1950 Handle<Object> return_value = callable().ToHandleChecked();
1951 CHECK(return_value->SameValue(*snippets[i].return_value()));
1952 }
1953 }
1954
1955
1883 } // namespace compiler 1956 } // namespace compiler
1884 } // namespace internal 1957 } // namespace internal
1885 } // namespace v8 1958 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-interpreter.cc ('k') | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698