| 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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 int length() const { return module_bytes_.length(); } | 264 int length() const { return module_bytes_.length(); } |
| 265 | 265 |
| 266 private: | 266 private: |
| 267 const Vector<const byte> module_bytes_; | 267 const Vector<const byte> module_bytes_; |
| 268 }; | 268 }; |
| 269 | 269 |
| 270 // Interface provided to the decoder/graph builder which contains only | 270 // Interface provided to the decoder/graph builder which contains only |
| 271 // minimal information about the globals, functions, and function tables. | 271 // minimal information about the globals, functions, and function tables. |
| 272 struct V8_EXPORT_PRIVATE ModuleEnv { | 272 struct V8_EXPORT_PRIVATE ModuleEnv { |
| 273 ModuleEnv(const WasmModule* module, WasmInstance* instance) | 273 ModuleEnv(const WasmModule* module, WasmInstance* instance) |
| 274 : module(module), instance(instance) {} | 274 : module(module), instance(instance) { |
| 275 if (instance) { |
| 276 function_tables = &instance->function_tables; |
| 277 signature_tables = &instance->signature_tables; |
| 278 } |
| 279 } |
| 275 | 280 |
| 276 const WasmModule* module; | 281 const WasmModule* module; |
| 277 WasmInstance* instance; | 282 WasmInstance* instance; |
| 278 | 283 |
| 284 // TODO(clemensh): Find a better solution for this. |
| 285 std::vector<Handle<FixedArray>>* function_tables = nullptr; |
| 286 std::vector<Handle<FixedArray>>* signature_tables = nullptr; |
| 287 bool used_indirect_tables = false; |
| 288 |
| 289 Handle<FixedArray> GetFunctionTableObj(size_t index) { |
| 290 used_indirect_tables = true; |
| 291 return (*function_tables)[index]; |
| 292 } |
| 293 Handle<FixedArray> GetSignatureTableObj(size_t index) { |
| 294 used_indirect_tables = true; |
| 295 return (*signature_tables)[index]; |
| 296 } |
| 297 |
| 279 bool IsValidGlobal(uint32_t index) const { | 298 bool IsValidGlobal(uint32_t index) const { |
| 280 return module && index < module->globals.size(); | 299 return module && index < module->globals.size(); |
| 281 } | 300 } |
| 282 bool IsValidFunction(uint32_t index) const { | 301 bool IsValidFunction(uint32_t index) const { |
| 283 return module && index < module->functions.size(); | 302 return module && index < module->functions.size(); |
| 284 } | 303 } |
| 285 bool IsValidSignature(uint32_t index) const { | 304 bool IsValidSignature(uint32_t index) const { |
| 286 return module && index < module->signatures.size(); | 305 return module && index < module->signatures.size(); |
| 287 } | 306 } |
| 288 bool IsValidTable(uint32_t index) const { | 307 bool IsValidTable(uint32_t index) const { |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 | 455 |
| 437 V8_EXPORT_PRIVATE void AsyncInstantiate(Isolate* isolate, | 456 V8_EXPORT_PRIVATE void AsyncInstantiate(Isolate* isolate, |
| 438 Handle<JSPromise> promise, | 457 Handle<JSPromise> promise, |
| 439 Handle<WasmModuleObject> module_object, | 458 Handle<WasmModuleObject> module_object, |
| 440 MaybeHandle<JSReceiver> imports); | 459 MaybeHandle<JSReceiver> imports); |
| 441 | 460 |
| 442 V8_EXPORT_PRIVATE void AsyncCompileAndInstantiate( | 461 V8_EXPORT_PRIVATE void AsyncCompileAndInstantiate( |
| 443 Isolate* isolate, Handle<JSPromise> promise, const ModuleWireBytes& bytes, | 462 Isolate* isolate, Handle<JSPromise> promise, const ModuleWireBytes& bytes, |
| 444 MaybeHandle<JSReceiver> imports); | 463 MaybeHandle<JSReceiver> imports); |
| 445 | 464 |
| 465 Handle<Code> CompileLazy(Isolate* isolate); |
| 466 |
| 446 namespace testing { | 467 namespace testing { |
| 447 void ValidateInstancesChain(Isolate* isolate, | 468 void ValidateInstancesChain(Isolate* isolate, |
| 448 Handle<WasmModuleObject> module_obj, | 469 Handle<WasmModuleObject> module_obj, |
| 449 int instance_count); | 470 int instance_count); |
| 450 void ValidateModuleState(Isolate* isolate, Handle<WasmModuleObject> module_obj); | 471 void ValidateModuleState(Isolate* isolate, Handle<WasmModuleObject> module_obj); |
| 451 void ValidateOrphanedInstance(Isolate* isolate, | 472 void ValidateOrphanedInstance(Isolate* isolate, |
| 452 Handle<WasmInstanceObject> instance); | 473 Handle<WasmInstanceObject> instance); |
| 453 } // namespace testing | 474 } // namespace testing |
| 454 } // namespace wasm | 475 } // namespace wasm |
| 455 } // namespace internal | 476 } // namespace internal |
| 456 } // namespace v8 | 477 } // namespace v8 |
| 457 | 478 |
| 458 #endif // V8_WASM_MODULE_H_ | 479 #endif // V8_WASM_MODULE_H_ |
| OLD | NEW |