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

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: Rebase after de-opt landed. 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 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 last = 0;\n"
1891 "for (var x in [ 10, 20, 30 ]) {\n"
1892 " last = x;\n"
1893 "}\n"
1894 "return +last;",
1895 {factory->NewNumberFromInt(2)}},
1896 {"var first = -1;\n"
1897 "for (var x in [ 10, 20, 30 ]) {\n"
1898 " first = +x;\n"
1899 " if (first > 0) break;\n"
1900 "}\n"
1901 "return first;",
1902 {factory->NewNumberFromInt(1)}},
1903 {"var first = -1;\n"
1904 "for (var x in [ 10, 20, 30 ]) {\n"
1905 " if (first >= 0) continue;\n"
1906 " first = x;\n"
1907 "}\n"
1908 "return +first;",
1909 {factory->NewNumberFromInt(0)}},
1910 {"var sum = 0;\n"
1911 "for (var x in [ 10, 20, 30 ]) {\n"
1912 " for (var y in [ 11, 22, 33, 44, 55, 66, 77 ]) {\n"
1913 " sum += 1;\n"
1914 " }\n"
1915 "}\n"
1916 "return sum;",
1917 {factory->NewNumberFromInt(21)}},
1918 {"var sum = 0;\n"
1919 "for (var x in [ 10, 20, 30 ]) {\n"
1920 " for (var y in [ 11, 22, 33, 44, 55, 66, 77 ]) {\n"
1921 " if (sum == 7) break;\n"
1922 " if (sum == 6) continue;\n"
1923 " sum += 1;\n"
1924 " }\n"
1925 "}\n"
1926 "return sum;",
1927 {factory->NewNumberFromInt(6)}},
1928 };
1929
1930 for (size_t i = 0; i < arraysize(snippets); i++) {
1931 ScopedVector<char> script(1024);
1932 SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName,
1933 snippets[i].code_snippet, kFunctionName);
1934
1935 BytecodeGraphTester tester(isolate, zone, script.start());
1936 auto callable = tester.GetCallable<>();
1937 Handle<Object> return_value = callable().ToHandleChecked();
1938 CHECK(return_value->SameValue(*snippets[i].return_value()));
1939 }
1940 }
1941
1942
1883 } // namespace compiler 1943 } // namespace compiler
1884 } // namespace internal 1944 } // namespace internal
1885 } // namespace v8 1945 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698