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

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

Issue 2424623002: [wasm] Use a Managed<WasmModule> to hold metadata about modules. (Closed)
Patch Set: [wasm] Use a Managed<WasmModule> to hold metadata about modules. Created 4 years, 2 months 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-js.cc ('k') | src/wasm/wasm-module.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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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_MODULE_H_ 5 #ifndef V8_WASM_MODULE_H_
6 #define V8_WASM_MODULE_H_ 6 #define V8_WASM_MODULE_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "src/api.h" 10 #include "src/api.h"
11 #include "src/globals.h" 11 #include "src/globals.h"
12 #include "src/handles.h" 12 #include "src/handles.h"
13 #include "src/parsing/preparse-data.h" 13 #include "src/parsing/preparse-data.h"
14 14
15 #include "src/wasm/managed.h"
15 #include "src/wasm/signature-map.h" 16 #include "src/wasm/signature-map.h"
16 #include "src/wasm/wasm-opcodes.h" 17 #include "src/wasm/wasm-opcodes.h"
17 18
18 namespace v8 { 19 namespace v8 {
19 namespace internal { 20 namespace internal {
20 21
21 namespace compiler { 22 namespace compiler {
22 class CallDescriptor; 23 class CallDescriptor;
23 class WasmCompilationUnit; 24 class WasmCompilationUnit;
24 } 25 }
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 170
170 class WasmCompiledModule; 171 class WasmCompiledModule;
171 172
172 // Static representation of a module. 173 // Static representation of a module.
173 struct V8_EXPORT_PRIVATE WasmModule { 174 struct V8_EXPORT_PRIVATE WasmModule {
174 static const uint32_t kPageSize = 0x10000; // Page size, 64kb. 175 static const uint32_t kPageSize = 0x10000; // Page size, 64kb.
175 static const uint32_t kMaxLegalPages = 65536; // Maximum legal pages 176 static const uint32_t kMaxLegalPages = 65536; // Maximum legal pages
176 static const uint32_t kMinMemPages = 1; // Minimum memory size = 64kb 177 static const uint32_t kMinMemPages = 1; // Minimum memory size = 64kb
177 static const uint32_t kMaxMemPages = 16384; // Maximum memory size = 1gb 178 static const uint32_t kMaxMemPages = 16384; // Maximum memory size = 1gb
178 179
179 const byte* module_start; // starting address for the module bytes. 180 Zone* owned_zone;
180 const byte* module_end; // end address for the module bytes. 181 const byte* module_start = nullptr; // starting address for the module bytes
181 uint32_t min_mem_pages; // minimum size of the memory in 64k pages. 182 const byte* module_end = nullptr; // end address for the module bytes
182 uint32_t max_mem_pages; // maximum size of the memory in 64k pages. 183 uint32_t min_mem_pages = 0; // minimum size of the memory in 64k pages
183 bool mem_export; // true if the memory is exported. 184 uint32_t max_mem_pages = 0; // maximum size of the memory in 64k pages
185 bool mem_export = false; // true if the memory is exported
184 // TODO(wasm): reconcile start function index being an int with 186 // TODO(wasm): reconcile start function index being an int with
185 // the fact that we index on uint32_t, so we may technically not be 187 // the fact that we index on uint32_t, so we may technically not be
186 // able to represent some start_function_index -es. 188 // able to represent some start_function_index -es.
187 int start_function_index; // start function, if any. 189 int start_function_index = -1; // start function, if any
188 ModuleOrigin origin; // origin of the module 190 ModuleOrigin origin = kWasmOrigin; // origin of the module
189 191
190 std::vector<WasmGlobal> globals; // globals in this module. 192 std::vector<WasmGlobal> globals; // globals in this module.
191 uint32_t globals_size; // size of globals table. 193 uint32_t globals_size = 0; // size of globals table.
192 uint32_t num_imported_functions; // number of imported functions. 194 uint32_t num_imported_functions = 0; // number of imported functions.
193 uint32_t num_declared_functions; // number of declared functions. 195 uint32_t num_declared_functions = 0; // number of declared functions.
194 uint32_t num_exported_functions; // number of exported functions. 196 uint32_t num_exported_functions = 0; // number of exported functions.
195 std::vector<FunctionSig*> signatures; // signatures in this module. 197 std::vector<FunctionSig*> signatures; // signatures in this module.
196 std::vector<WasmFunction> functions; // functions in this module. 198 std::vector<WasmFunction> functions; // functions in this module.
197 std::vector<WasmDataSegment> data_segments; // data segments in this module. 199 std::vector<WasmDataSegment> data_segments; // data segments in this module.
198 std::vector<WasmIndirectFunctionTable> function_tables; // function tables. 200 std::vector<WasmIndirectFunctionTable> function_tables; // function tables.
199 std::vector<WasmImport> import_table; // import table. 201 std::vector<WasmImport> import_table; // import table.
200 std::vector<WasmExport> export_table; // export table. 202 std::vector<WasmExport> export_table; // export table.
201 std::vector<WasmTableInit> table_inits; // initializations of tables 203 std::vector<WasmTableInit> table_inits; // initializations of tables
202 // We store the semaphore here to extend its lifetime. In <libc-2.21, which we 204 // We store the semaphore here to extend its lifetime. In <libc-2.21, which we
203 // use on the try bots, semaphore::Wait() can return while some compilation 205 // use on the try bots, semaphore::Wait() can return while some compilation
204 // tasks are still executing semaphore::Signal(). If the semaphore is cleaned 206 // tasks are still executing semaphore::Signal(). If the semaphore is cleaned
205 // up right after semaphore::Wait() returns, then this can cause an 207 // up right after semaphore::Wait() returns, then this can cause an
206 // invalid-semaphore error in the compilation tasks. 208 // invalid-semaphore error in the compilation tasks.
207 // TODO(wasm): Move this semaphore back to CompileInParallel when the try bots 209 // TODO(wasm): Move this semaphore back to CompileInParallel when the try bots
208 // switch to libc-2.21 or higher. 210 // switch to libc-2.21 or higher.
209 std::unique_ptr<base::Semaphore> pending_tasks; 211 std::unique_ptr<base::Semaphore> pending_tasks;
210 212
211 WasmModule() : WasmModule(nullptr) {} 213 WasmModule() : WasmModule(nullptr, nullptr) {}
212 explicit WasmModule(byte* module_start); 214 WasmModule(Zone* owned_zone, const byte* module_start);
215 ~WasmModule() {
216 if (owned_zone) delete owned_zone;
217 }
213 218
214 // Get a string stored in the module bytes representing a name. 219 // Get a string stored in the module bytes representing a name.
215 WasmName GetName(uint32_t offset, uint32_t length) const { 220 WasmName GetName(uint32_t offset, uint32_t length) const {
216 if (length == 0) return {"<?>", 3}; // no name. 221 if (length == 0) return {"<?>", 3}; // no name.
217 CHECK(BoundsCheck(offset, offset + length)); 222 CHECK(BoundsCheck(offset, offset + length));
218 DCHECK_GE(static_cast<int>(length), 0); 223 DCHECK_GE(static_cast<int>(length), 0);
219 return {reinterpret_cast<const char*>(module_start + offset), 224 return {reinterpret_cast<const char*>(module_start + offset),
220 static_cast<int>(length)}; 225 static_cast<int>(length)};
221 } 226 }
222 227
(...skipping 18 matching lines...) Expand all
241 246
242 // Checks the given offset range is contained within the module bytes. 247 // Checks the given offset range is contained within the module bytes.
243 bool BoundsCheck(uint32_t start, uint32_t end) const { 248 bool BoundsCheck(uint32_t start, uint32_t end) const {
244 size_t size = module_end - module_start; 249 size_t size = module_end - module_start;
245 return start <= size && end <= size; 250 return start <= size && end <= size;
246 } 251 }
247 252
248 // Creates a new instantiation of the module in the given isolate. 253 // Creates a new instantiation of the module in the given isolate.
249 static MaybeHandle<JSObject> Instantiate(Isolate* isolate, 254 static MaybeHandle<JSObject> Instantiate(Isolate* isolate,
250 ErrorThrower* thrower, 255 ErrorThrower* thrower,
251 Handle<JSObject> module_object, 256 Handle<JSObject> wasm_module,
252 Handle<JSReceiver> ffi, 257 Handle<JSReceiver> ffi,
253 Handle<JSArrayBuffer> memory); 258 Handle<JSArrayBuffer> memory);
254 259
255 MaybeHandle<WasmCompiledModule> CompileFunctions(Isolate* isolate, 260 MaybeHandle<WasmCompiledModule> CompileFunctions(
256 ErrorThrower* thrower) const; 261 Isolate* isolate, Handle<Managed<WasmModule>> module_wrapper,
262 ErrorThrower* thrower) const;
263 };
257 264
258 private: 265 typedef Managed<WasmModule> WasmModuleWrapper;
259 DISALLOW_COPY_AND_ASSIGN(WasmModule);
260 };
261 266
262 // An instantiated WASM module, including memory, function table, etc. 267 // An instantiated WASM module, including memory, function table, etc.
263 struct WasmInstance { 268 struct WasmInstance {
264 const WasmModule* module; // static representation of the module. 269 const WasmModule* module; // static representation of the module.
265 // -- Heap allocated -------------------------------------------------------- 270 // -- Heap allocated --------------------------------------------------------
266 Handle<JSObject> js_object; // JavaScript module object. 271 Handle<JSObject> js_object; // JavaScript module object.
267 Handle<Context> context; // JavaScript native context. 272 Handle<Context> context; // JavaScript native context.
268 Handle<JSArrayBuffer> mem_buffer; // Handle to array buffer of memory. 273 Handle<JSArrayBuffer> mem_buffer; // Handle to array buffer of memory.
269 Handle<JSArrayBuffer> globals_buffer; // Handle to array buffer of globals. 274 Handle<JSArrayBuffer> globals_buffer; // Handle to array buffer of globals.
270 std::vector<Handle<FixedArray>> function_tables; // indirect function tables. 275 std::vector<Handle<FixedArray>> function_tables; // indirect function tables.
271 std::vector<Handle<Code>> function_code; // code objects for each function. 276 std::vector<Handle<Code>> function_code; // code objects for each function.
272 // -- raw memory ------------------------------------------------------------ 277 // -- raw memory ------------------------------------------------------------
273 byte* mem_start; // start of linear memory. 278 byte* mem_start = nullptr; // start of linear memory.
274 uint32_t mem_size; // size of the linear memory. 279 uint32_t mem_size = 0; // size of the linear memory.
275 // -- raw globals ----------------------------------------------------------- 280 // -- raw globals -----------------------------------------------------------
276 byte* globals_start; // start of the globals area. 281 byte* globals_start = nullptr; // start of the globals area.
277 282
278 explicit WasmInstance(const WasmModule* m) 283 explicit WasmInstance(const WasmModule* m)
279 : module(m), 284 : module(m),
280 function_tables(m->function_tables.size()), 285 function_tables(m->function_tables.size()),
281 function_code(m->functions.size()), 286 function_code(m->functions.size()) {}
282 mem_start(nullptr),
283 mem_size(0),
284 globals_start(nullptr) {}
285 }; 287 };
286 288
287 // Interface provided to the decoder/graph builder which contains only 289 // Interface provided to the decoder/graph builder which contains only
288 // minimal information about the globals, functions, and function tables. 290 // minimal information about the globals, functions, and function tables.
289 struct V8_EXPORT_PRIVATE ModuleEnv { 291 struct V8_EXPORT_PRIVATE ModuleEnv {
290 const WasmModule* module; 292 const WasmModule* module;
291 WasmInstance* instance; 293 WasmInstance* instance;
292 ModuleOrigin origin; 294 ModuleOrigin origin;
293 295
294 bool IsValidGlobal(uint32_t index) const { 296 bool IsValidGlobal(uint32_t index) const {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 \ 374 \
373 bool has_##NAME() const { return get(ID)->Is##TYPE(); } \ 375 bool has_##NAME() const { return get(ID)->Is##TYPE(); } \
374 \ 376 \
375 void reset_##NAME() { set_undefined(ID); } 377 void reset_##NAME() { set_undefined(ID); }
376 378
377 #define WCM_OBJECT(TYPE, NAME) WCM_OBJECT_OR_WEAK(TYPE, NAME, kID_##NAME) 379 #define WCM_OBJECT(TYPE, NAME) WCM_OBJECT_OR_WEAK(TYPE, NAME, kID_##NAME)
378 380
379 #define WCM_SMALL_NUMBER(TYPE, NAME) \ 381 #define WCM_SMALL_NUMBER(TYPE, NAME) \
380 TYPE NAME() const { \ 382 TYPE NAME() const { \
381 return static_cast<TYPE>(Smi::cast(get(kID_##NAME))->value()); \ 383 return static_cast<TYPE>(Smi::cast(get(kID_##NAME))->value()); \
382 } 384 } \
385 void set_##NAME(TYPE value) { set(kID_##NAME, Smi::FromInt(value)); }
383 386
384 #define WCM_WEAK_LINK(TYPE, NAME) \ 387 #define WCM_WEAK_LINK(TYPE, NAME) \
385 WCM_OBJECT_OR_WEAK(WeakCell, weak_##NAME, kID_##NAME); \ 388 WCM_OBJECT_OR_WEAK(WeakCell, weak_##NAME, kID_##NAME); \
386 \ 389 \
387 Handle<TYPE> NAME() const { \ 390 Handle<TYPE> NAME() const { \
388 return handle(TYPE::cast(weak_##NAME()->value())); \ 391 return handle(TYPE::cast(weak_##NAME()->value())); \
389 } 392 }
390 393
391 #define CORE_WCM_PROPERTY_TABLE(MACRO) \ 394 #define CORE_WCM_PROPERTY_TABLE(MACRO) \
392 MACRO(OBJECT, FixedArray, code_table) \ 395 MACRO(OBJECT, FixedArray, code_table) \
393 MACRO(OBJECT, FixedArray, imports) \ 396 MACRO(OBJECT, Foreign, module_wrapper) \
394 MACRO(OBJECT, FixedArray, exports) \
395 MACRO(OBJECT, FixedArray, inits) \
396 MACRO(OBJECT, FixedArray, startup_function) \
397 MACRO(OBJECT, FixedArray, indirect_function_tables) \
398 MACRO(OBJECT, SeqOneByteString, module_bytes) \ 397 MACRO(OBJECT, SeqOneByteString, module_bytes) \
399 MACRO(OBJECT, ByteArray, function_names) \
400 MACRO(OBJECT, Script, asm_js_script) \ 398 MACRO(OBJECT, Script, asm_js_script) \
399 MACRO(OBJECT, FixedArray, function_tables) \
400 MACRO(OBJECT, FixedArray, empty_function_tables) \
401 MACRO(OBJECT, ByteArray, asm_js_offset_tables) \ 401 MACRO(OBJECT, ByteArray, asm_js_offset_tables) \
402 MACRO(SMALL_NUMBER, uint32_t, min_memory_pages) \ 402 MACRO(OBJECT, JSArrayBuffer, memory) \
403 MACRO(OBJECT, FixedArray, data_segments_info) \ 403 MACRO(SMALL_NUMBER, uint32_t, min_mem_pages) \
404 MACRO(OBJECT, ByteArray, data_segments) \
405 MACRO(SMALL_NUMBER, uint32_t, globals_size) \
406 MACRO(OBJECT, JSArrayBuffer, heap) \
407 MACRO(SMALL_NUMBER, ModuleOrigin, origin) \
408 MACRO(WEAK_LINK, WasmCompiledModule, next_instance) \ 404 MACRO(WEAK_LINK, WasmCompiledModule, next_instance) \
409 MACRO(WEAK_LINK, WasmCompiledModule, prev_instance) \ 405 MACRO(WEAK_LINK, WasmCompiledModule, prev_instance) \
410 MACRO(WEAK_LINK, JSObject, owning_instance) \ 406 MACRO(WEAK_LINK, JSObject, owning_instance) \
411 MACRO(WEAK_LINK, JSObject, module_object) 407 MACRO(WEAK_LINK, JSObject, wasm_module)
412 408
413 #if DEBUG 409 #if DEBUG
414 #define DEBUG_ONLY_TABLE(MACRO) MACRO(SMALL_NUMBER, uint32_t, instance_id) 410 #define DEBUG_ONLY_TABLE(MACRO) MACRO(SMALL_NUMBER, uint32_t, instance_id)
415 #else 411 #else
416 #define DEBUG_ONLY_TABLE(IGNORE) 412 #define DEBUG_ONLY_TABLE(IGNORE)
417 uint32_t instance_id() const { return -1; } 413 uint32_t instance_id() const { return -1; }
418 #endif 414 #endif
419 415
420 #define WCM_PROPERTY_TABLE(MACRO) \ 416 #define WCM_PROPERTY_TABLE(MACRO) \
421 CORE_WCM_PROPERTY_TABLE(MACRO) \ 417 CORE_WCM_PROPERTY_TABLE(MACRO) \
422 DEBUG_ONLY_TABLE(MACRO) 418 DEBUG_ONLY_TABLE(MACRO)
423 419
424 private: 420 private:
425 enum PropertyIndices { 421 enum PropertyIndices {
426 #define INDICES(IGNORE1, IGNORE2, NAME) kID_##NAME, 422 #define INDICES(IGNORE1, IGNORE2, NAME) kID_##NAME,
427 WCM_PROPERTY_TABLE(INDICES) Count 423 WCM_PROPERTY_TABLE(INDICES) Count
428 #undef INDICES 424 #undef INDICES
429 }; 425 };
430 426
431 public: 427 public:
432 static Handle<WasmCompiledModule> New(Isolate* isolate, 428 static Handle<WasmCompiledModule> New(
433 uint32_t min_memory_pages, 429 Isolate* isolate, Handle<Managed<WasmModule>> module_wrapper);
434 uint32_t globals_size,
435 ModuleOrigin origin);
436 430
437 static Handle<WasmCompiledModule> Clone(Isolate* isolate, 431 static Handle<WasmCompiledModule> Clone(Isolate* isolate,
438 Handle<WasmCompiledModule> module) { 432 Handle<WasmCompiledModule> module) {
439 Handle<WasmCompiledModule> ret = Handle<WasmCompiledModule>::cast( 433 Handle<WasmCompiledModule> ret = Handle<WasmCompiledModule>::cast(
440 isolate->factory()->CopyFixedArray(module)); 434 isolate->factory()->CopyFixedArray(module));
441 ret->Init(); 435 ret->InitId();
442 ret->reset_weak_owning_instance(); 436 ret->reset_weak_owning_instance();
443 ret->reset_weak_next_instance(); 437 ret->reset_weak_next_instance();
444 ret->reset_weak_prev_instance(); 438 ret->reset_weak_prev_instance();
445 return ret; 439 return ret;
446 } 440 }
447 441
448 uint32_t mem_size() const { 442 uint32_t mem_size() const {
449 DCHECK(has_heap()); 443 return has_memory() ? memory()->byte_length()->Number()
450 return heap()->byte_length()->Number(); 444 : default_mem_size();
451 } 445 }
452 446
453 uint32_t default_mem_size() const { 447 uint32_t default_mem_size() const {
454 return min_memory_pages() * WasmModule::kPageSize; 448 return min_mem_pages() * WasmModule::kPageSize;
455 } 449 }
456 450
457 #define DECLARATION(KIND, TYPE, NAME) WCM_##KIND(TYPE, NAME) 451 #define DECLARATION(KIND, TYPE, NAME) WCM_##KIND(TYPE, NAME)
458 WCM_PROPERTY_TABLE(DECLARATION) 452 WCM_PROPERTY_TABLE(DECLARATION)
459 #undef DECLARATION 453 #undef DECLARATION
460 454
461 static bool IsWasmCompiledModule(Object* obj); 455 static bool IsWasmCompiledModule(Object* obj);
462 456
463 void PrintInstancesChain(); 457 void PrintInstancesChain();
464 458
459 static void RecreateModuleWrapper(Isolate* isolate,
460 Handle<FixedArray> compiled_module);
461
465 private: 462 private:
466 void Init(); 463 void InitId();
467 464
468 DISALLOW_IMPLICIT_CONSTRUCTORS(WasmCompiledModule); 465 DISALLOW_IMPLICIT_CONSTRUCTORS(WasmCompiledModule);
469 }; 466 };
470 467
471 // Extract a function name from the given wasm object. 468 // Extract a function name from the given wasm object.
472 // Returns "<WASM UNNAMED>" if the function is unnamed or the name is not a 469 // Returns "<WASM UNNAMED>" if the function is unnamed or the name is not a
473 // valid UTF-8 string. 470 // valid UTF-8 string.
474 Handle<String> GetWasmFunctionName(Isolate* isolate, Handle<Object> wasm, 471 Handle<String> GetWasmFunctionName(Isolate* isolate, Handle<Object> wasm,
475 uint32_t func_index); 472 uint32_t func_index);
476 473
477 // Extract a function name from the given wasm object. 474 // Extract a function name from the given wasm object.
478 // Returns a null handle if the function is unnamed or the name is not a valid 475 // Returns a null handle if the function is unnamed or the name is not a valid
479 // UTF-8 string. 476 // UTF-8 string.
480 Handle<Object> GetWasmFunctionNameOrNull(Isolate* isolate, Handle<Object> wasm, 477 Handle<Object> GetWasmFunctionNameOrNull(Isolate* isolate, Handle<Object> wasm,
481 uint32_t func_index); 478 uint32_t func_index);
482 479
483 // Return the binary source bytes of a wasm module. 480 // Return the binary source bytes of a wasm module.
484 Handle<SeqOneByteString> GetWasmBytes(Handle<JSObject> wasm); 481 Handle<SeqOneByteString> GetWasmBytes(Handle<JSObject> wasm);
485 482
486 // Get the debug info associated with the given wasm object. 483 // Get the debug info associated with the given wasm object.
487 // If no debug info exists yet, it is created automatically. 484 // If no debug info exists yet, it is created automatically.
488 Handle<WasmDebugInfo> GetDebugInfo(Handle<JSObject> wasm); 485 Handle<WasmDebugInfo> GetDebugInfo(Handle<JSObject> wasm);
489 486
490 // Return the number of functions in the given wasm object. 487 // Return the number of functions in the given wasm object.
491 int GetNumberOfFunctions(Handle<JSObject> wasm); 488 int GetNumberOfFunctions(Handle<JSObject> wasm);
492 489
493 // Create and export JSFunction 490 // Create and export JSFunction
494 Handle<JSFunction> WrapExportCodeAsJSFunction(Isolate* isolate, 491 Handle<JSFunction> WrapExportCodeAsJSFunction(Isolate* isolate,
495 Handle<Code> export_code, 492 Handle<Code> export_code,
496 Handle<String> name, int arity, 493 Handle<String> name,
497 MaybeHandle<ByteArray> signature, 494 FunctionSig* sig, int func_index,
498 Handle<JSObject> instance); 495 Handle<JSObject> instance);
499 496
500 // Check whether the given object is a wasm object. 497 // Check whether the given object represents a WebAssembly.Instance instance.
501 // This checks the number and type of internal fields, so it's not 100 percent 498 // This checks the number and type of internal fields, so it's not 100 percent
502 // secure. If it turns out that we need more complete checks, we could add a 499 // secure. If it turns out that we need more complete checks, we could add a
503 // special marker as internal field, which will definitely never occur anywhere 500 // special marker as internal field, which will definitely never occur anywhere
504 // else. 501 // else.
505 bool IsWasmInstance(Object* object); 502 bool IsWasmInstance(Object* instance);
506 503
507 // Return the compiled module object for this wasm object. 504 // Return the compiled module object for this WASM instance.
508 WasmCompiledModule* GetCompiledModule(JSObject* instance); 505 WasmCompiledModule* GetCompiledModule(Object* wasm_instance);
509 506
510 // Check whether the wasm module was generated from asm.js code. 507 // Check whether the wasm module was generated from asm.js code.
511 bool WasmIsAsmJs(Object* instance, Isolate* isolate); 508 bool WasmIsAsmJs(Object* instance, Isolate* isolate);
512 509
513 // Get the script for the asm.js origin of the wasm module. 510 // Get the script for the asm.js origin of the wasm module.
514 Handle<Script> GetAsmWasmScript(Handle<JSObject> instance); 511 Handle<Script> GetAsmWasmScript(Handle<JSObject> instance);
515 512
516 // Get the asm.js source position for the given byte offset in the given 513 // Get the asm.js source position for the given byte offset in the given
517 // function. 514 // function.
518 int GetAsmWasmSourcePosition(Handle<JSObject> instance, int func_index, 515 int GetAsmWasmSourcePosition(Handle<JSObject> instance, int func_index,
519 int byte_offset); 516 int byte_offset);
520 517
521 // Constructs a single function table as a FixedArray of double size, 518 // Constructs a single function table as a FixedArray of double size,
522 // populating it with function signature indices and function indices. 519 // populating it with function signature indices and function indices.
523 Handle<FixedArray> BuildFunctionTable(Isolate* isolate, uint32_t index, 520 Handle<FixedArray> BuildFunctionTable(Isolate* isolate, uint32_t index,
524 const WasmModule* module); 521 const WasmModule* module);
525 522
526 // Populates a function table by replacing function indices with handles to 523 // Populates a function table by replacing function indices with handles to
527 // the compiled code. 524 // the compiled code.
528 void PopulateFunctionTable(Handle<FixedArray> table, uint32_t table_size, 525 void PopulateFunctionTable(Handle<FixedArray> table, uint32_t table_size,
529 const std::vector<Handle<Code>>* code_table); 526 const std::vector<Handle<Code>>* code_table);
530 527
531 Handle<JSObject> CreateCompiledModuleObject( 528 Handle<JSObject> CreateWasmModuleObject(
532 Isolate* isolate, Handle<WasmCompiledModule> compiled_module, 529 Isolate* isolate, Handle<WasmCompiledModule> compiled_module,
533 ModuleOrigin origin); 530 ModuleOrigin origin);
534 531
535 V8_EXPORT_PRIVATE MaybeHandle<JSObject> CreateModuleObjectFromBytes( 532 V8_EXPORT_PRIVATE MaybeHandle<JSObject> CreateModuleObjectFromBytes(
536 Isolate* isolate, const byte* start, const byte* end, ErrorThrower* thrower, 533 Isolate* isolate, const byte* start, const byte* end, ErrorThrower* thrower,
537 ModuleOrigin origin, Handle<Script> asm_js_script, 534 ModuleOrigin origin, Handle<Script> asm_js_script,
538 const byte* asm_offset_tables_start, const byte* asm_offset_tables_end); 535 const byte* asm_offset_tables_start, const byte* asm_offset_tables_end);
539 536
540 V8_EXPORT_PRIVATE bool ValidateModuleBytes(Isolate* isolate, const byte* start, 537 V8_EXPORT_PRIVATE bool ValidateModuleBytes(Isolate* isolate, const byte* start,
541 const byte* end, 538 const byte* end,
(...skipping 11 matching lines...) Expand all
553 MaybeHandle<JSArrayBuffer> GetInstanceMemory(Isolate* isolate, 550 MaybeHandle<JSArrayBuffer> GetInstanceMemory(Isolate* isolate,
554 Handle<JSObject> instance); 551 Handle<JSObject> instance);
555 552
556 int32_t GetInstanceMemorySize(Isolate* isolate, Handle<JSObject> instance); 553 int32_t GetInstanceMemorySize(Isolate* isolate, Handle<JSObject> instance);
557 554
558 int32_t GrowInstanceMemory(Isolate* isolate, Handle<JSObject> instance, 555 int32_t GrowInstanceMemory(Isolate* isolate, Handle<JSObject> instance,
559 uint32_t pages); 556 uint32_t pages);
560 557
561 namespace testing { 558 namespace testing {
562 559
563 void ValidateInstancesChain(Isolate* isolate, Handle<JSObject> module_obj, 560 void ValidateInstancesChain(Isolate* isolate, Handle<JSObject> wasm_module,
564 int instance_count); 561 int instance_count);
565 void ValidateModuleState(Isolate* isolate, Handle<JSObject> module_obj); 562 void ValidateModuleState(Isolate* isolate, Handle<JSObject> wasm_module);
566 void ValidateOrphanedInstance(Isolate* isolate, Handle<JSObject> instance); 563 void ValidateOrphanedInstance(Isolate* isolate, Handle<JSObject> instance);
567 564
568 } // namespace testing 565 } // namespace testing
569 } // namespace wasm 566 } // namespace wasm
570 } // namespace internal 567 } // namespace internal
571 } // namespace v8 568 } // namespace v8
572 569
573 #endif // V8_WASM_MODULE_H_ 570 #endif // V8_WASM_MODULE_H_
OLDNEW
« no previous file with comments | « src/wasm/wasm-js.cc ('k') | src/wasm/wasm-module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698