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/api.h" | 8 #include "src/api.h" |
9 #include "src/handles.h" | 9 #include "src/handles.h" |
10 #include "src/wasm/wasm-opcodes.h" | 10 #include "src/wasm/wasm-opcodes.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 struct WasmExport { | 131 struct WasmExport { |
132 uint32_t func_index; // index into the function table. | 132 uint32_t func_index; // index into the function table. |
133 uint32_t name_offset; // offset in module bytes of the name to export. | 133 uint32_t name_offset; // offset in module bytes of the name to export. |
134 uint32_t name_length; // length in bytes of the exported name. | 134 uint32_t name_length; // length in bytes of the exported name. |
135 }; | 135 }; |
136 | 136 |
137 // Static representation of a wasm global variable. | 137 // Static representation of a wasm global variable. |
138 struct WasmGlobal { | 138 struct WasmGlobal { |
139 uint32_t name_offset; // offset in the module bytes of the name, if any. | 139 uint32_t name_offset; // offset in the module bytes of the name, if any. |
140 uint32_t name_length; // length in bytes of the global name. | 140 uint32_t name_length; // length in bytes of the global name. |
141 MachineType type; // type of the global. | 141 LocalType type; // type of the global. |
142 uint32_t offset; // offset from beginning of globals area. | 142 uint32_t offset; // offset from beginning of globals area. |
143 bool exported; // true if this global is exported. | 143 bool exported; // true if this global is exported. |
144 }; | 144 }; |
145 | 145 |
146 // Static representation of a wasm data segment. | 146 // Static representation of a wasm data segment. |
147 struct WasmDataSegment { | 147 struct WasmDataSegment { |
148 uint32_t dest_addr; // destination memory address of the data. | 148 uint32_t dest_addr; // destination memory address of the data. |
149 uint32_t source_offset; // start offset in the module bytes. | 149 uint32_t source_offset; // start offset in the module bytes. |
150 uint32_t source_size; // end offset in the module bytes. | 150 uint32_t source_size; // end offset in the module bytes. |
151 bool init; // true if loaded upon instantiation. | 151 bool init; // true if loaded upon instantiation. |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 } | 286 } |
287 bool IsValidFunction(uint32_t index) const { | 287 bool IsValidFunction(uint32_t index) const { |
288 return module && index < module->functions.size(); | 288 return module && index < module->functions.size(); |
289 } | 289 } |
290 bool IsValidSignature(uint32_t index) { | 290 bool IsValidSignature(uint32_t index) { |
291 return module && index < module->signatures.size(); | 291 return module && index < module->signatures.size(); |
292 } | 292 } |
293 bool IsValidImport(uint32_t index) { | 293 bool IsValidImport(uint32_t index) { |
294 return module && index < module->import_table.size(); | 294 return module && index < module->import_table.size(); |
295 } | 295 } |
296 MachineType GetGlobalType(uint32_t index) { | 296 LocalType GetGlobalType(uint32_t index) { |
297 DCHECK(IsValidGlobal(index)); | 297 DCHECK(IsValidGlobal(index)); |
298 return module->globals[index].type; | 298 return module->globals[index].type; |
299 } | 299 } |
300 FunctionSig* GetFunctionSignature(uint32_t index) { | 300 FunctionSig* GetFunctionSignature(uint32_t index) { |
301 DCHECK(IsValidFunction(index)); | 301 DCHECK(IsValidFunction(index)); |
302 return module->functions[index].sig; | 302 return module->functions[index].sig; |
303 } | 303 } |
304 FunctionSig* GetImportSignature(uint32_t index) { | 304 FunctionSig* GetImportSignature(uint32_t index) { |
305 DCHECK(IsValidImport(index)); | 305 DCHECK(IsValidImport(index)); |
306 return module->import_table[index].sig; | 306 return module->import_table[index].sig; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 // given encoded module. The module should have no imports. | 388 // given encoded module. The module should have no imports. |
389 int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start, | 389 int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start, |
390 const byte* module_end, bool asm_js = false); | 390 const byte* module_end, bool asm_js = false); |
391 | 391 |
392 } // namespace testing | 392 } // namespace testing |
393 } // namespace wasm | 393 } // namespace wasm |
394 } // namespace internal | 394 } // namespace internal |
395 } // namespace v8 | 395 } // namespace v8 |
396 | 396 |
397 #endif // V8_WASM_MODULE_H_ | 397 #endif // V8_WASM_MODULE_H_ |
OLD | NEW |