| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 static WasmSection::Code end(); | 89 static WasmSection::Code end(); |
| 90 static WasmSection::Code next(WasmSection::Code code); | 90 static WasmSection::Code next(WasmSection::Code code); |
| 91 static const char* getName(Code code); | 91 static const char* getName(Code code); |
| 92 static int getOrder(Code code); | 92 static int getOrder(Code code); |
| 93 static size_t getNameLength(Code code); | 93 static size_t getNameLength(Code code); |
| 94 static WasmSection::Code lookup(const byte* string, uint32_t length); | 94 static WasmSection::Code lookup(const byte* string, uint32_t length); |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 enum WasmFunctionDeclBit { | 97 enum WasmFunctionDeclBit { |
| 98 kDeclFunctionName = 0x01, | 98 kDeclFunctionName = 0x01, |
| 99 kDeclFunctionImport = 0x02, | |
| 100 kDeclFunctionLocals = 0x04, | 99 kDeclFunctionLocals = 0x04, |
| 101 kDeclFunctionExport = 0x08 | 100 kDeclFunctionExport = 0x08 |
| 102 }; | 101 }; |
| 103 | 102 |
| 104 // Constants for fixed-size elements within a module. | 103 // Constants for fixed-size elements within a module. |
| 105 static const size_t kDeclMemorySize = 3; | 104 static const size_t kDeclMemorySize = 3; |
| 106 static const size_t kDeclDataSegmentSize = 13; | 105 static const size_t kDeclDataSegmentSize = 13; |
| 107 | 106 |
| 108 static const uint32_t kMaxReturnCount = 1; | 107 static const uint32_t kMaxReturnCount = 1; |
| 109 | 108 |
| 110 // Static representation of a WASM function. | 109 // Static representation of a WASM function. |
| 111 struct WasmFunction { | 110 struct WasmFunction { |
| 112 FunctionSig* sig; // signature of the function. | 111 FunctionSig* sig; // signature of the function. |
| 113 uint32_t func_index; // index into the function table. | 112 uint32_t func_index; // index into the function table. |
| 114 uint32_t sig_index; // index into the signature table. | 113 uint32_t sig_index; // index into the signature table. |
| 115 uint32_t name_offset; // offset in the module bytes of the name, if any. | 114 uint32_t name_offset; // offset in the module bytes of the name, if any. |
| 116 uint32_t name_length; // length in bytes of the name. | 115 uint32_t name_length; // length in bytes of the name. |
| 117 uint32_t code_start_offset; // offset in the module bytes of code start. | 116 uint32_t code_start_offset; // offset in the module bytes of code start. |
| 118 uint32_t code_end_offset; // offset in the module bytes of code end. | 117 uint32_t code_end_offset; // offset in the module bytes of code end. |
| 119 uint16_t local_i32_count; // number of i32 local variables. | 118 uint16_t local_i32_count; // number of i32 local variables. |
| 120 uint16_t local_i64_count; // number of i64 local variables. | 119 uint16_t local_i64_count; // number of i64 local variables. |
| 121 uint16_t local_f32_count; // number of f32 local variables. | 120 uint16_t local_f32_count; // number of f32 local variables. |
| 122 uint16_t local_f64_count; // number of f64 local variables. | 121 uint16_t local_f64_count; // number of f64 local variables. |
| 123 bool exported; // true if this function is exported. | 122 bool exported; // true if this function is exported. |
| 124 bool external; // true if this function is externally supplied. | |
| 125 }; | 123 }; |
| 126 | 124 |
| 127 // Static representation of an imported WASM function. | 125 // Static representation of an imported WASM function. |
| 128 struct WasmImport { | 126 struct WasmImport { |
| 129 FunctionSig* sig; // signature of the function. | 127 FunctionSig* sig; // signature of the function. |
| 130 uint32_t sig_index; // index into the signature table. | 128 uint32_t sig_index; // index into the signature table. |
| 131 uint32_t module_name_offset; // offset in module bytes of the module name. | 129 uint32_t module_name_offset; // offset in module bytes of the module name. |
| 132 uint32_t module_name_length; // length in bytes of the module name. | 130 uint32_t module_name_length; // length in bytes of the module name. |
| 133 uint32_t function_name_offset; // offset in module bytes of the import name. | 131 uint32_t function_name_offset; // offset in module bytes of the import name. |
| 134 uint32_t function_name_length; // length in bytes of the import name. | 132 uint32_t function_name_length; // length in bytes of the import name. |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 // Extract a function name from the given wasm object. | 332 // Extract a function name from the given wasm object. |
| 335 // Returns undefined if the function is unnamed or the function index is | 333 // Returns undefined if the function is unnamed or the function index is |
| 336 // invalid. | 334 // invalid. |
| 337 Handle<Object> GetWasmFunctionName(Handle<JSObject> wasm, uint32_t func_index); | 335 Handle<Object> GetWasmFunctionName(Handle<JSObject> wasm, uint32_t func_index); |
| 338 | 336 |
| 339 } // namespace wasm | 337 } // namespace wasm |
| 340 } // namespace internal | 338 } // namespace internal |
| 341 } // namespace v8 | 339 } // namespace v8 |
| 342 | 340 |
| 343 #endif // V8_WASM_MODULE_H_ | 341 #endif // V8_WASM_MODULE_H_ |
| OLD | NEW |