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

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

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

Powered by Google App Engine
This is Rietveld 408576698