Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef V8_WASM_MODULE_DECODER_H_ |
| 6 | #define V8_WASM_MODULE_DECODER_H_ |
| 7 | |
| 8 | #include "src/wasm/ast-decoder.h" |
| 9 | #include "src/wasm/wasm-module.h" |
| 10 | |
| 11 | namespace v8 { |
| 12 | namespace internal { |
| 13 | namespace wasm { |
| 14 | // Decodes the bytes of a WASM module between {module_start} and {module_end}. |
| 15 | ModuleResult DecodeWasmModule(Isolate* isolate, Zone* zone, |
| 16 | const byte* module_start, const byte* module_end, |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 17 | bool verify_functions, ModuleOrigin origin); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 18 | |
| 19 | // Exposed for testing. Decodes a single function signature, allocating it |
| 20 | // in the given zone. Returns {nullptr} upon failure. |
| 21 | FunctionSig* DecodeWasmSignatureForTesting(Zone* zone, const byte* start, |
| 22 | const byte* end); |
| 23 | |
| 24 | // Decodes the bytes of a WASM function between |
| 25 | // {function_start} and {function_end}. |
| 26 | FunctionResult DecodeWasmFunction(Isolate* isolate, Zone* zone, ModuleEnv* env, |
| 27 | const byte* function_start, |
| 28 | const byte* function_end); |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 29 | |
| 30 | // Extracts the function offset table from the wasm module bytes. |
| 31 | // Returns a vector with <offset, length> entries, or failure if the wasm bytes |
| 32 | // are detected as invalid. Note that this validation is not complete. |
| 33 | FunctionOffsetsResult DecodeWasmFunctionOffsets(const byte* module_start, |
| 34 | const byte* module_end); |
| 35 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 36 | } // namespace wasm |
| 37 | } // namespace internal |
| 38 | } // namespace v8 |
| 39 | |
| 40 | #endif // V8_WASM_MODULE_DECODER_H_ |