| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 kDeclFunctionName = 0x01, | 98 kDeclFunctionName = 0x01, |
| 99 kDeclFunctionExport = 0x08 | 99 kDeclFunctionExport = 0x08 |
| 100 }; | 100 }; |
| 101 | 101 |
| 102 // Constants for fixed-size elements within a module. | 102 // Constants for fixed-size elements within a module. |
| 103 static const size_t kDeclMemorySize = 3; | 103 static const size_t kDeclMemorySize = 3; |
| 104 static const size_t kDeclDataSegmentSize = 13; | 104 static const size_t kDeclDataSegmentSize = 13; |
| 105 | 105 |
| 106 static const uint32_t kMaxReturnCount = 1; | 106 static const uint32_t kMaxReturnCount = 1; |
| 107 | 107 |
| 108 // minimum number of entries in the table for JITing |
| 109 static const uint32_t kMinimumIndirectTableSize = 1024; |
| 110 |
| 108 // Static representation of a WASM function. | 111 // Static representation of a WASM function. |
| 109 struct WasmFunction { | 112 struct WasmFunction { |
| 110 FunctionSig* sig; // signature of the function. | 113 FunctionSig* sig; // signature of the function. |
| 111 uint32_t func_index; // index into the function table. | 114 uint32_t func_index; // index into the function table. |
| 112 uint32_t sig_index; // index into the signature table. | 115 uint32_t sig_index; // index into the signature table. |
| 113 uint32_t name_offset; // offset in the module bytes of the name, if any. | 116 uint32_t name_offset; // offset in the module bytes of the name, if any. |
| 114 uint32_t name_length; // length in bytes of the name. | 117 uint32_t name_length; // length in bytes of the name. |
| 115 uint32_t code_start_offset; // offset in the module bytes of code start. | 118 uint32_t code_start_offset; // offset in the module bytes of code start. |
| 116 uint32_t code_end_offset; // offset in the module bytes of code end. | 119 uint32_t code_end_offset; // offset in the module bytes of code end. |
| 117 bool exported; // true if this function is exported. | 120 bool exported; // true if this function is exported. |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 Handle<JSArrayBuffer> globals_buffer; // Handle to array buffer of globals. | 231 Handle<JSArrayBuffer> globals_buffer; // Handle to array buffer of globals. |
| 229 Handle<FixedArray> function_table; // indirect function table. | 232 Handle<FixedArray> function_table; // indirect function table. |
| 230 std::vector<Handle<Code>> function_code; // code objects for each function. | 233 std::vector<Handle<Code>> function_code; // code objects for each function. |
| 231 std::vector<Handle<Code>> import_code; // code objects for each import. | 234 std::vector<Handle<Code>> import_code; // code objects for each import. |
| 232 // -- raw memory ------------------------------------------------------------ | 235 // -- raw memory ------------------------------------------------------------ |
| 233 byte* mem_start; // start of linear memory. | 236 byte* mem_start; // start of linear memory. |
| 234 size_t mem_size; // size of the linear memory. | 237 size_t mem_size; // size of the linear memory. |
| 235 // -- raw globals ----------------------------------------------------------- | 238 // -- raw globals ----------------------------------------------------------- |
| 236 byte* globals_start; // start of the globals area. | 239 byte* globals_start; // start of the globals area. |
| 237 size_t globals_size; // size of the globals area. | 240 size_t globals_size; // size of the globals area. |
| 241 // -- indirect function table information ----------------------------------- |
| 242 int padded_entries; // number of entries padded to the indirect func. table |
| 238 | 243 |
| 239 explicit WasmModuleInstance(WasmModule* m) | 244 explicit WasmModuleInstance(WasmModule* m) |
| 240 : module(m), | 245 : module(m), |
| 241 mem_start(nullptr), | 246 mem_start(nullptr), |
| 242 mem_size(0), | 247 mem_size(0), |
| 243 globals_start(nullptr), | 248 globals_start(nullptr), |
| 244 globals_size(0) {} | 249 globals_size(0) {} |
| 245 }; | 250 }; |
| 246 | 251 |
| 247 // forward declaration. | 252 // forward declaration. |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 // Extract a function name from the given wasm object. | 332 // Extract a function name from the given wasm object. |
| 328 // 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 |
| 329 // invalid. | 334 // invalid. |
| 330 Handle<Object> GetWasmFunctionName(Handle<JSObject> wasm, uint32_t func_index); | 335 Handle<Object> GetWasmFunctionName(Handle<JSObject> wasm, uint32_t func_index); |
| 331 | 336 |
| 332 } // namespace wasm | 337 } // namespace wasm |
| 333 } // namespace internal | 338 } // namespace internal |
| 334 } // namespace v8 | 339 } // namespace v8 |
| 335 | 340 |
| 336 #endif // V8_WASM_MODULE_H_ | 341 #endif // V8_WASM_MODULE_H_ |
| OLD | NEW |