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 kDeclFunctionLocals = 0x04, | |
100 kDeclFunctionExport = 0x08 | 99 kDeclFunctionExport = 0x08 |
101 }; | 100 }; |
102 | 101 |
103 // Constants for fixed-size elements within a module. | 102 // Constants for fixed-size elements within a module. |
104 static const size_t kDeclMemorySize = 3; | 103 static const size_t kDeclMemorySize = 3; |
105 static const size_t kDeclDataSegmentSize = 13; | 104 static const size_t kDeclDataSegmentSize = 13; |
106 | 105 |
107 static const uint32_t kMaxReturnCount = 1; | 106 static const uint32_t kMaxReturnCount = 1; |
108 | 107 |
109 // Static representation of a WASM function. | 108 // Static representation of a WASM function. |
110 struct WasmFunction { | 109 struct WasmFunction { |
111 FunctionSig* sig; // signature of the function. | 110 FunctionSig* sig; // signature of the function. |
112 uint32_t func_index; // index into the function table. | 111 uint32_t func_index; // index into the function table. |
113 uint32_t sig_index; // index into the signature table. | 112 uint32_t sig_index; // index into the signature table. |
114 uint32_t name_offset; // offset in the module bytes of the name, if any. | 113 uint32_t name_offset; // offset in the module bytes of the name, if any. |
115 uint32_t name_length; // length in bytes of the name. | 114 uint32_t name_length; // length in bytes of the name. |
116 uint32_t code_start_offset; // offset in the module bytes of code start. | 115 uint32_t code_start_offset; // offset in the module bytes of code start. |
117 uint32_t code_end_offset; // offset in the module bytes of code end. | 116 uint32_t code_end_offset; // offset in the module bytes of code end. |
118 uint16_t local_i32_count; // number of i32 local variables. | |
119 uint16_t local_i64_count; // number of i64 local variables. | |
120 uint16_t local_f32_count; // number of f32 local variables. | |
121 uint16_t local_f64_count; // number of f64 local variables. | |
122 bool exported; // true if this function is exported. | 117 bool exported; // true if this function is exported. |
123 }; | 118 }; |
124 | 119 |
125 // Static representation of an imported WASM function. | 120 // Static representation of an imported WASM function. |
126 struct WasmImport { | 121 struct WasmImport { |
127 FunctionSig* sig; // signature of the function. | 122 FunctionSig* sig; // signature of the function. |
128 uint32_t sig_index; // index into the signature table. | 123 uint32_t sig_index; // index into the signature table. |
129 uint32_t module_name_offset; // offset in module bytes of the module name. | 124 uint32_t module_name_offset; // offset in module bytes of the module name. |
130 uint32_t module_name_length; // length in bytes of the module name. | 125 uint32_t module_name_length; // length in bytes of the module name. |
131 uint32_t function_name_offset; // offset in module bytes of the import name. | 126 uint32_t function_name_offset; // offset in module bytes of the import name. |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 // Extract a function name from the given wasm object. | 327 // Extract a function name from the given wasm object. |
333 // Returns undefined if the function is unnamed or the function index is | 328 // Returns undefined if the function is unnamed or the function index is |
334 // invalid. | 329 // invalid. |
335 Handle<Object> GetWasmFunctionName(Handle<JSObject> wasm, uint32_t func_index); | 330 Handle<Object> GetWasmFunctionName(Handle<JSObject> wasm, uint32_t func_index); |
336 | 331 |
337 } // namespace wasm | 332 } // namespace wasm |
338 } // namespace internal | 333 } // namespace internal |
339 } // namespace v8 | 334 } // namespace v8 |
340 | 335 |
341 #endif // V8_WASM_MODULE_H_ | 336 #endif // V8_WASM_MODULE_H_ |
OLD | NEW |