summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/literal.h5
-rw-r--r--src/wasm-builder.h2
-rw-r--r--src/wasm-interpreter.h8
3 files changed, 9 insertions, 6 deletions
diff --git a/src/literal.h b/src/literal.h
index 33300c920..86e460223 100644
--- a/src/literal.h
+++ b/src/literal.h
@@ -166,7 +166,7 @@ public:
WASM_UNREACHABLE("unexpected type");
}
}
- static Literal makeFromUInt64(uint64_t x, Type type) {
+ static Literal makeFromInt64(int64_t x, Type type) {
switch (type.getBasic()) {
case Type::i32:
return Literal(int32_t(x));
@@ -176,6 +176,9 @@ public:
return Literal(float(x));
case Type::f64:
return Literal(double(x));
+ case Type::v128:
+ return Literal(
+ std::array<Literal, 2>{{Literal(x), Literal(int64_t(0))}});
default:
WASM_UNREACHABLE("unexpected type");
}
diff --git a/src/wasm-builder.h b/src/wasm-builder.h
index a2f098a54..6433c1b57 100644
--- a/src/wasm-builder.h
+++ b/src/wasm-builder.h
@@ -486,7 +486,7 @@ public:
return ret;
}
Const* makeConstPtr(uint64_t val) {
- return makeConst(Literal::makeFromUInt64(val, wasm.memory.indexType));
+ return makeConst(Literal::makeFromInt64(val, wasm.memory.indexType));
}
Binary* makeBinary(BinaryOp op, Expression* left, Expression* right) {
auto* ret = wasm.allocator.alloc<Binary>();
diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h
index e44ffca3a..1f61685b8 100644
--- a/src/wasm-interpreter.h
+++ b/src/wasm-interpreter.h
@@ -2382,18 +2382,18 @@ private:
}
Flow visitMemorySize(MemorySize* curr) {
NOTE_ENTER("MemorySize");
- return Literal::makeFromUInt64(instance.memorySize,
- instance.wasm.memory.indexType);
+ return Literal::makeFromInt64(instance.memorySize,
+ instance.wasm.memory.indexType);
}
Flow visitMemoryGrow(MemoryGrow* curr) {
NOTE_ENTER("MemoryGrow");
auto indexType = instance.wasm.memory.indexType;
- auto fail = Literal::makeFromUInt64(-1, indexType);
+ auto fail = Literal::makeFromInt64(-1, indexType);
Flow flow = this->visit(curr->delta);
if (flow.breaking()) {
return flow;
}
- Flow ret = Literal::makeFromUInt64(instance.memorySize, indexType);
+ Flow ret = Literal::makeFromInt64(instance.memorySize, indexType);
uint64_t delta = flow.getSingleValue().getUnsigned();
if (delta > uint32_t(-1) / Memory::kPageSize && indexType == Type::i32) {
return fail;