summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-02-21 12:10:26 -0800
committerAlon Zakai <alonzakai@gmail.com>2016-02-21 12:10:26 -0800
commited567a4f49d3296dcf91bdb966c0deb077dacff7 (patch)
tree736f07fcd61a8c4623938220c6c3768c3d2b5807 /src
parent7bf31d447bca02947b56f05edf0a171c68c92c7a (diff)
parent1956794aa5200274d7b67329be55bf97af83f49e (diff)
downloadbinaryen-ed567a4f49d3296dcf91bdb966c0deb077dacff7.tar.gz
binaryen-ed567a4f49d3296dcf91bdb966c0deb077dacff7.tar.bz2
binaryen-ed567a4f49d3296dcf91bdb966c0deb077dacff7.zip
Merge pull request #209 from WebAssembly/asm-fixes
Asm fixes
Diffstat (limited to 'src')
-rw-r--r--src/asm2wasm.h9
-rw-r--r--src/binaryen-shell.cpp1
-rw-r--r--src/shared-constants.h1
-rw-r--r--src/wasm-s-parser.h3
-rw-r--r--src/wasm.h9
5 files changed, 12 insertions, 11 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h
index 16ed0cf68..353f80413 100644
--- a/src/asm2wasm.h
+++ b/src/asm2wasm.h
@@ -197,6 +197,7 @@ private:
IString Math_fround;
IString Math_abs;
IString Math_floor;
+ IString Math_ceil;
IString Math_sqrt;
// function types. we fill in this information as we see
@@ -458,6 +459,10 @@ void Asm2WasmBuilder::processAsm(Ref ast) {
assert(Math_floor.isNull());
Math_floor = name;
return;
+ } else if (imported[2] == CEIL) {
+ assert(Math_ceil.isNull());
+ Math_ceil = name;
+ return;
} else if (imported[2] == SQRT) {
assert(Math_sqrt.isNull());
Math_sqrt = name;
@@ -1126,12 +1131,12 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) {
abort();
}
}
- if (name == Math_floor || name == Math_sqrt) {
+ if (name == Math_floor || name == Math_sqrt || name == Math_ceil) {
// overloaded on type: f32 or f64
Expression* value = process(ast[2][0]);
if (value->type == f32 || value->type == f64) {
auto ret = allocator.alloc<Unary>();
- ret->op = name == Math_floor ? Floor : Sqrt;
+ ret->op = name == Math_floor ? Floor : name == Math_ceil ? Ceil : Sqrt;
ret->value = value;
ret->type = value->type;
return ret;
diff --git a/src/binaryen-shell.cpp b/src/binaryen-shell.cpp
index 68d00d019..866ea2fa4 100644
--- a/src/binaryen-shell.cpp
+++ b/src/binaryen-shell.cpp
@@ -376,7 +376,6 @@ int main(int argc, const char* argv[]) {
if (options.debug) std::cerr << "parsing text to s-expressions...\n";
SExpressionParser parser(input.data());
Element& root = *parser.root;
- if (options.debug) std::cout << root << '\n';
// A .wast may have multiple modules, with some asserts after them
bool checked = false;
diff --git a/src/shared-constants.h b/src/shared-constants.h
index 6662c50b2..053aecc83 100644
--- a/src/shared-constants.h
+++ b/src/shared-constants.h
@@ -46,6 +46,7 @@ cashew::IString GLOBAL("global"),
GLOBAL_MATH("global.Math"),
ABS("abs"),
FLOOR("floor"),
+ CEIL("ceil"),
SQRT("sqrt"),
I32_TEMP("asm2wasm_i32_temp"),
DEBUGGER("debugger"),
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h
index 64f127b91..cf900ce28 100644
--- a/src/wasm-s-parser.h
+++ b/src/wasm-s-parser.h
@@ -317,6 +317,7 @@ private:
// unnamed, use an index
func->name = Name::fromInt(functionCounter);
}
+ if (debug) std::cerr << "parse function " << func->name << '\n';
functionCounter++;
func->body = nullptr;
localIndex = 0;
@@ -416,7 +417,7 @@ public:
#define abort_on(str) { std::cerr << "aborting on " << str << '\n'; onError(); }
Expression* parseExpression(Element& s) {
- if (debug) std::cerr << "parse expression " << s << '\n';
+ //if (debug) std::cerr << "parse expression " << s << '\n';
IString id = s[0]->str();
const char *str = id.str;
const char *dot = strchr(str, '.');
diff --git a/src/wasm.h b/src/wasm.h
index 6aff3f55e..4c8dca331 100644
--- a/src/wasm.h
+++ b/src/wasm.h
@@ -104,6 +104,7 @@ inline const char* printWasmType(WasmType type) {
case WasmType::i64: return "i64";
case WasmType::f32: return "f32";
case WasmType::f64: return "f64";
+ case WasmType::unreachable: return "unreachable";
default: WASM_UNREACHABLE();
}
}
@@ -687,12 +688,6 @@ enum HostOp {
PageSize, MemorySize, GrowMemory, HasFeature
};
-#define assert_node(condition, node) \
- if (!(condition)) { \
- std::cerr << "node: " << (node) << std::endl; \
- assert(0 && #condition); \
- }
-
//
// Expressions
//
@@ -981,7 +976,7 @@ public:
if (isRelational()) {
type = i32;
} else {
- assert_node(left->type != unreachable && right->type != unreachable ? left->type == right->type : true, this);
+ assert(left->type != unreachable && right->type != unreachable ? left->type == right->type : true);
type = getReachableWasmType(left->type, right->type);
}
}