| Index: src/wasm/wasm-module.cc
|
| diff --git a/src/wasm/wasm-module.cc b/src/wasm/wasm-module.cc
|
| index e15b8d1f55318c7dcc8a51ad1746c06b4b8c3fc6..b2484736db9d053305b271d8ab79e708833158da 100644
|
| --- a/src/wasm/wasm-module.cc
|
| +++ b/src/wasm/wasm-module.cc
|
| @@ -101,9 +101,9 @@ std::ostream& operator<<(std::ostream& os, const WasmFunctionName& pair) {
|
| os << "#" << pair.function_->func_index << ":";
|
| if (pair.function_->name_offset > 0) {
|
| if (pair.module_) {
|
| - WasmName name = pair.module_->GetName(pair.function_->name_offset,
|
| - pair.function_->name_length);
|
| - os.write(name.name, name.length);
|
| + Vector<const char> name = pair.module_->GetName(
|
| + pair.function_->name_offset, pair.function_->name_length);
|
| + os.write(name.start(), name.length());
|
| } else {
|
| os << "+" << pair.function_->func_index;
|
| }
|
| @@ -333,17 +333,16 @@ WasmModule::WasmModule()
|
| start_function_index(-1),
|
| origin(kWasmOrigin) {}
|
|
|
| -static MaybeHandle<JSFunction> ReportFFIError(ErrorThrower& thrower,
|
| - const char* error, uint32_t index,
|
| - wasm::WasmName module_name,
|
| - wasm::WasmName function_name) {
|
| - if (function_name.name) {
|
| +static MaybeHandle<JSFunction> ReportFFIError(
|
| + ErrorThrower& thrower, const char* error, uint32_t index,
|
| + Vector<const char> module_name, Vector<const char> function_name) {
|
| + if (function_name.start()) {
|
| thrower.Error("Import #%d module=\"%.*s\" function=\"%.*s\" error: %s",
|
| - index, module_name.length, module_name.name,
|
| - function_name.length, function_name.name, error);
|
| + index, module_name.length(), module_name.start(),
|
| + function_name.length(), function_name.start(), error);
|
| } else {
|
| thrower.Error("Import #%d module=\"%.*s\" error: %s", index,
|
| - module_name.length, module_name.name, error);
|
| + module_name.length(), module_name.start(), error);
|
| }
|
| thrower.Error("Import ");
|
| return MaybeHandle<JSFunction>();
|
| @@ -351,15 +350,15 @@ static MaybeHandle<JSFunction> ReportFFIError(ErrorThrower& thrower,
|
|
|
| static MaybeHandle<JSFunction> LookupFunction(
|
| ErrorThrower& thrower, Factory* factory, Handle<JSObject> ffi,
|
| - uint32_t index, wasm::WasmName module_name, wasm::WasmName function_name) {
|
| + uint32_t index, Vector<const char> module_name,
|
| + Vector<const char> function_name) {
|
| if (ffi.is_null()) {
|
| return ReportFFIError(thrower, "FFI is not an object", index, module_name,
|
| function_name);
|
| }
|
|
|
| // Look up the module first.
|
| - Handle<String> name = factory->InternalizeUtf8String(
|
| - Vector<const char>(module_name.name, module_name.length));
|
| + Handle<String> name = factory->InternalizeUtf8String(module_name);
|
| MaybeHandle<Object> result = Object::GetProperty(ffi, name);
|
| if (result.is_null()) {
|
| return ReportFFIError(thrower, "module not found", index, module_name,
|
| @@ -374,10 +373,9 @@ static MaybeHandle<JSFunction> LookupFunction(
|
| }
|
|
|
| Handle<Object> function;
|
| - if (function_name.name) {
|
| + if (function_name.start()) {
|
| // Look up the function in the module.
|
| - Handle<String> name = factory->InternalizeUtf8String(
|
| - Vector<const char>(function_name.name, function_name.length));
|
| + Handle<String> name = factory->InternalizeUtf8String(function_name);
|
| MaybeHandle<Object> result = Object::GetProperty(module, name);
|
| if (result.is_null()) {
|
| return ReportFFIError(thrower, "function not found", index, module_name,
|
| @@ -471,10 +469,10 @@ MaybeHandle<JSObject> WasmModule::Instantiate(Isolate* isolate,
|
| if (import_table.size() > 0) {
|
| instance.import_code.reserve(import_table.size());
|
| for (const WasmImport& import : import_table) {
|
| - WasmName module_name =
|
| + Vector<const char> module_name =
|
| GetNameOrNull(import.module_name_offset, import.module_name_length);
|
| - WasmName function_name = GetNameOrNull(import.function_name_offset,
|
| - import.function_name_length);
|
| + Vector<const char> function_name = GetNameOrNull(
|
| + import.function_name_offset, import.function_name_length);
|
| MaybeHandle<JSFunction> function = LookupFunction(
|
| thrower, factory, ffi, index, module_name, function_name);
|
| if (function.is_null()) return MaybeHandle<JSObject>();
|
| @@ -500,10 +498,9 @@ MaybeHandle<JSObject> WasmModule::Instantiate(Isolate* isolate,
|
| if (thrower.error()) break;
|
| DCHECK_EQ(index, func.func_index);
|
|
|
| - WasmName str = GetName(func.name_offset, func.name_length);
|
| - WasmName str_null = {nullptr, 0};
|
| - Handle<String> name = factory->InternalizeUtf8String(
|
| - Vector<const char>(str.name, str.length));
|
| + Vector<const char> str = GetName(func.name_offset, func.name_length);
|
| + Vector<const char> str_null = {nullptr, 0};
|
| + Handle<String> name = factory->InternalizeUtf8String(str);
|
| Handle<Code> code = Handle<Code>::null();
|
| Handle<JSFunction> function = Handle<JSFunction>::null();
|
| if (func.external) {
|
| @@ -519,8 +516,8 @@ MaybeHandle<JSObject> WasmModule::Instantiate(Isolate* isolate,
|
| code =
|
| compiler::CompileWasmFunction(thrower, isolate, &module_env, func);
|
| if (code.is_null()) {
|
| - thrower.Error("Compilation of #%d:%.*s failed.", index, str.length,
|
| - str.name);
|
| + thrower.Error("Compilation of #%d:%.*s failed.", index, str.length(),
|
| + str.start());
|
| return MaybeHandle<JSObject>();
|
| }
|
| if (func.exported) {
|
| @@ -563,9 +560,8 @@ MaybeHandle<JSObject> WasmModule::Instantiate(Isolate* isolate,
|
| // Compile wrappers and add them to the exports object.
|
| for (const WasmExport& exp : export_table) {
|
| if (thrower.error()) break;
|
| - WasmName str = GetName(exp.name_offset, exp.name_length);
|
| - Handle<String> name = factory->InternalizeUtf8String(
|
| - Vector<const char>(str.name, str.length));
|
| + Vector<const char> str = GetName(exp.name_offset, exp.name_length);
|
| + Handle<String> name = factory->InternalizeUtf8String(str);
|
| Handle<Code> code = linker.GetFunctionCode(exp.func_index);
|
| Handle<JSFunction> function = compiler::CompileJSToWasmWrapper(
|
| isolate, &module_env, name, code, instance.js_object,
|
|
|