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