OLD | NEW |
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 #include "src/base/atomic-utils.h" | 5 #include "src/base/atomic-utils.h" |
6 #include "src/macro-assembler.h" | 6 #include "src/macro-assembler.h" |
7 #include "src/objects.h" | 7 #include "src/objects.h" |
8 #include "src/property-descriptor.h" | 8 #include "src/property-descriptor.h" |
9 #include "src/v8.h" | 9 #include "src/v8.h" |
10 | 10 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 } | 135 } |
136 return function_code_[index]; | 136 return function_code_[index]; |
137 } | 137 } |
138 | 138 |
139 void Finish(uint32_t index, Handle<Code> code) { | 139 void Finish(uint32_t index, Handle<Code> code) { |
140 DCHECK(index < function_code_.size()); | 140 DCHECK(index < function_code_.size()); |
141 function_code_[index] = code; | 141 function_code_[index] = code; |
142 } | 142 } |
143 | 143 |
144 void Link(Handle<FixedArray> function_table, | 144 void Link(Handle<FixedArray> function_table, |
145 std::vector<uint16_t>& functions) { | 145 const std::vector<uint16_t>& functions) { |
146 for (size_t i = 0; i < function_code_.size(); i++) { | 146 for (size_t i = 0; i < function_code_.size(); i++) { |
147 LinkFunction(function_code_[i]); | 147 LinkFunction(function_code_[i]); |
148 } | 148 } |
149 if (!function_table.is_null()) { | 149 if (!function_table.is_null()) { |
150 int table_size = static_cast<int>(functions.size()); | 150 int table_size = static_cast<int>(functions.size()); |
151 DCHECK_EQ(function_table->length(), table_size * 2); | 151 DCHECK_EQ(function_table->length(), table_size * 2); |
152 for (int i = 0; i < table_size; i++) { | 152 for (int i = 0; i < table_size; i++) { |
153 function_table->set(i + table_size, *function_code_[functions[i]]); | 153 function_table->set(i + table_size, *function_code_[functions[i]]); |
154 } | 154 } |
155 } | 155 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 | 196 |
197 namespace { | 197 namespace { |
198 // Internal constants for the layout of the module object. | 198 // Internal constants for the layout of the module object. |
199 const int kWasmModuleInternalFieldCount = 5; | 199 const int kWasmModuleInternalFieldCount = 5; |
200 const int kWasmModuleFunctionTable = 0; | 200 const int kWasmModuleFunctionTable = 0; |
201 const int kWasmModuleCodeTable = 1; | 201 const int kWasmModuleCodeTable = 1; |
202 const int kWasmMemArrayBuffer = 2; | 202 const int kWasmMemArrayBuffer = 2; |
203 const int kWasmGlobalsArrayBuffer = 3; | 203 const int kWasmGlobalsArrayBuffer = 3; |
204 const int kWasmFunctionNamesArray = 4; | 204 const int kWasmFunctionNamesArray = 4; |
205 | 205 |
206 size_t AllocateGlobalsOffsets(std::vector<WasmGlobal>& globals) { | 206 void LoadDataSegments(const WasmModule* module, byte* mem_addr, |
207 uint32_t offset = 0; | 207 size_t mem_size) { |
208 if (globals.size() == 0) return 0; | |
209 for (WasmGlobal& global : globals) { | |
210 byte size = WasmOpcodes::MemSize(global.type); | |
211 offset = (offset + size - 1) & ~(size - 1); // align | |
212 global.offset = offset; | |
213 offset += size; | |
214 } | |
215 return offset; | |
216 } | |
217 | |
218 void LoadDataSegments(WasmModule* module, byte* mem_addr, size_t mem_size) { | |
219 for (const WasmDataSegment& segment : module->data_segments) { | 208 for (const WasmDataSegment& segment : module->data_segments) { |
220 if (!segment.init) continue; | 209 if (!segment.init) continue; |
221 if (!segment.source_size) continue; | 210 if (!segment.source_size) continue; |
222 CHECK_LT(segment.dest_addr, mem_size); | 211 CHECK_LT(segment.dest_addr, mem_size); |
223 CHECK_LE(segment.source_size, mem_size); | 212 CHECK_LE(segment.source_size, mem_size); |
224 CHECK_LE(segment.dest_addr + segment.source_size, mem_size); | 213 CHECK_LE(segment.dest_addr + segment.source_size, mem_size); |
225 byte* addr = mem_addr + segment.dest_addr; | 214 byte* addr = mem_addr + segment.dest_addr; |
226 memcpy(addr, module->module_start + segment.source_offset, | 215 memcpy(addr, module->module_start + segment.source_offset, |
227 segment.source_size); | 216 segment.source_size); |
228 } | 217 } |
229 } | 218 } |
230 | 219 |
231 Handle<FixedArray> BuildFunctionTable(Isolate* isolate, WasmModule* module) { | 220 Handle<FixedArray> BuildFunctionTable(Isolate* isolate, |
| 221 const WasmModule* module) { |
232 if (module->function_table.size() == 0) { | 222 if (module->function_table.size() == 0) { |
233 return Handle<FixedArray>::null(); | 223 return Handle<FixedArray>::null(); |
234 } | 224 } |
235 int table_size = static_cast<int>(module->function_table.size()); | 225 int table_size = static_cast<int>(module->function_table.size()); |
236 Handle<FixedArray> fixed = isolate->factory()->NewFixedArray(2 * table_size); | 226 Handle<FixedArray> fixed = isolate->factory()->NewFixedArray(2 * table_size); |
237 for (int i = 0; i < table_size; i++) { | 227 for (int i = 0; i < table_size; i++) { |
238 WasmFunction* function = &module->functions[module->function_table[i]]; | 228 const WasmFunction* function = |
| 229 &module->functions[module->function_table[i]]; |
239 fixed->set(i, Smi::FromInt(function->sig_index)); | 230 fixed->set(i, Smi::FromInt(function->sig_index)); |
240 } | 231 } |
241 return fixed; | 232 return fixed; |
242 } | 233 } |
243 | 234 |
244 Handle<JSArrayBuffer> NewArrayBuffer(Isolate* isolate, size_t size, | 235 Handle<JSArrayBuffer> NewArrayBuffer(Isolate* isolate, size_t size, |
245 byte** backing_store) { | 236 byte** backing_store) { |
246 if (size > (WasmModule::kMaxMemPages * WasmModule::kPageSize)) { | 237 if (size > (WasmModule::kMaxMemPages * WasmModule::kPageSize)) { |
247 // TODO(titzer): lift restriction on maximum memory allocated here. | 238 // TODO(titzer): lift restriction on maximum memory allocated here. |
248 *backing_store = nullptr; | 239 *backing_store = nullptr; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 if (!instance->mem_start) { | 286 if (!instance->mem_start) { |
296 thrower->Error("Out of memory: wasm memory"); | 287 thrower->Error("Out of memory: wasm memory"); |
297 instance->mem_size = 0; | 288 instance->mem_size = 0; |
298 return false; | 289 return false; |
299 } | 290 } |
300 return true; | 291 return true; |
301 } | 292 } |
302 | 293 |
303 bool AllocateGlobals(ErrorThrower* thrower, Isolate* isolate, | 294 bool AllocateGlobals(ErrorThrower* thrower, Isolate* isolate, |
304 WasmModuleInstance* instance) { | 295 WasmModuleInstance* instance) { |
305 instance->globals_size = AllocateGlobalsOffsets(instance->module->globals); | 296 uint32_t globals_size = instance->module->globals_size; |
306 | 297 if (globals_size > 0) { |
307 if (instance->globals_size > 0) { | 298 instance->globals_buffer = |
308 instance->globals_buffer = NewArrayBuffer(isolate, instance->globals_size, | 299 NewArrayBuffer(isolate, globals_size, &instance->globals_start); |
309 &instance->globals_start); | |
310 if (!instance->globals_start) { | 300 if (!instance->globals_start) { |
311 // Not enough space for backing store of globals. | 301 // Not enough space for backing store of globals. |
312 thrower->Error("Out of memory: wasm globals"); | 302 thrower->Error("Out of memory: wasm globals"); |
313 return false; | 303 return false; |
314 } | 304 } |
315 } | 305 } |
316 return true; | 306 return true; |
317 } | 307 } |
318 } // namespace | 308 } // namespace |
319 | 309 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 base::Mutex* result_mutex_; | 440 base::Mutex* result_mutex_; |
451 base::AtomicNumber<size_t>* next_unit_; | 441 base::AtomicNumber<size_t>* next_unit_; |
452 }; | 442 }; |
453 | 443 |
454 void record_code_size(uint32_t& total_code_size, Code* code) { | 444 void record_code_size(uint32_t& total_code_size, Code* code) { |
455 if (FLAG_print_wasm_code_size) { | 445 if (FLAG_print_wasm_code_size) { |
456 total_code_size += code->body_size() + code->relocation_info()->length(); | 446 total_code_size += code->body_size() + code->relocation_info()->length(); |
457 } | 447 } |
458 } | 448 } |
459 | 449 |
460 bool CompileWrappersToImportedFunctions(Isolate* isolate, WasmModule* module, | 450 bool CompileWrappersToImportedFunctions( |
461 const Handle<JSReceiver> ffi, | 451 Isolate* isolate, const WasmModule* module, const Handle<JSReceiver> ffi, |
462 WasmModuleInstance* instance, | 452 WasmModuleInstance* instance, ErrorThrower* thrower, Factory* factory, |
463 ErrorThrower* thrower, Factory* factory, | 453 ModuleEnv* module_env, uint32_t& total_code_size) { |
464 ModuleEnv* module_env, | |
465 uint32_t& total_code_size) { | |
466 uint32_t index = 0; | 454 uint32_t index = 0; |
467 if (module->import_table.size() > 0) { | 455 if (module->import_table.size() > 0) { |
468 instance->import_code.reserve(module->import_table.size()); | 456 instance->import_code.reserve(module->import_table.size()); |
469 for (const WasmImport& import : module->import_table) { | 457 for (const WasmImport& import : module->import_table) { |
470 WasmName module_name = module->GetNameOrNull(import.module_name_offset, | 458 WasmName module_name = module->GetNameOrNull(import.module_name_offset, |
471 import.module_name_length); | 459 import.module_name_length); |
472 WasmName function_name = module->GetNameOrNull( | 460 WasmName function_name = module->GetNameOrNull( |
473 import.function_name_offset, import.function_name_length); | 461 import.function_name_offset, import.function_name_length); |
474 MaybeHandle<JSFunction> function = LookupFunction( | 462 MaybeHandle<JSFunction> function = LookupFunction( |
475 *thrower, factory, ffi, index, module_name, function_name); | 463 *thrower, factory, ffi, index, module_name, function_name); |
476 if (function.is_null()) return false; | 464 if (function.is_null()) return false; |
477 | 465 |
478 Handle<Code> code = compiler::CompileWasmToJSWrapper( | 466 Handle<Code> code = compiler::CompileWasmToJSWrapper( |
479 isolate, module_env, function.ToHandleChecked(), import.sig, | 467 isolate, module_env, function.ToHandleChecked(), import.sig, |
480 module_name, function_name); | 468 module_name, function_name); |
481 instance->import_code.push_back(code); | 469 instance->import_code.push_back(code); |
482 record_code_size(total_code_size, *code); | 470 record_code_size(total_code_size, *code); |
483 index++; | 471 index++; |
484 } | 472 } |
485 } | 473 } |
486 return true; | 474 return true; |
487 } | 475 } |
488 | 476 |
489 void InitializeParallelCompilation( | 477 void InitializeParallelCompilation( |
490 Isolate* isolate, std::vector<WasmFunction>& functions, | 478 Isolate* isolate, const std::vector<WasmFunction>& functions, |
491 std::vector<compiler::WasmCompilationUnit*>& compilation_units, | 479 std::vector<compiler::WasmCompilationUnit*>& compilation_units, |
492 ModuleEnv& module_env, ErrorThrower& thrower) { | 480 ModuleEnv& module_env, ErrorThrower& thrower) { |
493 // Create a placeholder code object for all functions. | 481 // Create a placeholder code object for all functions. |
494 // TODO(ahaas): Maybe we could skip this for external functions. | 482 // TODO(ahaas): Maybe we could skip this for external functions. |
495 for (uint32_t i = 0; i < functions.size(); i++) { | 483 for (uint32_t i = 0; i < functions.size(); i++) { |
496 module_env.linker->GetFunctionCode(i); | 484 module_env.linker->GetFunctionCode(i); |
497 } | 485 } |
498 | 486 |
499 for (uint32_t i = FLAG_skip_compiling_wasm_funcs; i < functions.size(); i++) { | 487 for (uint32_t i = FLAG_skip_compiling_wasm_funcs; i < functions.size(); i++) { |
500 compilation_units[i] = new compiler::WasmCompilationUnit( | 488 compilation_units[i] = new compiler::WasmCompilationUnit( |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 for (size_t i = 0; i < num_tasks; i++) { | 520 for (size_t i = 0; i < num_tasks; i++) { |
533 // If the task has not started yet, then we abort it. Otherwise we wait for | 521 // If the task has not started yet, then we abort it. Otherwise we wait for |
534 // it to finish. | 522 // it to finish. |
535 if (!isolate->cancelable_task_manager()->TryAbort(task_ids[i])) { | 523 if (!isolate->cancelable_task_manager()->TryAbort(task_ids[i])) { |
536 pending_tasks->Wait(); | 524 pending_tasks->Wait(); |
537 } | 525 } |
538 } | 526 } |
539 } | 527 } |
540 | 528 |
541 void FinishCompilationUnits( | 529 void FinishCompilationUnits( |
542 WasmModule* module, | |
543 std::queue<compiler::WasmCompilationUnit*>& executed_units, | 530 std::queue<compiler::WasmCompilationUnit*>& executed_units, |
544 std::vector<Handle<Code>>& results, base::Mutex& result_mutex) { | 531 std::vector<Handle<Code>>& results, base::Mutex& result_mutex) { |
545 while (true) { | 532 while (true) { |
546 compiler::WasmCompilationUnit* unit = nullptr; | 533 compiler::WasmCompilationUnit* unit = nullptr; |
547 { | 534 { |
548 base::LockGuard<base::Mutex> guard(&result_mutex); | 535 base::LockGuard<base::Mutex> guard(&result_mutex); |
549 if (executed_units.empty()) { | 536 if (executed_units.empty()) { |
550 break; | 537 break; |
551 } | 538 } |
552 unit = executed_units.front(); | 539 unit = executed_units.front(); |
553 executed_units.pop(); | 540 executed_units.pop(); |
554 } | 541 } |
555 int j = unit->index(); | 542 int j = unit->index(); |
556 results[j] = unit->FinishCompilation(); | 543 results[j] = unit->FinishCompilation(); |
557 delete unit; | 544 delete unit; |
558 } | 545 } |
559 } | 546 } |
560 | 547 |
561 bool FinishCompilation(Isolate* isolate, WasmModule* module, | 548 bool FinishCompilation(Isolate* isolate, const WasmModule* module, |
562 const Handle<JSReceiver> ffi, | 549 const Handle<JSReceiver> ffi, |
563 const std::vector<Handle<Code>>& results, | 550 const std::vector<Handle<Code>>& results, |
564 const WasmModuleInstance& instance, | 551 const WasmModuleInstance& instance, |
565 const Handle<FixedArray>& code_table, | 552 const Handle<FixedArray>& code_table, |
566 ErrorThrower& thrower, Factory* factory, | 553 ErrorThrower& thrower, Factory* factory, |
567 ModuleEnv& module_env, uint32_t& total_code_size, | 554 ModuleEnv& module_env, uint32_t& total_code_size, |
568 PropertyDescriptor& desc) { | 555 PropertyDescriptor& desc) { |
569 for (uint32_t i = FLAG_skip_compiling_wasm_funcs; | 556 for (uint32_t i = FLAG_skip_compiling_wasm_funcs; |
570 i < module->functions.size(); i++) { | 557 i < module->functions.size(); i++) { |
571 const WasmFunction& func = module->functions[i]; | 558 const WasmFunction& func = module->functions[i]; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 } | 600 } |
614 return true; | 601 return true; |
615 } | 602 } |
616 } // namespace | 603 } // namespace |
617 | 604 |
618 // Instantiates a wasm module as a JSObject. | 605 // Instantiates a wasm module as a JSObject. |
619 // * allocates a backing store of {mem_size} bytes. | 606 // * allocates a backing store of {mem_size} bytes. |
620 // * installs a named property "memory" for that buffer if exported | 607 // * installs a named property "memory" for that buffer if exported |
621 // * installs named properties on the object for exported functions | 608 // * installs named properties on the object for exported functions |
622 // * compiles wasm code to machine code | 609 // * compiles wasm code to machine code |
623 MaybeHandle<JSObject> WasmModule::Instantiate(Isolate* isolate, | 610 MaybeHandle<JSObject> WasmModule::Instantiate( |
624 Handle<JSReceiver> ffi, | 611 Isolate* isolate, Handle<JSReceiver> ffi, |
625 Handle<JSArrayBuffer> memory) { | 612 Handle<JSArrayBuffer> memory) const { |
626 HistogramTimerScope wasm_instantiate_module_time_scope( | 613 HistogramTimerScope wasm_instantiate_module_time_scope( |
627 isolate->counters()->wasm_instantiate_module_time()); | 614 isolate->counters()->wasm_instantiate_module_time()); |
628 ErrorThrower thrower(isolate, "WasmModule::Instantiate()"); | 615 ErrorThrower thrower(isolate, "WasmModule::Instantiate()"); |
629 Factory* factory = isolate->factory(); | 616 Factory* factory = isolate->factory(); |
630 | 617 |
631 PropertyDescriptor desc; | 618 PropertyDescriptor desc; |
632 desc.set_writable(false); | 619 desc.set_writable(false); |
633 | 620 |
634 // If FLAG_print_wasm_code_size is set, this aggregates the sum of all code | 621 // If FLAG_print_wasm_code_size is set, this aggregates the sum of all code |
635 // objects created for this module. | 622 // objects created for this module. |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 // unit at a time and execute the parallel phase of the compilation | 739 // unit at a time and execute the parallel phase of the compilation |
753 // unit. After finishing the execution of the parallel phase, the | 740 // unit. After finishing the execution of the parallel phase, the |
754 // result is enqueued in {executed_units}. | 741 // result is enqueued in {executed_units}. |
755 while (FetchAndExecuteCompilationUnit(isolate, &compilation_units, | 742 while (FetchAndExecuteCompilationUnit(isolate, &compilation_units, |
756 &executed_units, &result_mutex, | 743 &executed_units, &result_mutex, |
757 &next_unit)) { | 744 &next_unit)) { |
758 // 3.b) If {executed_units} contains a compilation unit, the main thread | 745 // 3.b) If {executed_units} contains a compilation unit, the main thread |
759 // dequeues it and finishes the compilation unit. Compilation units | 746 // dequeues it and finishes the compilation unit. Compilation units |
760 // are finished concurrently to the background threads to save | 747 // are finished concurrently to the background threads to save |
761 // memory. | 748 // memory. |
762 FinishCompilationUnits(this, executed_units, results, result_mutex); | 749 FinishCompilationUnits(executed_units, results, result_mutex); |
763 } | 750 } |
764 // 4) After the parallel phase of all compilation units has started, the | 751 // 4) After the parallel phase of all compilation units has started, the |
765 // main thread waits for all {WasmCompilationTask} instances to finish. | 752 // main thread waits for all {WasmCompilationTask} instances to finish. |
766 WaitForCompilationTasks(isolate, task_ids.get(), pending_tasks); | 753 WaitForCompilationTasks(isolate, task_ids.get(), pending_tasks); |
767 // Finish the compilation of the remaining compilation units. | 754 // Finish the compilation of the remaining compilation units. |
768 FinishCompilationUnits(this, executed_units, results, result_mutex); | 755 FinishCompilationUnits(executed_units, results, result_mutex); |
769 } | 756 } |
770 // 5) The main thread finishes the compilation. | 757 // 5) The main thread finishes the compilation. |
771 if (!FinishCompilation(isolate, this, ffi, results, instance, code_table, | 758 if (!FinishCompilation(isolate, this, ffi, results, instance, code_table, |
772 thrower, factory, module_env, total_code_size, | 759 thrower, factory, module_env, total_code_size, |
773 desc)) { | 760 desc)) { |
774 instance.js_object = Handle<JSObject>::null(); | 761 instance.js_object = Handle<JSObject>::null(); |
775 } | 762 } |
776 | 763 |
777 // Patch all direct call sites. | 764 // Patch all direct call sites. |
778 linker.Link(instance.function_table, this->function_table); | 765 linker.Link(instance.function_table, this->function_table); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 Handle<Code> ModuleEnv::GetImportCode(uint32_t index) { | 847 Handle<Code> ModuleEnv::GetImportCode(uint32_t index) { |
861 DCHECK(IsValidImport(index)); | 848 DCHECK(IsValidImport(index)); |
862 return instance ? instance->import_code[index] : Handle<Code>::null(); | 849 return instance ? instance->import_code[index] : Handle<Code>::null(); |
863 } | 850 } |
864 | 851 |
865 compiler::CallDescriptor* ModuleEnv::GetCallDescriptor(Zone* zone, | 852 compiler::CallDescriptor* ModuleEnv::GetCallDescriptor(Zone* zone, |
866 uint32_t index) { | 853 uint32_t index) { |
867 DCHECK(IsValidFunction(index)); | 854 DCHECK(IsValidFunction(index)); |
868 // Always make a direct call to whatever is in the table at that location. | 855 // Always make a direct call to whatever is in the table at that location. |
869 // A wrapper will be generated for FFI calls. | 856 // A wrapper will be generated for FFI calls. |
870 WasmFunction* function = &module->functions[index]; | 857 const WasmFunction* function = &module->functions[index]; |
871 return GetWasmCallDescriptor(zone, function->sig); | 858 return GetWasmCallDescriptor(zone, function->sig); |
872 } | 859 } |
873 | 860 |
874 int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start, | 861 int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start, |
875 const byte* module_end, bool asm_js) { | 862 const byte* module_end, bool asm_js) { |
876 HandleScope scope(isolate); | 863 HandleScope scope(isolate); |
877 Zone zone(isolate->allocator()); | 864 Zone zone(isolate->allocator()); |
878 // Decode the module, but don't verify function bodies, since we'll | 865 // Decode the module, but don't verify function bodies, since we'll |
879 // be compiling them anyway. | 866 // be compiling them anyway. |
880 ModuleResult result = DecodeWasmModule(isolate, &zone, module_start, | 867 ModuleResult result = DecodeWasmModule(isolate, &zone, module_start, |
881 module_end, false, kWasmOrigin); | 868 module_end, false, kWasmOrigin); |
882 if (result.failed()) { | 869 if (result.failed()) { |
883 if (result.val) { | 870 if (result.val) { |
884 delete result.val; | 871 delete result.val; |
885 } | 872 } |
886 // Module verification failed. throw. | 873 // Module verification failed. throw. |
887 std::ostringstream str; | 874 std::ostringstream str; |
888 str << "WASM.compileRun() failed: " << result; | 875 str << "WASM.compileRun() failed: " << result; |
889 isolate->Throw( | 876 isolate->Throw( |
890 *isolate->factory()->NewStringFromAsciiChecked(str.str().c_str())); | 877 *isolate->factory()->NewStringFromAsciiChecked(str.str().c_str())); |
891 return -1; | 878 return -1; |
892 } | 879 } |
893 | 880 |
894 int32_t retval = CompileAndRunWasmModule(isolate, result.val); | 881 int32_t retval = CompileAndRunWasmModule(isolate, result.val); |
895 delete result.val; | 882 delete result.val; |
896 return retval; | 883 return retval; |
897 } | 884 } |
898 | 885 |
899 int32_t CompileAndRunWasmModule(Isolate* isolate, WasmModule* module) { | 886 int32_t CompileAndRunWasmModule(Isolate* isolate, const WasmModule* module) { |
900 ErrorThrower thrower(isolate, "CompileAndRunWasmModule"); | 887 ErrorThrower thrower(isolate, "CompileAndRunWasmModule"); |
901 WasmModuleInstance instance(module); | 888 WasmModuleInstance instance(module); |
902 | 889 |
903 // Allocate and initialize the linear memory. | 890 // Allocate and initialize the linear memory. |
904 if (!AllocateMemory(&thrower, isolate, &instance)) { | 891 if (!AllocateMemory(&thrower, isolate, &instance)) { |
905 return -1; | 892 return -1; |
906 } | 893 } |
907 LoadDataSegments(module, instance.mem_start, instance.mem_size); | 894 LoadDataSegments(module, instance.mem_start, instance.mem_size); |
908 | 895 |
909 // Allocate the globals area if necessary. | 896 // Allocate the globals area if necessary. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
980 uint32_t func_index) { | 967 uint32_t func_index) { |
981 Object* func_names_arr_obj = wasm->GetInternalField(kWasmFunctionNamesArray); | 968 Object* func_names_arr_obj = wasm->GetInternalField(kWasmFunctionNamesArray); |
982 if (func_names_arr_obj->IsUndefined()) return Handle<String>::null(); | 969 if (func_names_arr_obj->IsUndefined()) return Handle<String>::null(); |
983 return GetWasmFunctionNameFromTable( | 970 return GetWasmFunctionNameFromTable( |
984 handle(ByteArray::cast(func_names_arr_obj)), func_index); | 971 handle(ByteArray::cast(func_names_arr_obj)), func_index); |
985 } | 972 } |
986 | 973 |
987 } // namespace wasm | 974 } // namespace wasm |
988 } // namespace internal | 975 } // namespace internal |
989 } // namespace v8 | 976 } // namespace v8 |
OLD | NEW |