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