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 #ifndef V8_WASM_MODULE_DECODER_H_ | 5 #ifndef V8_WASM_MODULE_DECODER_H_ |
6 #define V8_WASM_MODULE_DECODER_H_ | 6 #define V8_WASM_MODULE_DECODER_H_ |
7 | 7 |
| 8 #include "src/globals.h" |
8 #include "src/wasm/ast-decoder.h" | 9 #include "src/wasm/ast-decoder.h" |
9 #include "src/wasm/wasm-module.h" | 10 #include "src/wasm/wasm-module.h" |
10 #include "src/wasm/wasm-result.h" | 11 #include "src/wasm/wasm-result.h" |
11 | 12 |
12 namespace v8 { | 13 namespace v8 { |
13 namespace internal { | 14 namespace internal { |
14 namespace wasm { | 15 namespace wasm { |
15 | 16 |
16 typedef Result<const WasmModule*> ModuleResult; | 17 typedef Result<const WasmModule*> ModuleResult; |
17 typedef Result<WasmFunction*> FunctionResult; | 18 typedef Result<WasmFunction*> FunctionResult; |
18 typedef std::vector<std::pair<int, int>> FunctionOffsets; | 19 typedef std::vector<std::pair<int, int>> FunctionOffsets; |
19 typedef Result<FunctionOffsets> FunctionOffsetsResult; | 20 typedef Result<FunctionOffsets> FunctionOffsetsResult; |
20 typedef std::vector<std::vector<std::pair<int, int>>> AsmJsOffsets; | 21 typedef std::vector<std::vector<std::pair<int, int>>> AsmJsOffsets; |
21 typedef Result<AsmJsOffsets> AsmJsOffsetsResult; | 22 typedef Result<AsmJsOffsets> AsmJsOffsetsResult; |
22 | 23 |
23 // Decodes the bytes of a WASM module between {module_start} and {module_end}. | 24 // Decodes the bytes of a WASM module between {module_start} and {module_end}. |
24 V8_EXPORT_PRIVATE ModuleResult DecodeWasmModule(Isolate* isolate, Zone* zone, | 25 V8_EXPORT_PRIVATE ModuleResult DecodeWasmModule(Isolate* isolate, Zone* zone, |
25 const byte* module_start, | 26 const byte* module_start, |
26 const byte* module_end, | 27 const byte* module_end, |
27 bool verify_functions, | 28 bool verify_functions, |
28 ModuleOrigin origin); | 29 ModuleOrigin origin); |
29 | 30 |
30 // Exposed for testing. Decodes a single function signature, allocating it | 31 // Exposed for testing. Decodes a single function signature, allocating it |
31 // in the given zone. Returns {nullptr} upon failure. | 32 // in the given zone. Returns {nullptr} upon failure. |
32 FunctionSig* DecodeWasmSignatureForTesting(Zone* zone, const byte* start, | 33 V8_EXPORT_PRIVATE FunctionSig* DecodeWasmSignatureForTesting(Zone* zone, |
33 const byte* end); | 34 const byte* start, |
| 35 const byte* end); |
34 | 36 |
35 // Decodes the bytes of a WASM function between | 37 // Decodes the bytes of a WASM function between |
36 // {function_start} and {function_end}. | 38 // {function_start} and {function_end}. |
37 FunctionResult DecodeWasmFunction(Isolate* isolate, Zone* zone, ModuleEnv* env, | 39 V8_EXPORT_PRIVATE FunctionResult DecodeWasmFunction(Isolate* isolate, |
38 const byte* function_start, | 40 Zone* zone, ModuleEnv* env, |
39 const byte* function_end); | 41 const byte* function_start, |
| 42 const byte* function_end); |
40 | 43 |
41 // Extracts the function offset table from the wasm module bytes. | 44 // Extracts the function offset table from the wasm module bytes. |
42 // Returns a vector with <offset, length> entries, or failure if the wasm bytes | 45 // Returns a vector with <offset, length> entries, or failure if the wasm bytes |
43 // are detected as invalid. Note that this validation is not complete. | 46 // are detected as invalid. Note that this validation is not complete. |
44 FunctionOffsetsResult DecodeWasmFunctionOffsets( | 47 FunctionOffsetsResult DecodeWasmFunctionOffsets( |
45 const byte* module_start, const byte* module_end, | 48 const byte* module_start, const byte* module_end, |
46 uint32_t num_imported_functions); | 49 uint32_t num_imported_functions); |
47 | 50 |
48 WasmInitExpr DecodeWasmInitExprForTesting(const byte* start, const byte* end); | 51 V8_EXPORT_PRIVATE WasmInitExpr DecodeWasmInitExprForTesting(const byte* start, |
| 52 const byte* end); |
49 | 53 |
50 // Extracts the mapping from wasm byte offset to asm.js source position per | 54 // Extracts the mapping from wasm byte offset to asm.js source position per |
51 // function. | 55 // function. |
52 // Returns a vector of vectors with <byte_offset, source_position> entries, or | 56 // Returns a vector of vectors with <byte_offset, source_position> entries, or |
53 // failure if the wasm bytes are detected as invalid. Note that this validation | 57 // failure if the wasm bytes are detected as invalid. Note that this validation |
54 // is not complete. | 58 // is not complete. |
55 AsmJsOffsetsResult DecodeAsmJsOffsets(const byte* module_start, | 59 AsmJsOffsetsResult DecodeAsmJsOffsets(const byte* module_start, |
56 const byte* module_end, | 60 const byte* module_end, |
57 uint32_t num_imported_functions); | 61 uint32_t num_imported_functions); |
58 | 62 |
59 } // namespace wasm | 63 } // namespace wasm |
60 } // namespace internal | 64 } // namespace internal |
61 } // namespace v8 | 65 } // namespace v8 |
62 | 66 |
63 #endif // V8_WASM_MODULE_DECODER_H_ | 67 #endif // V8_WASM_MODULE_DECODER_H_ |
OLD | NEW |