OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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_OBJECTS_H_ | 5 #ifndef V8_WASM_OBJECTS_H_ |
6 #define V8_WASM_OBJECTS_H_ | 6 #define V8_WASM_OBJECTS_H_ |
7 | 7 |
8 #include "src/debug/interface-types.h" | 8 #include "src/debug/interface-types.h" |
9 #include "src/objects-inl.h" | 9 #include "src/objects-inl.h" |
10 #include "src/trap-handler/trap-handler.h" | 10 #include "src/trap-handler/trap-handler.h" |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 uint32_t default_mem_size() const; | 247 uint32_t default_mem_size() const; |
248 | 248 |
249 wasm::WasmModule* module() const; | 249 wasm::WasmModule* module() const; |
250 | 250 |
251 #define DECLARATION(KIND, TYPE, NAME) WCM_##KIND(TYPE, NAME) | 251 #define DECLARATION(KIND, TYPE, NAME) WCM_##KIND(TYPE, NAME) |
252 WCM_PROPERTY_TABLE(DECLARATION) | 252 WCM_PROPERTY_TABLE(DECLARATION) |
253 #undef DECLARATION | 253 #undef DECLARATION |
254 | 254 |
255 static bool IsWasmCompiledModule(Object* obj); | 255 static bool IsWasmCompiledModule(Object* obj); |
256 | 256 |
| 257 // Check whether this module wasm generated from asm.js source. |
| 258 bool is_asm_js() const { return has_asm_js_offset_table(); } |
| 259 |
257 void PrintInstancesChain(); | 260 void PrintInstancesChain(); |
258 | 261 |
259 static void RecreateModuleWrapper(Isolate* isolate, | 262 static void RecreateModuleWrapper(Isolate* isolate, |
260 Handle<FixedArray> compiled_module); | 263 Handle<FixedArray> compiled_module); |
261 | 264 |
262 // Get the function name of the function identified by the given index. | 265 // Get the function name of the function identified by the given index. |
263 // Returns a null handle if the function is unnamed or the name is not a valid | 266 // Returns a null handle if the function is unnamed or the name is not a valid |
264 // UTF-8 string. | 267 // UTF-8 string. |
265 static MaybeHandle<String> GetFunctionName( | 268 static MaybeHandle<String> GetFunctionNameOrNull( |
266 Handle<WasmCompiledModule> compiled_module, uint32_t func_index); | 269 Isolate* isolate, Handle<WasmCompiledModule> compiled_module, |
| 270 uint32_t func_index); |
| 271 |
| 272 // Get the function name of the function identified by the given index. |
| 273 // Returns "<WASM UNNAMED>" if the function is unnamed or the name is not a |
| 274 // valid UTF-8 string. |
| 275 static Handle<String> GetFunctionName( |
| 276 Isolate* isolate, Handle<WasmCompiledModule> compiled_module, |
| 277 uint32_t func_index); |
267 | 278 |
268 // Get the raw bytes of the function name of the function identified by the | 279 // Get the raw bytes of the function name of the function identified by the |
269 // given index. | 280 // given index. |
270 // Meant to be used for debugging or frame printing. | 281 // Meant to be used for debugging or frame printing. |
271 // Does not allocate, hence gc-safe. | 282 // Does not allocate, hence gc-safe. |
272 Vector<const uint8_t> GetRawFunctionName(uint32_t func_index); | 283 Vector<const uint8_t> GetRawFunctionName(uint32_t func_index); |
273 | 284 |
274 // Return the byte offset of the function identified by the given index. | 285 // Return the byte offset of the function identified by the given index. |
275 // The offset will be relative to the start of the module bytes. | 286 // The offset will be relative to the start of the module bytes. |
276 // Returns -1 if the function index is invalid. | 287 // Returns -1 if the function index is invalid. |
(...skipping 15 matching lines...) Expand all Loading... |
292 uint32_t func_index, uint32_t byte_offset, | 303 uint32_t func_index, uint32_t byte_offset, |
293 bool is_at_number_conversion); | 304 bool is_at_number_conversion); |
294 | 305 |
295 // Compute the disassembly of a wasm function. | 306 // Compute the disassembly of a wasm function. |
296 // Returns the disassembly string and a list of <byte_offset, line, column> | 307 // Returns the disassembly string and a list of <byte_offset, line, column> |
297 // entries, mapping wasm byte offsets to line and column in the disassembly. | 308 // entries, mapping wasm byte offsets to line and column in the disassembly. |
298 // The list is guaranteed to be ordered by the byte_offset. | 309 // The list is guaranteed to be ordered by the byte_offset. |
299 // Returns an empty string and empty vector if the function index is invalid. | 310 // Returns an empty string and empty vector if the function index is invalid. |
300 debug::WasmDisassembly DisassembleFunction(int func_index); | 311 debug::WasmDisassembly DisassembleFunction(int func_index); |
301 | 312 |
| 313 // Extract a portion of the wire bytes as UTF-8 string. |
| 314 // Returns a null handle if the respective bytes do not form a valid UTF-8 |
| 315 // string. |
| 316 static MaybeHandle<String> ExtractUtf8StringFromModuleBytes( |
| 317 Isolate* isolate, Handle<WasmCompiledModule> compiled_module, |
| 318 uint32_t offset, uint32_t size); |
| 319 |
302 private: | 320 private: |
303 void InitId(); | 321 void InitId(); |
304 | 322 |
305 DISALLOW_IMPLICIT_CONSTRUCTORS(WasmCompiledModule); | 323 DISALLOW_IMPLICIT_CONSTRUCTORS(WasmCompiledModule); |
306 }; | 324 }; |
307 | 325 |
308 // TODO(clemensh): Extend this object for breakpoint support, or remove it. | 326 // TODO(clemensh): Extend this object for breakpoint support, or remove it. |
309 class WasmDebugInfo : public FixedArray { | 327 class WasmDebugInfo : public FixedArray { |
310 public: | 328 public: |
311 enum class Fields { kFieldCount }; | 329 enum class Fields { kFieldCount }; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 }; | 391 }; |
374 }; | 392 }; |
375 | 393 |
376 #undef DECLARE_ACCESSORS | 394 #undef DECLARE_ACCESSORS |
377 #undef DECLARE_OPTIONAL_ACCESSORS | 395 #undef DECLARE_OPTIONAL_ACCESSORS |
378 | 396 |
379 } // namespace internal | 397 } // namespace internal |
380 } // namespace v8 | 398 } // namespace v8 |
381 | 399 |
382 #endif // V8_WASM_OBJECTS_H_ | 400 #endif // V8_WASM_OBJECTS_H_ |
OLD | NEW |