@@ -71,23 +71,16 @@ class EvallingModuleRunner;
7171
7272class EvallingImportResolver : public ImportResolver {
7373public:
74- EvallingImportResolver (
75- std::map<Name, std::shared_ptr<EvallingModuleRunner>> linkedInstances,
76- ModuleRunnerBase<EvallingModuleRunner>::ExternalInterface*
77- externalInterface)
78- : externalInterface(externalInterface) {}
74+ EvallingImportResolver () {}
7975
8076 std::optional<Literals*> getGlobal (QualifiedName name,
8177 Type type) const override {
82- externalInterface->trap ((std::stringstream ()
83- << " EvallingImportResolver: unexpected getGlobal "
84- << name)
85- .str ());
86- return std::nullopt ;
78+ auto [it, _] = stubLiterals.try_emplace (name, Literals ({Literal (type)}));
79+ return &it->second ;
8780 }
8881
8982private:
90- ModuleRunnerBase<EvallingModuleRunner>::ExternalInterface* externalInterface ;
83+ mutable std::map<QualifiedName, Literals> stubLiterals ;
9184};
9285
9386class EvallingModuleRunner : public ModuleRunnerBase <EvallingModuleRunner> {
@@ -98,8 +91,7 @@ class EvallingModuleRunner : public ModuleRunnerBase<EvallingModuleRunner> {
9891 std::map<Name, std::shared_ptr<EvallingModuleRunner>> linkedInstances_ = {})
9992 : ModuleRunnerBase(wasm,
10093 externalInterface,
101- std::make_shared<EvallingImportResolver>(
102- linkedInstances_, externalInterface),
94+ std::make_shared<EvallingImportResolver>(),
10395 linkedInstances_) {}
10496
10597 Flow visitGlobalGet (GlobalGet* curr) {
@@ -570,6 +562,9 @@ struct CtorEvalExternalInterface : EvallingModuleRunner::ExternalInterface {
570562 wasm->updateMaps ();
571563
572564 for (auto & oldGlobal : oldGlobals) {
565+ if (oldGlobal->imported ()) {
566+ continue ;
567+ }
573568 // Serialize the global's value. While doing so, pass in the name of this
574569 // global, as we may be able to reuse the global as the defining global
575570 // for the value. See getSerialization() for more details.
0 commit comments