From 6d79a8885f2de38de9d830dd39d8cce40aa1ffcf Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 27 Oct 2020 17:09:30 +0000 Subject: [PATCH 1/2] [ewasm] Implement stop() in EVM->Ewasm translator --- libyul/backends/wasm/EVMToEwasmTranslator.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libyul/backends/wasm/EVMToEwasmTranslator.cpp b/libyul/backends/wasm/EVMToEwasmTranslator.cpp index 4f9b0ed08..c92cd6652 100644 --- a/libyul/backends/wasm/EVMToEwasmTranslator.cpp +++ b/libyul/backends/wasm/EVMToEwasmTranslator.cpp @@ -1211,6 +1211,9 @@ function revert(x1, x2, x3, x4, y1, y2, y3, y4) { function invalid() { unreachable() } +function stop() { + eth.finish(0:i32, 0:i32) +} function memoryguard(x:i64) -> y1, y2, y3, y4 { y4 := x } From 13652bd4a9c95223162bf4a7f924bd1434ec99ca Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 27 Oct 2020 17:43:27 +0000 Subject: [PATCH 2/2] [ewasm] Add assertion for datasize/dataoffset in BinaryTransform --- libyul/backends/wasm/BinaryTransform.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libyul/backends/wasm/BinaryTransform.cpp b/libyul/backends/wasm/BinaryTransform.cpp index 148ed2786..6c19b19f5 100644 --- a/libyul/backends/wasm/BinaryTransform.cpp +++ b/libyul/backends/wasm/BinaryTransform.cpp @@ -356,11 +356,15 @@ bytes BinaryTransform::operator()(BuiltinCall const& _call) if (_call.functionName == "dataoffset") { string name = get(_call.arguments.at(0)).value; + // TODO: support the case where name refers to the current object + yulAssert(m_subModulePosAndSize.count(name), ""); return toBytes(Opcode::I64Const) + lebEncodeSigned(static_cast(m_subModulePosAndSize.at(name).first)); } else if (_call.functionName == "datasize") { string name = get(_call.arguments.at(0)).value; + // TODO: support the case where name refers to the current object + yulAssert(m_subModulePosAndSize.count(name), ""); return toBytes(Opcode::I64Const) + lebEncodeSigned(static_cast(m_subModulePosAndSize.at(name).second)); }