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

Side by Side Diff: test/mjsunit/wasm/memory-size.js

Issue 2640453003: [wasm] Fix and tighten memory validation (Closed)
Patch Set: Comments Created 3 years, 11 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 | « test/mjsunit/wasm/grow-memory.js ('k') | test/mjsunit/wasm/stack.js » ('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 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 // Flags: --expose-wasm 5 // Flags: --expose-wasm
6 6
7 load("test/mjsunit/wasm/wasm-constants.js"); 7 load("test/mjsunit/wasm/wasm-constants.js");
8 load("test/mjsunit/wasm/wasm-module-builder.js"); 8 load("test/mjsunit/wasm/wasm-module-builder.js");
9 9
10 (function testMemorySizeZero() { 10 (function testMemorySizeZero() {
11 print("testMemorySizeZero()"); 11 print("testMemorySizeZero()");
12 var builder = new WasmModuleBuilder(); 12 var builder = new WasmModuleBuilder();
13 builder.addMemory(0, 0, false);
13 builder.addFunction("memory_size", kSig_i_v) 14 builder.addFunction("memory_size", kSig_i_v)
14 .addBody([kExprMemorySize, kMemoryZero]) 15 .addBody([kExprMemorySize, kMemoryZero])
15 .exportFunc(); 16 .exportFunc();
16 var module = builder.instantiate(); 17 var module = builder.instantiate();
17 assertEquals(0, module.exports.memory_size()); 18 assertEquals(0, module.exports.memory_size());
18 })(); 19 })();
19 20
20 (function testMemorySizeNonZero() { 21 (function testMemorySizeNonZero() {
21 print("testMemorySizeNonZero()"); 22 print("testMemorySizeNonZero()");
22 var builder = new WasmModuleBuilder(); 23 var builder = new WasmModuleBuilder();
23 var size = 11; 24 var size = 11;
24 builder.addMemory(size, size, false); 25 builder.addMemory(size, size, false);
25 builder.addFunction("memory_size", kSig_i_v) 26 builder.addFunction("memory_size", kSig_i_v)
26 .addBody([kExprMemorySize, kMemoryZero]) 27 .addBody([kExprMemorySize, kMemoryZero])
27 .exportFunc(); 28 .exportFunc();
28 var module = builder.instantiate(); 29 var module = builder.instantiate();
29 assertEquals(size, module.exports.memory_size()); 30 assertEquals(size, module.exports.memory_size());
30 })(); 31 })();
OLDNEW
« no previous file with comments | « test/mjsunit/wasm/grow-memory.js ('k') | test/mjsunit/wasm/stack.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698