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/api.h" | 8 #include "src/api.h" |
9 #include "src/handles.h" | 9 #include "src/handles.h" |
10 #include "src/wasm/wasm-opcodes.h" | 10 #include "src/wasm/wasm-opcodes.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 #define WASM_SECTION_DATA_SEGMENTS_SIZE ((size_t)5) | 66 #define WASM_SECTION_DATA_SEGMENTS_SIZE ((size_t)5) |
67 #define WASM_SECTION_FUNCTION_TABLE_SIZE ((size_t)6) | 67 #define WASM_SECTION_FUNCTION_TABLE_SIZE ((size_t)6) |
68 #define WASM_SECTION_END_SIZE ((size_t)4) | 68 #define WASM_SECTION_END_SIZE ((size_t)4) |
69 #define WASM_SECTION_START_FUNCTION_SIZE ((size_t)6) | 69 #define WASM_SECTION_START_FUNCTION_SIZE ((size_t)6) |
70 #define WASM_SECTION_IMPORT_TABLE_SIZE ((size_t)7) | 70 #define WASM_SECTION_IMPORT_TABLE_SIZE ((size_t)7) |
71 #define WASM_SECTION_EXPORT_TABLE_SIZE ((size_t)7) | 71 #define WASM_SECTION_EXPORT_TABLE_SIZE ((size_t)7) |
72 #define WASM_SECTION_FUNCTION_SIGNATURES_SIZE ((size_t)9) | 72 #define WASM_SECTION_FUNCTION_SIGNATURES_SIZE ((size_t)9) |
73 #define WASM_SECTION_FUNCTION_BODIES_SIZE ((size_t)5) | 73 #define WASM_SECTION_FUNCTION_BODIES_SIZE ((size_t)5) |
74 #define WASM_SECTION_NAMES_SIZE ((size_t)5) | 74 #define WASM_SECTION_NAMES_SIZE ((size_t)5) |
75 | 75 |
| 76 class WasmDebugInfo; |
| 77 |
76 struct WasmSection { | 78 struct WasmSection { |
77 enum class Code : uint32_t { | 79 enum class Code : uint32_t { |
78 #define F(enumerator, order, string) enumerator, | 80 #define F(enumerator, order, string) enumerator, |
79 FOR_EACH_WASM_SECTION_TYPE(F) | 81 FOR_EACH_WASM_SECTION_TYPE(F) |
80 #undef F | 82 #undef F |
81 Max | 83 Max |
82 }; | 84 }; |
83 static WasmSection::Code begin(); | 85 static WasmSection::Code begin(); |
84 static WasmSection::Code end(); | 86 static WasmSection::Code end(); |
85 static WasmSection::Code next(WasmSection::Code code); | 87 static WasmSection::Code next(WasmSection::Code code); |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 // valid UTF-8 string. | 326 // valid UTF-8 string. |
325 Handle<String> GetWasmFunctionName(Isolate* isolate, Handle<Object> wasm, | 327 Handle<String> GetWasmFunctionName(Isolate* isolate, Handle<Object> wasm, |
326 uint32_t func_index); | 328 uint32_t func_index); |
327 | 329 |
328 // Extract a function name from the given wasm object. | 330 // Extract a function name from the given wasm object. |
329 // Returns a null handle if the function is unnamed or the name is not a valid | 331 // Returns a null handle if the function is unnamed or the name is not a valid |
330 // UTF-8 string. | 332 // UTF-8 string. |
331 Handle<Object> GetWasmFunctionNameOrNull(Isolate* isolate, Handle<Object> wasm, | 333 Handle<Object> GetWasmFunctionNameOrNull(Isolate* isolate, Handle<Object> wasm, |
332 uint32_t func_index); | 334 uint32_t func_index); |
333 | 335 |
| 336 // Return the binary source bytes of a wasm module. |
| 337 SeqOneByteString* GetWasmBytes(JSObject* wasm); |
| 338 |
| 339 // Get the debug info associated with the given wasm object. |
| 340 // If no debug info exists yet, it is created automatically. |
| 341 WasmDebugInfo* GetDebugInfo(JSObject* wasm); |
| 342 |
334 // Check whether the given object is a wasm object. | 343 // Check whether the given object is a wasm object. |
335 // This checks the number and type of internal fields, so it's not 100 percent | 344 // This checks the number and type of internal fields, so it's not 100 percent |
336 // secure. If it turns out that we need more complete checks, we could add a | 345 // secure. If it turns out that we need more complete checks, we could add a |
337 // special marker as internal field, which will definitely never occur anywhere | 346 // special marker as internal field, which will definitely never occur anywhere |
338 // else. | 347 // else. |
339 bool IsWasmObject(Handle<JSObject> object); | 348 bool IsWasmObject(Object* object); |
340 | 349 |
341 } // namespace wasm | 350 } // namespace wasm |
342 } // namespace internal | 351 } // namespace internal |
343 } // namespace v8 | 352 } // namespace v8 |
344 | 353 |
345 #endif // V8_WASM_MODULE_H_ | 354 #endif // V8_WASM_MODULE_H_ |
OLD | NEW |