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

Side by Side Diff: test/cctest/asmjs/test-asm-typer.cc

Issue 2268363002: [Asm.js] Prevents assignments to immutables. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addresses comments. Created 4 years, 3 months 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/asmjs/asm-typer.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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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 <cstring> 5 #include <cstring>
6 #include <functional> 6 #include <functional>
7 #include <iostream> 7 #include <iostream>
8 #include <memory> 8 #include <memory>
9 9
10 #include "src/asmjs/asm-typer.h" 10 #include "src/asmjs/asm-typer.h"
(...skipping 1923 matching lines...) Expand 10 before | Expand all | Expand 10 after
1934 1934
1935 for (size_t ii = 0; ii < arraysize(kTests); ++ii) { 1935 for (size_t ii = 0; ii < arraysize(kTests); ++ii) {
1936 if (!ValidationOf(Module(kTests[ii])) 1936 if (!ValidationOf(Module(kTests[ii]))
1937 ->FailsWithMessage("Invalid heap access index")) { 1937 ->FailsWithMessage("Invalid heap access index")) {
1938 std::cerr << "Test:\n" << kTests[ii]; 1938 std::cerr << "Test:\n" << kTests[ii];
1939 CHECK(false); 1939 CHECK(false);
1940 } 1940 }
1941 } 1941 }
1942 } 1942 }
1943 1943
1944 // This issue was triggered because assignments to immutable symbols (e.g., the
1945 // module's name, or any of the asm.js' module parameters) was not being
1946 // handled.
1947 TEST(B640194) {
1948 const char* kTests[] = {
1949 "function asm() {\n"
1950 " 'use asm';\n"
1951 " function f() {\n"
1952 " asm = 0;\n"
1953 " }\n"
1954 " return f;\n"
1955 "}",
1956 "function asm(stdlib) {\n"
1957 " 'use asm';\n"
1958 " function f() {\n"
1959 " stdlib = 0;\n"
1960 " }\n"
1961 " return f;\n"
1962 "}",
1963 "function asm(stdlib, foreign) {\n"
1964 " 'use asm';\n"
1965 " function f() {\n"
1966 " foreign = 0;\n"
1967 " }\n"
1968 " return f;\n"
1969 "}",
1970 "function asm(stdlib, foreign, heap) {\n"
1971 " 'use asm';\n"
1972 " function f() {\n"
1973 " heap = 0;\n"
1974 " }\n"
1975 " return f;\n"
1976 "}",
1977 "function asm(stdlib, foreign, heap) {\n"
1978 " 'use asm';\n"
1979 " var f = stdlib.Math.fround;\n"
1980 " function f() {\n"
1981 " f = 0;\n"
1982 " }\n"
1983 " return f;\n"
1984 "}",
1985 "function asm(stdlib, foreign, heap) {\n"
1986 " 'use asm';\n"
1987 " var E = stdlib.Math.E;\n"
1988 " function f() {\n"
1989 " E = 0;\n"
1990 " }\n"
1991 " return f;\n"
1992 "}",
1993 };
1994 for (size_t ii = 0; ii < arraysize(kTests); ++ii) {
1995 if (!ValidationOf(Module(kTests[ii]))
1996 ->FailsWithMessage("Can't assign to immutable symbol")) {
1997 std::cerr << "Test:\n" << kTests[ii];
1998 CHECK(false);
1999 }
2000 }
2001 }
2002
1944 } // namespace 2003 } // namespace
OLDNEW
« no previous file with comments | « src/asmjs/asm-typer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698