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/debug.h" |
8 #include "src/debug/interface-types.h" | 9 #include "src/debug/interface-types.h" |
9 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
10 #include "src/trap-handler/trap-handler.h" | 11 #include "src/trap-handler/trap-handler.h" |
11 #include "src/wasm/managed.h" | 12 #include "src/wasm/managed.h" |
12 #include "src/wasm/wasm-limits.h" | 13 #include "src/wasm/wasm-limits.h" |
13 | 14 |
14 namespace v8 { | 15 namespace v8 { |
15 namespace internal { | 16 namespace internal { |
16 namespace wasm { | 17 namespace wasm { |
17 struct WasmModule; | 18 struct WasmModule; |
(...skipping 11 matching lines...) Expand all Loading... |
29 #define DECLARE_GETTER(name, type) type* name() | 30 #define DECLARE_GETTER(name, type) type* name() |
30 | 31 |
31 #define DECLARE_ACCESSORS(name, type) \ | 32 #define DECLARE_ACCESSORS(name, type) \ |
32 void set_##name(type* value); \ | 33 void set_##name(type* value); \ |
33 DECLARE_GETTER(name, type) | 34 DECLARE_GETTER(name, type) |
34 | 35 |
35 #define DECLARE_OPTIONAL_ACCESSORS(name, type) \ | 36 #define DECLARE_OPTIONAL_ACCESSORS(name, type) \ |
36 bool has_##name(); \ | 37 bool has_##name(); \ |
37 DECLARE_ACCESSORS(name, type) | 38 DECLARE_ACCESSORS(name, type) |
38 | 39 |
| 40 #define DECLARE_OPTIONAL_GETTER(name, type) \ |
| 41 bool has_##name(); \ |
| 42 DECLARE_GETTER(name, type) |
| 43 |
39 // Representation of a WebAssembly.Module JavaScript-level object. | 44 // Representation of a WebAssembly.Module JavaScript-level object. |
40 class WasmModuleObject : public JSObject { | 45 class WasmModuleObject : public JSObject { |
41 public: | 46 public: |
42 // TODO(titzer): add the brand as an internal field instead of a property. | 47 // TODO(titzer): add the brand as an internal field instead of a property. |
43 enum Fields { kCompiledModule, kFieldCount }; | 48 enum Fields { kCompiledModule, kFieldCount }; |
44 | 49 |
45 DECLARE_CASTS(WasmModuleObject); | 50 DECLARE_CASTS(WasmModuleObject); |
46 | 51 |
47 WasmCompiledModule* compiled_module(); | 52 WasmCompiledModule* compiled_module(); |
48 | 53 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 Handle<Code> export_wrapper); | 156 Handle<Code> export_wrapper); |
152 }; | 157 }; |
153 | 158 |
154 // Information shared by all WasmCompiledModule objects for the same module. | 159 // Information shared by all WasmCompiledModule objects for the same module. |
155 class WasmSharedModuleData : public FixedArray { | 160 class WasmSharedModuleData : public FixedArray { |
156 enum Fields { | 161 enum Fields { |
157 kModuleWrapper, | 162 kModuleWrapper, |
158 kModuleBytes, | 163 kModuleBytes, |
159 kScript, | 164 kScript, |
160 kAsmJsOffsetTable, | 165 kAsmJsOffsetTable, |
| 166 kBreakPointInfos, |
161 kFieldCount | 167 kFieldCount |
162 }; | 168 }; |
163 | 169 |
164 public: | 170 public: |
165 DECLARE_CASTS(WasmSharedModuleData); | 171 DECLARE_CASTS(WasmSharedModuleData); |
166 | 172 |
167 DECLARE_GETTER(module, wasm::WasmModule); | 173 DECLARE_GETTER(module, wasm::WasmModule); |
168 DECLARE_OPTIONAL_ACCESSORS(module_bytes, SeqOneByteString); | 174 DECLARE_OPTIONAL_ACCESSORS(module_bytes, SeqOneByteString); |
169 DECLARE_GETTER(script, Script); | 175 DECLARE_GETTER(script, Script); |
170 DECLARE_OPTIONAL_ACCESSORS(asm_js_offset_table, ByteArray); | 176 DECLARE_OPTIONAL_ACCESSORS(asm_js_offset_table, ByteArray); |
| 177 DECLARE_OPTIONAL_GETTER(breakpoint_infos, FixedArray); |
171 | 178 |
172 static Handle<WasmSharedModuleData> New( | 179 static Handle<WasmSharedModuleData> New( |
173 Isolate* isolate, Handle<Foreign> module_wrapper, | 180 Isolate* isolate, Handle<Foreign> module_wrapper, |
174 Handle<SeqOneByteString> module_bytes, Handle<Script> script, | 181 Handle<SeqOneByteString> module_bytes, Handle<Script> script, |
175 Handle<ByteArray> asm_js_offset_table); | 182 Handle<ByteArray> asm_js_offset_table); |
176 | 183 |
177 // Check whether this module was generated from asm.js source. | 184 // Check whether this module was generated from asm.js source. |
178 bool is_asm_js(); | 185 bool is_asm_js(); |
179 | 186 |
180 // Recreate the ModuleWrapper from the module bytes after deserialization. | 187 // Recreate the ModuleWrapper from the module bytes after deserialization. |
181 static void RecreateModuleWrapper(Isolate*, Handle<WasmSharedModuleData>); | 188 static void RecreateModuleWrapper(Isolate*, Handle<WasmSharedModuleData>); |
| 189 |
| 190 static void AddBreakpoint(Handle<WasmSharedModuleData>, int position, |
| 191 Handle<Object> break_point_object); |
| 192 |
| 193 static void SetBreakpointsOnNewInstance(Handle<WasmSharedModuleData>, |
| 194 Handle<WasmInstanceObject>); |
182 }; | 195 }; |
183 | 196 |
184 class WasmCompiledModule : public FixedArray { | 197 class WasmCompiledModule : public FixedArray { |
185 public: | 198 public: |
186 enum Fields { kFieldCount }; | 199 enum Fields { kFieldCount }; |
187 | 200 |
188 static WasmCompiledModule* cast(Object* fixed_array) { | 201 static WasmCompiledModule* cast(Object* fixed_array) { |
189 SLOW_DCHECK(IsWasmCompiledModule(fixed_array)); | 202 SLOW_DCHECK(IsWasmCompiledModule(fixed_array)); |
190 return reinterpret_cast<WasmCompiledModule*>(fixed_array); | 203 return reinterpret_cast<WasmCompiledModule*>(fixed_array); |
191 } | 204 } |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 // string. | 380 // string. |
368 static MaybeHandle<String> ExtractUtf8StringFromModuleBytes( | 381 static MaybeHandle<String> ExtractUtf8StringFromModuleBytes( |
369 Isolate* isolate, Handle<WasmCompiledModule> compiled_module, | 382 Isolate* isolate, Handle<WasmCompiledModule> compiled_module, |
370 uint32_t offset, uint32_t size); | 383 uint32_t offset, uint32_t size); |
371 | 384 |
372 // Get a list of all possible breakpoints within a given range of this module. | 385 // Get a list of all possible breakpoints within a given range of this module. |
373 bool GetPossibleBreakpoints(const debug::Location& start, | 386 bool GetPossibleBreakpoints(const debug::Location& start, |
374 const debug::Location& end, | 387 const debug::Location& end, |
375 std::vector<debug::Location>* locations); | 388 std::vector<debug::Location>* locations); |
376 | 389 |
| 390 // Set a breakpoint on the given byte position inside the given module. |
| 391 // This will affect all live and future instances of the module. |
| 392 // The passed position might be modified to point to the next breakable |
| 393 // location inside the same function. |
| 394 // If it points outside a function, or behind the last breakable location, |
| 395 // this function returns false and does not set any breakpoint. |
| 396 static bool SetBreakPoint(Handle<WasmCompiledModule>, int* position, |
| 397 Handle<Object> break_point_object); |
| 398 |
377 private: | 399 private: |
378 void InitId(); | 400 void InitId(); |
379 | 401 |
380 DISALLOW_IMPLICIT_CONSTRUCTORS(WasmCompiledModule); | 402 DISALLOW_IMPLICIT_CONSTRUCTORS(WasmCompiledModule); |
381 }; | 403 }; |
382 | 404 |
383 class WasmDebugInfo : public FixedArray { | 405 class WasmDebugInfo : public FixedArray { |
384 public: | 406 public: |
385 enum Fields { | 407 enum Fields { |
386 kInstance, | 408 kInstance, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 }; | 479 }; |
458 }; | 480 }; |
459 | 481 |
460 #undef DECLARE_ACCESSORS | 482 #undef DECLARE_ACCESSORS |
461 #undef DECLARE_OPTIONAL_ACCESSORS | 483 #undef DECLARE_OPTIONAL_ACCESSORS |
462 | 484 |
463 } // namespace internal | 485 } // namespace internal |
464 } // namespace v8 | 486 } // namespace v8 |
465 | 487 |
466 #endif // V8_WASM_OBJECTS_H_ | 488 #endif // V8_WASM_OBJECTS_H_ |
OLD | NEW |