OLD | NEW |
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 #include "src/value-serializer.h" | 5 #include "src/value-serializer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "include/v8.h" | 10 #include "include/v8.h" |
(...skipping 2453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2464 | 2464 |
2465 private: | 2465 private: |
2466 static bool g_saved_flag; | 2466 static bool g_saved_flag; |
2467 }; | 2467 }; |
2468 | 2468 |
2469 bool ValueSerializerTestWithWasm::g_saved_flag = false; | 2469 bool ValueSerializerTestWithWasm::g_saved_flag = false; |
2470 | 2470 |
2471 // A simple module which exports an "increment" function. | 2471 // A simple module which exports an "increment" function. |
2472 // Copied from test/mjsunit/wasm/incrementer.wasm. | 2472 // Copied from test/mjsunit/wasm/incrementer.wasm. |
2473 const unsigned char kIncrementerWasm[] = { | 2473 const unsigned char kIncrementerWasm[] = { |
2474 0, 97, 115, 109, 13, 0, 0, 0, 1, 6, 1, 96, 1, 127, 1, 127, | 2474 0, 97, 115, 109, 1, 0, 0, 0, 1, 6, 1, 96, 1, 127, 1, 127, |
2475 3, 2, 1, 0, 7, 13, 1, 9, 105, 110, 99, 114, 101, 109, 101, 110, | 2475 3, 2, 1, 0, 7, 13, 1, 9, 105, 110, 99, 114, 101, 109, 101, 110, |
2476 116, 0, 0, 10, 9, 1, 7, 0, 32, 0, 65, 1, 106, 11, | 2476 116, 0, 0, 10, 9, 1, 7, 0, 32, 0, 65, 1, 106, 11, |
2477 }; | 2477 }; |
2478 | 2478 |
2479 TEST_F(ValueSerializerTestWithWasm, RoundTripWasmModule) { | 2479 TEST_F(ValueSerializerTestWithWasm, RoundTripWasmModule) { |
2480 RoundTripTest( | 2480 RoundTripTest( |
2481 [this]() { | 2481 [this]() { |
2482 return WasmCompiledModule::DeserializeOrCompile( | 2482 return WasmCompiledModule::DeserializeOrCompile( |
2483 isolate(), {nullptr, 0}, | 2483 isolate(), {nullptr, 0}, |
2484 {kIncrementerWasm, sizeof(kIncrementerWasm)}) | 2484 {kIncrementerWasm, sizeof(kIncrementerWasm)}) |
2485 .ToLocalChecked(); | 2485 .ToLocalChecked(); |
2486 }, | 2486 }, |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2598 InvalidDecodeTest(raw); | 2598 InvalidDecodeTest(raw); |
2599 } | 2599 } |
2600 | 2600 |
2601 TEST_F(ValueSerializerTestWithWasm, DecodeWasmModuleWithInvalidDataLength) { | 2601 TEST_F(ValueSerializerTestWithWasm, DecodeWasmModuleWithInvalidDataLength) { |
2602 InvalidDecodeTest({0xff, 0x09, 0x3f, 0x00, 0x57, 0x79, 0x7f, 0x00}); | 2602 InvalidDecodeTest({0xff, 0x09, 0x3f, 0x00, 0x57, 0x79, 0x7f, 0x00}); |
2603 InvalidDecodeTest({0xff, 0x09, 0x3f, 0x00, 0x57, 0x79, 0x00, 0x7f}); | 2603 InvalidDecodeTest({0xff, 0x09, 0x3f, 0x00, 0x57, 0x79, 0x00, 0x7f}); |
2604 } | 2604 } |
2605 | 2605 |
2606 } // namespace | 2606 } // namespace |
2607 } // namespace v8 | 2607 } // namespace v8 |
OLD | NEW |