| 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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 max_mem_pages(0), | 331 max_mem_pages(0), |
| 332 mem_export(false), | 332 mem_export(false), |
| 333 mem_external(false), | 333 mem_external(false), |
| 334 start_function_index(-1), | 334 start_function_index(-1), |
| 335 origin(kWasmOrigin) {} | 335 origin(kWasmOrigin) {} |
| 336 | 336 |
| 337 static MaybeHandle<JSFunction> ReportFFIError(ErrorThrower& thrower, | 337 static MaybeHandle<JSFunction> ReportFFIError(ErrorThrower& thrower, |
| 338 const char* error, uint32_t index, | 338 const char* error, uint32_t index, |
| 339 wasm::WasmName module_name, | 339 wasm::WasmName module_name, |
| 340 wasm::WasmName function_name) { | 340 wasm::WasmName function_name) { |
| 341 if (function_name.start()) { | 341 if (!function_name.is_empty()) { |
| 342 thrower.Error("Import #%d module=\"%.*s\" function=\"%.*s\" error: %s", | 342 thrower.Error("Import #%d module=\"%.*s\" function=\"%.*s\" error: %s", |
| 343 index, module_name.length(), module_name.start(), | 343 index, module_name.length(), module_name.start(), |
| 344 function_name.length(), function_name.start(), error); | 344 function_name.length(), function_name.start(), error); |
| 345 } else { | 345 } else { |
| 346 thrower.Error("Import #%d module=\"%.*s\" error: %s", index, | 346 thrower.Error("Import #%d module=\"%.*s\" error: %s", index, |
| 347 module_name.length(), module_name.start(), error); | 347 module_name.length(), module_name.start(), error); |
| 348 } | 348 } |
| 349 thrower.Error("Import "); | 349 thrower.Error("Import "); |
| 350 return MaybeHandle<JSFunction>(); | 350 return MaybeHandle<JSFunction>(); |
| 351 } | 351 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 367 } | 367 } |
| 368 | 368 |
| 369 Handle<Object> module = result.ToHandleChecked(); | 369 Handle<Object> module = result.ToHandleChecked(); |
| 370 | 370 |
| 371 if (!module->IsJSReceiver()) { | 371 if (!module->IsJSReceiver()) { |
| 372 return ReportFFIError(thrower, "module is not an object or function", index, | 372 return ReportFFIError(thrower, "module is not an object or function", index, |
| 373 module_name, function_name); | 373 module_name, function_name); |
| 374 } | 374 } |
| 375 | 375 |
| 376 Handle<Object> function; | 376 Handle<Object> function; |
| 377 if (function_name.start()) { | 377 if (!function_name.is_empty()) { |
| 378 // Look up the function in the module. | 378 // Look up the function in the module. |
| 379 Handle<String> name = factory->InternalizeUtf8String(function_name); | 379 Handle<String> name = factory->InternalizeUtf8String(function_name); |
| 380 MaybeHandle<Object> result = Object::GetProperty(module, name); | 380 MaybeHandle<Object> result = Object::GetProperty(module, name); |
| 381 if (result.is_null()) { | 381 if (result.is_null()) { |
| 382 return ReportFFIError(thrower, "function not found", index, module_name, | 382 return ReportFFIError(thrower, "function not found", index, module_name, |
| 383 function_name); | 383 function_name); |
| 384 } | 384 } |
| 385 function = result.ToHandleChecked(); | 385 function = result.ToHandleChecked(); |
| 386 } else { | 386 } else { |
| 387 // No function specified. Use the "default export". | 387 // No function specified. Use the "default export". |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 wasm->GetInternalField(kWasmFunctionNamesArray), wasm->GetIsolate()); | 1009 wasm->GetInternalField(kWasmFunctionNamesArray), wasm->GetIsolate()); |
| 1010 if (func_names_arr_obj->IsUndefined()) | 1010 if (func_names_arr_obj->IsUndefined()) |
| 1011 return func_names_arr_obj; // Return undefined. | 1011 return func_names_arr_obj; // Return undefined. |
| 1012 return GetWasmFunctionNameFromTable( | 1012 return GetWasmFunctionNameFromTable( |
| 1013 Handle<ByteArray>::cast(func_names_arr_obj), func_index); | 1013 Handle<ByteArray>::cast(func_names_arr_obj), func_index); |
| 1014 } | 1014 } |
| 1015 | 1015 |
| 1016 } // namespace wasm | 1016 } // namespace wasm |
| 1017 } // namespace internal | 1017 } // namespace internal |
| 1018 } // namespace v8 | 1018 } // namespace v8 |
| OLD | NEW |