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/globals.h" |
9 #include "src/wasm/function-body-decoder.h" | 9 #include "src/wasm/function-body-decoder.h" |
10 #include "src/wasm/wasm-module.h" | 10 #include "src/wasm/wasm-module.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 typedef Result<FunctionOffsets> FunctionOffsetsResult; | 53 typedef Result<FunctionOffsets> FunctionOffsetsResult; |
54 struct AsmJsOffsetEntry { | 54 struct AsmJsOffsetEntry { |
55 int byte_offset; | 55 int byte_offset; |
56 int source_position_call; | 56 int source_position_call; |
57 int source_position_number_conversion; | 57 int source_position_number_conversion; |
58 }; | 58 }; |
59 typedef std::vector<std::vector<AsmJsOffsetEntry>> AsmJsOffsets; | 59 typedef std::vector<std::vector<AsmJsOffsetEntry>> AsmJsOffsets; |
60 typedef Result<AsmJsOffsets> AsmJsOffsetsResult; | 60 typedef Result<AsmJsOffsets> AsmJsOffsetsResult; |
61 | 61 |
62 // Decodes the bytes of a wasm module between {module_start} and {module_end}. | 62 // Decodes the bytes of a wasm module between {module_start} and {module_end}. |
63 V8_EXPORT_PRIVATE ModuleResult DecodeWasmModule( | 63 V8_EXPORT_PRIVATE ModuleResult SyncDecodeWasmModule(Isolate* isolate, |
| 64 const byte* module_start, |
| 65 const byte* module_end, |
| 66 bool verify_functions, |
| 67 ModuleOrigin origin); |
| 68 |
| 69 V8_EXPORT_PRIVATE ModuleResult AsyncDecodeWasmModule( |
64 Isolate* isolate, const byte* module_start, const byte* module_end, | 70 Isolate* isolate, const byte* module_start, const byte* module_end, |
65 bool verify_functions, ModuleOrigin origin, bool is_sync = true); | 71 bool verify_functions, ModuleOrigin origin, Counters* async_counters); |
66 | 72 |
67 // Exposed for testing. Decodes a single function signature, allocating it | 73 // Exposed for testing. Decodes a single function signature, allocating it |
68 // in the given zone. Returns {nullptr} upon failure. | 74 // in the given zone. Returns {nullptr} upon failure. |
69 V8_EXPORT_PRIVATE FunctionSig* DecodeWasmSignatureForTesting(Zone* zone, | 75 V8_EXPORT_PRIVATE FunctionSig* DecodeWasmSignatureForTesting(Zone* zone, |
70 const byte* start, | 76 const byte* start, |
71 const byte* end); | 77 const byte* end); |
72 | 78 |
73 // Decodes the bytes of a wasm function between | 79 // Decodes the bytes of a wasm function between |
74 // {function_start} and {function_end}. | 80 // {function_start} and {function_end}. |
75 V8_EXPORT_PRIVATE FunctionResult DecodeWasmFunction( | 81 V8_EXPORT_PRIVATE FunctionResult |
76 Isolate* isolate, Zone* zone, ModuleBytesEnv* env, | 82 SyncDecodeWasmFunction(Isolate* isolate, Zone* zone, ModuleBytesEnv* env, |
77 const byte* function_start, const byte* function_end, bool is_sync = true); | 83 const byte* function_start, const byte* function_end); |
| 84 |
| 85 V8_EXPORT_PRIVATE FunctionResult |
| 86 AsyncDecodeWasmFunction(Isolate* isolate, Zone* zone, ModuleBytesEnv* env, |
| 87 const byte* function_start, const byte* function_end, |
| 88 Counters* async_counters); |
78 | 89 |
79 V8_EXPORT_PRIVATE WasmInitExpr DecodeWasmInitExprForTesting(const byte* start, | 90 V8_EXPORT_PRIVATE WasmInitExpr DecodeWasmInitExprForTesting(const byte* start, |
80 const byte* end); | 91 const byte* end); |
81 | 92 |
82 struct CustomSectionOffset { | 93 struct CustomSectionOffset { |
83 WireBytesRef section; | 94 WireBytesRef section; |
84 WireBytesRef name; | 95 WireBytesRef name; |
85 WireBytesRef payload; | 96 WireBytesRef payload; |
86 }; | 97 }; |
87 | 98 |
88 V8_EXPORT_PRIVATE std::vector<CustomSectionOffset> DecodeCustomSections( | 99 V8_EXPORT_PRIVATE std::vector<CustomSectionOffset> DecodeCustomSections( |
89 const byte* start, const byte* end); | 100 const byte* start, const byte* end); |
90 | 101 |
91 // Extracts the mapping from wasm byte offset to asm.js source position per | 102 // Extracts the mapping from wasm byte offset to asm.js source position per |
92 // function. | 103 // function. |
93 // Returns a vector of vectors with <byte_offset, source_position> entries, or | 104 // Returns a vector of vectors with <byte_offset, source_position> entries, or |
94 // failure if the wasm bytes are detected as invalid. Note that this validation | 105 // failure if the wasm bytes are detected as invalid. Note that this validation |
95 // is not complete. | 106 // is not complete. |
96 AsmJsOffsetsResult DecodeAsmJsOffsets(const byte* module_start, | 107 AsmJsOffsetsResult DecodeAsmJsOffsets(const byte* module_start, |
97 const byte* module_end); | 108 const byte* module_end); |
98 | 109 |
99 } // namespace wasm | 110 } // namespace wasm |
100 } // namespace internal | 111 } // namespace internal |
101 } // namespace v8 | 112 } // namespace v8 |
102 | 113 |
103 #endif // V8_WASM_MODULE_DECODER_H_ | 114 #endif // V8_WASM_MODULE_DECODER_H_ |
OLD | NEW |