| 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" |
| 11 #include "src/handles.h" | 11 #include "src/handles.h" |
| 12 #include "src/parsing/preparse-data.h" | 12 #include "src/parsing/preparse-data.h" |
| 13 | 13 |
| 14 #include "src/wasm/signature-map.h" |
| 14 #include "src/wasm/wasm-opcodes.h" | 15 #include "src/wasm/wasm-opcodes.h" |
| 15 #include "src/wasm/wasm-result.h" | |
| 16 | 16 |
| 17 namespace v8 { | 17 namespace v8 { |
| 18 namespace internal { | 18 namespace internal { |
| 19 | 19 |
| 20 namespace compiler { | 20 namespace compiler { |
| 21 class CallDescriptor; | 21 class CallDescriptor; |
| 22 class WasmCompilationUnit; | 22 class WasmCompilationUnit; |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace wasm { | 25 namespace wasm { |
| 26 class ErrorThrower; |
| 27 |
| 26 const size_t kMaxModuleSize = 1024 * 1024 * 1024; | 28 const size_t kMaxModuleSize = 1024 * 1024 * 1024; |
| 27 const size_t kMaxFunctionSize = 128 * 1024; | 29 const size_t kMaxFunctionSize = 128 * 1024; |
| 28 const size_t kMaxStringSize = 256; | 30 const size_t kMaxStringSize = 256; |
| 29 const uint32_t kWasmMagic = 0x6d736100; | 31 const uint32_t kWasmMagic = 0x6d736100; |
| 30 const uint32_t kWasmVersion = 0x0c; | 32 const uint32_t kWasmVersion = 0x0c; |
| 31 | 33 |
| 32 const uint8_t kWasmFunctionTypeForm = 0x40; | 34 const uint8_t kWasmFunctionTypeForm = 0x40; |
| 33 const uint8_t kWasmAnyFunctionTypeForm = 0x20; | 35 const uint8_t kWasmAnyFunctionTypeForm = 0x20; |
| 34 | 36 |
| 35 enum WasmSectionCode { | 37 enum WasmSectionCode { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 uint32_t source_size; // end offset in the module bytes. | 129 uint32_t source_size; // end offset in the module bytes. |
| 128 }; | 130 }; |
| 129 | 131 |
| 130 // Static representation of a wasm indirect call table. | 132 // Static representation of a wasm indirect call table. |
| 131 struct WasmIndirectFunctionTable { | 133 struct WasmIndirectFunctionTable { |
| 132 uint32_t size; // initial table size. | 134 uint32_t size; // initial table size. |
| 133 uint32_t max_size; // maximum table size. | 135 uint32_t max_size; // maximum table size. |
| 134 std::vector<int32_t> values; // function table, -1 indicating invalid. | 136 std::vector<int32_t> values; // function table, -1 indicating invalid. |
| 135 bool imported; // true if imported. | 137 bool imported; // true if imported. |
| 136 bool exported; // true if exported. | 138 bool exported; // true if exported. |
| 139 SignatureMap map; // canonicalizing map for sig indexes. |
| 137 }; | 140 }; |
| 138 | 141 |
| 139 // Static representation of how to initialize a table. | 142 // Static representation of how to initialize a table. |
| 140 struct WasmTableInit { | 143 struct WasmTableInit { |
| 141 uint32_t table_index; | 144 uint32_t table_index; |
| 142 WasmInitExpr offset; | 145 WasmInitExpr offset; |
| 143 std::vector<uint32_t> entries; | 146 std::vector<uint32_t> entries; |
| 144 }; | 147 }; |
| 145 | 148 |
| 146 // Static representation of a WASM import. | 149 // Static representation of a WASM import. |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 const WasmFunction* function_; | 335 const WasmFunction* function_; |
| 333 const WasmModule* module_; | 336 const WasmModule* module_; |
| 334 WasmFunctionName(const WasmFunction* function, const ModuleEnv* menv) | 337 WasmFunctionName(const WasmFunction* function, const ModuleEnv* menv) |
| 335 : function_(function), module_(menv ? menv->module : nullptr) {} | 338 : function_(function), module_(menv ? menv->module : nullptr) {} |
| 336 }; | 339 }; |
| 337 | 340 |
| 338 std::ostream& operator<<(std::ostream& os, const WasmModule& module); | 341 std::ostream& operator<<(std::ostream& os, const WasmModule& module); |
| 339 std::ostream& operator<<(std::ostream& os, const WasmFunction& function); | 342 std::ostream& operator<<(std::ostream& os, const WasmFunction& function); |
| 340 std::ostream& operator<<(std::ostream& os, const WasmFunctionName& name); | 343 std::ostream& operator<<(std::ostream& os, const WasmFunctionName& name); |
| 341 | 344 |
| 342 typedef Result<const WasmModule*> ModuleResult; | |
| 343 typedef Result<WasmFunction*> FunctionResult; | |
| 344 typedef std::vector<std::pair<int, int>> FunctionOffsets; | |
| 345 typedef Result<FunctionOffsets> FunctionOffsetsResult; | |
| 346 | |
| 347 class WasmCompiledModule : public FixedArray { | 345 class WasmCompiledModule : public FixedArray { |
| 348 public: | 346 public: |
| 349 static WasmCompiledModule* cast(Object* fixed_array) { | 347 static WasmCompiledModule* cast(Object* fixed_array) { |
| 350 SLOW_DCHECK(IsWasmCompiledModule(fixed_array)); | 348 SLOW_DCHECK(IsWasmCompiledModule(fixed_array)); |
| 351 return reinterpret_cast<WasmCompiledModule*>(fixed_array); | 349 return reinterpret_cast<WasmCompiledModule*>(fixed_array); |
| 352 } | 350 } |
| 353 | 351 |
| 354 #define WCM_OBJECT_OR_WEAK(TYPE, NAME, ID) \ | 352 #define WCM_OBJECT_OR_WEAK(TYPE, NAME, ID) \ |
| 355 Handle<TYPE> NAME() const { return handle(ptr_to_##NAME()); } \ | 353 Handle<TYPE> NAME() const { return handle(ptr_to_##NAME()); } \ |
| 356 \ | 354 \ |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 int instance_count); | 546 int instance_count); |
| 549 void ValidateModuleState(Isolate* isolate, Handle<JSObject> module_obj); | 547 void ValidateModuleState(Isolate* isolate, Handle<JSObject> module_obj); |
| 550 void ValidateOrphanedInstance(Isolate* isolate, Handle<JSObject> instance); | 548 void ValidateOrphanedInstance(Isolate* isolate, Handle<JSObject> instance); |
| 551 | 549 |
| 552 } // namespace testing | 550 } // namespace testing |
| 553 } // namespace wasm | 551 } // namespace wasm |
| 554 } // namespace internal | 552 } // namespace internal |
| 555 } // namespace v8 | 553 } // namespace v8 |
| 556 | 554 |
| 557 #endif // V8_WASM_MODULE_H_ | 555 #endif // V8_WASM_MODULE_H_ |
| OLD | NEW |