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_H_ | 5 #ifndef V8_WASM_MODULE_H_ |
6 #define V8_WASM_MODULE_H_ | 6 #define V8_WASM_MODULE_H_ |
7 | 7 |
8 #include "src/wasm/wasm-opcodes.h" | 8 #include "src/wasm/wasm-opcodes.h" |
9 #include "src/wasm/wasm-result.h" | 9 #include "src/wasm/wasm-result.h" |
10 | 10 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 uint8_t max_mem_size_log2; // maximum size of the memory (log base 2). | 92 uint8_t max_mem_size_log2; // maximum size of the memory (log base 2). |
93 bool mem_export; // true if the memory is exported. | 93 bool mem_export; // true if the memory is exported. |
94 bool mem_external; // true if the memory is external. | 94 bool mem_external; // true if the memory is external. |
95 | 95 |
96 std::vector<WasmGlobal>* globals; // globals in this module. | 96 std::vector<WasmGlobal>* globals; // globals in this module. |
97 std::vector<FunctionSig*>* signatures; // signatures in this module. | 97 std::vector<FunctionSig*>* signatures; // signatures in this module. |
98 std::vector<WasmFunction>* functions; // functions in this module. | 98 std::vector<WasmFunction>* functions; // functions in this module. |
99 std::vector<WasmDataSegment>* data_segments; // data segments in this module. | 99 std::vector<WasmDataSegment>* data_segments; // data segments in this module. |
100 std::vector<uint16_t>* function_table; // function table. | 100 std::vector<uint16_t>* function_table; // function table. |
101 | 101 |
| 102 WasmModule(); |
| 103 ~WasmModule(); |
| 104 |
102 // Get a pointer to a string stored in the module bytes representing a name. | 105 // Get a pointer to a string stored in the module bytes representing a name. |
103 const char* GetName(uint32_t offset) { | 106 const char* GetName(uint32_t offset) { |
104 CHECK(BoundsCheck(offset, offset + 1)); | 107 CHECK(BoundsCheck(offset, offset + 1)); |
105 if (offset == 0) return "<?>"; // no name. | 108 if (offset == 0) return "<?>"; // no name. |
106 return reinterpret_cast<const char*>(module_start + offset); | 109 return reinterpret_cast<const char*>(module_start + offset); |
107 } | 110 } |
108 | 111 |
109 // Checks the given offset range is contained within the module bytes. | 112 // Checks the given offset range is contained within the module bytes. |
110 bool BoundsCheck(uint32_t start, uint32_t end) { | 113 bool BoundsCheck(uint32_t start, uint32_t end) { |
111 size_t size = module_end - module_start; | 114 size_t size = module_end - module_start; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 const byte* module_end, bool asm_js = false); | 182 const byte* module_end, bool asm_js = false); |
180 | 183 |
181 // For testing. Decode, verify, and run the last exported function in the | 184 // For testing. Decode, verify, and run the last exported function in the |
182 // given decoded module. | 185 // given decoded module. |
183 int32_t CompileAndRunWasmModule(Isolate* isolate, WasmModule* module); | 186 int32_t CompileAndRunWasmModule(Isolate* isolate, WasmModule* module); |
184 } // namespace wasm | 187 } // namespace wasm |
185 } // namespace internal | 188 } // namespace internal |
186 } // namespace v8 | 189 } // namespace v8 |
187 | 190 |
188 #endif // V8_WASM_MODULE_H_ | 191 #endif // V8_WASM_MODULE_H_ |
OLD | NEW |