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 <memory> | 8 #include <memory> |
9 | 9 |
10 #include "src/api.h" | 10 #include "src/api.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 | 126 |
127 // Static representation of a wasm data segment. | 127 // Static representation of a wasm data segment. |
128 struct WasmDataSegment { | 128 struct WasmDataSegment { |
129 WasmInitExpr dest_addr; // destination memory address of the data. | 129 WasmInitExpr dest_addr; // destination memory address of the data. |
130 uint32_t source_offset; // start offset in the module bytes. | 130 uint32_t source_offset; // start offset in the module bytes. |
131 uint32_t source_size; // end offset in the module bytes. | 131 uint32_t source_size; // end offset in the module bytes. |
132 }; | 132 }; |
133 | 133 |
134 // Static representation of a wasm indirect call table. | 134 // Static representation of a wasm indirect call table. |
135 struct WasmIndirectFunctionTable { | 135 struct WasmIndirectFunctionTable { |
136 uint32_t min_size; // minimum table size. | 136 uint32_t size; // initial table size. |
137 uint32_t max_size; // maximum table size. | 137 uint32_t max_size; // maximum table size. |
138 bool has_max; // true if there is a maximum size. | |
139 // TODO(titzer): Move this to WasmInstance. Needed by interpreter only. | |
140 std::vector<int32_t> values; // function table, -1 indicating invalid. | 138 std::vector<int32_t> values; // function table, -1 indicating invalid. |
141 bool imported; // true if imported. | 139 bool imported; // true if imported. |
142 bool exported; // true if exported. | 140 bool exported; // true if exported. |
143 SignatureMap map; // canonicalizing map for sig indexes. | 141 SignatureMap map; // canonicalizing map for sig indexes. |
144 }; | 142 }; |
145 | 143 |
146 // Static representation of how to initialize a table. | 144 // Static representation of how to initialize a table. |
147 struct WasmTableInit { | 145 struct WasmTableInit { |
148 uint32_t table_index; | 146 uint32_t table_index; |
149 WasmInitExpr offset; | 147 WasmInitExpr offset; |
(...skipping 18 matching lines...) Expand all Loading... |
168 uint32_t index; // index into the respective space. | 166 uint32_t index; // index into the respective space. |
169 }; | 167 }; |
170 | 168 |
171 enum ModuleOrigin { kWasmOrigin, kAsmJsOrigin }; | 169 enum ModuleOrigin { kWasmOrigin, kAsmJsOrigin }; |
172 | 170 |
173 class WasmCompiledModule; | 171 class WasmCompiledModule; |
174 | 172 |
175 // Static representation of a module. | 173 // Static representation of a module. |
176 struct V8_EXPORT_PRIVATE WasmModule { | 174 struct V8_EXPORT_PRIVATE WasmModule { |
177 static const uint32_t kPageSize = 0x10000; // Page size, 64kb. | 175 static const uint32_t kPageSize = 0x10000; // Page size, 64kb. |
| 176 static const uint32_t kMaxLegalPages = 65536; // Maximum legal pages |
178 static const uint32_t kMinMemPages = 1; // Minimum memory size = 64kb | 177 static const uint32_t kMinMemPages = 1; // Minimum memory size = 64kb |
179 static const size_t kV8MaxPages = 16384; // Maximum memory size = 1gb | 178 static const uint32_t kMaxMemPages = 16384; // Maximum memory size = 1gb |
180 static const size_t kV8MaxTableSize = 16 * 1024 * 1024; | |
181 | 179 |
182 Zone* owned_zone; | 180 Zone* owned_zone; |
183 const byte* module_start = nullptr; // starting address for the module bytes | 181 const byte* module_start = nullptr; // starting address for the module bytes |
184 const byte* module_end = nullptr; // end address for the module bytes | 182 const byte* module_end = nullptr; // end address for the module bytes |
185 uint32_t min_mem_pages = 0; // minimum size of the memory in 64k pages | 183 uint32_t min_mem_pages = 0; // minimum size of the memory in 64k pages |
186 uint32_t max_mem_pages = 0; // maximum size of the memory in 64k pages | 184 uint32_t max_mem_pages = 0; // maximum size of the memory in 64k pages |
187 bool mem_export = false; // true if the memory is exported | 185 bool mem_export = false; // true if the memory is exported |
188 // TODO(wasm): reconcile start function index being an int with | 186 // TODO(wasm): reconcile start function index being an int with |
189 // the fact that we index on uint32_t, so we may technically not be | 187 // the fact that we index on uint32_t, so we may technically not be |
190 // able to represent some start_function_index -es. | 188 // able to represent some start_function_index -es. |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 Object* GetOwningWasmInstance(Code* code); | 550 Object* GetOwningWasmInstance(Code* code); |
553 | 551 |
554 MaybeHandle<JSArrayBuffer> GetInstanceMemory(Isolate* isolate, | 552 MaybeHandle<JSArrayBuffer> GetInstanceMemory(Isolate* isolate, |
555 Handle<JSObject> instance); | 553 Handle<JSObject> instance); |
556 | 554 |
557 int32_t GetInstanceMemorySize(Isolate* isolate, Handle<JSObject> instance); | 555 int32_t GetInstanceMemorySize(Isolate* isolate, Handle<JSObject> instance); |
558 | 556 |
559 int32_t GrowInstanceMemory(Isolate* isolate, Handle<JSObject> instance, | 557 int32_t GrowInstanceMemory(Isolate* isolate, Handle<JSObject> instance, |
560 uint32_t pages); | 558 uint32_t pages); |
561 | 559 |
562 void UpdateDispatchTables(Isolate* isolate, Handle<FixedArray> dispatch_tables, | |
563 int index, Handle<JSFunction> js_function); | |
564 | |
565 namespace testing { | 560 namespace testing { |
566 | 561 |
567 void ValidateInstancesChain(Isolate* isolate, Handle<JSObject> wasm_module, | 562 void ValidateInstancesChain(Isolate* isolate, Handle<JSObject> wasm_module, |
568 int instance_count); | 563 int instance_count); |
569 void ValidateModuleState(Isolate* isolate, Handle<JSObject> wasm_module); | 564 void ValidateModuleState(Isolate* isolate, Handle<JSObject> wasm_module); |
570 void ValidateOrphanedInstance(Isolate* isolate, Handle<JSObject> instance); | 565 void ValidateOrphanedInstance(Isolate* isolate, Handle<JSObject> instance); |
571 | 566 |
572 } // namespace testing | 567 } // namespace testing |
573 } // namespace wasm | 568 } // namespace wasm |
574 } // namespace internal | 569 } // namespace internal |
575 } // namespace v8 | 570 } // namespace v8 |
576 | 571 |
577 #endif // V8_WASM_MODULE_H_ | 572 #endif // V8_WASM_MODULE_H_ |
OLD | NEW |