Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: src/wasm/wasm-module.h

Issue 1743773002: WebAssembly: skip unknown sections, add names (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 25
26 // WebAssembly sections are named as strings in the binary format, but
27 // internally V8 uses an enum to handle them.
28 //
29 // Entries have the form F(enumerator, string).
30 #define FOR_EACH_WASM_SECTION_TYPE(F) \
31 F(kDeclMemory, "memory") \
32 F(kDeclSignatures, "signatures") \
33 F(kDeclFunctions, "functions") \
34 F(kDeclGlobals, "globals") \
35 F(kDeclDataSegments, "data_segments") \
36 F(kDeclFunctionTable, "function_tables") \
titzer 2016/02/26 22:54:17 function_table
JF 2016/02/26 23:42:41 Done.
37 F(kDeclEnd, "end") \
38 F(kDeclStartFunction, "start_function") \
39 F(kDeclImportTable, "import_table")
40
26 enum WasmSectionDeclCode { 41 enum WasmSectionDeclCode {
27 kDeclMemory = 0x00, 42 #define F(enumerator, string) enumerator,
28 kDeclSignatures = 0x01, 43 FOR_EACH_WASM_SECTION_TYPE(F)
29 kDeclFunctions = 0x02, 44 #undef F
30 kDeclGlobals = 0x03, 45 kMaxModuleSectionCode
31 kDeclDataSegments = 0x04,
32 kDeclFunctionTable = 0x05,
33 kDeclEnd = 0x06,
34 kDeclStartFunction = 0x07,
35 kDeclImportTable = 0x08,
36 kDeclWLL = 0x11,
37 }; 46 };
38 47
39 static const int kMaxModuleSectionCode = 0x11;
40
41 enum WasmFunctionDeclBit { 48 enum WasmFunctionDeclBit {
42 kDeclFunctionName = 0x01, 49 kDeclFunctionName = 0x01,
43 kDeclFunctionImport = 0x02, 50 kDeclFunctionImport = 0x02,
44 kDeclFunctionLocals = 0x04, 51 kDeclFunctionLocals = 0x04,
45 kDeclFunctionExport = 0x08 52 kDeclFunctionExport = 0x08
46 }; 53 };
47 54
48 // Constants for fixed-size elements within a module. 55 // Constants for fixed-size elements within a module.
49 static const size_t kDeclMemorySize = 3; 56 static const size_t kDeclMemorySize = 3;
50 static const size_t kDeclGlobalSize = 6; 57 static const size_t kDeclGlobalSize = 6;
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 243
237 // For testing. Decode, verify, and run the last exported function in the 244 // For testing. Decode, verify, and run the last exported function in the
238 // given decoded module. 245 // given decoded module.
239 int32_t CompileAndRunWasmModule(Isolate* isolate, WasmModule* module); 246 int32_t CompileAndRunWasmModule(Isolate* isolate, WasmModule* module);
240 247
241 } // namespace wasm 248 } // namespace wasm
242 } // namespace internal 249 } // namespace internal
243 } // namespace v8 250 } // namespace v8
244 251
245 #endif // V8_WASM_MODULE_H_ 252 #endif // V8_WASM_MODULE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698