| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 // Constants for fixed-size elements within a module. | 58 // Constants for fixed-size elements within a module. |
| 59 static const size_t kDeclMemorySize = 3; | 59 static const size_t kDeclMemorySize = 3; |
| 60 static const size_t kDeclGlobalSize = 6; | 60 static const size_t kDeclGlobalSize = 6; |
| 61 static const size_t kDeclDataSegmentSize = 13; | 61 static const size_t kDeclDataSegmentSize = 13; |
| 62 | 62 |
| 63 // Static representation of a WASM function. | 63 // Static representation of a WASM function. |
| 64 struct WasmFunction { | 64 struct WasmFunction { |
| 65 FunctionSig* sig; // signature of the function. | 65 FunctionSig* sig; // signature of the function. |
| 66 uint32_t func_index; // index into the function table. | 66 uint32_t func_index; // index into the function table. |
| 67 uint16_t sig_index; // index into the signature table. | 67 uint32_t sig_index; // index into the signature table. |
| 68 uint32_t name_offset; // offset in the module bytes of the name, if any. | 68 uint32_t name_offset; // offset in the module bytes of the name, if any. |
| 69 uint32_t code_start_offset; // offset in the module bytes of code start. | 69 uint32_t code_start_offset; // offset in the module bytes of code start. |
| 70 uint32_t code_end_offset; // offset in the module bytes of code end. | 70 uint32_t code_end_offset; // offset in the module bytes of code end. |
| 71 uint16_t local_i32_count; // number of i32 local variables. | 71 uint16_t local_i32_count; // number of i32 local variables. |
| 72 uint16_t local_i64_count; // number of i64 local variables. | 72 uint16_t local_i64_count; // number of i64 local variables. |
| 73 uint16_t local_f32_count; // number of f32 local variables. | 73 uint16_t local_f32_count; // number of f32 local variables. |
| 74 uint16_t local_f64_count; // number of f64 local variables. | 74 uint16_t local_f64_count; // number of f64 local variables. |
| 75 bool exported; // true if this function is exported. | 75 bool exported; // true if this function is exported. |
| 76 bool external; // true if this function is externally supplied. | 76 bool external; // true if this function is externally supplied. |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 // Static representation of an imported WASM function. | 79 // Static representation of an imported WASM function. |
| 80 struct WasmImport { | 80 struct WasmImport { |
| 81 FunctionSig* sig; // signature of the function. | 81 FunctionSig* sig; // signature of the function. |
| 82 uint16_t sig_index; // index into the signature table. | 82 uint32_t sig_index; // index into the signature table. |
| 83 uint32_t module_name_offset; // offset in module bytes of the module name. | 83 uint32_t module_name_offset; // offset in module bytes of the module name. |
| 84 uint32_t function_name_offset; // offset in module bytes of the import name. | 84 uint32_t function_name_offset; // offset in module bytes of the import name. |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 // Static representation of an exported WASM function. | 87 // Static representation of an exported WASM function. |
| 88 struct WasmExport { | 88 struct WasmExport { |
| 89 uint16_t func_index; // index into the function table. | 89 uint32_t func_index; // index into the function table. |
| 90 uint32_t name_offset; // offset in module bytes of the name to export. | 90 uint32_t name_offset; // offset in module bytes of the name to export. |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 // Static representation of a wasm global variable. | 93 // Static representation of a wasm global variable. |
| 94 struct WasmGlobal { | 94 struct WasmGlobal { |
| 95 uint32_t name_offset; // offset in the module bytes of the name, if any. | 95 uint32_t name_offset; // offset in the module bytes of the name, if any. |
| 96 MachineType type; // type of the global. | 96 MachineType type; // type of the global. |
| 97 uint32_t offset; // offset from beginning of globals area. | 97 uint32_t offset; // offset from beginning of globals area. |
| 98 bool exported; // true if this global is exported. | 98 bool exported; // true if this global is exported. |
| 99 }; | 99 }; |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 | 256 |
| 257 // For testing. Decode, verify, and run the last exported function in the | 257 // For testing. Decode, verify, and run the last exported function in the |
| 258 // given decoded module. | 258 // given decoded module. |
| 259 int32_t CompileAndRunWasmModule(Isolate* isolate, WasmModule* module); | 259 int32_t CompileAndRunWasmModule(Isolate* isolate, WasmModule* module); |
| 260 | 260 |
| 261 } // namespace wasm | 261 } // namespace wasm |
| 262 } // namespace internal | 262 } // namespace internal |
| 263 } // namespace v8 | 263 } // namespace v8 |
| 264 | 264 |
| 265 #endif // V8_WASM_MODULE_H_ | 265 #endif // V8_WASM_MODULE_H_ |
| OLD | NEW |