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/macro-assembler.h" | 5 #include "src/macro-assembler.h" |
6 #include "src/objects.h" | 6 #include "src/objects.h" |
7 #include "src/property-descriptor.h" | 7 #include "src/property-descriptor.h" |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/simulator.h" | 10 #include "src/simulator.h" |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 max_mem_pages(0), | 333 max_mem_pages(0), |
334 mem_export(false), | 334 mem_export(false), |
335 mem_external(false), | 335 mem_external(false), |
336 start_function_index(-1), | 336 start_function_index(-1), |
337 origin(kWasmOrigin) {} | 337 origin(kWasmOrigin) {} |
338 | 338 |
339 static MaybeHandle<JSFunction> ReportFFIError(ErrorThrower& thrower, | 339 static MaybeHandle<JSFunction> ReportFFIError(ErrorThrower& thrower, |
340 const char* error, uint32_t index, | 340 const char* error, uint32_t index, |
341 wasm::WasmName module_name, | 341 wasm::WasmName module_name, |
342 wasm::WasmName function_name) { | 342 wasm::WasmName function_name) { |
343 if (function_name.start()) { | 343 if (!function_name.is_empty()) { |
344 thrower.Error("Import #%d module=\"%.*s\" function=\"%.*s\" error: %s", | 344 thrower.Error("Import #%d module=\"%.*s\" function=\"%.*s\" error: %s", |
345 index, module_name.length(), module_name.start(), | 345 index, module_name.length(), module_name.start(), |
346 function_name.length(), function_name.start(), error); | 346 function_name.length(), function_name.start(), error); |
347 } else { | 347 } else { |
348 thrower.Error("Import #%d module=\"%.*s\" error: %s", index, | 348 thrower.Error("Import #%d module=\"%.*s\" error: %s", index, |
349 module_name.length(), module_name.start(), error); | 349 module_name.length(), module_name.start(), error); |
350 } | 350 } |
351 thrower.Error("Import "); | 351 thrower.Error("Import "); |
352 return MaybeHandle<JSFunction>(); | 352 return MaybeHandle<JSFunction>(); |
353 } | 353 } |
(...skipping 15 matching lines...) Expand all Loading... |
369 } | 369 } |
370 | 370 |
371 Handle<Object> module = result.ToHandleChecked(); | 371 Handle<Object> module = result.ToHandleChecked(); |
372 | 372 |
373 if (!module->IsJSReceiver()) { | 373 if (!module->IsJSReceiver()) { |
374 return ReportFFIError(thrower, "module is not an object or function", index, | 374 return ReportFFIError(thrower, "module is not an object or function", index, |
375 module_name, function_name); | 375 module_name, function_name); |
376 } | 376 } |
377 | 377 |
378 Handle<Object> function; | 378 Handle<Object> function; |
379 if (function_name.start()) { | 379 if (!function_name.is_empty()) { |
380 // Look up the function in the module. | 380 // Look up the function in the module. |
381 Handle<String> name = factory->InternalizeUtf8String(function_name); | 381 Handle<String> name = factory->InternalizeUtf8String(function_name); |
382 MaybeHandle<Object> result = Object::GetProperty(module, name); | 382 MaybeHandle<Object> result = Object::GetProperty(module, name); |
383 if (result.is_null()) { | 383 if (result.is_null()) { |
384 return ReportFFIError(thrower, "function not found", index, module_name, | 384 return ReportFFIError(thrower, "function not found", index, module_name, |
385 function_name); | 385 function_name); |
386 } | 386 } |
387 function = result.ToHandleChecked(); | 387 function = result.ToHandleChecked(); |
388 } else { | 388 } else { |
389 // No function specified. Use the "default export". | 389 // No function specified. Use the "default export". |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 wasm->GetInternalField(kWasmFunctionNamesArray), wasm->GetIsolate()); | 816 wasm->GetInternalField(kWasmFunctionNamesArray), wasm->GetIsolate()); |
817 if (func_names_arr_obj->IsUndefined()) | 817 if (func_names_arr_obj->IsUndefined()) |
818 return func_names_arr_obj; // Return undefined. | 818 return func_names_arr_obj; // Return undefined. |
819 return GetWasmFunctionNameFromTable( | 819 return GetWasmFunctionNameFromTable( |
820 Handle<ByteArray>::cast(func_names_arr_obj), func_index); | 820 Handle<ByteArray>::cast(func_names_arr_obj), func_index); |
821 } | 821 } |
822 | 822 |
823 } // namespace wasm | 823 } // namespace wasm |
824 } // namespace internal | 824 } // namespace internal |
825 } // namespace v8 | 825 } // namespace v8 |
OLD | NEW |