summaryrefslogtreecommitdiff
path: root/src/wasm-interpreter.h
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-05-18 20:28:43 -0700
committerAlon Zakai <alonzakai@gmail.com>2016-05-18 23:11:07 -0700
commit50c94e3e9fb6cdf043c7841d73299ee8be5d2cbd (patch)
treee95b728bfad8651cfb89b4a8d3e2f292e440011c /src/wasm-interpreter.h
parentd8adcc182d69974096063ad57b50e8fec3fcccf8 (diff)
downloadbinaryen-50c94e3e9fb6cdf043c7841d73299ee8be5d2cbd.tar.gz
binaryen-50c94e3e9fb6cdf043c7841d73299ee8be5d2cbd.tar.bz2
binaryen-50c94e3e9fb6cdf043c7841d73299ee8be5d2cbd.zip
store locals in a vector in the interpreter and update wasm.js. also fix address usage in wasm.js
Diffstat (limited to 'src/wasm-interpreter.h')
-rw-r--r--src/wasm-interpreter.h21
1 files changed, 11 insertions, 10 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) {