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 |
(...skipping 24 matching lines...) Expand all Loading... |
35 F(Signatures, 1, "type") \ | 35 F(Signatures, 1, "type") \ |
36 F(ImportTable, 2, "import") \ | 36 F(ImportTable, 2, "import") \ |
37 F(FunctionSignatures, 3, "function") \ | 37 F(FunctionSignatures, 3, "function") \ |
38 F(FunctionTable, 4, "table") \ | 38 F(FunctionTable, 4, "table") \ |
39 F(Memory, 5, "memory") \ | 39 F(Memory, 5, "memory") \ |
40 F(ExportTable, 6, "export") \ | 40 F(ExportTable, 6, "export") \ |
41 F(StartFunction, 7, "start") \ | 41 F(StartFunction, 7, "start") \ |
42 F(FunctionBodies, 8, "code") \ | 42 F(FunctionBodies, 8, "code") \ |
43 F(DataSegments, 9, "data") \ | 43 F(DataSegments, 9, "data") \ |
44 F(Names, 10, "name") \ | 44 F(Names, 10, "name") \ |
45 F(OldFunctions, 0, "old_function") \ | |
46 F(Globals, 0, "global") \ | 45 F(Globals, 0, "global") \ |
47 F(End, 0, "end") | 46 F(End, 0, "end") |
48 | 47 |
49 // Contants for the above section types: {LEB128 length, characters...}. | 48 // Contants for the above section types: {LEB128 length, characters...}. |
50 #define WASM_SECTION_MEMORY 6, 'm', 'e', 'm', 'o', 'r', 'y' | 49 #define WASM_SECTION_MEMORY 6, 'm', 'e', 'm', 'o', 'r', 'y' |
51 #define WASM_SECTION_SIGNATURES 4, 't', 'y', 'p', 'e' | 50 #define WASM_SECTION_SIGNATURES 4, 't', 'y', 'p', 'e' |
52 #define WASM_SECTION_OLD_FUNCTIONS \ | |
53 12, 'o', 'l', 'd', '_', 'f', 'u', 'n', 'c', 't', 'i', 'o', 'n' | |
54 #define WASM_SECTION_GLOBALS 6, 'g', 'l', 'o', 'b', 'a', 'l' | 51 #define WASM_SECTION_GLOBALS 6, 'g', 'l', 'o', 'b', 'a', 'l' |
55 #define WASM_SECTION_DATA_SEGMENTS 4, 'd', 'a', 't', 'a' | 52 #define WASM_SECTION_DATA_SEGMENTS 4, 'd', 'a', 't', 'a' |
56 #define WASM_SECTION_FUNCTION_TABLE 5, 't', 'a', 'b', 'l', 'e' | 53 #define WASM_SECTION_FUNCTION_TABLE 5, 't', 'a', 'b', 'l', 'e' |
57 #define WASM_SECTION_END 3, 'e', 'n', 'd' | 54 #define WASM_SECTION_END 3, 'e', 'n', 'd' |
58 #define WASM_SECTION_START_FUNCTION 5, 's', 't', 'a', 'r', 't' | 55 #define WASM_SECTION_START_FUNCTION 5, 's', 't', 'a', 'r', 't' |
59 #define WASM_SECTION_IMPORT_TABLE 6, 'i', 'm', 'p', 'o', 'r', 't' | 56 #define WASM_SECTION_IMPORT_TABLE 6, 'i', 'm', 'p', 'o', 'r', 't' |
60 #define WASM_SECTION_EXPORT_TABLE 6, 'e', 'x', 'p', 'o', 'r', 't' | 57 #define WASM_SECTION_EXPORT_TABLE 6, 'e', 'x', 'p', 'o', 'r', 't' |
61 #define WASM_SECTION_FUNCTION_SIGNATURES \ | 58 #define WASM_SECTION_FUNCTION_SIGNATURES \ |
62 8, 'f', 'u', 'n', 'c', 't', 'i', 'o', 'n' | 59 8, 'f', 'u', 'n', 'c', 't', 'i', 'o', 'n' |
63 #define WASM_SECTION_FUNCTION_BODIES 4, 'c', 'o', 'd', 'e' | 60 #define WASM_SECTION_FUNCTION_BODIES 4, 'c', 'o', 'd', 'e' |
64 #define WASM_SECTION_NAMES 4, 'n', 'a', 'm', 'e' | 61 #define WASM_SECTION_NAMES 4, 'n', 'a', 'm', 'e' |
65 | 62 |
66 // Constants for the above section headers' size (LEB128 + characters). | 63 // Constants for the above section headers' size (LEB128 + characters). |
67 #define WASM_SECTION_MEMORY_SIZE ((size_t)7) | 64 #define WASM_SECTION_MEMORY_SIZE ((size_t)7) |
68 #define WASM_SECTION_SIGNATURES_SIZE ((size_t)5) | 65 #define WASM_SECTION_SIGNATURES_SIZE ((size_t)5) |
69 #define WASM_SECTION_OLD_FUNCTIONS_SIZE ((size_t)13) | |
70 #define WASM_SECTION_GLOBALS_SIZE ((size_t)7) | 66 #define WASM_SECTION_GLOBALS_SIZE ((size_t)7) |
71 #define WASM_SECTION_DATA_SEGMENTS_SIZE ((size_t)5) | 67 #define WASM_SECTION_DATA_SEGMENTS_SIZE ((size_t)5) |
72 #define WASM_SECTION_FUNCTION_TABLE_SIZE ((size_t)6) | 68 #define WASM_SECTION_FUNCTION_TABLE_SIZE ((size_t)6) |
73 #define WASM_SECTION_END_SIZE ((size_t)4) | 69 #define WASM_SECTION_END_SIZE ((size_t)4) |
74 #define WASM_SECTION_START_FUNCTION_SIZE ((size_t)6) | 70 #define WASM_SECTION_START_FUNCTION_SIZE ((size_t)6) |
75 #define WASM_SECTION_IMPORT_TABLE_SIZE ((size_t)7) | 71 #define WASM_SECTION_IMPORT_TABLE_SIZE ((size_t)7) |
76 #define WASM_SECTION_EXPORT_TABLE_SIZE ((size_t)7) | 72 #define WASM_SECTION_EXPORT_TABLE_SIZE ((size_t)7) |
77 #define WASM_SECTION_FUNCTION_SIGNATURES_SIZE ((size_t)9) | 73 #define WASM_SECTION_FUNCTION_SIGNATURES_SIZE ((size_t)9) |
78 #define WASM_SECTION_FUNCTION_BODIES_SIZE ((size_t)5) | 74 #define WASM_SECTION_FUNCTION_BODIES_SIZE ((size_t)5) |
79 #define WASM_SECTION_NAMES_SIZE ((size_t)5) | 75 #define WASM_SECTION_NAMES_SIZE ((size_t)5) |
(...skipping 27 matching lines...) Expand all Loading... |
107 | 103 |
108 // Static representation of a WASM function. | 104 // Static representation of a WASM function. |
109 struct WasmFunction { | 105 struct WasmFunction { |
110 FunctionSig* sig; // signature of the function. | 106 FunctionSig* sig; // signature of the function. |
111 uint32_t func_index; // index into the function table. | 107 uint32_t func_index; // index into the function table. |
112 uint32_t sig_index; // index into the signature table. | 108 uint32_t sig_index; // index into the signature table. |
113 uint32_t name_offset; // offset in the module bytes of the name, if any. | 109 uint32_t name_offset; // offset in the module bytes of the name, if any. |
114 uint32_t name_length; // length in bytes of the name. | 110 uint32_t name_length; // length in bytes of the name. |
115 uint32_t code_start_offset; // offset in the module bytes of code start. | 111 uint32_t code_start_offset; // offset in the module bytes of code start. |
116 uint32_t code_end_offset; // offset in the module bytes of code end. | 112 uint32_t code_end_offset; // offset in the module bytes of code end. |
117 bool exported; // true if this function is exported. | |
118 }; | 113 }; |
119 | 114 |
120 // Static representation of an imported WASM function. | 115 // Static representation of an imported WASM function. |
121 struct WasmImport { | 116 struct WasmImport { |
122 FunctionSig* sig; // signature of the function. | 117 FunctionSig* sig; // signature of the function. |
123 uint32_t sig_index; // index into the signature table. | 118 uint32_t sig_index; // index into the signature table. |
124 uint32_t module_name_offset; // offset in module bytes of the module name. | 119 uint32_t module_name_offset; // offset in module bytes of the module name. |
125 uint32_t module_name_length; // length in bytes of the module name. | 120 uint32_t module_name_length; // length in bytes of the module name. |
126 uint32_t function_name_offset; // offset in module bytes of the import name. | 121 uint32_t function_name_offset; // offset in module bytes of the import name. |
127 uint32_t function_name_length; // length in bytes of the import name. | 122 uint32_t function_name_length; // length in bytes of the import name. |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 // Returns a null handle if the function is unnamed or the name is not a valid | 318 // Returns a null handle if the function is unnamed or the name is not a valid |
324 // UTF-8 string. | 319 // UTF-8 string. |
325 MaybeHandle<String> GetWasmFunctionName(Handle<JSObject> wasm, | 320 MaybeHandle<String> GetWasmFunctionName(Handle<JSObject> wasm, |
326 uint32_t func_index); | 321 uint32_t func_index); |
327 | 322 |
328 } // namespace wasm | 323 } // namespace wasm |
329 } // namespace internal | 324 } // namespace internal |
330 } // namespace v8 | 325 } // namespace v8 |
331 | 326 |
332 #endif // V8_WASM_MODULE_H_ | 327 #endif // V8_WASM_MODULE_H_ |
OLD | NEW |