summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/binary-reader-interpreter.cc173
-rw-r--r--src/interpreter.cc57
-rw-r--r--src/interpreter.h114
-rw-r--r--src/tools/wasm-interp.cc11
-rw-r--r--test/spec/globals.txt4
-rw-r--r--test/spec/imports.txt16
-rw-r--r--test/spec/linking.txt4
7 files changed, 192 insertions, 187 deletions
diff --git a/src/binary-reader-interpreter.cc b/src/binary-reader-interpreter.cc
index b369b2f8..7cb3e676 100644
--- a/src/binary-reader-interpreter.cc
+++ b/src/binary-reader-interpreter.cc
@@ -23,6 +23,7 @@
#include <vector>
#include "binary-reader-nop.h"
+#include "cast.h"
#include "error-handler.h"
#include "interpreter.h"
#include "type-checker.h"
@@ -94,10 +95,6 @@ class BinaryReaderInterpreter : public BinaryReaderNop {
Index result_count,
Type* result_types) override;
- wabt::Result OnImportCount(Index count) override;
- wabt::Result OnImport(Index index,
- string_view module_name,
- string_view field_name) override;
wabt::Result OnImportFunc(Index import_index,
string_view module_name,
string_view field_name,
@@ -258,6 +255,11 @@ class BinaryReaderInterpreter : public BinaryReaderNop {
ExternalKind kind,
Index item_index,
string_view name);
+ wabt::Result FindRegisteredModule(string_view module_name,
+ Module** out_module);
+ wabt::Result GetModuleExport(Module* module,
+ string_view field_name,
+ Export** out_export);
HostImportDelegate::ErrorCallback MakePrintErrorCallback();
@@ -286,12 +288,9 @@ class BinaryReaderInterpreter : public BinaryReaderNop {
std::vector<ElemSegmentInfo> elem_segment_infos;
std::vector<DataSegmentInfo> data_segment_infos;
- /* values cached so they can be shared between callbacks */
+ // Values cached so they can be shared between callbacks.
TypedValue init_expr_value;
IstreamOffset table_offset = 0;
- bool is_host_import = false;
- HostModule* host_import_module = nullptr;
- Index import_env_index = 0;
};
BinaryReaderInterpreter::BinaryReaderInterpreter(
@@ -371,7 +370,7 @@ Type BinaryReaderInterpreter::GetGlobalTypeByModuleIndex(Index global_index) {
Type BinaryReaderInterpreter::GetLocalTypeByIndex(Func* func,
Index local_index) {
assert(!func->is_host);
- return func->as_defined()->param_and_local_types[local_index];
+ return cast<DefinedFunc>(func)->param_and_local_types[local_index];
}
IstreamOffset BinaryReaderInterpreter::GetIstreamOffset() {
@@ -549,44 +548,6 @@ wabt::Result BinaryReaderInterpreter::OnType(Index index,
return wabt::Result::Ok;
}
-wabt::Result BinaryReaderInterpreter::OnImportCount(Index count) {
- module->imports.resize(count);
- return wabt::Result::Ok;
-}
-
-wabt::Result BinaryReaderInterpreter::OnImport(Index index,
- string_view module_name,
- string_view field_name) {
- Import* import = &module->imports[index];
- import->module_name = module_name.to_string();
- import->field_name = field_name.to_string();
- Module* module = env->FindRegisteredModule(import->module_name);
- if (!module) {
- PrintError("unknown import module \"" PRIstringview "\"",
- WABT_PRINTF_STRING_VIEW_ARG(import->module_name));
- return wabt::Result::Error;
- }
- if (module->is_host) {
- /* We don't yet know the kind of a host import module, so just assume it
- * exists for now. We'll fail later (in on_import_* below) if it doesn't
- * exist). */
- is_host_import = true;
- host_import_module = module->as_host();
- } else {
- Export* export_ = module->GetExport(import->field_name);
- if (!export_) {
- PrintError("unknown module field \"" PRIstringview "\"",
- WABT_PRINTF_STRING_VIEW_ARG(import->field_name));
- return wabt::Result::Error;
- }
-
- import->kind = export_->kind;
- is_host_import = false;
- import_env_index = export_->index;
- }
- return wabt::Result::Ok;
-}
-
wabt::Result BinaryReaderInterpreter::CheckLocal(Index local_index) {
Index max_local_index = current_func->param_and_local_types.size();
if (local_index >= max_local_index) {
@@ -609,13 +570,13 @@ wabt::Result BinaryReaderInterpreter::CheckGlobal(Index global_index) {
wabt::Result BinaryReaderInterpreter::CheckImportKind(
Import* import,
- ExternalKind expected_kind) {
- if (import->kind != expected_kind) {
+ ExternalKind actual_kind) {
+ if (import->kind != actual_kind) {
PrintError("expected import \"" PRIstringview "." PRIstringview
"\" to have kind %s, not %s",
WABT_PRINTF_STRING_VIEW_ARG(import->module_name),
WABT_PRINTF_STRING_VIEW_ARG(import->field_name),
- GetKindName(expected_kind), GetKindName(import->kind));
+ GetKindName(import->kind), GetKindName(actual_kind));
return wabt::Result::Error;
}
return wabt::Result::Ok;
@@ -663,6 +624,34 @@ wabt::Result BinaryReaderInterpreter::AppendExport(Module* module,
return wabt::Result::Ok;
}
+wabt::Result BinaryReaderInterpreter::FindRegisteredModule(
+ string_view module_name,
+ Module** out_module) {
+ Module* module = env->FindRegisteredModule(module_name);
+ if (!module) {
+ PrintError("unknown import module \"" PRIstringview "\"",
+ WABT_PRINTF_STRING_VIEW_ARG(module_name));
+ return wabt::Result::Error;
+ }
+
+ *out_module = module;
+ return wabt::Result::Ok;
+}
+
+wabt::Result BinaryReaderInterpreter::GetModuleExport(Module* module,
+ string_view field_name,
+ Export** out_export) {
+ Export* export_ = module->GetExport(field_name);
+ if (!export_) {
+ PrintError("unknown module field \"" PRIstringview "\"",
+ WABT_PRINTF_STRING_VIEW_ARG(field_name));
+ return wabt::Result::Error;
+ }
+
+ *out_export = export_;
+ return wabt::Result::Ok;
+}
+
HostImportDelegate::ErrorCallback
BinaryReaderInterpreter::MakePrintErrorCallback() {
return [this](const char* msg) { PrintError("%s", msg); };
@@ -673,13 +662,17 @@ wabt::Result BinaryReaderInterpreter::OnImportFunc(Index import_index,
string_view field_name,
Index func_index,
Index sig_index) {
- Import* import = &module->imports[import_index];
- import->func.sig_index = TranslateSigIndexToEnv(sig_index);
+ module->func_imports.emplace_back(module_name, field_name);
+ FuncImport* import = &module->func_imports.back();
+ import->sig_index = TranslateSigIndexToEnv(sig_index);
+
+ Module* import_module;
+ CHECK_RESULT(FindRegisteredModule(import->module_name, &import_module));
Index func_env_index;
- if (is_host_import) {
+ if (auto* host_import_module = dyn_cast<HostModule>(import_module)) {
HostFunc* func = new HostFunc(import->module_name, import->field_name,
- import->func.sig_index);
+ import->sig_index);
env->EmplaceBackFunc(func);
FuncSignature* sig = env->GetFuncSignature(func->sig_index);
@@ -691,14 +684,17 @@ wabt::Result BinaryReaderInterpreter::OnImportFunc(Index import_index,
AppendExport(host_import_module, ExternalKind::Func, func_env_index,
import->field_name);
} else {
- CHECK_RESULT(CheckImportKind(import, ExternalKind::Func));
- Func* func = env->GetFunc(import_env_index);
- if (!env->FuncSignaturesAreEqual(import->func.sig_index, func->sig_index)) {
+ Export* export_;
+ CHECK_RESULT(GetModuleExport(import_module, import->field_name, &export_));
+ CHECK_RESULT(CheckImportKind(import, export_->kind));
+
+ Func* func = env->GetFunc(export_->index);
+ if (!env->FuncSignaturesAreEqual(import->sig_index, func->sig_index)) {
PrintError("import signature mismatch");
return wabt::Result::Error;
}
- func_env_index = import_env_index;
+ func_env_index = export_->index;
}
func_index_mapping.push_back(func_env_index);
num_func_imports++;
@@ -716,9 +712,13 @@ wabt::Result BinaryReaderInterpreter::OnImportTable(Index import_index,
return wabt::Result::Error;
}
- Import* import = &module->imports[import_index];
+ module->table_imports.emplace_back(module_name, field_name);
+ TableImport* import = &module->table_imports.back();
- if (is_host_import) {
+ Module* import_module;
+ CHECK_RESULT(FindRegisteredModule(import->module_name, &import_module));
+
+ if (auto* host_import_module = dyn_cast<HostModule>(import_module)) {
Table* table = env->EmplaceBackTable(*elem_limits);
CHECK_RESULT(host_import_module->import_delegate->ImportTable(
@@ -730,12 +730,15 @@ wabt::Result BinaryReaderInterpreter::OnImportTable(Index import_index,
AppendExport(host_import_module, ExternalKind::Table, module->table_index,
import->field_name);
} else {
- CHECK_RESULT(CheckImportKind(import, ExternalKind::Table));
- Table* table = env->GetTable(import_env_index);
+ Export* export_;
+ CHECK_RESULT(GetModuleExport(import_module, import->field_name, &export_));
+ CHECK_RESULT(CheckImportKind(import, export_->kind));
+
+ Table* table = env->GetTable(export_->index);
CHECK_RESULT(CheckImportLimits(elem_limits, &table->limits));
- import->table.limits = *elem_limits;
- module->table_index = import_env_index;
+ import->limits = *elem_limits;
+ module->table_index = export_->index;
}
return wabt::Result::Ok;
}
@@ -751,9 +754,13 @@ wabt::Result BinaryReaderInterpreter::OnImportMemory(
return wabt::Result::Error;
}
- Import* import = &module->imports[import_index];
+ module->memory_imports.emplace_back(module_name, field_name);
+ MemoryImport* import = &module->memory_imports.back();
- if (is_host_import) {
+ Module* import_module;
+ CHECK_RESULT(FindRegisteredModule(import->module_name, &import_module));
+
+ if (auto* host_import_module = dyn_cast<HostModule>(import_module)) {
Memory* memory = env->EmplaceBackMemory();
CHECK_RESULT(host_import_module->import_delegate->ImportMemory(
@@ -765,12 +772,15 @@ wabt::Result BinaryReaderInterpreter::OnImportMemory(
AppendExport(host_import_module, ExternalKind::Memory, module->memory_index,
import->field_name);
} else {
- CHECK_RESULT(CheckImportKind(import, ExternalKind::Memory));
- Memory* memory = env->GetMemory(import_env_index);
+ Export* export_;
+ CHECK_RESULT(GetModuleExport(import_module, import->field_name, &export_));
+ CHECK_RESULT(CheckImportKind(import, export_->kind));
+
+ Memory* memory = env->GetMemory(export_->index);
CHECK_RESULT(CheckImportLimits(page_limits, &memory->page_limits));
- import->memory.limits = *page_limits;
- module->memory_index = import_env_index;
+ import->limits = *page_limits;
+ module->memory_index = export_->index;
}
return wabt::Result::Ok;
}
@@ -781,10 +791,14 @@ wabt::Result BinaryReaderInterpreter::OnImportGlobal(Index import_index,
Index global_index,
Type type,
bool mutable_) {
- Import* import = &module->imports[import_index];
+ module->global_imports.emplace_back(module_name, field_name);
+ GlobalImport* import = &module->global_imports.back();
+
+ Module* import_module;
+ CHECK_RESULT(FindRegisteredModule(import->module_name, &import_module));
Index global_env_index = env->GetGlobalCount() - 1;
- if (is_host_import) {
+ if (auto* host_import_module = dyn_cast<HostModule>(import_module)) {
Global* global = env->EmplaceBackGlobal(TypedValue(type), mutable_);
CHECK_RESULT(host_import_module->import_delegate->ImportGlobal(
@@ -794,11 +808,14 @@ wabt::Result BinaryReaderInterpreter::OnImportGlobal(Index import_index,
AppendExport(host_import_module, ExternalKind::Global, global_env_index,
import->field_name);
} else {
- CHECK_RESULT(CheckImportKind(import, ExternalKind::Global));
+ Export* export_;
+ CHECK_RESULT(GetModuleExport(import_module, import->field_name, &export_));
+ CHECK_RESULT(CheckImportKind(import, export_->kind));
+
// TODO: check type and mutability
- import->global.type = type;
- import->global.mutable_ = mutable_;
- global_env_index = import_env_index;
+ import->type = type;
+ import->mutable_ = mutable_;
+ global_env_index = export_->index;
}
global_index_mapping.push_back(global_env_index);
num_global_imports++;
@@ -1039,7 +1056,7 @@ void BinaryReaderInterpreter::PopLabel() {
}
wabt::Result BinaryReaderInterpreter::BeginFunctionBody(Index index) {
- DefinedFunc* func = GetFuncByModuleIndex(index)->as_defined();
+ auto* func = cast<DefinedFunc>(GetFuncByModuleIndex(index));
FuncSignature* sig = env->GetFuncSignature(func->sig_index);
func->offset = GetIstreamOffset();
@@ -1238,7 +1255,7 @@ wabt::Result BinaryReaderInterpreter::OnCallExpr(Index func_index) {
CHECK_RESULT(EmitI32(TranslateFuncIndexToEnv(func_index)));
} else {
CHECK_RESULT(EmitOpcode(interpreter::Opcode::Call));
- CHECK_RESULT(EmitFuncOffset(func->as_defined(), func_index));
+ CHECK_RESULT(EmitFuncOffset(cast<DefinedFunc>(func), func_index));
}
return wabt::Result::Ok;
diff --git a/src/interpreter.cc b/src/interpreter.cc
index 793d1aef..51d377a7 100644
--- a/src/interpreter.cc
+++ b/src/interpreter.cc
@@ -24,6 +24,7 @@
#include <type_traits>
#include <vector>
+#include "cast.h"
#include "stream.h"
namespace wabt {
@@ -107,40 +108,6 @@ FuncSignature::FuncSignature(Index param_count,
: param_types(param_types, param_types + param_count),
result_types(result_types, result_types + result_count) {}
-Import::Import() : kind(ExternalKind::Func) {
- func.sig_index = kInvalidIndex;
-}
-
-Import::Import(Import&& other) {
- *this = std::move(other);
-}
-
-Import& Import::operator=(Import&& other) {
- kind = other.kind;
- module_name = std::move(other.module_name);
- field_name = std::move(other.field_name);
- switch (kind) {
- case ExternalKind::Func:
- func.sig_index = other.func.sig_index;
- break;
- case ExternalKind::Table:
- table.limits = other.table.limits;
- break;
- case ExternalKind::Memory:
- memory.limits = other.memory.limits;
- break;
- case ExternalKind::Global:
- global.type = other.global.type;
- global.mutable_ = other.global.mutable_;
- break;
- case ExternalKind::Except:
- // TODO(karlschimpf) Define
- WABT_FATAL("Import::operator=() not implemented for exceptions");
- break;
- }
- return *this;
-}
-
Module::Module(bool is_host)
: memory_index(kInvalidIndex),
table_index(kInvalidIndex),
@@ -1089,8 +1056,9 @@ Result Thread::RunFunction(Index func_index,
Result result = PushArgs(sig, args);
if (result == Result::Ok) {
- result = func->is_host ? CallHost(func->as_host())
- : RunDefinedFunction(func->as_defined()->offset);
+ result = func->is_host
+ ? CallHost(cast<HostFunc>(func))
+ : RunDefinedFunction(cast<DefinedFunc>(func)->offset);
if (result == Result::Ok)
CopyResults(sig, out_results);
}
@@ -1110,9 +1078,9 @@ Result Thread::TraceFunction(Index func_index,
Result result = PushArgs(sig, args);
if (result == Result::Ok) {
- result = func->is_host
- ? CallHost(func->as_host())
- : TraceDefinedFunction(func->as_defined()->offset, stream);
+ result = func->is_host ? CallHost(cast<HostFunc>(func))
+ : TraceDefinedFunction(
+ cast<DefinedFunc>(func)->offset, stream);
if (result == Result::Ok)
CopyResults(sig, out_results);
}
@@ -1302,17 +1270,17 @@ Result Thread::Run(int num_instructions, IstreamOffset* call_stack_return_top) {
TRAP_UNLESS(env_->FuncSignaturesAreEqual(func->sig_index, sig_index),
IndirectCallSignatureMismatch);
if (func->is_host) {
- CallHost(func->as_host());
+ CallHost(cast<HostFunc>(func));
} else {
CHECK_TRAP(PushCall(pc));
- GOTO(func->as_defined()->offset);
+ GOTO(cast<DefinedFunc>(func)->offset);
}
break;
}
case Opcode::CallHost: {
Index func_index = read_u32(&pc);
- CallHost(env_->funcs_[func_index]->as_host());
+ CallHost(cast<HostFunc>(env_->funcs_[func_index].get()));
break;
}
@@ -2713,8 +2681,9 @@ void Environment::Disassemble(Stream* stream,
void Environment::DisassembleModule(Stream* stream, Module* module) {
assert(!module->is_host);
- Disassemble(stream, module->as_defined()->istream_start,
- module->as_defined()->istream_end);
+ auto* defined_module = cast<DefinedModule>(module);
+ Disassemble(stream, defined_module->istream_start,
+ defined_module->istream_end);
}
} // namespace interpreter
diff --git a/src/interpreter.h b/src/interpreter.h
index fd1ac5e7..6eb10029 100644
--- a/src/interpreter.h
+++ b/src/interpreter.h
@@ -172,26 +172,54 @@ struct Global {
};
struct Import {
- Import();
- Import(Import&&);
- Import& operator=(Import&&);
- ~Import() = default;
+ explicit Import(ExternalKind kind) : kind(kind) {}
+ Import(ExternalKind kind, string_view module_name, string_view field_name)
+ : kind(kind),
+ module_name(module_name.to_string()),
+ field_name(field_name.to_string()) {}
+ ExternalKind kind;
std::string module_name;
std::string field_name;
- ExternalKind kind;
- union {
- struct {
- Index sig_index;
- } func;
- struct {
- Limits limits;
- } table, memory;
- struct {
- Type type;
- bool mutable_;
- } global;
- };
+};
+
+struct FuncImport : Import {
+ FuncImport() : Import(ExternalKind::Func) {}
+ FuncImport(string_view module_name, string_view field_name)
+ : Import(ExternalKind::Func, module_name, field_name) {}
+
+ Index sig_index = kInvalidIndex;
+};
+
+struct TableImport : Import {
+ TableImport() : Import(ExternalKind::Table) { ZeroMemory(limits); }
+ TableImport(string_view module_name, string_view field_name)
+ : Import(ExternalKind::Table, module_name, field_name) {}
+
+ Limits limits;
+};
+
+struct MemoryImport : Import {
+ MemoryImport() : Import(ExternalKind::Memory) { ZeroMemory(limits); }
+ MemoryImport(string_view module_name, string_view field_name)
+ : Import(ExternalKind::Memory, module_name, field_name) {}
+
+ Limits limits;
+};
+
+struct GlobalImport : Import {
+ GlobalImport() : Import(ExternalKind::Global) {}
+ GlobalImport(string_view module_name, string_view field_name)
+ : Import(ExternalKind::Global, module_name, field_name) {}
+
+ Type type = Type::Void;
+ bool mutable_ = false;
+};
+
+struct ExceptImport : Import {
+ ExceptImport() : Import(ExternalKind::Except) {}
+ ExceptImport(string_view module_name, string_view field_name)
+ : Import(ExternalKind::Except, module_name, field_name) {}
};
struct Func;
@@ -210,9 +238,6 @@ struct Func {
: sig_index(sig_index), is_host(is_host) {}
virtual ~Func() {}
- inline struct DefinedFunc* as_defined();
- inline struct HostFunc* as_host();
-
Index sig_index;
bool is_host;
};
@@ -224,6 +249,8 @@ struct DefinedFunc : Func {
local_decl_count(0),
local_count(0) {}
+ static bool classof(const Func* func) { return !func->is_host; }
+
IstreamOffset offset;
Index local_decl_count;
Index local_count;
@@ -236,22 +263,14 @@ struct HostFunc : Func {
module_name(module_name.to_string()),
field_name(field_name.to_string()) {}
+ static bool classof(const Func* func) { return func->is_host; }
+
std::string module_name;
std::string field_name;
HostFuncCallback callback;
void* user_data;
};
-DefinedFunc* Func::as_defined() {
- assert(!is_host);
- return static_cast<DefinedFunc*>(this);
-}
-
-HostFunc* Func::as_host() {
- assert(is_host);
- return static_cast<HostFunc*>(this);
-}
-
struct Export {
Export(string_view name, ExternalKind kind, Index index)
: name(name.to_string()), kind(kind), index(index) {}
@@ -266,13 +285,19 @@ class HostImportDelegate {
typedef std::function<void(const char* msg)> ErrorCallback;
virtual ~HostImportDelegate() {}
- virtual wabt::Result ImportFunc(Import*,
+ virtual wabt::Result ImportFunc(FuncImport*,
Func*,
FuncSignature*,
const ErrorCallback&) = 0;
- virtual wabt::Result ImportTable(Import*, Table*, const ErrorCallback&) = 0;
- virtual wabt::Result ImportMemory(Import*, Memory*, const ErrorCallback&) = 0;
- virtual wabt::Result ImportGlobal(Import*, Global*, const ErrorCallback&) = 0;
+ virtual wabt::Result ImportTable(TableImport*,
+ Table*,
+ const ErrorCallback&) = 0;
+ virtual wabt::Result ImportMemory(MemoryImport*,
+ Memory*,
+ const ErrorCallback&) = 0;
+ virtual wabt::Result ImportGlobal(GlobalImport*,
+ Global*,
+ const ErrorCallback&) = 0;
};
struct Module {
@@ -281,9 +306,6 @@ struct Module {
Module(string_view name, bool is_host);
virtual ~Module() = default;
- inline struct DefinedModule* as_defined();
- inline struct HostModule* as_host();
-
Export* GetExport(string_view name);
std::string name;
@@ -296,8 +318,13 @@ struct Module {
struct DefinedModule : Module {
DefinedModule();
+ static bool classof(const Module* module) { return !module->is_host; }
- std::vector<Import> imports;
+ std::vector<FuncImport> func_imports;
+ std::vector<TableImport> table_imports;
+ std::vector<MemoryImport> memory_imports;
+ std::vector<GlobalImport> global_imports;
+ std::vector<ExceptImport> except_imports;
Index start_func_index; /* kInvalidIndex if not defined */
IstreamOffset istream_start;
IstreamOffset istream_end;
@@ -305,20 +332,11 @@ struct DefinedModule : Module {
struct HostModule : Module {
explicit HostModule(string_view name);
+ static bool classof(const Module* module) { return module->is_host; }
std::unique_ptr<HostImportDelegate> import_delegate;
};
-DefinedModule* Module::as_defined() {
- assert(!is_host);
- return static_cast<DefinedModule*>(this);
-}
-
-HostModule* Module::as_host() {
- assert(is_host);
- return static_cast<HostModule*>(this);
-}
-
class Environment {
public:
// Used to track and reset the state of the environment.
diff --git a/src/tools/wasm-interp.cc b/src/tools/wasm-interp.cc
index df9f8e4c..b79e3010 100644
--- a/src/tools/wasm-interp.cc
+++ b/src/tools/wasm-interp.cc
@@ -25,6 +25,7 @@
#include "binary-reader-interpreter.h"
#include "binary-reader.h"
+#include "cast.h"
#include "error-handler.h"
#include "feature.h"
#include "interpreter.h"
@@ -344,12 +345,12 @@ static interpreter::Result DefaultHostCallback(
class SpectestHostImportDelegate : public HostImportDelegate {
public:
- wabt::Result ImportFunc(interpreter::Import* import,
+ wabt::Result ImportFunc(interpreter::FuncImport* import,
interpreter::Func* func,
interpreter::FuncSignature* func_sig,
const ErrorCallback& callback) override {
if (import->field_name == "print") {
- func->as_host()->callback = DefaultHostCallback;
+ cast<HostFunc>(func)->callback = DefaultHostCallback;
return wabt::Result::Ok;
} else {
PrintError(callback, "unknown host function import " PRIimport,
@@ -358,7 +359,7 @@ class SpectestHostImportDelegate : public HostImportDelegate {
}
}
- wabt::Result ImportTable(interpreter::Import* import,
+ wabt::Result ImportTable(interpreter::TableImport* import,
interpreter::Table* table,
const ErrorCallback& callback) override {
if (import->field_name == "table") {
@@ -373,7 +374,7 @@ class SpectestHostImportDelegate : public HostImportDelegate {
}
}
- wabt::Result ImportMemory(interpreter::Import* import,
+ wabt::Result ImportMemory(interpreter::MemoryImport* import,
interpreter::Memory* memory,
const ErrorCallback& callback) override {
if (import->field_name == "memory") {
@@ -389,7 +390,7 @@ class SpectestHostImportDelegate : public HostImportDelegate {
}
}
- wabt::Result ImportGlobal(interpreter::Import* import,
+ wabt::Result ImportGlobal(interpreter::GlobalImport* import,
interpreter::Global* global,
const ErrorCallback& callback) override {
if (import->field_name == "global") {
diff --git a/test/spec/globals.txt b/test/spec/globals.txt
index 1bde1463..b9c9400e 100644
--- a/test/spec/globals.txt
+++ b/test/spec/globals.txt
@@ -6,10 +6,10 @@ out/third_party/testsuite/globals.wast:50: assert_invalid passed:
0000026: error: OnSetGlobalExpr callback failed
out/third_party/testsuite/globals.wast:55: assert_invalid passed:
error: unknown import module "m"
- 0000012: error: OnImport callback failed
+ 0000012: error: OnImportGlobal callback failed
out/third_party/testsuite/globals.wast:60: assert_invalid passed:
error: unknown import module "m"
- 0000012: error: OnImport callback failed
+ 0000012: error: OnImportGlobal callback failed
out/third_party/testsuite/globals.wast:65: assert_invalid passed:
error: mutable globals cannot be exported
000001a: error: OnExport callback failed
diff --git a/test/spec/imports.txt b/test/spec/imports.txt
index ad5786e6..1faf3280 100644
--- a/test/spec/imports.txt
+++ b/test/spec/imports.txt
@@ -13,7 +13,7 @@ called host spectest.print(f64:24.000000) =>
called host spectest.print(f64:24.000000) =>
out/third_party/testsuite/imports.wast:99: assert_unlinkable passed:
error: unknown module field "unknown"
- 0000020: error: OnImport callback failed
+ 0000020: error: OnImportFunc callback failed
out/third_party/testsuite/imports.wast:103: assert_unlinkable passed:
error: unknown host function import "spectest.unknown"
0000024: error: OnImportFunc callback failed
@@ -85,7 +85,7 @@ out/third_party/testsuite/imports.wast:193: assert_unlinkable passed:
0000023: error: OnImportFunc callback failed
out/third_party/testsuite/imports.wast:227: assert_unlinkable passed:
error: unknown module field "unknown"
- 000001b: error: OnImport callback failed
+ 000001b: error: OnImportGlobal callback failed
out/third_party/testsuite/imports.wast:231: assert_unlinkable passed:
error: unknown host global import "spectest.unknown"
000001f: error: OnImportGlobal callback failed
@@ -109,15 +109,15 @@ out/third_party/testsuite/imports.wast:256: assert_unlinkable passed:
000001e: error: OnImportGlobal callback failed
out/third_party/testsuite/imports.wast:298: assert_invalid passed:
error: unknown import module ""
- 0000011: error: OnImport callback failed
+ 0000011: error: OnImportTable callback failed
out/third_party/testsuite/imports.wast:302: assert_invalid passed:
error: unknown import module ""
- 0000011: error: OnImport callback failed
+ 0000011: error: OnImportTable callback failed
out/third_party/testsuite/imports.wast:306: assert_invalid passed:
000000b: error: table count (2) must be 0 or 1
out/third_party/testsuite/imports.wast:323: assert_unlinkable passed:
error: unknown module field "unknown"
- 000001c: error: OnImport callback failed
+ 000001c: error: OnImportTable callback failed
out/third_party/testsuite/imports.wast:327: assert_unlinkable passed:
error: unknown host table import "spectest.unknown"
0000020: error: OnImportTable callback failed
@@ -147,15 +147,15 @@ out/third_party/testsuite/imports.wast:361: assert_unlinkable passed:
000001e: error: OnImportTable callback failed
out/third_party/testsuite/imports.wast:393: assert_invalid passed:
error: unknown import module ""
- 0000010: error: OnImport callback failed
+ 0000010: error: OnImportMemory callback failed
out/third_party/testsuite/imports.wast:397: assert_invalid passed:
error: unknown import module ""
- 0000010: error: OnImport callback failed
+ 0000010: error: OnImportMemory callback failed
out/third_party/testsuite/imports.wast:401: assert_invalid passed:
000000b: error: memory count must be 0 or 1
out/third_party/testsuite/imports.wast:416: assert_unlinkable passed:
error: unknown module field "unknown"
- 000001b: error: OnImport callback failed
+ 000001b: error: OnImportMemory callback failed
out/third_party/testsuite/imports.wast:420: assert_unlinkable passed:
error: unknown host memory import "spectest.unknown"
000001f: error: OnImportMemory callback failed
diff --git a/test/spec/linking.txt b/test/spec/linking.txt
index d8d9e831..081f24c2 100644
--- a/test/spec/linking.txt
+++ b/test/spec/linking.txt
@@ -12,7 +12,7 @@ out/third_party/testsuite/linking.wast:166: assert_unlinkable passed:
0000029: error: OnElemSegmentFunctionIndex callback failed
out/third_party/testsuite/linking.wast:175: assert_unlinkable passed:
error: unknown module field "mem"
- 0000027: error: OnImport callback failed
+ 0000027: error: OnImportMemory callback failed
out/third_party/testsuite/linking.wast:187: assert_unlinkable passed:
error: elem segment offset is out of bounds: 12 >= max value 10
0000030: error: OnElemSegmentFunctionIndex callback failed
@@ -25,7 +25,7 @@ out/third_party/testsuite/linking.wast:258: assert_unlinkable passed:
out/third_party/testsuite/linking.wast:283: assert_unlinkable passed:
error: duplicate export "print"
error: unknown module field "tab"
- 0000037: error: OnImport callback failed
+ 0000037: error: OnImportTable callback failed
out/third_party/testsuite/linking.wast:294: assert_unlinkable passed:
error: data segment is out of bounds: [327680, 327681) >= max value 327680
0000028: error: OnDataSegmentData callback failed