diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/wasm-interpreter.h | 21 | ||||
-rw-r--r-- | src/wasm-js.cpp | 10 |
2 files changed, 17 insertions, 14 deletions
diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h index 3ac3cf1e4..b8f6554ec 100644 --- a/src/wasm-interpreter.h +++ b/src/wasm-interpreter.h @@ -145,7 +145,7 @@ private: class FunctionScope { public: - std::map<IString, Literal> locals; + std::vector<Literal> locals; Function* function; FunctionScope(Function* function, LiteralList& arguments) @@ -156,6 +156,7 @@ private: << arguments.size() << " arguments." << std::endl; abort(); } + locals.resize(function->getNumLocals()); for (size_t i = 0; i < function->getNumLocals(); i++) { if (i < arguments.size()) { assert(function->isParam(i)); @@ -166,10 +167,10 @@ private: << printWasmType(arguments[i].type) << "." << std::endl; abort(); } - locals[function->getLocalName(i)] = arguments[i]; + locals[i] = arguments[i]; } else { assert(function->isVar(i)); - locals[function->getLocalName(i)].type = function->getLocalType(i); + locals[i].type = function->getLocalType(i); } } } @@ -358,20 +359,20 @@ private: Flow visitGetLocal(GetLocal *curr) { NOTE_ENTER("GetLocal"); - IString name = scope.function->getLocalName(curr->index); - NOTE_NAME(name); - NOTE_EVAL1(scope.locals[name]); - return scope.locals[name]; + auto index = curr->index; + NOTE_EVAL1(index); + NOTE_EVAL1(scope.locals[index]); + return scope.locals[index]; } Flow visitSetLocal(SetLocal *curr) { NOTE_ENTER("SetLocal"); - IString name = scope.function->getLocalName(curr->index); + auto index = curr->index; Flow flow = visit(curr->value); if (flow.breaking()) return flow; - NOTE_NAME(name); + NOTE_EVAL1(index); NOTE_EVAL1(flow.value); assert(flow.value.type == curr->type); - scope.locals[name] = flow.value; + scope.locals[index] = flow.value; return flow; } Flow visitLoad(Load *curr) { diff --git a/src/wasm-js.cpp b/src/wasm-js.cpp index ea1883072..87059f9be 100644 --- a/src/wasm-js.cpp +++ b/src/wasm-js.cpp @@ -91,7 +91,7 @@ extern "C" void EMSCRIPTEN_KEEPALIVE load_asm2wasm(char *input) { auto& global = pair.second; if (!global.import) continue; // non-imports are initialized to zero in the typed array anyhow, so nothing to do here double value = EM_ASM_DOUBLE({ return Module['lookupImport'](Pointer_stringify($0), Pointer_stringify($1)) }, global.module.str, global.base.str); - unsigned address = global.address; + uint32_t address = global.address; switch (global.type) { case i32: EM_ASM_({ Module['info'].parent['HEAP32'][$0 >> 2] = $1 }, address, value); break; case f32: EM_ASM_({ Module['info'].parent['HEAPF32'][$0 >> 2] = $1 }, address, value); break; @@ -196,7 +196,7 @@ extern "C" void EMSCRIPTEN_KEEPALIVE instantiate() { var source = Module['HEAP8'].subarray($1, $1 + $2); var target = new Int8Array(Module['outside']['newBuffer']); target.set(source, $0); - }, segment.offset, &segment.data[0], segment.data.size()); + }, (uint32_t)segment.offset, &segment.data[0], segment.data.size()); } } @@ -236,7 +236,8 @@ extern "C" void EMSCRIPTEN_KEEPALIVE instantiate() { } } - Literal load(Load* load, Address addr) override { + Literal load(Load* load, Address address) override { + uint32_t addr = address; if (load->align < load->bytes || (addr & (load->bytes-1))) { int64_t out64; double ret = EM_ASM_DOUBLE({ @@ -325,7 +326,8 @@ extern "C" void EMSCRIPTEN_KEEPALIVE instantiate() { } } - void store(Store* store_, Address addr, Literal value) override { + void store(Store* store_, Address address, Literal value) override { + uint32_t addr = address; // support int64 stores if (value.type == WasmType::i64) { Store fake = *store_; |