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 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 CHECK(ret_count >= 0); | 641 CHECK(ret_count >= 0); |
642 Handle<ByteArray> sig_data = data->GetValueChecked<ByteArray>(kSignature); | 642 Handle<ByteArray> sig_data = data->GetValueChecked<ByteArray>(kSignature); |
643 int sig_data_size = sig_data->length(); | 643 int sig_data_size = sig_data->length(); |
644 int param_count = sig_data_size - ret_count; | 644 int param_count = sig_data_size - ret_count; |
645 CHECK(param_count >= 0); | 645 CHECK(param_count >= 0); |
646 | 646 |
647 MaybeHandle<JSFunction> function = LookupFunction( | 647 MaybeHandle<JSFunction> function = LookupFunction( |
648 *thrower, isolate->factory(), ffi, index, module_name, function_name); | 648 *thrower, isolate->factory(), ffi, index, module_name, function_name); |
649 if (function.is_null()) return false; | 649 if (function.is_null()) return false; |
650 | 650 |
651 FunctionSig sig( | 651 { |
652 ret_count, param_count, | 652 // Copy the signature to avoid a raw pointer into a heap object when |
653 reinterpret_cast<const MachineRepresentation*>(sig_data->data())); | 653 // GC can happen. |
| 654 Zone zone(isolate->allocator()); |
| 655 MachineRepresentation* reps = |
| 656 zone.NewArray<MachineRepresentation>(sig_data_size); |
| 657 memcpy(reps, sig_data->data(), |
| 658 sizeof(MachineRepresentation) * sig_data_size); |
| 659 FunctionSig sig(ret_count, param_count, reps); |
654 | 660 |
655 Handle<Code> code = compiler::CompileWasmToJSWrapper( | 661 Handle<Code> code = compiler::CompileWasmToJSWrapper( |
656 isolate, function.ToHandleChecked(), &sig, index, module_name, | 662 isolate, function.ToHandleChecked(), &sig, index, module_name, |
657 function_name); | 663 function_name); |
658 | 664 |
659 imports.push_back(code); | 665 imports.push_back(code); |
| 666 } |
660 } | 667 } |
661 } | 668 } |
662 return true; | 669 return true; |
663 } | 670 } |
664 | 671 |
665 void InitializeParallelCompilation( | 672 void InitializeParallelCompilation( |
666 Isolate* isolate, const std::vector<WasmFunction>& functions, | 673 Isolate* isolate, const std::vector<WasmFunction>& functions, |
667 std::vector<compiler::WasmCompilationUnit*>& compilation_units, | 674 std::vector<compiler::WasmCompilationUnit*>& compilation_units, |
668 ModuleEnv& module_env, ErrorThrower& thrower) { | 675 ModuleEnv& module_env, ErrorThrower& thrower) { |
669 for (uint32_t i = FLAG_skip_compiling_wasm_funcs; i < functions.size(); ++i) { | 676 for (uint32_t i = FLAG_skip_compiling_wasm_funcs; i < functions.size(); ++i) { |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1386 return static_cast<int32_t>(HeapNumber::cast(*result)->value()); | 1393 return static_cast<int32_t>(HeapNumber::cast(*result)->value()); |
1387 } | 1394 } |
1388 thrower.Error("WASM.compileRun() failed: Return value should be number"); | 1395 thrower.Error("WASM.compileRun() failed: Return value should be number"); |
1389 return -1; | 1396 return -1; |
1390 } | 1397 } |
1391 | 1398 |
1392 } // namespace testing | 1399 } // namespace testing |
1393 } // namespace wasm | 1400 } // namespace wasm |
1394 } // namespace internal | 1401 } // namespace internal |
1395 } // namespace v8 | 1402 } // namespace v8 |
OLD | NEW |