Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: src/wasm/wasm-objects.h

Issue 2591653002: [wasm] Introduce WasmSharedModuleData and refactor other objects (Closed)
Patch Set: Fix SLOW_DCHECK Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/wasm/wasm-module.cc ('k') | src/wasm/wasm-objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "src/wasm/managed.h" 11 #include "src/wasm/managed.h"
12 12
13 namespace v8 { 13 namespace v8 {
14 namespace internal { 14 namespace internal {
15 namespace wasm { 15 namespace wasm {
16 struct WasmModule; 16 struct WasmModule;
17 } 17 }
18 18
19 class WasmCompiledModule; 19 class WasmCompiledModule;
20 class WasmDebugInfo; 20 class WasmDebugInfo;
21 class WasmInstanceObject; 21 class WasmInstanceObject;
22 class WasmInstanceWrapper; 22 class WasmInstanceWrapper;
23 23
24 #define DECLARE_CASTS(name) \ 24 #define DECLARE_CASTS(name) \
25 static bool Is##name(Object* object); \ 25 static bool Is##name(Object* object); \
26 static name* cast(Object* object) 26 static name* cast(Object* object)
27 27
28 #define DECLARE_GETTER(name, type) type* name()
29
28 #define DECLARE_ACCESSORS(name, type) \ 30 #define DECLARE_ACCESSORS(name, type) \
29 type* get_##name(); \ 31 void set_##name(type* value); \
30 void set_##name(type* value) 32 DECLARE_GETTER(name, type)
31 33
32 #define DECLARE_OPTIONAL_ACCESSORS(name, type) \ 34 #define DECLARE_OPTIONAL_ACCESSORS(name, type) \
33 bool has_##name(); \ 35 bool has_##name(); \
34 type* get_##name(); \ 36 DECLARE_ACCESSORS(name, type)
35 void set_##name(type* value)
36 37
37 // Representation of a WebAssembly.Module JavaScript-level object. 38 // Representation of a WebAssembly.Module JavaScript-level object.
38 class WasmModuleObject : public JSObject { 39 class WasmModuleObject : public JSObject {
39 public: 40 public:
40 // TODO(titzer): add the brand as an internal field instead of a property. 41 // TODO(titzer): add the brand as an internal field instead of a property.
41 enum Fields { kCompiledModule, kFieldCount }; 42 enum Fields { kCompiledModule, kFieldCount };
42 43
43 DECLARE_CASTS(WasmModuleObject); 44 DECLARE_CASTS(WasmModuleObject);
44 45
45 WasmCompiledModule* get_compiled_module(); 46 WasmCompiledModule* compiled_module();
46 47
47 static Handle<WasmModuleObject> New( 48 static Handle<WasmModuleObject> New(
48 Isolate* isolate, Handle<WasmCompiledModule> compiled_module); 49 Isolate* isolate, Handle<WasmCompiledModule> compiled_module);
49 }; 50 };
50 51
51 // Representation of a WebAssembly.Table JavaScript-level object. 52 // Representation of a WebAssembly.Table JavaScript-level object.
52 class WasmTableObject : public JSObject { 53 class WasmTableObject : public JSObject {
53 public: 54 public:
54 // TODO(titzer): add the brand as an internal field instead of a property. 55 // TODO(titzer): add the brand as an internal field instead of a property.
55 enum Fields { kFunctions, kMaximum, kDispatchTables, kFieldCount }; 56 enum Fields { kFunctions, kMaximum, kDispatchTables, kFieldCount };
56 57
57 DECLARE_CASTS(WasmTableObject); 58 DECLARE_CASTS(WasmTableObject);
58 DECLARE_ACCESSORS(functions, FixedArray); 59 DECLARE_ACCESSORS(functions, FixedArray);
59 60
60 FixedArray* get_dispatch_tables(); 61 FixedArray* dispatch_tables();
61 uint32_t current_length(); 62 uint32_t current_length();
62 uint32_t maximum_length(); 63 uint32_t maximum_length();
63 64
64 static Handle<WasmTableObject> New(Isolate* isolate, uint32_t initial, 65 static Handle<WasmTableObject> New(Isolate* isolate, uint32_t initial,
65 uint32_t maximum, 66 uint32_t maximum,
66 Handle<FixedArray>* js_functions); 67 Handle<FixedArray>* js_functions);
67 static bool Grow(Handle<WasmTableObject> table, uint32_t count); 68 static bool Grow(Handle<WasmTableObject> table, uint32_t count);
68 static Handle<FixedArray> AddDispatchTable( 69 static Handle<FixedArray> AddDispatchTable(
69 Isolate* isolate, Handle<WasmTableObject> table, 70 Isolate* isolate, Handle<WasmTableObject> table,
70 Handle<WasmInstanceObject> instance, int table_index, 71 Handle<WasmInstanceObject> instance, int table_index,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 DECLARE_ACCESSORS(compiled_module, WasmCompiledModule); 113 DECLARE_ACCESSORS(compiled_module, WasmCompiledModule);
113 DECLARE_OPTIONAL_ACCESSORS(globals_buffer, JSArrayBuffer); 114 DECLARE_OPTIONAL_ACCESSORS(globals_buffer, JSArrayBuffer);
114 DECLARE_OPTIONAL_ACCESSORS(memory_buffer, JSArrayBuffer); 115 DECLARE_OPTIONAL_ACCESSORS(memory_buffer, JSArrayBuffer);
115 DECLARE_OPTIONAL_ACCESSORS(memory_object, WasmMemoryObject); 116 DECLARE_OPTIONAL_ACCESSORS(memory_object, WasmMemoryObject);
116 DECLARE_OPTIONAL_ACCESSORS(debug_info, WasmDebugInfo); 117 DECLARE_OPTIONAL_ACCESSORS(debug_info, WasmDebugInfo);
117 DECLARE_OPTIONAL_ACCESSORS(instance_wrapper, WasmInstanceWrapper); 118 DECLARE_OPTIONAL_ACCESSORS(instance_wrapper, WasmInstanceWrapper);
118 119
119 WasmModuleObject* module_object(); 120 WasmModuleObject* module_object();
120 wasm::WasmModule* module(); 121 wasm::WasmModule* module();
121 122
123 // Get the debug info associated with the given wasm object.
124 // If no debug info exists yet, it is created automatically.
125 static Handle<WasmDebugInfo> GetOrCreateDebugInfo(
126 Handle<WasmInstanceObject> instance);
127
122 static Handle<WasmInstanceObject> New( 128 static Handle<WasmInstanceObject> New(
123 Isolate* isolate, Handle<WasmCompiledModule> compiled_module); 129 Isolate* isolate, Handle<WasmCompiledModule> compiled_module);
124 }; 130 };
125 131
126 // Representation of an exported WASM function. 132 // Representation of an exported WASM function.
127 class WasmExportedFunction : public JSFunction { 133 class WasmExportedFunction : public JSFunction {
128 public: 134 public:
129 enum Fields { kInstance, kIndex, kFieldCount }; 135 enum Fields { kInstance, kIndex, kFieldCount };
130 136
131 DECLARE_CASTS(WasmExportedFunction); 137 DECLARE_CASTS(WasmExportedFunction);
132 138
133 WasmInstanceObject* instance(); 139 WasmInstanceObject* instance();
134 int function_index(); 140 int function_index();
135 141
136 static Handle<WasmExportedFunction> New(Isolate* isolate, 142 static Handle<WasmExportedFunction> New(Isolate* isolate,
137 Handle<WasmInstanceObject> instance, 143 Handle<WasmInstanceObject> instance,
138 MaybeHandle<String> maybe_name, 144 MaybeHandle<String> maybe_name,
139 int func_index, int arity, 145 int func_index, int arity,
140 Handle<Code> export_wrapper); 146 Handle<Code> export_wrapper);
141 }; 147 };
142 148
149 // Information shared by all WasmCompiledModule objects for the same module.
150 class WasmSharedModuleData : public FixedArray {
151 enum Fields {
152 kModuleWrapper,
153 kModuleBytes,
154 kScript,
155 kAsmJsOffsetTable,
156 kFieldCount
157 };
158
159 public:
160 DECLARE_CASTS(WasmSharedModuleData);
161
162 DECLARE_GETTER(module, wasm::WasmModule);
163 DECLARE_OPTIONAL_ACCESSORS(module_bytes, SeqOneByteString);
164 DECLARE_GETTER(script, Script);
165 DECLARE_OPTIONAL_ACCESSORS(asm_js_offset_table, ByteArray);
166
167 static Handle<WasmSharedModuleData> New(
168 Isolate* isolate, Handle<Foreign> module_wrapper,
169 Handle<SeqOneByteString> module_bytes, Handle<Script> script,
170 Handle<ByteArray> asm_js_offset_table);
171
172 // Check whether this module was generated from asm.js source.
173 bool is_asm_js();
174
175 // Recreate the ModuleWrapper from the module bytes after deserialization.
176 static void RecreateModuleWrapper(Isolate*, Handle<WasmSharedModuleData>);
177 };
178
143 class WasmCompiledModule : public FixedArray { 179 class WasmCompiledModule : public FixedArray {
144 public: 180 public:
145 enum Fields { kFieldCount }; 181 enum Fields { kFieldCount };
146 182
147 static WasmCompiledModule* cast(Object* fixed_array) { 183 static WasmCompiledModule* cast(Object* fixed_array) {
148 SLOW_DCHECK(IsWasmCompiledModule(fixed_array)); 184 SLOW_DCHECK(IsWasmCompiledModule(fixed_array));
149 return reinterpret_cast<WasmCompiledModule*>(fixed_array); 185 return reinterpret_cast<WasmCompiledModule*>(fixed_array);
150 } 186 }
151 187
152 #define WCM_OBJECT_OR_WEAK(TYPE, NAME, ID) \ 188 #define WCM_OBJECT_OR_WEAK(TYPE, NAME, ID, TYPE_CHECK) \
153 Handle<TYPE> NAME() const { return handle(ptr_to_##NAME()); } \ 189 Handle<TYPE> NAME() const { return handle(ptr_to_##NAME()); } \
154 \ 190 \
155 MaybeHandle<TYPE> maybe_##NAME() const { \ 191 MaybeHandle<TYPE> maybe_##NAME() const { \
156 if (has_##NAME()) return NAME(); \ 192 if (has_##NAME()) return NAME(); \
157 return MaybeHandle<TYPE>(); \ 193 return MaybeHandle<TYPE>(); \
158 } \ 194 } \
159 \ 195 \
160 TYPE* maybe_ptr_to_##NAME() const { \ 196 TYPE* maybe_ptr_to_##NAME() const { \
161 Object* obj = get(ID); \ 197 Object* obj = get(ID); \
162 if (!obj->Is##TYPE()) return nullptr; \ 198 if (!(TYPE_CHECK)) return nullptr; \
163 return TYPE::cast(obj); \ 199 return TYPE::cast(obj); \
164 } \ 200 } \
165 \ 201 \
166 TYPE* ptr_to_##NAME() const { \ 202 TYPE* ptr_to_##NAME() const { \
167 Object* obj = get(ID); \ 203 Object* obj = get(ID); \
168 DCHECK(obj->Is##TYPE()); \ 204 DCHECK(TYPE_CHECK); \
169 return TYPE::cast(obj); \ 205 return TYPE::cast(obj); \
170 } \ 206 } \
171 \ 207 \
172 void set_##NAME(Handle<TYPE> value) { set_ptr_to_##NAME(*value); } \ 208 void set_##NAME(Handle<TYPE> value) { set_ptr_to_##NAME(*value); } \
173 \ 209 \
174 void set_ptr_to_##NAME(TYPE* value) { set(ID, value); } \ 210 void set_ptr_to_##NAME(TYPE* value) { set(ID, value); } \
175 \ 211 \
176 bool has_##NAME() const { return get(ID)->Is##TYPE(); } \ 212 bool has_##NAME() const { \
213 Object* obj = get(ID); \
214 return TYPE_CHECK; \
215 } \
177 \ 216 \
178 void reset_##NAME() { set_undefined(ID); } 217 void reset_##NAME() { set_undefined(ID); }
179 218
180 #define WCM_OBJECT(TYPE, NAME) WCM_OBJECT_OR_WEAK(TYPE, NAME, kID_##NAME) 219 #define WCM_OBJECT(TYPE, NAME) \
220 WCM_OBJECT_OR_WEAK(TYPE, NAME, kID_##NAME, obj->Is##TYPE())
221
222 #define WCM_WASM_OBJECT(TYPE, NAME) \
223 WCM_OBJECT_OR_WEAK(TYPE, NAME, kID_##NAME, TYPE::Is##TYPE(obj))
181 224
182 #define WCM_SMALL_NUMBER(TYPE, NAME) \ 225 #define WCM_SMALL_NUMBER(TYPE, NAME) \
183 TYPE NAME() const { \ 226 TYPE NAME() const { \
184 return static_cast<TYPE>(Smi::cast(get(kID_##NAME))->value()); \ 227 return static_cast<TYPE>(Smi::cast(get(kID_##NAME))->value()); \
185 } \ 228 } \
186 void set_##NAME(TYPE value) { set(kID_##NAME, Smi::FromInt(value)); } 229 void set_##NAME(TYPE value) { set(kID_##NAME, Smi::FromInt(value)); }
187 230
188 #define WCM_WEAK_LINK(TYPE, NAME) \ 231 #define WCM_WEAK_LINK(TYPE, NAME) \
189 WCM_OBJECT_OR_WEAK(WeakCell, weak_##NAME, kID_##NAME); \ 232 WCM_OBJECT_OR_WEAK(WeakCell, weak_##NAME, kID_##NAME, obj->IsWeakCell()); \
190 \ 233 \
191 Handle<TYPE> NAME() const { \ 234 Handle<TYPE> NAME() const { \
192 return handle(TYPE::cast(weak_##NAME()->value())); \ 235 return handle(TYPE::cast(weak_##NAME()->value())); \
193 } 236 }
194 237
195 #define CORE_WCM_PROPERTY_TABLE(MACRO) \ 238 #define CORE_WCM_PROPERTY_TABLE(MACRO) \
239 MACRO(WASM_OBJECT, WasmSharedModuleData, shared) \
196 MACRO(OBJECT, FixedArray, code_table) \ 240 MACRO(OBJECT, FixedArray, code_table) \
197 MACRO(OBJECT, Foreign, module_wrapper) \
198 /* For debugging: */ \
199 MACRO(OBJECT, SeqOneByteString, module_bytes) \
200 MACRO(OBJECT, Script, script) \
201 MACRO(OBJECT, ByteArray, asm_js_offset_table) \
202 /* End of debugging stuff */ \
203 MACRO(OBJECT, FixedArray, function_tables) \ 241 MACRO(OBJECT, FixedArray, function_tables) \
204 MACRO(OBJECT, FixedArray, empty_function_tables) \ 242 MACRO(OBJECT, FixedArray, empty_function_tables) \
205 MACRO(OBJECT, JSArrayBuffer, memory) \ 243 MACRO(OBJECT, JSArrayBuffer, memory) \
206 MACRO(SMALL_NUMBER, uint32_t, min_mem_pages) \ 244 MACRO(SMALL_NUMBER, uint32_t, min_mem_pages) \
207 MACRO(SMALL_NUMBER, uint32_t, max_mem_pages) \ 245 MACRO(SMALL_NUMBER, uint32_t, max_mem_pages) \
208 MACRO(WEAK_LINK, WasmCompiledModule, next_instance) \ 246 MACRO(WEAK_LINK, WasmCompiledModule, next_instance) \
209 MACRO(WEAK_LINK, WasmCompiledModule, prev_instance) \ 247 MACRO(WEAK_LINK, WasmCompiledModule, prev_instance) \
210 MACRO(WEAK_LINK, JSObject, owning_instance) \ 248 MACRO(WEAK_LINK, JSObject, owning_instance) \
211 MACRO(WEAK_LINK, JSObject, wasm_module) 249 MACRO(WEAK_LINK, WasmModuleObject, wasm_module)
212 250
213 #if DEBUG 251 #if DEBUG
214 #define DEBUG_ONLY_TABLE(MACRO) MACRO(SMALL_NUMBER, uint32_t, instance_id) 252 #define DEBUG_ONLY_TABLE(MACRO) MACRO(SMALL_NUMBER, uint32_t, instance_id)
215 #else 253 #else
216 #define DEBUG_ONLY_TABLE(IGNORE) 254 #define DEBUG_ONLY_TABLE(IGNORE)
217 uint32_t instance_id() const { return -1; } 255 uint32_t instance_id() const { return -1; }
218 #endif 256 #endif
219 257
220 #define WCM_PROPERTY_TABLE(MACRO) \ 258 #define WCM_PROPERTY_TABLE(MACRO) \
221 CORE_WCM_PROPERTY_TABLE(MACRO) \ 259 CORE_WCM_PROPERTY_TABLE(MACRO) \
222 DEBUG_ONLY_TABLE(MACRO) 260 DEBUG_ONLY_TABLE(MACRO)
223 261
224 private: 262 private:
225 enum PropertyIndices { 263 enum PropertyIndices {
226 #define INDICES(IGNORE1, IGNORE2, NAME) kID_##NAME, 264 #define INDICES(IGNORE1, IGNORE2, NAME) kID_##NAME,
227 WCM_PROPERTY_TABLE(INDICES) Count 265 WCM_PROPERTY_TABLE(INDICES) Count
228 #undef INDICES 266 #undef INDICES
229 }; 267 };
230 268
231 public: 269 public:
232 static Handle<WasmCompiledModule> New( 270 static Handle<WasmCompiledModule> New(Isolate* isolate,
233 Isolate* isolate, Handle<Managed<wasm::WasmModule>> module_wrapper); 271 Handle<WasmSharedModuleData> shared);
234 272
235 static Handle<WasmCompiledModule> Clone(Isolate* isolate, 273 static Handle<WasmCompiledModule> Clone(Isolate* isolate,
236 Handle<WasmCompiledModule> module) { 274 Handle<WasmCompiledModule> module) {
237 Handle<WasmCompiledModule> ret = Handle<WasmCompiledModule>::cast( 275 Handle<WasmCompiledModule> ret = Handle<WasmCompiledModule>::cast(
238 isolate->factory()->CopyFixedArray(module)); 276 isolate->factory()->CopyFixedArray(module));
239 ret->InitId(); 277 ret->InitId();
240 ret->reset_weak_owning_instance(); 278 ret->reset_weak_owning_instance();
241 ret->reset_weak_next_instance(); 279 ret->reset_weak_next_instance();
242 ret->reset_weak_prev_instance(); 280 ret->reset_weak_prev_instance();
243 return ret; 281 return ret;
244 } 282 }
245 283
246 uint32_t mem_size() const; 284 uint32_t mem_size() const;
247 uint32_t default_mem_size() const; 285 uint32_t default_mem_size() const;
248 286
249 wasm::WasmModule* module() const;
250
251 #define DECLARATION(KIND, TYPE, NAME) WCM_##KIND(TYPE, NAME) 287 #define DECLARATION(KIND, TYPE, NAME) WCM_##KIND(TYPE, NAME)
252 WCM_PROPERTY_TABLE(DECLARATION) 288 WCM_PROPERTY_TABLE(DECLARATION)
253 #undef DECLARATION 289 #undef DECLARATION
254 290
291 // Allow to call method on WasmSharedModuleData also on this object.
292 #define FORWARD_SHARED(type, name) \
293 type name() { return shared()->name(); }
294 FORWARD_SHARED(SeqOneByteString*, module_bytes)
295 FORWARD_SHARED(wasm::WasmModule*, module)
296 FORWARD_SHARED(Script*, script)
297 FORWARD_SHARED(bool, is_asm_js)
298 #undef FORWARD_SHARED
299
255 static bool IsWasmCompiledModule(Object* obj); 300 static bool IsWasmCompiledModule(Object* obj);
256 301
257 // Check whether this module wasm generated from asm.js source.
258 bool is_asm_js() const { return has_asm_js_offset_table(); }
259
260 void PrintInstancesChain(); 302 void PrintInstancesChain();
261 303
304 // Recreate the ModuleWrapper from the module bytes after deserialization.
262 static void RecreateModuleWrapper(Isolate* isolate, 305 static void RecreateModuleWrapper(Isolate* isolate,
263 Handle<FixedArray> compiled_module); 306 Handle<WasmCompiledModule> compiled_module);
264 307
265 // Get the function name of the function identified by the given index. 308 // Get the function name of the function identified by the given index.
266 // Returns a null handle if the function is unnamed or the name is not a valid 309 // Returns a null handle if the function is unnamed or the name is not a valid
267 // UTF-8 string. 310 // UTF-8 string.
268 static MaybeHandle<String> GetFunctionNameOrNull( 311 static MaybeHandle<String> GetFunctionNameOrNull(
269 Isolate* isolate, Handle<WasmCompiledModule> compiled_module, 312 Isolate* isolate, Handle<WasmCompiledModule> compiled_module,
270 uint32_t func_index); 313 uint32_t func_index);
271 314
272 // Get the function name of the function identified by the given index. 315 // 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 316 // Returns "<WASM UNNAMED>" if the function is unnamed or the name is not a
274 // valid UTF-8 string. 317 // valid UTF-8 string.
275 static Handle<String> GetFunctionName( 318 static Handle<String> GetFunctionName(
276 Isolate* isolate, Handle<WasmCompiledModule> compiled_module, 319 Isolate* isolate, Handle<WasmCompiledModule> compiled_module,
277 uint32_t func_index); 320 uint32_t func_index);
278 321
279 // Get the raw bytes of the function name of the function identified by the 322 // Get the raw bytes of the function name of the function identified by the
280 // given index. 323 // given index.
281 // Meant to be used for debugging or frame printing. 324 // Meant to be used for debugging or frame printing.
282 // Does not allocate, hence gc-safe. 325 // Does not allocate, hence gc-safe.
283 Vector<const uint8_t> GetRawFunctionName(uint32_t func_index); 326 Vector<const uint8_t> GetRawFunctionName(uint32_t func_index);
284 327
285 // Return the byte offset of the function identified by the given index. 328 // Return the byte offset of the function identified by the given index.
286 // The offset will be relative to the start of the module bytes. 329 // The offset will be relative to the start of the module bytes.
287 // Returns -1 if the function index is invalid. 330 // Returns -1 if the function index is invalid.
288 int GetFunctionOffset(uint32_t func_index) const; 331 int GetFunctionOffset(uint32_t func_index);
289 332
290 // Returns the function containing the given byte offset. 333 // Returns the function containing the given byte offset.
291 // Returns -1 if the byte offset is not contained in any function of this 334 // Returns -1 if the byte offset is not contained in any function of this
292 // module. 335 // module.
293 int GetContainingFunction(uint32_t byte_offset) const; 336 int GetContainingFunction(uint32_t byte_offset);
294 337
295 // Translate from byte offset in the module to function number and byte offset 338 // Translate from byte offset in the module to function number and byte offset
296 // within that function, encoded as line and column in the position info. 339 // within that function, encoded as line and column in the position info.
297 // Returns true if the position is valid inside this module, false otherwise. 340 // Returns true if the position is valid inside this module, false otherwise.
298 bool GetPositionInfo(uint32_t position, Script::PositionInfo* info); 341 bool GetPositionInfo(uint32_t position, Script::PositionInfo* info);
299 342
300 // Get the asm.js source position from a byte offset. 343 // Get the asm.js source position from a byte offset.
301 // Must only be called if the associated wasm object was created from asm.js. 344 // Must only be called if the associated wasm object was created from asm.js.
302 static int GetAsmJsSourcePosition(Handle<WasmCompiledModule> debug_info, 345 static int GetAsmJsSourcePosition(Handle<WasmCompiledModule> compiled_module,
303 uint32_t func_index, uint32_t byte_offset, 346 uint32_t func_index, uint32_t byte_offset,
304 bool is_at_number_conversion); 347 bool is_at_number_conversion);
305 348
306 // Compute the disassembly of a wasm function. 349 // Compute the disassembly of a wasm function.
307 // Returns the disassembly string and a list of <byte_offset, line, column> 350 // Returns the disassembly string and a list of <byte_offset, line, column>
308 // entries, mapping wasm byte offsets to line and column in the disassembly. 351 // entries, mapping wasm byte offsets to line and column in the disassembly.
309 // The list is guaranteed to be ordered by the byte_offset. 352 // The list is guaranteed to be ordered by the byte_offset.
310 // Returns an empty string and empty vector if the function index is invalid. 353 // Returns an empty string and empty vector if the function index is invalid.
311 debug::WasmDisassembly DisassembleFunction(int func_index); 354 debug::WasmDisassembly DisassembleFunction(int func_index);
312 355
313 // Extract a portion of the wire bytes as UTF-8 string. 356 // 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 357 // Returns a null handle if the respective bytes do not form a valid UTF-8
315 // string. 358 // string.
316 static MaybeHandle<String> ExtractUtf8StringFromModuleBytes( 359 static MaybeHandle<String> ExtractUtf8StringFromModuleBytes(
317 Isolate* isolate, Handle<WasmCompiledModule> compiled_module, 360 Isolate* isolate, Handle<WasmCompiledModule> compiled_module,
318 uint32_t offset, uint32_t size); 361 uint32_t offset, uint32_t size);
319 362
320 // Get a list of all possible breakpoints within a given range of this module. 363 // Get a list of all possible breakpoints within a given range of this module.
321 bool GetPossibleBreakpoints(const debug::Location& start, 364 bool GetPossibleBreakpoints(const debug::Location& start,
322 const debug::Location& end, 365 const debug::Location& end,
323 std::vector<debug::Location>* locations) const; 366 std::vector<debug::Location>* locations);
324 367
325 private: 368 private:
326 void InitId(); 369 void InitId();
327 370
328 DISALLOW_IMPLICIT_CONSTRUCTORS(WasmCompiledModule); 371 DISALLOW_IMPLICIT_CONSTRUCTORS(WasmCompiledModule);
329 }; 372 };
330 373
331 // TODO(clemensh): Extend this object for breakpoint support, or remove it. 374 // TODO(clemensh): Extend this object for breakpoint support, or remove it.
375 // TODO(clemensh): Exclude this object from serialization.
332 class WasmDebugInfo : public FixedArray { 376 class WasmDebugInfo : public FixedArray {
377 enum Fields { kInstance, kFieldCount };
378
333 public: 379 public:
334 enum class Fields { kFieldCount }; 380 static Handle<WasmDebugInfo> New(Handle<WasmInstanceObject>);
335 381
336 static Handle<WasmDebugInfo> New(Handle<WasmInstanceObject> instance); 382 static bool IsDebugInfo(Object*);
383 static WasmDebugInfo* cast(Object*);
337 384
338 static bool IsDebugInfo(Object* object); 385 DECLARE_GETTER(wasm_instance, WasmInstanceObject);
339 static WasmDebugInfo* cast(Object* object);
340
341 WasmInstanceObject* wasm_instance();
342 }; 386 };
343 387
344 class WasmInstanceWrapper : public FixedArray { 388 class WasmInstanceWrapper : public FixedArray {
345 public: 389 public:
346 static Handle<WasmInstanceWrapper> New(Isolate* isolate, 390 static Handle<WasmInstanceWrapper> New(Isolate* isolate,
347 Handle<WasmInstanceObject> instance); 391 Handle<WasmInstanceObject> instance);
348 static WasmInstanceWrapper* cast(Object* fixed_array) { 392 static WasmInstanceWrapper* cast(Object* fixed_array) {
349 SLOW_DCHECK(IsWasmInstanceWrapper(fixed_array)); 393 SLOW_DCHECK(IsWasmInstanceWrapper(fixed_array));
350 return reinterpret_cast<WasmInstanceWrapper*>(fixed_array); 394 return reinterpret_cast<WasmInstanceWrapper*>(fixed_array);
351 } 395 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 }; 440 };
397 }; 441 };
398 442
399 #undef DECLARE_ACCESSORS 443 #undef DECLARE_ACCESSORS
400 #undef DECLARE_OPTIONAL_ACCESSORS 444 #undef DECLARE_OPTIONAL_ACCESSORS
401 445
402 } // namespace internal 446 } // namespace internal
403 } // namespace v8 447 } // namespace v8
404 448
405 #endif // V8_WASM_OBJECTS_H_ 449 #endif // V8_WASM_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/wasm/wasm-module.cc ('k') | src/wasm/wasm-objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698