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

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: file change 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-compiler.cc ('K') | « src/runtime/runtime-test.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.
Michael Starzinger 2016/08/11 11:44:10 Can we add tests for the following? - Instantiati
bradn 2016/08/12 01:17:09 Done, but Questions: * The new case seems to be a
Michael Starzinger 2016/08/12 09:21:55 Yes, that is what my intuition of the asm.js spec
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 TestBadArgTypes() {
52 function Module(a, b, c) {
53 "use asm";
54 return {};
55 }
56 var m = Module(1, 2, 3);
57 assertFalse(%IsAsmWasmCode(Module));
58 assertEquals({}, m);
59 })();
60
61 (function TestBadArgTypesMismatch() {
62 function Module(a, b, c) {
63 "use asm";
64 return {};
65 }
66 var m = Module(1, 2);
67 assertFalse(%IsAsmWasmCode(Module));
68 assertEquals({}, m);
69 })();
70
71 (function TestModuleNoStdlib() {
72 // TODO(bradnelson):
73 // Support modules like this if they don't use the whole stdlib.
74 function Module() {
75 "use asm";
76 function foo() { return 123; }
77 return { foo: foo };
78 }
79 var m = Module({});
80 assertFalse(%IsAsmWasmCode(Module));
81 assertEquals(123, m.foo());
82 })();
83
84 (function TestModuleNoStdlibCall() {
85 function Module(stdlib, ffi, heap) {
86 "use asm";
87 function foo() { return 123; }
88 return { foo: foo };
89 }
90 // TODO(bradnelson): Support instantiation like this if stdlib is unused.
91 var m = Module();
92 assertFalse(%IsAsmWasmCode(Module));
93 assertEquals(123, m.foo());
94 })();
OLDNEW
« src/runtime/runtime-compiler.cc ('K') | « src/runtime/runtime-test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698