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

Side by Side Diff: test/mjsunit/wasm/calls.js

Issue 1763433002: [wasm] Rework encoding of local declarations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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
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 // 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 8
9 var module = (function () { 9 var module = (function () {
10 var kBodySize = 5; 10 var kBodySize = 6;
11 var kNameOffset = kHeaderSize + 21 + kBodySize + 1; 11 var kNameOffset = kHeaderSize + 21 + kBodySize + 1;
12 12
13 return _WASMEXP_.instantiateModule(bytesWithHeader( 13 return _WASMEXP_.instantiateModule(bytesWithHeader(
14 // -- memory 14 // -- memory
15 kDeclMemory, 15 kDeclMemory,
16 12, 12, 1, 16 12, 12, 1,
17 // -- signatures 17 // -- signatures
18 kDeclSignatures, 1, 18 kDeclSignatures, 1,
19 2, kAstI32, kAstI32, kAstI32, // int, int -> int 19 2, kAstI32, kAstI32, kAstI32, // int, int -> int
20 // -- functions 20 // -- functions
21 kDeclFunctions, 1, 21 kDeclFunctions, 1,
22 kDeclFunctionName | kDeclFunctionExport, 22 kDeclFunctionName | kDeclFunctionExport,
23 0, 0, 23 0, 0,
24 kNameOffset, 0, 0, 0, // name offset 24 kNameOffset, 0, 0, 0, // name offset
25 kBodySize, 0, 25 kBodySize, 0,
26 // -- body 26 // -- body
27 kDeclNoLocals,
27 kExprI32Sub, // -- 28 kExprI32Sub, // --
28 kExprGetLocal, 0, // -- 29 kExprGetLocal, 0, // --
29 kExprGetLocal, 1, // -- 30 kExprGetLocal, 1, // --
30 kDeclEnd, 31 kDeclEnd,
31 's', 'u', 'b', 0 // name 32 's', 'u', 'b', 0 // name
32 )); 33 ));
33 })(); 34 })();
34 35
35 // Check the module exists. 36 // Check the module exists.
36 assertFalse(module === undefined); 37 assertFalse(module === undefined);
(...skipping 17 matching lines...) Expand all
54 55
55 // Check the properties of the sub function. 56 // Check the properties of the sub function.
56 assertEquals("function", typeof module.sub); 57 assertEquals("function", typeof module.sub);
57 58
58 assertEquals(-55, module.sub(33, 88)); 59 assertEquals(-55, module.sub(33, 88));
59 assertEquals(-55555, module.sub(33333, 88888)); 60 assertEquals(-55555, module.sub(33333, 88888));
60 assertEquals(-5555555, module.sub(3333333, 8888888)); 61 assertEquals(-5555555, module.sub(3333333, 8888888));
61 62
62 63
63 var module = (function() { 64 var module = (function() {
64 var kBodySize = 1; 65 var kBodySize = 2;
65 var kNameOffset2 = kHeaderSize + 19 + kBodySize + 1; 66 var kNameOffset2 = kHeaderSize + 19 + kBodySize + 1;
66 67
67 return _WASMEXP_.instantiateModule(bytesWithHeader( 68 return _WASMEXP_.instantiateModule(bytesWithHeader(
68 // -- memory 69 // -- memory
69 kDeclMemory, 70 kDeclMemory,
70 12, 12, 1, 71 12, 12, 1,
71 // -- signatures 72 // -- signatures
72 kDeclSignatures, 1, 73 kDeclSignatures, 1,
73 0, kAstStmt, // signature: void -> void 74 0, kAstStmt, // signature: void -> void
74 // -- functions 75 // -- functions
75 kDeclFunctions, 1, 76 kDeclFunctions, 1,
76 kDeclFunctionName | kDeclFunctionExport, 77 kDeclFunctionName | kDeclFunctionExport,
77 0, 0, // signature index 78 0, 0, // signature index
78 kNameOffset2, 0, 0, 0, // name offset 79 kNameOffset2, 0, 0, 0, // name offset
79 kBodySize, 0, 80 kBodySize, 0,
81 kDeclNoLocals,
80 kExprNop, // body 82 kExprNop, // body
81 kDeclEnd, 83 kDeclEnd,
82 'n', 'o', 'p', 0 // name 84 'n', 'o', 'p', 0 // name
83 )); 85 ));
84 })(); 86 })();
85 87
86 // Check the module exists. 88 // Check the module exists.
87 assertFalse(module === undefined); 89 assertFalse(module === undefined);
88 assertFalse(module === null); 90 assertFalse(module === null);
89 assertFalse(module === 0); 91 assertFalse(module === 0);
(...skipping 15 matching lines...) Expand all
105 107
106 // Check the properties of the sub function. 108 // Check the properties of the sub function.
107 assertFalse(module.nop === undefined); 109 assertFalse(module.nop === undefined);
108 assertFalse(module.nop === null); 110 assertFalse(module.nop === null);
109 assertFalse(module.nop === 0); 111 assertFalse(module.nop === 0);
110 assertEquals("function", typeof module.nop); 112 assertEquals("function", typeof module.nop);
111 113
112 assertEquals(undefined, module.nop()); 114 assertEquals(undefined, module.nop());
113 115
114 (function testLt() { 116 (function testLt() {
115 var kBodySize = 5; 117 var kBodySize = 6;
116 var kNameOffset = kHeaderSize + 21 + kBodySize + 1; 118 var kNameOffset = kHeaderSize + 21 + kBodySize + 1;
117 119
118 var data = bytesWithHeader( 120 var data = bytesWithHeader(
119 // -- memory 121 // -- memory
120 kDeclMemory, 122 kDeclMemory,
121 12, 12, 1, 123 12, 12, 1,
122 // -- signatures 124 // -- signatures
123 kDeclSignatures, 1, 125 kDeclSignatures, 1,
124 2, kAstI32, kAstF64, kAstF64, // (f64,f64)->int 126 2, kAstI32, kAstF64, kAstF64, // (f64,f64)->int
125 // -- functions 127 // -- functions
126 kDeclFunctions, 1, 128 kDeclFunctions, 1,
127 kDeclFunctionName | kDeclFunctionExport, 129 kDeclFunctionName | kDeclFunctionExport,
128 0, 0, // signature index 130 0, 0, // signature index
129 kNameOffset, 0, 0, 0, // name offset 131 kNameOffset, 0, 0, 0, // name offset
130 kBodySize, 0, 132 kBodySize, 0,
131 // -- body 133 // -- body
134 kDeclNoLocals,
132 kExprF64Lt, // -- 135 kExprF64Lt, // --
133 kExprGetLocal, 0, // -- 136 kExprGetLocal, 0, // --
134 kExprGetLocal, 1, // -- 137 kExprGetLocal, 1, // --
135 kDeclEnd, 138 kDeclEnd,
136 'f', 'l', 't', 0 // name 139 'f', 'l', 't', 0 // name
137 ); 140 );
138 141
139 var module = _WASMEXP_.instantiateModule(data); 142 var module = _WASMEXP_.instantiateModule(data);
140 143
141 assertEquals("function", typeof module.flt); 144 assertEquals("function", typeof module.flt);
142 assertEquals(1, module.flt(-2, -1)); 145 assertEquals(1, module.flt(-2, -1));
143 assertEquals(0, module.flt(7.3, 7.1)); 146 assertEquals(0, module.flt(7.3, 7.1));
144 assertEquals(1, module.flt(7.1, 7.3)); 147 assertEquals(1, module.flt(7.1, 7.3));
145 })(); 148 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698