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

Side by Side Diff: test/mjsunit/asm/asm-validation.js

Issue 2229723002: [wasm] Support validation of asm.js modules with != 3 args. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 4 years, 4 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
« src/runtime/runtime.h ('K') | « src/x87/macro-assembler-x87.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
(Empty)
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
3 // found in the LICENSE file.
4
5 // Flags: --validate-asm --allow-natives-syntax
6
7 (function TestModuleArgs() {
8 function Module1(stdlib) {
9 "use asm";
10 function foo() { }
11 return { foo: foo };
12 }
13 function Module2(stdlib, ffi) {
14 "use asm";
15 function foo() { }
16 return { foo: foo };
17 }
18 function Module3(stdlib, ffi, heap) {
19 "use asm";
20 function foo() { }
21 return { foo: foo };
22 }
23 var modules = [Module1, Module2, Module3];
24 var heap = new ArrayBuffer(1024 * 1024);
25 for (var i = 0; i < modules.length; ++i) {
26 print('Module' + (i + 1));
27 var module = modules[i];
28 // TODO(bradnelson): Support modules without the stdlib.
29 var m = module({});
30 assertTrue(%IsAsmWasmCode(module));
31 var m = module({}, {});
32 assertTrue(%IsAsmWasmCode(module));
33 var m = module({}, {}, heap);
34 assertTrue(%IsAsmWasmCode(module));
35 var m = module({}, {}, heap, {});
36 assertTrue(%IsAsmWasmCode(module));
37 }
38 })();
39
40 (function TestBadModule() {
41 function Module(stdlib, ffi, heap) {
42 "use asm";
43 function foo() { var y = 3; var x = 1 + y; return 123; }
44 return { foo: foo };
45 }
46 var m = Module({});
47 assertFalse(%IsAsmWasmCode(Module));
48 assertEquals(123, m.foo());
49 })();
50
51 (function TestModuleNoStdlib() {
52 // TODO(bradnelson): Support modules like if they don't use the whole stdlib.
53 function Module() {
54 "use asm";
55 function foo() { return 123; }
56 return { foo: foo };
57 }
58 var m = Module({});
59 assertFalse(%IsAsmWasmCode(Module));
60 assertEquals(123, m.foo());
61 })();
62
63 (function TestModuleNoStdlibCall() {
64 function Module(stdlib, ffi, heap) {
65 "use asm";
66 function foo() { return 123; }
67 return { foo: foo };
68 }
69 // TODO(bradnelson): Support instantiation like this if stdlib is unused.
70 var m = Module();
71 assertFalse(%IsAsmWasmCode(Module));
72 assertEquals(123, m.foo());
73 })();
OLDNEW
« src/runtime/runtime.h ('K') | « src/x87/macro-assembler-x87.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698