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

Side by Side Diff: test/unittests/wasm/ast-decoder-unittest.cc

Issue 1961853002: [wasm] Verify expressions do not cross control boundaries in WASM. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add comment Created 4 years, 7 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/wasm/ast-decoder.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 "test/unittests/test-utils.h" 5 #include "test/unittests/test-utils.h"
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "test/cctest/wasm/test-signatures.h" 9 #include "test/cctest/wasm/test-signatures.h"
10 10
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 } 300 }
301 301
302 byte code3[] = {kExprGetLocal, 0, 0}; // [expr] [opcode] 302 byte code3[] = {kExprGetLocal, 0, 0}; // [expr] [opcode]
303 for (size_t i = 0; i < arraysize(kInt32BinopOpcodes); i++) { 303 for (size_t i = 0; i < arraysize(kInt32BinopOpcodes); i++) {
304 code3[2] = kInt32BinopOpcodes[i]; 304 code3[2] = kInt32BinopOpcodes[i];
305 EXPECT_FAILURE(sigs.i_i(), code3); 305 EXPECT_FAILURE(sigs.i_i(), code3);
306 } 306 }
307 307
308 byte code4[] = {kExprGetLocal, 0, 0, 0}; // [expr] [opcode] [opcode] 308 byte code4[] = {kExprGetLocal, 0, 0, 0}; // [expr] [opcode] [opcode]
309 for (size_t i = 0; i < arraysize(kInt32BinopOpcodes); i++) { 309 for (size_t i = 0; i < arraysize(kInt32BinopOpcodes); i++) {
310 code4[1] = kInt32BinopOpcodes[i]; 310 code4[2] = kInt32BinopOpcodes[i];
311 code4[3] = kInt32BinopOpcodes[i]; 311 code4[3] = kInt32BinopOpcodes[i];
312 EXPECT_FAILURE(sigs.i_i(), code4); 312 EXPECT_FAILURE(sigs.i_i(), code4);
313 } 313 }
314 } 314 }
315 315
316 TEST_F(AstDecoderTest, BinopsAcrossBlock1) {
317 static const byte code[] = {WASM_ZERO, kExprBlock, WASM_ZERO, kExprI32Add,
318 kExprEnd};
319 EXPECT_FAILURE(sigs.i_i(), code);
320 }
316 321
317 //=================================================================== 322 TEST_F(AstDecoderTest, BinopsAcrossBlock2) {
318 //== Statements 323 static const byte code[] = {WASM_ZERO, WASM_ZERO, kExprBlock, kExprI32Add,
319 //=================================================================== 324 kExprEnd};
325 EXPECT_FAILURE(sigs.i_i(), code);
326 }
327
328 TEST_F(AstDecoderTest, BinopsAcrossBlock3) {
329 static const byte code[] = {WASM_ZERO, WASM_ZERO, kExprIf, kExprI32Add,
330 kExprElse, kExprI32Add, kExprEnd};
331 EXPECT_FAILURE(sigs.i_i(), code);
332 }
333
320 TEST_F(AstDecoderTest, Nop) { 334 TEST_F(AstDecoderTest, Nop) {
321 static const byte code[] = {kExprNop}; 335 static const byte code[] = {kExprNop};
322 EXPECT_VERIFIES(sigs.v_v(), code); 336 EXPECT_VERIFIES(sigs.v_v(), code);
323 } 337 }
324 338
325 TEST_F(AstDecoderTest, SetLocal0_param) { 339 TEST_F(AstDecoderTest, SetLocal0_param) {
326 EXPECT_VERIFIES(sigs.i_i(), kCodeSetLocal0); 340 EXPECT_VERIFIES(sigs.i_i(), kCodeSetLocal0);
327 EXPECT_FAILURE(sigs.f_ff(), kCodeSetLocal0); 341 EXPECT_FAILURE(sigs.f_ff(), kCodeSetLocal0);
328 EXPECT_FAILURE(sigs.d_dd(), kCodeSetLocal0); 342 EXPECT_FAILURE(sigs.d_dd(), kCodeSetLocal0);
329 } 343 }
(...skipping 2092 matching lines...) Expand 10 before | Expand all | Expand 10 after
2422 size_t pos = 0; 2436 size_t pos = 0;
2423 pos = ExpectRun(map, pos, kAstF32, 5); 2437 pos = ExpectRun(map, pos, kAstF32, 5);
2424 pos = ExpectRun(map, pos, kAstI32, 1337); 2438 pos = ExpectRun(map, pos, kAstI32, 1337);
2425 pos = ExpectRun(map, pos, kAstI64, 212); 2439 pos = ExpectRun(map, pos, kAstI64, 212);
2426 delete[] data; 2440 delete[] data;
2427 } 2441 }
2428 2442
2429 } // namespace wasm 2443 } // namespace wasm
2430 } // namespace internal 2444 } // namespace internal
2431 } // namespace v8 2445 } // namespace v8
OLDNEW
« no previous file with comments | « src/wasm/ast-decoder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698