Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/passes/Memory64Lowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ struct Memory64Lowering : public WalkerPass<PostWalker<Memory64Lowering>> {
if (memory->is64()) {
auto size = static_cast<Expression*>(curr);
extendAddress64(size, curr->memory);
curr->ptrType = Type::i32;
curr->type = Type::i32;
replaceCurrent(size);
}
}
Expand All @@ -82,7 +82,7 @@ struct Memory64Lowering : public WalkerPass<PostWalker<Memory64Lowering>> {
wrapAddress64(curr->delta, curr->memory);
auto size = static_cast<Expression*>(curr);
extendAddress64(size, curr->memory);
curr->ptrType = Type::i32;
curr->type = Type::i32;
replaceCurrent(size);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/wasm-builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ class Builder {
MemoryInfo info = MemoryInfo::Unspecified) {
auto* ret = wasm.allocator.alloc<MemorySize>();
if (isMemory64(memoryName, info)) {
ret->make64();
ret->type = Type::i64;
}
ret->memory = memoryName;
ret->finalize();
Expand All @@ -677,7 +677,7 @@ class Builder {
MemoryInfo info = MemoryInfo::Unspecified) {
auto* ret = wasm.allocator.alloc<MemoryGrow>();
if (isMemory64(memoryName, info)) {
ret->make64();
ret->type = Type::i64;
}
ret->delta = delta;
ret->memory = memoryName;
Expand Down
2 changes: 0 additions & 2 deletions src/wasm-delegations-fields.def
Original file line number Diff line number Diff line change
Expand Up @@ -485,12 +485,10 @@ DELEGATE_FIELD_OPTIONAL_CHILD(Return, value)
DELEGATE_FIELD_CASE_END(Return)

DELEGATE_FIELD_CASE_START(MemorySize)
DELEGATE_FIELD_TYPE(MemorySize, ptrType)
DELEGATE_FIELD_NAME_KIND(MemorySize, memory, ModuleItemKind::Memory)
DELEGATE_FIELD_CASE_END(MemorySize)

DELEGATE_FIELD_CASE_START(MemoryGrow)
DELEGATE_FIELD_TYPE(MemoryGrow, ptrType)
DELEGATE_FIELD_CHILD(MemoryGrow, delta)
DELEGATE_FIELD_NAME_KIND(MemoryGrow, memory, ModuleItemKind::Memory)
DELEGATE_FIELD_CASE_END(MemoryGrow)
Expand Down
4 changes: 0 additions & 4 deletions src/wasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -1305,10 +1305,8 @@ class MemorySize : public SpecificExpression<Expression::MemorySizeId> {
MemorySize() { type = Type::i32; }
MemorySize(MixedArena& allocator) : MemorySize() {}

Type ptrType = Type::i32;
Name memory;

void make64();
void finalize();
};

Expand All @@ -1318,10 +1316,8 @@ class MemoryGrow : public SpecificExpression<Expression::MemoryGrowId> {
MemoryGrow(MixedArena& allocator) : MemoryGrow() {}

Expression* delta = nullptr;
Type ptrType = Type::i32;
Name memory;

void make64();
void finalize();
};

Expand Down
4 changes: 2 additions & 2 deletions src/wasm/wasm-binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6882,7 +6882,7 @@ void WasmBinaryReader::visitMemorySize(MemorySize* curr) {
BYN_TRACE("zz node: MemorySize\n");
Index index = getU32LEB();
if (getMemory(index)->is64()) {
curr->make64();
curr->type = Type::i64;
}
curr->finalize();
memoryRefs[index].push_back(&curr->memory);
Expand All @@ -6893,7 +6893,7 @@ void WasmBinaryReader::visitMemoryGrow(MemoryGrow* curr) {
curr->delta = popNonVoidExpression();
Index index = getU32LEB();
if (getMemory(index)->is64()) {
curr->make64();
curr->type = Type::i64;
}
memoryRefs[index].push_back(&curr->memory);
}
Expand Down
4 changes: 2 additions & 2 deletions src/wasm/wasm-s-parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1533,7 +1533,7 @@ Expression* SExpressionWasmBuilder::makeMemorySize(Element& s) {
}
ret->memory = memory;
if (isMemory64(memory)) {
ret->make64();
ret->type = Type::i64;
}
ret->finalize();
return ret;
Expand All @@ -1550,7 +1550,7 @@ Expression* SExpressionWasmBuilder::makeMemoryGrow(Element& s) {
}
ret->memory = memory;
if (isMemory64(memory)) {
ret->make64();
ret->type = Type::i64;
}
ret->delta = parseExpression(s[i]);
ret->finalize();
Expand Down
6 changes: 1 addition & 5 deletions src/wasm/wasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -789,15 +789,11 @@ void Drop::finalize() {
}
}

void MemorySize::make64() { type = ptrType = Type::i64; }
void MemorySize::finalize() { type = ptrType; }
void MemorySize::finalize() {}

void MemoryGrow::make64() { type = ptrType = Type::i64; }
void MemoryGrow::finalize() {
if (delta->type == Type::unreachable) {
type = Type::unreachable;
} else {
type = ptrType;
}
}

Expand Down
7 changes: 0 additions & 7 deletions test/binaryen.js/expressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,11 +482,7 @@ console.log("# MemorySize");
assert(theMemorySize instanceof binaryen.MemorySize);
assert(theMemorySize instanceof binaryen.Expression);
assert(theMemorySize.type === type);

theMemorySize.type = type = binaryen.f64;
assert(theMemorySize.type === type);
theMemorySize.finalize();
assert(theMemorySize.type === binaryen.i32);

console.log(theMemorySize.toText());
assert(
Expand All @@ -513,10 +509,7 @@ console.log("# MemoryGrow");

theMemoryGrow.delta = delta = module.i32.const(2);
assert(theMemoryGrow.delta === delta);
theMemoryGrow.type = type = binaryen.f64;
assert(theMemoryGrow.type === type);
theMemoryGrow.finalize();
assert(theMemoryGrow.type === binaryen.i32);

console.log(theMemoryGrow.toText());
assert(
Expand Down