| 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "src/base/atomic-utils.h" | 7 #include "src/base/atomic-utils.h" |
| 8 #include "src/macro-assembler.h" | 8 #include "src/macro-assembler.h" |
| 9 #include "src/objects.h" | 9 #include "src/objects.h" |
| 10 #include "src/property-descriptor.h" | 10 #include "src/property-descriptor.h" |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 function_name_handle->length(), | 448 function_name_handle->length(), |
| 449 function_name_handle->ToCString().get(), error); | 449 function_name_handle->ToCString().get(), error); |
| 450 } else { | 450 } else { |
| 451 thrower.Error("Import #%d module=\"%.*s\" error: %s", index, | 451 thrower.Error("Import #%d module=\"%.*s\" error: %s", index, |
| 452 module_name->length(), module_name->ToCString().get(), error); | 452 module_name->length(), module_name->ToCString().get(), error); |
| 453 } | 453 } |
| 454 thrower.Error("Import "); | 454 thrower.Error("Import "); |
| 455 return MaybeHandle<JSFunction>(); | 455 return MaybeHandle<JSFunction>(); |
| 456 } | 456 } |
| 457 | 457 |
| 458 static MaybeHandle<JSFunction> LookupFunction( | 458 static MaybeHandle<JSReceiver> LookupFunction( |
| 459 ErrorThrower& thrower, Factory* factory, Handle<JSReceiver> ffi, | 459 ErrorThrower& thrower, Factory* factory, Handle<JSReceiver> ffi, |
| 460 uint32_t index, Handle<String> module_name, | 460 uint32_t index, Handle<String> module_name, |
| 461 MaybeHandle<String> function_name) { | 461 MaybeHandle<String> function_name) { |
| 462 if (ffi.is_null()) { | 462 if (ffi.is_null()) { |
| 463 return ReportFFIError(thrower, "FFI is not an object", index, module_name, | 463 return ReportFFIError(thrower, "FFI is not an object", index, module_name, |
| 464 function_name); | 464 function_name); |
| 465 } | 465 } |
| 466 | 466 |
| 467 // Look up the module first. | 467 // Look up the module first. |
| 468 MaybeHandle<Object> result = Object::GetProperty(ffi, module_name); | 468 MaybeHandle<Object> result = Object::GetProperty(ffi, module_name); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 486 if (result.is_null()) { | 486 if (result.is_null()) { |
| 487 return ReportFFIError(thrower, "function not found", index, module_name, | 487 return ReportFFIError(thrower, "function not found", index, module_name, |
| 488 function_name); | 488 function_name); |
| 489 } | 489 } |
| 490 function = result.ToHandleChecked(); | 490 function = result.ToHandleChecked(); |
| 491 } else { | 491 } else { |
| 492 // No function specified. Use the "default export". | 492 // No function specified. Use the "default export". |
| 493 function = module; | 493 function = module; |
| 494 } | 494 } |
| 495 | 495 |
| 496 if (!function->IsJSFunction()) { | 496 if (!function->IsCallable()) { |
| 497 return ReportFFIError(thrower, "not a function", index, module_name, | 497 return ReportFFIError(thrower, "not a callable", index, module_name, |
| 498 function_name); | 498 function_name); |
| 499 } | 499 } |
| 500 | 500 |
| 501 return Handle<JSFunction>::cast(function); | 501 return Handle<JSReceiver>::cast(function); |
| 502 } | 502 } |
| 503 | 503 |
| 504 namespace { | 504 namespace { |
| 505 // Fetches the compilation unit of a wasm function and executes its parallel | 505 // Fetches the compilation unit of a wasm function and executes its parallel |
| 506 // phase. | 506 // phase. |
| 507 bool FetchAndExecuteCompilationUnit( | 507 bool FetchAndExecuteCompilationUnit( |
| 508 Isolate* isolate, | 508 Isolate* isolate, |
| 509 std::vector<compiler::WasmCompilationUnit*>* compilation_units, | 509 std::vector<compiler::WasmCompilationUnit*>* compilation_units, |
| 510 std::queue<compiler::WasmCompilationUnit*>* executed_units, | 510 std::queue<compiler::WasmCompilationUnit*>* executed_units, |
| 511 base::Mutex* result_mutex, base::AtomicNumber<size_t>* next_unit) { | 511 base::Mutex* result_mutex, base::AtomicNumber<size_t>* next_unit) { |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 // TODO(mtrofin): this is an uint32_t, actually. We should rationalize | 638 // TODO(mtrofin): this is an uint32_t, actually. We should rationalize |
| 639 // it when we rationalize signed/unsigned stuff. | 639 // it when we rationalize signed/unsigned stuff. |
| 640 int ret_count = Smi::cast(data->get(kOutputCount))->value(); | 640 int ret_count = Smi::cast(data->get(kOutputCount))->value(); |
| 641 CHECK(ret_count >= 0); | 641 CHECK(ret_count >= 0); |
| 642 Handle<ByteArray> sig_data = | 642 Handle<ByteArray> sig_data = |
| 643 data->GetValueChecked<ByteArray>(isolate, kSignature); | 643 data->GetValueChecked<ByteArray>(isolate, kSignature); |
| 644 int sig_data_size = sig_data->length(); | 644 int sig_data_size = sig_data->length(); |
| 645 int param_count = sig_data_size - ret_count; | 645 int param_count = sig_data_size - ret_count; |
| 646 CHECK(param_count >= 0); | 646 CHECK(param_count >= 0); |
| 647 | 647 |
| 648 MaybeHandle<JSFunction> function = LookupFunction( | 648 MaybeHandle<JSReceiver> function = LookupFunction( |
| 649 *thrower, isolate->factory(), ffi, index, module_name, function_name); | 649 *thrower, isolate->factory(), ffi, index, module_name, function_name); |
| 650 if (function.is_null()) return false; | 650 if (function.is_null()) return false; |
| 651 | 651 |
| 652 { | 652 { |
| 653 // Copy the signature to avoid a raw pointer into a heap object when | 653 // Copy the signature to avoid a raw pointer into a heap object when |
| 654 // GC can happen. | 654 // GC can happen. |
| 655 Zone zone(isolate->allocator()); | 655 Zone zone(isolate->allocator()); |
| 656 MachineRepresentation* reps = | 656 MachineRepresentation* reps = |
| 657 zone.NewArray<MachineRepresentation>(sig_data_size); | 657 zone.NewArray<MachineRepresentation>(sig_data_size); |
| 658 memcpy(reps, sig_data->data(), | 658 memcpy(reps, sig_data->data(), |
| (...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1586 return static_cast<int32_t>(HeapNumber::cast(*result)->value()); | 1586 return static_cast<int32_t>(HeapNumber::cast(*result)->value()); |
| 1587 } | 1587 } |
| 1588 thrower.Error("WASM.compileRun() failed: Return value should be number"); | 1588 thrower.Error("WASM.compileRun() failed: Return value should be number"); |
| 1589 return -1; | 1589 return -1; |
| 1590 } | 1590 } |
| 1591 | 1591 |
| 1592 } // namespace testing | 1592 } // namespace testing |
| 1593 } // namespace wasm | 1593 } // namespace wasm |
| 1594 } // namespace internal | 1594 } // namespace internal |
| 1595 } // namespace v8 | 1595 } // namespace v8 |
| OLD | NEW |