Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: src/wasm/wasm-module.cc

Issue 1970503004: [wasm] Differentiate unnamed and empty names (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@add-utf8-check
Patch Set: Yang's last comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/wasm/wasm-module.h ('k') | test/cctest/wasm/test-wasm-function-name-table.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 max_mem_pages(0), 325 max_mem_pages(0),
326 mem_export(false), 326 mem_export(false),
327 mem_external(false), 327 mem_external(false),
328 start_function_index(-1), 328 start_function_index(-1),
329 origin(kWasmOrigin) {} 329 origin(kWasmOrigin) {}
330 330
331 static MaybeHandle<JSFunction> ReportFFIError(ErrorThrower& thrower, 331 static MaybeHandle<JSFunction> ReportFFIError(ErrorThrower& thrower,
332 const char* error, uint32_t index, 332 const char* error, uint32_t index,
333 wasm::WasmName module_name, 333 wasm::WasmName module_name,
334 wasm::WasmName function_name) { 334 wasm::WasmName function_name) {
335 if (function_name.start()) { 335 if (!function_name.is_empty()) {
336 thrower.Error("Import #%d module=\"%.*s\" function=\"%.*s\" error: %s", 336 thrower.Error("Import #%d module=\"%.*s\" function=\"%.*s\" error: %s",
337 index, module_name.length(), module_name.start(), 337 index, module_name.length(), module_name.start(),
338 function_name.length(), function_name.start(), error); 338 function_name.length(), function_name.start(), error);
339 } else { 339 } else {
340 thrower.Error("Import #%d module=\"%.*s\" error: %s", index, 340 thrower.Error("Import #%d module=\"%.*s\" error: %s", index,
341 module_name.length(), module_name.start(), error); 341 module_name.length(), module_name.start(), error);
342 } 342 }
343 thrower.Error("Import "); 343 thrower.Error("Import ");
344 return MaybeHandle<JSFunction>(); 344 return MaybeHandle<JSFunction>();
345 } 345 }
(...skipping 15 matching lines...) Expand all
361 } 361 }
362 362
363 Handle<Object> module = result.ToHandleChecked(); 363 Handle<Object> module = result.ToHandleChecked();
364 364
365 if (!module->IsJSReceiver()) { 365 if (!module->IsJSReceiver()) {
366 return ReportFFIError(thrower, "module is not an object or function", index, 366 return ReportFFIError(thrower, "module is not an object or function", index,
367 module_name, function_name); 367 module_name, function_name);
368 } 368 }
369 369
370 Handle<Object> function; 370 Handle<Object> function;
371 if (function_name.start()) { 371 if (!function_name.is_empty()) {
372 // Look up the function in the module. 372 // Look up the function in the module.
373 Handle<String> name = factory->InternalizeUtf8String(function_name); 373 Handle<String> name = factory->InternalizeUtf8String(function_name);
374 MaybeHandle<Object> result = Object::GetProperty(module, name); 374 MaybeHandle<Object> result = Object::GetProperty(module, name);
375 if (result.is_null()) { 375 if (result.is_null()) {
376 return ReportFFIError(thrower, "function not found", index, module_name, 376 return ReportFFIError(thrower, "function not found", index, module_name,
377 function_name); 377 function_name);
378 } 378 }
379 function = result.ToHandleChecked(); 379 function = result.ToHandleChecked();
380 } else { 380 } else {
381 // No function specified. Use the "default export". 381 // No function specified. Use the "default export".
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 if (result->IsSmi()) { 970 if (result->IsSmi()) {
971 return Smi::cast(*result)->value(); 971 return Smi::cast(*result)->value();
972 } 972 }
973 if (result->IsHeapNumber()) { 973 if (result->IsHeapNumber()) {
974 return static_cast<int32_t>(HeapNumber::cast(*result)->value()); 974 return static_cast<int32_t>(HeapNumber::cast(*result)->value());
975 } 975 }
976 thrower.Error("WASM.compileRun() failed: Return value should be number"); 976 thrower.Error("WASM.compileRun() failed: Return value should be number");
977 return -1; 977 return -1;
978 } 978 }
979 979
980 Handle<Object> GetWasmFunctionName(Handle<JSObject> wasm, uint32_t func_index) { 980 MaybeHandle<String> GetWasmFunctionName(Handle<JSObject> wasm,
981 Handle<Object> func_names_arr_obj = handle( 981 uint32_t func_index) {
982 wasm->GetInternalField(kWasmFunctionNamesArray), wasm->GetIsolate()); 982 Object* func_names_arr_obj = wasm->GetInternalField(kWasmFunctionNamesArray);
983 if (func_names_arr_obj->IsUndefined()) 983 if (func_names_arr_obj->IsUndefined()) return Handle<String>::null();
984 return func_names_arr_obj; // Return undefined.
985 return GetWasmFunctionNameFromTable( 984 return GetWasmFunctionNameFromTable(
986 Handle<ByteArray>::cast(func_names_arr_obj), func_index); 985 handle(ByteArray::cast(func_names_arr_obj)), func_index);
987 } 986 }
988 987
989 } // namespace wasm 988 } // namespace wasm
990 } // namespace internal 989 } // namespace internal
991 } // namespace v8 990 } // namespace v8
OLDNEW
« no previous file with comments | « src/wasm/wasm-module.h ('k') | test/cctest/wasm/test-wasm-function-name-table.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698