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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 Handle<JSReceiver> ffi, Handle<JSArrayBuffer> memory); | 250 Handle<JSReceiver> ffi, Handle<JSArrayBuffer> memory); |
251 | 251 |
252 MaybeHandle<WasmCompiledModule> CompileFunctions(Isolate* isolate, | 252 MaybeHandle<WasmCompiledModule> CompileFunctions(Isolate* isolate, |
253 ErrorThrower* thrower) const; | 253 ErrorThrower* thrower) const; |
254 | 254 |
255 private: | 255 private: |
256 DISALLOW_COPY_AND_ASSIGN(WasmModule); | 256 DISALLOW_COPY_AND_ASSIGN(WasmModule); |
257 }; | 257 }; |
258 | 258 |
259 // An instantiated WASM module, including memory, function table, etc. | 259 // An instantiated WASM module, including memory, function table, etc. |
260 struct WasmModuleInstance { | 260 struct WasmInstance { |
261 const WasmModule* module; // static representation of the module. | 261 const WasmModule* module; // static representation of the module. |
262 // -- Heap allocated -------------------------------------------------------- | 262 // -- Heap allocated -------------------------------------------------------- |
263 Handle<JSObject> js_object; // JavaScript module object. | 263 Handle<JSObject> js_object; // JavaScript module object. |
264 Handle<Context> context; // JavaScript native context. | 264 Handle<Context> context; // JavaScript native context. |
265 Handle<JSArrayBuffer> mem_buffer; // Handle to array buffer of memory. | 265 Handle<JSArrayBuffer> mem_buffer; // Handle to array buffer of memory. |
266 Handle<JSArrayBuffer> globals_buffer; // Handle to array buffer of globals. | 266 Handle<JSArrayBuffer> globals_buffer; // Handle to array buffer of globals. |
267 std::vector<Handle<FixedArray>> function_tables; // indirect function tables. | 267 std::vector<Handle<FixedArray>> function_tables; // indirect function tables. |
268 std::vector<Handle<Code>> function_code; // code objects for each function. | 268 std::vector<Handle<Code>> function_code; // code objects for each function. |
269 // -- raw memory ------------------------------------------------------------ | 269 // -- raw memory ------------------------------------------------------------ |
270 byte* mem_start; // start of linear memory. | 270 byte* mem_start; // start of linear memory. |
271 uint32_t mem_size; // size of the linear memory. | 271 uint32_t mem_size; // size of the linear memory. |
272 // -- raw globals ----------------------------------------------------------- | 272 // -- raw globals ----------------------------------------------------------- |
273 byte* globals_start; // start of the globals area. | 273 byte* globals_start; // start of the globals area. |
274 | 274 |
275 explicit WasmModuleInstance(const WasmModule* m) | 275 explicit WasmInstance(const WasmModule* m) |
276 : module(m), | 276 : module(m), |
277 function_tables(m->function_tables.size()), | 277 function_tables(m->function_tables.size()), |
278 function_code(m->functions.size()), | 278 function_code(m->functions.size()), |
279 mem_start(nullptr), | 279 mem_start(nullptr), |
280 mem_size(0), | 280 mem_size(0), |
281 globals_start(nullptr) {} | 281 globals_start(nullptr) {} |
282 }; | 282 }; |
283 | 283 |
284 // Interface provided to the decoder/graph builder which contains only | 284 // Interface provided to the decoder/graph builder which contains only |
285 // minimal information about the globals, functions, and function tables. | 285 // minimal information about the globals, functions, and function tables. |
286 struct ModuleEnv { | 286 struct ModuleEnv { |
287 const WasmModule* module; | 287 const WasmModule* module; |
288 WasmModuleInstance* instance; | 288 WasmInstance* instance; |
289 ModuleOrigin origin; | 289 ModuleOrigin origin; |
290 | 290 |
291 bool IsValidGlobal(uint32_t index) const { | 291 bool IsValidGlobal(uint32_t index) const { |
292 return module && index < module->globals.size(); | 292 return module && index < module->globals.size(); |
293 } | 293 } |
294 bool IsValidFunction(uint32_t index) const { | 294 bool IsValidFunction(uint32_t index) const { |
295 return module && index < module->functions.size(); | 295 return module && index < module->functions.size(); |
296 } | 296 } |
297 bool IsValidSignature(uint32_t index) const { | 297 bool IsValidSignature(uint32_t index) const { |
298 return module && index < module->signatures.size(); | 298 return module && index < module->signatures.size(); |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 int instance_count); | 563 int instance_count); |
564 void ValidateModuleState(Isolate* isolate, Handle<JSObject> module_obj); | 564 void ValidateModuleState(Isolate* isolate, Handle<JSObject> module_obj); |
565 void ValidateOrphanedInstance(Isolate* isolate, Handle<JSObject> instance); | 565 void ValidateOrphanedInstance(Isolate* isolate, Handle<JSObject> instance); |
566 | 566 |
567 } // namespace testing | 567 } // namespace testing |
568 } // namespace wasm | 568 } // namespace wasm |
569 } // namespace internal | 569 } // namespace internal |
570 } // namespace v8 | 570 } // namespace v8 |
571 | 571 |
572 #endif // V8_WASM_MODULE_H_ | 572 #endif // V8_WASM_MODULE_H_ |
OLD | NEW |