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

Side by Side Diff: test/cctest/test-asm-validator.cc

Issue 1691723004: Only allow |0 and *1.0 for asm validator foreign variables. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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/typing-asm.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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/ast/ast.h" 7 #include "src/ast/ast.h"
8 #include "src/ast/ast-expression-visitor.h" 8 #include "src/ast/ast-expression-visitor.h"
9 #include "src/ast/scopes.h" 9 #include "src/ast/scopes.h"
10 #include "src/parsing/parser.h" 10 #include "src/parsing/parser.h"
(...skipping 2083 matching lines...) Expand 10 before | Expand all | Expand 10 after
2094 " return { testFunc1: test1 };\n" 2094 " return { testFunc1: test1 };\n"
2095 "}\n"; 2095 "}\n";
2096 v8::V8::Initialize(); 2096 v8::V8::Initialize();
2097 HandleAndZoneScope handles; 2097 HandleAndZoneScope handles;
2098 Zone* zone = handles.main_zone(); 2098 Zone* zone = handles.main_zone();
2099 ZoneVector<ExpressionTypeEntry> types(zone); 2099 ZoneVector<ExpressionTypeEntry> types(zone);
2100 CHECK_EQ("asm: line 4: illegal variable reference in module body\n", 2100 CHECK_EQ("asm: line 4: illegal variable reference in module body\n",
2101 Validate(zone, test_function, &types)); 2101 Validate(zone, test_function, &types));
2102 } 2102 }
2103 2103
2104 TEST(BadForeignVariableReferenceValueOr) {
2105 const char test_function[] =
2106 "function TestModule(stdlib, foreign, buffer) {\n"
2107 " \"use asm\";\n"
2108 " var fint = foreign.bar | 1;\n"
2109 "}\n";
2110 v8::V8::Initialize();
2111 HandleAndZoneScope handles;
2112 Zone* zone = handles.main_zone();
2113 ZoneVector<ExpressionTypeEntry> types(zone);
2114 CHECK_EQ("asm: line 3: illegal integer annotation value\n",
2115 Validate(zone, test_function, &types));
2116 }
2117
2118 TEST(BadForeignVariableReferenceValueOrDot) {
2119 const char test_function[] =
2120 "function TestModule(stdlib, foreign, buffer) {\n"
2121 " \"use asm\";\n"
2122 " var fint = foreign.bar | 1.0;\n"
2123 "}\n";
2124 v8::V8::Initialize();
2125 HandleAndZoneScope handles;
2126 Zone* zone = handles.main_zone();
2127 ZoneVector<ExpressionTypeEntry> types(zone);
2128 CHECK_EQ("asm: line 3: illegal integer annotation value\n",
2129 Validate(zone, test_function, &types));
2130 }
2131
2132 TEST(BadForeignVariableReferenceValueMul) {
2133 const char test_function[] =
2134 "function TestModule(stdlib, foreign, buffer) {\n"
2135 " \"use asm\";\n"
2136 " var fint = foreign.bar * 2.0;\n"
2137 "}\n";
2138 v8::V8::Initialize();
2139 HandleAndZoneScope handles;
2140 Zone* zone = handles.main_zone();
2141 ZoneVector<ExpressionTypeEntry> types(zone);
2142 CHECK_EQ("asm: line 3: illegal double annotation value\n",
2143 Validate(zone, test_function, &types));
2144 }
2145
2146 TEST(BadForeignVariableReferenceValueMulNoDot) {
2147 const char test_function[] =
2148 "function TestModule(stdlib, foreign, buffer) {\n"
2149 " \"use asm\";\n"
2150 " var fint = foreign.bar * 1;\n"
2151 "}\n";
2152 v8::V8::Initialize();
2153 HandleAndZoneScope handles;
2154 Zone* zone = handles.main_zone();
2155 ZoneVector<ExpressionTypeEntry> types(zone);
2156 CHECK_EQ("asm: line 3: ill-typed arithmetic operation\n",
2157 Validate(zone, test_function, &types));
2158 }
2159
2104 TEST(Imports) { 2160 TEST(Imports) {
2105 const char test_function[] = 2161 const char test_function[] =
2106 "function TestModule(stdlib, foreign, buffer) {\n" 2162 "function TestModule(stdlib, foreign, buffer) {\n"
2107 " \"use asm\";\n" 2163 " \"use asm\";\n"
2108 " var ffunc = foreign.foo;\n" 2164 " var ffunc = foreign.foo;\n"
2109 " var fint = foreign.bar | 0;\n" 2165 " var fint = foreign.bar | 0;\n"
2110 " var fdouble = +foreign.baz;\n" 2166 " var fdouble = +foreign.baz;\n"
2111 " function test1() { return ffunc(fint|0, fdouble) | 0; }\n" 2167 " function test1() { return ffunc(fint|0, fdouble) | 0; }\n"
2112 " function test2() { return +ffunc(fdouble, fint|0); }\n" 2168 " function test2() { return +ffunc(fdouble, fint|0); }\n"
2113 " return { testFunc1: test1, testFunc2: test2 };\n" 2169 " return { testFunc1: test1, testFunc2: test2 };\n"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
2185 } 2241 }
2186 // return { testFunc1: test1, testFunc2: test2 }; 2242 // return { testFunc1: test1, testFunc2: test2 };
2187 CHECK_EXPR(ObjectLiteral, Bounds::Unbounded()) { 2243 CHECK_EXPR(ObjectLiteral, Bounds::Unbounded()) {
2188 CHECK_VAR(test1, FUNC_I_TYPE); 2244 CHECK_VAR(test1, FUNC_I_TYPE);
2189 CHECK_VAR(test2, FUNC_D_TYPE); 2245 CHECK_VAR(test2, FUNC_D_TYPE);
2190 } 2246 }
2191 } 2247 }
2192 } 2248 }
2193 CHECK_TYPES_END 2249 CHECK_TYPES_END
2194 } 2250 }
OLDNEW
« no previous file with comments | « src/typing-asm.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698