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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 uint32_t dest_addr; // destination memory address of the data. | 96 uint32_t dest_addr; // destination memory address of the data. |
97 uint32_t source_offset; // start offset in the module bytes. | 97 uint32_t source_offset; // start offset in the module bytes. |
98 uint32_t source_size; // end offset in the module bytes. | 98 uint32_t source_size; // end offset in the module bytes. |
99 bool init; // true if loaded upon instantiation. | 99 bool init; // true if loaded upon instantiation. |
100 }; | 100 }; |
101 | 101 |
102 enum ModuleOrigin { kWasmOrigin, kAsmJsOrigin }; | 102 enum ModuleOrigin { kWasmOrigin, kAsmJsOrigin }; |
103 | 103 |
104 // Static representation of a module. | 104 // Static representation of a module. |
105 struct WasmModule { | 105 struct WasmModule { |
106 static const uint8_t kMinMemSize = 12; // Minimum memory size = 4kb | 106 static const uint32_t kPageSize = 0x10000; // Page size, 64kb. |
107 static const uint8_t kMaxMemSize = 30; // Maximum memory size = 1gb | 107 static const uint32_t kMinMemPages = 1; // Minimum memory size = 64kb |
| 108 static const uint32_t kMaxMemPages = 16384; // Maximum memory size = 1gb |
108 | 109 |
109 Isolate* shared_isolate; // isolate for storing shared code. | 110 Isolate* shared_isolate; // isolate for storing shared code. |
110 const byte* module_start; // starting address for the module bytes. | 111 const byte* module_start; // starting address for the module bytes. |
111 const byte* module_end; // end address for the module bytes. | 112 const byte* module_end; // end address for the module bytes. |
112 uint8_t min_mem_size_log2; // minimum size of the memory (log base 2). | 113 uint32_t min_mem_pages; // minimum size of the memory in 64k pages. |
113 uint8_t max_mem_size_log2; // maximum size of the memory (log base 2). | 114 uint32_t max_mem_pages; // maximum size of the memory in 64k pages. |
114 bool mem_export; // true if the memory is exported. | 115 bool mem_export; // true if the memory is exported. |
115 bool mem_external; // true if the memory is external. | 116 bool mem_external; // true if the memory is external. |
116 int start_function_index; // start function, if any. | 117 int start_function_index; // start function, if any. |
117 ModuleOrigin origin; // origin of the module | 118 ModuleOrigin origin; // origin of the module |
118 | 119 |
119 std::vector<WasmGlobal> globals; // globals in this module. | 120 std::vector<WasmGlobal> globals; // globals in this module. |
120 std::vector<FunctionSig*> signatures; // signatures in this module. | 121 std::vector<FunctionSig*> signatures; // signatures in this module. |
121 std::vector<WasmFunction> functions; // functions in this module. | 122 std::vector<WasmFunction> functions; // functions in this module. |
122 std::vector<WasmDataSegment> data_segments; // data segments in this module. | 123 std::vector<WasmDataSegment> data_segments; // data segments in this module. |
123 std::vector<uint16_t> function_table; // function table. | 124 std::vector<uint16_t> function_table; // function table. |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 | 249 |
249 // For testing. Decode, verify, and run the last exported function in the | 250 // For testing. Decode, verify, and run the last exported function in the |
250 // given decoded module. | 251 // given decoded module. |
251 int32_t CompileAndRunWasmModule(Isolate* isolate, WasmModule* module); | 252 int32_t CompileAndRunWasmModule(Isolate* isolate, WasmModule* module); |
252 | 253 |
253 } // namespace wasm | 254 } // namespace wasm |
254 } // namespace internal | 255 } // namespace internal |
255 } // namespace v8 | 256 } // namespace v8 |
256 | 257 |
257 #endif // V8_WASM_MODULE_H_ | 258 #endif // V8_WASM_MODULE_H_ |
OLD | NEW |