| 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 |
| 11 #include "src/api.h" | 11 #include "src/api.h" |
| 12 #include "src/handles.h" | 12 #include "src/handles.h" |
| 13 | 13 |
| 14 namespace v8 { | 14 namespace v8 { |
| 15 namespace internal { | 15 namespace internal { |
| 16 | 16 |
| 17 namespace compiler { | 17 namespace compiler { |
| 18 class CallDescriptor; | 18 class CallDescriptor; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace wasm { | 21 namespace wasm { |
| 22 const size_t kMaxModuleSize = 1024 * 1024 * 1024; | 22 const size_t kMaxModuleSize = 1024 * 1024 * 1024; |
| 23 const size_t kMaxFunctionSize = 128 * 1024; | 23 const size_t kMaxFunctionSize = 128 * 1024; |
| 24 const size_t kMaxStringSize = 256; | 24 const size_t kMaxStringSize = 256; |
| 25 const uint32_t kWasmMagic = 0x6d736100; | 25 const uint32_t kWasmMagic = 0x6d736100; |
| 26 const uint32_t kWasmVersion = 0x0a; | 26 const uint32_t kWasmVersion = 0x0a; |
| 27 | 27 |
| 28 enum WasmSectionDeclCode { | 28 // WebAssembly sections are named as strings in the binary format, but |
| 29 kDeclMemory = 0x00, | 29 // internally V8 uses an enum to handle them. |
| 30 kDeclSignatures = 0x01, | 30 // |
| 31 kDeclFunctions = 0x02, | 31 // Entries have the form F(enumerator, string). |
| 32 kDeclGlobals = 0x03, | 32 #define FOR_EACH_WASM_SECTION_TYPE(F) \ |
| 33 kDeclDataSegments = 0x04, | 33 F(kDeclMemory, "memory") \ |
| 34 kDeclFunctionTable = 0x05, | 34 F(kDeclSignatures, "signatures") \ |
| 35 kDeclEnd = 0x06, | 35 F(kDeclFunctions, "functions") \ |
| 36 kDeclStartFunction = 0x07, | 36 F(kDeclGlobals, "globals") \ |
| 37 kDeclImportTable = 0x08, | 37 F(kDeclDataSegments, "data_segments") \ |
| 38 kDeclExportTable = 0x09, | 38 F(kDeclFunctionTable, "function_table") \ |
| 39 kDeclWLL = 0x11, | 39 F(kDeclEnd, "end") \ |
| 40 F(kDeclStartFunction, "start_function") \ |
| 41 F(kDeclImportTable, "import_table") \ |
| 42 F(kDeclExportTable, "export_table") |
| 43 |
| 44 enum WasmSectionDeclCode : uint32_t { |
| 45 #define F(enumerator, string) enumerator, |
| 46 FOR_EACH_WASM_SECTION_TYPE(F) |
| 47 #undef F |
| 48 kMaxModuleSectionCode |
| 40 }; | 49 }; |
| 41 | 50 |
| 42 static const int kMaxModuleSectionCode = 0x11; | |
| 43 | |
| 44 enum WasmFunctionDeclBit { | 51 enum WasmFunctionDeclBit { |
| 45 kDeclFunctionName = 0x01, | 52 kDeclFunctionName = 0x01, |
| 46 kDeclFunctionImport = 0x02, | 53 kDeclFunctionImport = 0x02, |
| 47 kDeclFunctionLocals = 0x04, | 54 kDeclFunctionLocals = 0x04, |
| 48 kDeclFunctionExport = 0x08 | 55 kDeclFunctionExport = 0x08 |
| 49 }; | 56 }; |
| 50 | 57 |
| 51 // Constants for fixed-size elements within a module. | 58 // Constants for fixed-size elements within a module. |
| 52 static const size_t kDeclMemorySize = 3; | 59 static const size_t kDeclMemorySize = 3; |
| 53 static const size_t kDeclGlobalSize = 6; | 60 static const size_t kDeclGlobalSize = 6; |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 | 256 |
| 250 // For testing. Decode, verify, and run the last exported function in the | 257 // For testing. Decode, verify, and run the last exported function in the |
| 251 // given decoded module. | 258 // given decoded module. |
| 252 int32_t CompileAndRunWasmModule(Isolate* isolate, WasmModule* module); | 259 int32_t CompileAndRunWasmModule(Isolate* isolate, WasmModule* module); |
| 253 | 260 |
| 254 } // namespace wasm | 261 } // namespace wasm |
| 255 } // namespace internal | 262 } // namespace internal |
| 256 } // namespace v8 | 263 } // namespace v8 |
| 257 | 264 |
| 258 #endif // V8_WASM_MODULE_H_ | 265 #endif // V8_WASM_MODULE_H_ |
| OLD | NEW |