diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/asm2wasm-main.cpp | 2 | ||||
-rw-r--r-- | src/asm2wasm.h | 4 | ||||
-rw-r--r-- | src/binaryen-shell.cpp | 6 | ||||
-rw-r--r-- | src/js/binaryen.idl | 8 | ||||
-rw-r--r-- | src/s2wasm-main.cpp | 2 | ||||
-rw-r--r-- | src/s2wasm.h | 4 | ||||
-rw-r--r-- | src/wasm-as.cpp | 2 | ||||
-rw-r--r-- | src/wasm-binary.h | 4 | ||||
-rw-r--r-- | src/wasm-builder.h | 2 | ||||
-rw-r--r-- | src/wasm-dis.cpp | 2 | ||||
-rw-r--r-- | src/wasm-js.cpp | 8 | ||||
-rw-r--r-- | src/wasm-s-parser.h | 6 | ||||
-rw-r--r-- | src/wasm.h | 7 | ||||
-rw-r--r-- | src/wasm2asm-main.cpp | 2 |
14 files changed, 25 insertions, 34 deletions
diff --git a/src/asm2wasm-main.cpp b/src/asm2wasm-main.cpp index a9b1197ff..e18f78de9 100644 --- a/src/asm2wasm-main.cpp +++ b/src/asm2wasm-main.cpp @@ -90,7 +90,7 @@ int main(int argc, const char *argv[]) { } if (options.debug) std::cerr << "wasming..." << std::endl; - AllocatingModule wasm; + Module wasm; wasm.memory.initial = wasm.memory.max = totalMemory / Memory::kPageSize; Asm2WasmBuilder asm2wasm(wasm, pre.memoryGrowth, options.debug, imprecise); asm2wasm.processAsm(asmjs); diff --git a/src/asm2wasm.h b/src/asm2wasm.h index da97d7580..05f3a2c0c 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -129,7 +129,7 @@ struct Asm2WasmPreProcessor { // class Asm2WasmBuilder { - AllocatingModule& wasm; + Module& wasm; MixedArena &allocator; @@ -266,7 +266,7 @@ private: } public: - Asm2WasmBuilder(AllocatingModule& wasm, bool memoryGrowth, bool debug, bool imprecise) + Asm2WasmBuilder(Module& wasm, bool memoryGrowth, bool debug, bool imprecise) : wasm(wasm), allocator(wasm.allocator), builder(wasm), diff --git a/src/binaryen-shell.cpp b/src/binaryen-shell.cpp index 82094a697..12cda7a5d 100644 --- a/src/binaryen-shell.cpp +++ b/src/binaryen-shell.cpp @@ -74,7 +74,7 @@ static void verify_result(Literal a, Literal b) { } } -static void run_asserts(size_t* i, bool* checked, AllocatingModule* wasm, +static void run_asserts(size_t* i, bool* checked, Module* wasm, Element* root, std::unique_ptr<SExpressionWasmBuilder>* builder, Name entry) { @@ -112,7 +112,7 @@ static void run_asserts(size_t* i, bool* checked, AllocatingModule* wasm, std::cerr << curr << '\n'; if (id == ASSERT_INVALID) { // a module invalidity test - AllocatingModule wasm; + Module wasm; bool invalid = false; std::unique_ptr<SExpressionWasmBuilder> builder; try { @@ -217,7 +217,7 @@ int main(int argc, const char* argv[]) { IString id = curr[0]->str(); if (id == MODULE) { if (options.debug) std::cerr << "parsing s-expressions to wasm...\n"; - AllocatingModule wasm; + Module wasm; std::unique_ptr<SExpressionWasmBuilder> builder( new SExpressionWasmBuilder(wasm, *root[i], [&]() { abort(); })); i++; diff --git a/src/js/binaryen.idl b/src/js/binaryen.idl index 3b52b5912..3d0116db9 100644 --- a/src/js/binaryen.idl +++ b/src/js/binaryen.idl @@ -13,12 +13,6 @@ interface Name { interface Module { }; -interface AllocatingModule { - void AllocatingModule(); -}; - -AllocatingModule implements Module; - [Prefix="ModuleInstance::", NoDelete] interface ExternalInterface { }; @@ -63,7 +57,7 @@ interface SExpressionParser { }; interface SExpressionWasmBuilder { - void SExpressionWasmBuilder([Ref] AllocatingModule wasm, [Ref] Element input, boolean debug); + void SExpressionWasmBuilder([Ref] Module wasm, [Ref] Element input, boolean debug); }; // Wasm printing diff --git a/src/s2wasm-main.cpp b/src/s2wasm-main.cpp index f22116978..6e9592e21 100644 --- a/src/s2wasm-main.cpp +++ b/src/s2wasm-main.cpp @@ -83,7 +83,7 @@ int main(int argc, const char *argv[]) { auto input(read_file<std::string>(options.extra["infile"], Flags::Text, options.debug ? Flags::Debug : Flags::Release)); if (options.debug) std::cerr << "Parsing and wasming..." << std::endl; - AllocatingModule wasm; + Module wasm; uint64_t globalBase = options.extra.find("global-base") != options.extra.end() ? std::stoull(options.extra["global-base"]) : 0; diff --git a/src/s2wasm.h b/src/s2wasm.h index 4cfb4a20d..51d2a0e2f 100644 --- a/src/s2wasm.h +++ b/src/s2wasm.h @@ -39,7 +39,7 @@ cashew::IString EMSCRIPTEN_ASM_CONST("emscripten_asm_const"); // class S2WasmBuilder { - AllocatingModule& wasm; + Module& wasm; MixedArena& allocator; const char* s; bool debug; @@ -48,7 +48,7 @@ class S2WasmBuilder { std::vector<Name> globls; public: - S2WasmBuilder(AllocatingModule& wasm, const char* input, bool debug, + S2WasmBuilder(Module& wasm, const char* input, bool debug, size_t globalBase, size_t stackAllocation, size_t userInitialMemory, size_t userMaxMemory, bool ignoreUnknownSymbols, Name startFunction) diff --git a/src/wasm-as.cpp b/src/wasm-as.cpp index c2a8abc6e..eb03f853a 100644 --- a/src/wasm-as.cpp +++ b/src/wasm-as.cpp @@ -48,7 +48,7 @@ int main(int argc, const char *argv[]) { Element& root = *parser.root; if (options.debug) std::cerr << "w-parsing..." << std::endl; - AllocatingModule wasm; + Module wasm; SExpressionWasmBuilder builder(wasm, *root[0], [&]() { abort(); }); if (options.debug) std::cerr << "binarification..." << std::endl; diff --git a/src/wasm-binary.h b/src/wasm-binary.h index 0af60600d..935ffbae6 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -1120,7 +1120,7 @@ public: }; class WasmBinaryBuilder { - AllocatingModule& wasm; + Module& wasm; MixedArena& allocator; std::vector<char>& input; bool debug; @@ -1129,7 +1129,7 @@ class WasmBinaryBuilder { int32_t startIndex = -1; public: - WasmBinaryBuilder(AllocatingModule& wasm, std::vector<char>& input, bool debug) : wasm(wasm), allocator(wasm.allocator), input(input), debug(debug) {} + WasmBinaryBuilder(Module& wasm, std::vector<char>& input, bool debug) : wasm(wasm), allocator(wasm.allocator), input(input), debug(debug) {} void read() { diff --git a/src/wasm-builder.h b/src/wasm-builder.h index 0d6ba30cd..336a90e0d 100644 --- a/src/wasm-builder.h +++ b/src/wasm-builder.h @@ -36,7 +36,7 @@ class Builder { MixedArena &allocator; public: - Builder(AllocatingModule& wasm) : allocator(wasm.allocator) {} + Builder(Module& wasm) : allocator(wasm.allocator) {} // make* functions, create nodes diff --git a/src/wasm-dis.cpp b/src/wasm-dis.cpp index 5e1e61682..e2e103b46 100644 --- a/src/wasm-dis.cpp +++ b/src/wasm-dis.cpp @@ -44,7 +44,7 @@ int main(int argc, const char *argv[]) { auto input(read_file<std::vector<char>>(options.extra["infile"], Flags::Binary, options.debug ? Flags::Debug : Flags::Release)); if (options.debug) std::cerr << "parsing binary..." << std::endl; - AllocatingModule wasm; + Module wasm; WasmBinaryBuilder parser(wasm, input, options.debug); parser.read(); diff --git a/src/wasm-js.cpp b/src/wasm-js.cpp index c9cb06118..c1c7d10ec 100644 --- a/src/wasm-js.cpp +++ b/src/wasm-js.cpp @@ -41,7 +41,7 @@ Asm2WasmBuilder* asm2wasm = nullptr; SExpressionParser* sExpressionParser = nullptr; SExpressionWasmBuilder* sExpressionWasmBuilder = nullptr; ModuleInstance* instance = nullptr; -AllocatingModule* module = nullptr; +Module* module = nullptr; bool wasmJSDebug = false; static void prepare2wasm() { @@ -67,7 +67,7 @@ extern "C" void EMSCRIPTEN_KEEPALIVE load_asm2wasm(char *input) { cashew::Parser<Ref, DotZeroValueBuilder> builder; Ref asmjs = builder.parseToplevel(input); - module = new AllocatingModule(); + module = new Module(); uint32_t providedMemory = EM_ASM_INT_V({ return Module['providedTotalMemory']; // we receive the size of memory from emscripten }); @@ -127,7 +127,7 @@ extern "C" void EMSCRIPTEN_KEEPALIVE load_s_expr2wasm(char *input) { if (wasmJSDebug) std::cerr << "wasming...\n"; - module = new AllocatingModule(); + module = new Module(); // A .wast may have multiple modules, with some asserts after them, but we just read the first here. sExpressionWasmBuilder = new SExpressionWasmBuilder(*module, *root[0], [&]() { std::cerr << "error in parsing s-expressions to wasm\n"; @@ -143,7 +143,7 @@ extern "C" void EMSCRIPTEN_KEEPALIVE load_binary2wasm(char *raw, int32_t size) { if (wasmJSDebug) std::cerr << "wasm-binary parsing...\n"; - module = new AllocatingModule(); + module = new Module(); std::vector<char> input; input.resize(size); for (int32_t i = 0; i < size; i++) { diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h index 994aac4da..c1a1162e1 100644 --- a/src/wasm-s-parser.h +++ b/src/wasm-s-parser.h @@ -236,7 +236,7 @@ private: // class SExpressionWasmBuilder { - AllocatingModule& wasm; + Module& wasm; MixedArena& allocator; std::function<void ()> onError; std::vector<Name> functionNames; @@ -246,7 +246,7 @@ class SExpressionWasmBuilder { public: // Assumes control of and modifies the input. - SExpressionWasmBuilder(AllocatingModule& wasm, Element& module, std::function<void ()> onError) : wasm(wasm), allocator(wasm.allocator), onError(onError), importCounter(0) { + SExpressionWasmBuilder(Module& wasm, Element& module, std::function<void ()> onError) : wasm(wasm), allocator(wasm.allocator), onError(onError), importCounter(0) { assert(module[0]->str() == MODULE); functionCounter = 0; for (unsigned i = 1; i < module.size(); i++) { @@ -260,7 +260,7 @@ public: } // constructor without onError - SExpressionWasmBuilder(AllocatingModule& wasm, Element& module) : SExpressionWasmBuilder(wasm, module, [&]() { abort(); }) {} + SExpressionWasmBuilder(Module& wasm, Element& module) : SExpressionWasmBuilder(wasm, module, [&]() { abort(); }) {} private: diff --git a/src/wasm.h b/src/wasm.h index d62d4fcab..93c9d8709 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -1174,6 +1174,8 @@ public: Memory memory; Name start; + MixedArena allocator; + private: // TODO: add a build option where Names are just indices, and then these methods are not needed std::map<Name, FunctionType*> functionTypesMap; @@ -1257,11 +1259,6 @@ private: size_t functionTypeIndex, importIndex, exportIndex, functionIndex; }; -class AllocatingModule : public Module { - public: - MixedArena allocator; -}; - } // namespace wasm #endif // wasm_wasm_h diff --git a/src/wasm2asm-main.cpp b/src/wasm2asm-main.cpp index 2234f2343..fa652cb47 100644 --- a/src/wasm2asm-main.cpp +++ b/src/wasm2asm-main.cpp @@ -51,7 +51,7 @@ int main(int argc, const char *argv[]) { Element &root = *parser.root; if (options.debug) std::cerr << "w-parsing..." << std::endl; - AllocatingModule wasm; + Module wasm; SExpressionWasmBuilder builder(wasm, *root[0], [&]() { abort(); }); if (options.debug) std::cerr << "asming..." << std::endl; |