OLD | NEW |
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/handles.h" | 7 #include "src/handles.h" |
8 #include "src/objects-inl.h" | 8 #include "src/objects-inl.h" |
9 #include "src/wasm/module-decoder.h" | 9 #include "src/wasm/module-decoder.h" |
10 #include "src/wasm/wasm-macro-gen.h" | 10 #include "src/wasm/wasm-macro-gen.h" |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 TEST_F(WasmModuleVerifyTest, ZeroGlobals) { | 241 TEST_F(WasmModuleVerifyTest, ZeroGlobals) { |
242 static const byte data[] = { | 242 static const byte data[] = { |
243 SECTION(Global, 1), // -- | 243 SECTION(Global, 1), // -- |
244 0, // declare 0 globals | 244 0, // declare 0 globals |
245 }; | 245 }; |
246 ModuleResult result = DecodeModule(data, data + sizeof(data)); | 246 ModuleResult result = DecodeModule(data, data + sizeof(data)); |
247 EXPECT_OK(result); | 247 EXPECT_OK(result); |
248 if (result.val) delete result.val; | 248 if (result.val) delete result.val; |
249 } | 249 } |
250 | 250 |
| 251 TEST_F(WasmModuleVerifyTest, ExportMutableGlobal) { |
| 252 { |
| 253 static const byte data[] = { |
| 254 SECTION(Global, 6), // -- |
| 255 1, |
| 256 kLocalI32, // local type |
| 257 0, // immutable |
| 258 WASM_INIT_EXPR_I32V_1(13), // init |
| 259 SECTION(Export, 8), // -- |
| 260 1, // Export count |
| 261 4, // name length |
| 262 'n', // -- |
| 263 'a', // -- |
| 264 'm', // -- |
| 265 'e', // -- |
| 266 kExternalGlobal, // global |
| 267 0, // global index |
| 268 }; |
| 269 EXPECT_VERIFIES(data); |
| 270 } |
| 271 { |
| 272 static const byte data[] = { |
| 273 SECTION(Global, 6), // -- |
| 274 1, // -- |
| 275 kLocalI32, // local type |
| 276 1, // mutable |
| 277 WASM_INIT_EXPR_I32V_1(13), // init |
| 278 SECTION(Export, 8), // -- |
| 279 1, // Export count |
| 280 4, // name length |
| 281 'n', // -- |
| 282 'a', // -- |
| 283 'm', // -- |
| 284 'e', // -- |
| 285 kExternalGlobal, // global |
| 286 0, // global index |
| 287 }; |
| 288 EXPECT_FAILURE(data); |
| 289 } |
| 290 } |
| 291 |
251 static void AppendUint32v(std::vector<byte>& buffer, uint32_t val) { | 292 static void AppendUint32v(std::vector<byte>& buffer, uint32_t val) { |
252 while (true) { | 293 while (true) { |
253 uint32_t next = val >> 7; | 294 uint32_t next = val >> 7; |
254 uint32_t out = val & 0x7f; | 295 uint32_t out = val & 0x7f; |
255 if (next) { | 296 if (next) { |
256 buffer.push_back(static_cast<byte>(0x80 | out)); | 297 buffer.push_back(static_cast<byte>(0x80 | out)); |
257 val = next; | 298 val = next; |
258 } else { | 299 } else { |
259 buffer.push_back(static_cast<byte>(out)); | 300 buffer.push_back(static_cast<byte>(out)); |
260 break; | 301 break; |
(...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1304 SECTION(Unknown, 4), 1, 'X', 17, 18, // -- | 1345 SECTION(Unknown, 4), 1, 'X', 17, 18, // -- |
1305 SECTION(Unknown, 9), 3, 'f', 'o', 'o', 5, 6, 7, 8, 9, // -- | 1346 SECTION(Unknown, 9), 3, 'f', 'o', 'o', 5, 6, 7, 8, 9, // -- |
1306 SECTION(Unknown, 8), 5, 'o', 't', 'h', 'e', 'r', 7, 8, // -- | 1347 SECTION(Unknown, 8), 5, 'o', 't', 'h', 'e', 'r', 7, 8, // -- |
1307 }; | 1348 }; |
1308 EXPECT_VERIFIES(data); | 1349 EXPECT_VERIFIES(data); |
1309 } | 1350 } |
1310 | 1351 |
1311 } // namespace wasm | 1352 } // namespace wasm |
1312 } // namespace internal | 1353 } // namespace internal |
1313 } // namespace v8 | 1354 } // namespace v8 |
OLD | NEW |