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/objects-inl.h" | 8 #include "src/objects-inl.h" |
9 #include "src/wasm/managed.h" | 9 #include "src/wasm/managed.h" |
10 | 10 |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 Handle<TYPE> NAME() const { \ | 191 Handle<TYPE> NAME() const { \ |
192 return handle(TYPE::cast(weak_##NAME()->value())); \ | 192 return handle(TYPE::cast(weak_##NAME()->value())); \ |
193 } | 193 } |
194 | 194 |
195 #define CORE_WCM_PROPERTY_TABLE(MACRO) \ | 195 #define CORE_WCM_PROPERTY_TABLE(MACRO) \ |
196 MACRO(OBJECT, FixedArray, code_table) \ | 196 MACRO(OBJECT, FixedArray, code_table) \ |
197 MACRO(OBJECT, Foreign, module_wrapper) \ | 197 MACRO(OBJECT, Foreign, module_wrapper) \ |
198 /* For debugging: */ \ | 198 /* For debugging: */ \ |
199 MACRO(OBJECT, SeqOneByteString, module_bytes) \ | 199 MACRO(OBJECT, SeqOneByteString, module_bytes) \ |
200 MACRO(OBJECT, Script, script) \ | 200 MACRO(OBJECT, Script, script) \ |
201 MACRO(OBJECT, ByteArray, asm_js_offset_tables) \ | 201 MACRO(OBJECT, ByteArray, asm_js_offset_table) \ |
202 /* End of debugging stuff */ \ | 202 /* End of debugging stuff */ \ |
203 MACRO(OBJECT, FixedArray, function_tables) \ | 203 MACRO(OBJECT, FixedArray, function_tables) \ |
204 MACRO(OBJECT, FixedArray, empty_function_tables) \ | 204 MACRO(OBJECT, FixedArray, empty_function_tables) \ |
205 MACRO(OBJECT, JSArrayBuffer, memory) \ | 205 MACRO(OBJECT, JSArrayBuffer, memory) \ |
206 MACRO(SMALL_NUMBER, uint32_t, min_mem_pages) \ | 206 MACRO(SMALL_NUMBER, uint32_t, min_mem_pages) \ |
207 MACRO(SMALL_NUMBER, uint32_t, max_mem_pages) \ | 207 MACRO(SMALL_NUMBER, uint32_t, max_mem_pages) \ |
208 MACRO(WEAK_LINK, WasmCompiledModule, next_instance) \ | 208 MACRO(WEAK_LINK, WasmCompiledModule, next_instance) \ |
209 MACRO(WEAK_LINK, WasmCompiledModule, prev_instance) \ | 209 MACRO(WEAK_LINK, WasmCompiledModule, prev_instance) \ |
210 MACRO(WEAK_LINK, JSObject, owning_instance) \ | 210 MACRO(WEAK_LINK, JSObject, owning_instance) \ |
211 MACRO(WEAK_LINK, JSObject, wasm_module) | 211 MACRO(WEAK_LINK, JSObject, wasm_module) |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 // Returns the function containing the given byte offset. | 279 // Returns the function containing the given byte offset. |
280 // Returns -1 if the byte offset is not contained in any function of this | 280 // Returns -1 if the byte offset is not contained in any function of this |
281 // module. | 281 // module. |
282 int GetContainingFunction(uint32_t byte_offset) const; | 282 int GetContainingFunction(uint32_t byte_offset) const; |
283 | 283 |
284 // Translate from byte offset in the module to function number and byte offset | 284 // Translate from byte offset in the module to function number and byte offset |
285 // within that function, encoded as line and column in the position info. | 285 // within that function, encoded as line and column in the position info. |
286 // Returns true if the position is valid inside this module, false otherwise. | 286 // Returns true if the position is valid inside this module, false otherwise. |
287 bool GetPositionInfo(uint32_t position, Script::PositionInfo* info); | 287 bool GetPositionInfo(uint32_t position, Script::PositionInfo* info); |
288 | 288 |
| 289 // Get the asm.js source position from a byte offset. |
| 290 // Must only be called if the associated wasm object was created from asm.js. |
| 291 static int GetAsmJsSourcePosition(Handle<WasmCompiledModule> debug_info, |
| 292 uint32_t func_index, uint32_t byte_offset); |
| 293 |
289 private: | 294 private: |
290 void InitId(); | 295 void InitId(); |
291 | 296 |
292 DISALLOW_IMPLICIT_CONSTRUCTORS(WasmCompiledModule); | 297 DISALLOW_IMPLICIT_CONSTRUCTORS(WasmCompiledModule); |
293 }; | 298 }; |
294 | 299 |
| 300 // TODO(clemensh): Extend this object for breakpoint support, or remove it. |
295 class WasmDebugInfo : public FixedArray { | 301 class WasmDebugInfo : public FixedArray { |
296 public: | 302 public: |
297 enum class Fields { kFieldCount }; | 303 enum class Fields { kFieldCount }; |
298 | 304 |
299 static Handle<WasmDebugInfo> New(Handle<WasmInstanceObject> instance); | 305 static Handle<WasmDebugInfo> New(Handle<WasmInstanceObject> instance); |
300 | 306 |
301 static bool IsDebugInfo(Object* object); | 307 static bool IsDebugInfo(Object* object); |
302 static WasmDebugInfo* cast(Object* object); | 308 static WasmDebugInfo* cast(Object* object); |
303 | 309 |
304 WasmInstanceObject* wasm_instance(); | 310 WasmInstanceObject* wasm_instance(); |
305 | |
306 bool SetBreakPoint(int byte_offset); | |
307 | |
308 // Get the Script for the specified function. | |
309 static Script* GetFunctionScript(Handle<WasmDebugInfo> debug_info, | |
310 int func_index); | |
311 | |
312 // Disassemble the specified function from this module. | |
313 static Handle<String> DisassembleFunction(Handle<WasmDebugInfo> debug_info, | |
314 int func_index); | |
315 | |
316 // Get the offset table for the specified function, mapping from byte offsets | |
317 // to position in the disassembly. | |
318 // Returns an array with three entries per instruction: byte offset, line and | |
319 // column. | |
320 static Handle<FixedArray> GetFunctionOffsetTable( | |
321 Handle<WasmDebugInfo> debug_info, int func_index); | |
322 | |
323 // Get the asm.js source position from a byte offset. | |
324 // Must only be called if the associated wasm object was created from asm.js. | |
325 static int GetAsmJsSourcePosition(Handle<WasmDebugInfo> debug_info, | |
326 int func_index, int byte_offset); | |
327 }; | 311 }; |
328 | 312 |
329 #undef DECLARE_ACCESSORS | 313 #undef DECLARE_ACCESSORS |
330 #undef DECLARE_OPTIONAL_ACCESSORS | 314 #undef DECLARE_OPTIONAL_ACCESSORS |
331 | 315 |
332 } // namespace internal | 316 } // namespace internal |
333 } // namespace v8 | 317 } // namespace v8 |
334 | 318 |
335 #endif // V8_WASM_OBJECTS_H_ | 319 #endif // V8_WASM_OBJECTS_H_ |
OLD | NEW |