summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-04-18 17:56:23 -0700
committerAlon Zakai <alonzakai@gmail.com>2016-04-18 17:56:23 -0700
commiteb50dce005ad4ca10aaad7d15aa7a518d39ae887 (patch)
tree384eb285911224c5fb80f96aaa3c205a9963536f /src
parent684ed50648fd45199edca7532c743b16a7050695 (diff)
parent237cb832673ba6478bcd9bfa395f2f2c07e97a9d (diff)
downloadbinaryen-eb50dce005ad4ca10aaad7d15aa7a518d39ae887.tar.gz
binaryen-eb50dce005ad4ca10aaad7d15aa7a518d39ae887.tar.bz2
binaryen-eb50dce005ad4ca10aaad7d15aa7a518d39ae887.zip
Merge pull request #364 from WebAssembly/updates
Spec test updates
Diffstat (limited to 'src')
-rw-r--r--src/passes/Print.cpp2
-rw-r--r--src/s2wasm.h2
-rw-r--r--src/wasm-binary.h10
-rw-r--r--src/wasm-interpreter.h21
-rw-r--r--src/wasm-js.cpp4
-rw-r--r--src/wasm-s-parser.h6
-rw-r--r--src/wasm.h4
7 files changed, 22 insertions, 27 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index aa533849f..ddeec3dce 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -383,7 +383,7 @@ struct PrintSExpression : public Visitor<PrintSExpression> {
void visitHost(Host *curr) {
switch (curr->op) {
case PageSize: printOpening(o, "pagesize") << ')'; break;
- case MemorySize: printOpening(o, "memory_size") << ')'; break;
+ case CurrentMemory: printOpening(o, "current_memory") << ')'; break;
case GrowMemory: {
printOpening(o, "grow_memory");
incIndent();
diff --git a/src/s2wasm.h b/src/s2wasm.h
index ff3c1f29f..d0dbe8c6a 100644
--- a/src/s2wasm.h
+++ b/src/s2wasm.h
@@ -1066,7 +1066,7 @@ class S2WasmBuilder {
} else if (match("unreachable")) {
addToBlock(allocator.alloc<Unreachable>());
} else if (match("memory_size")) {
- makeHost(MemorySize);
+ makeHost(CurrentMemory);
} else if (match("grow_memory")) {
makeHost1(GrowMemory);
} else if (match(".Lfunc_end")) {
diff --git a/src/wasm-binary.h b/src/wasm-binary.h
index db2c0d71d..08dafc563 100644
--- a/src/wasm-binary.h
+++ b/src/wasm-binary.h
@@ -237,7 +237,7 @@ enum FunctionEntry {
};
enum ASTNodes {
- MemorySize = 0x3b,
+ CurrentMemory = 0x3b,
GrowMemory = 0x39,
I32Add = 0x40,
I32Sub = 0x41,
@@ -1097,8 +1097,8 @@ public:
void visitHost(Host *curr) {
if (debug) std::cerr << "zz node: Host" << std::endl;
switch (curr->op) {
- case MemorySize: {
- o << int8_t(BinaryConsts::MemorySize);
+ case CurrentMemory: {
+ o << int8_t(BinaryConsts::CurrentMemory);
break;
}
case GrowMemory: {
@@ -1943,8 +1943,8 @@ public:
}
bool maybeVisitImpl(Host *curr, uint8_t code) {
switch (code) {
- case BinaryConsts::MemorySize: {
- curr->op = MemorySize;
+ case BinaryConsts::CurrentMemory: {
+ curr->op = CurrentMemory;
curr->type = i32;
break;
}
diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h
index 8f3f09ed1..3d4eea722 100644
--- a/src/wasm-interpreter.h
+++ b/src/wasm-interpreter.h
@@ -292,24 +292,23 @@ private:
}
Flow visitSwitch(Switch *curr) {
NOTE_ENTER("Switch");
- Flow flow = visit(curr->condition);
- if (flow.breaking()) return flow;
- NOTE_EVAL1(flow.value);
- int64_t index = flow.value.getInteger();
-
+ Flow flow;
+ Literal value;
if (curr->value) {
flow = visit(curr->value);
if (flow.breaking()) return flow;
- NOTE_EVAL1(flow.value);
- } else {
- flow = Flow();
+ value = flow.value;
+ NOTE_EVAL1(value);
}
-
+ flow = visit(curr->condition);
+ if (flow.breaking()) return flow;
+ int64_t index = flow.value.getInteger();
Name target = curr->default_;
if (index >= 0 && (size_t)index < curr->targets.size()) {
target = curr->targets[(size_t)index];
}
flow.breakTo = target;
+ flow.value = value;
return flow;
}
@@ -605,7 +604,7 @@ private:
NOTE_ENTER("Host");
switch (curr->op) {
case PageSize: return Literal((int32_t)Memory::kPageSize);
- case MemorySize: return Literal(int32_t(instance.memorySize * Memory::kPageSize));
+ case CurrentMemory: return Literal(int32_t(instance.memorySize));
case GrowMemory: {
Flow flow = visit(curr->operands[0]);
if (flow.breaking()) return flow;
@@ -617,7 +616,7 @@ private:
if (newSize > instance.wasm.memory.max) trap("growMemory: exceeds max");
instance.externalInterface->growMemory(instance.memorySize * Memory::kPageSize, newSize * Memory::kPageSize);
instance.memorySize = newSize;
- return Literal(int32_t(ret * Memory::kPageSize));
+ return Literal(int32_t(ret));
}
case HasFeature: {
IString id = curr->nameOperand;
diff --git a/src/wasm-js.cpp b/src/wasm-js.cpp
index c1c7d10ec..116c52667 100644
--- a/src/wasm-js.cpp
+++ b/src/wasm-js.cpp
@@ -132,7 +132,7 @@ extern "C" void EMSCRIPTEN_KEEPALIVE load_s_expr2wasm(char *input) {
sExpressionWasmBuilder = new SExpressionWasmBuilder(*module, *root[0], [&]() {
std::cerr << "error in parsing s-expressions to wasm\n";
abort();
- }, false);
+ });
finalizeModule();
}
@@ -436,7 +436,7 @@ extern "C" void EMSCRIPTEN_KEEPALIVE call_from_js(const char *target) {
size_t actual = function->params.size();
ModuleInstance::LiteralList arguments;
for (size_t i = 0; i < actual; i++) {
- WasmType type = function->params[i].type;
+ WasmType type = function->params[i];
// add the parameter, with a zero value if JS did not provide it.
if (type == i32) {
arguments.push_back(Literal(i < seen ? EM_ASM_INT({ return Module['tempArguments'][$0] }, i) : (int32_t)0));
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h
index c1a1162e1..be3263312 100644
--- a/src/wasm-s-parser.h
+++ b/src/wasm-s-parser.h
@@ -623,7 +623,7 @@ public:
if (id == CALL) return makeCall(s);
if (id == CALL_IMPORT) return makeCallImport(s);
if (id == CALL_INDIRECT) return makeCallIndirect(s);
- }
+ } else if (str[1] == 'u') return makeHost(s, HostOp::CurrentMemory);
abort_on(str);
}
case 'e': {
@@ -647,10 +647,6 @@ public:
if (str[1] == 'o') return makeLoop(s);
abort_on(str);
}
- case 'm': {
- if (str[1] == 'e') return makeHost(s, HostOp::MemorySize);
- abort_on(str);
- }
case 'n': {
if (str[1] == 'o') return allocator.alloc<Nop>();
abort_on(str);
diff --git a/src/wasm.h b/src/wasm.h
index 93c9d8709..ee2f27388 100644
--- a/src/wasm.h
+++ b/src/wasm.h
@@ -709,7 +709,7 @@ enum BinaryOp {
};
enum HostOp {
- PageSize, MemorySize, GrowMemory, HasFeature
+ PageSize, CurrentMemory, GrowMemory, HasFeature
};
//
@@ -1041,7 +1041,7 @@ public:
void finalize() {
switch (op) {
- case PageSize: case MemorySize: case HasFeature: {
+ case PageSize: case CurrentMemory: case HasFeature: {
type = i32;
break;
}