aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-05-31 19:06:51 +0800
committerchriseth <chris@ethereum.org>2017-06-08 21:52:45 +0800
commit0185f3cbf6aae954d8c59a556af0e150850022bc (patch)
tree49786ecfb329931f3366162586fc199ae75d2ba0
parentba5ee71b7f7b1ac5d6bc4b3a70dde36b34d20d8e (diff)
downloaddexon-solidity-0185f3cbf6aae954d8c59a556af0e150850022bc.tar.gz
dexon-solidity-0185f3cbf6aae954d8c59a556af0e150850022bc.tar.zst
dexon-solidity-0185f3cbf6aae954d8c59a556af0e150850022bc.zip
Correct stack height adjustment after returnsub.
-rw-r--r--libjulia/backends/evm/AbstractAssembly.h2
-rw-r--r--libjulia/backends/evm/EVMAssembly.cpp4
-rw-r--r--libjulia/backends/evm/EVMAssembly.h2
-rw-r--r--libjulia/backends/evm/EVMCodeTransform.cpp2
-rw-r--r--libsolidity/inlineasm/AsmCodeGen.cpp2
5 files changed, 6 insertions, 6 deletions
diff --git a/libjulia/backends/evm/AbstractAssembly.h b/libjulia/backends/evm/AbstractAssembly.h
index ba2c8e20..73c6699f 100644
--- a/libjulia/backends/evm/AbstractAssembly.h
+++ b/libjulia/backends/evm/AbstractAssembly.h
@@ -83,7 +83,7 @@ public:
/// Call a subroutine.
virtual void appendJumpsub(LabelID _label, int _arguments, int _returns) = 0;
/// Return from a subroutine.
- virtual void appendReturnsub(int _returns) = 0;
+ virtual void appendReturnsub(int _returns, int _stackDiffAfter = 0) = 0;
};
enum class IdentifierContext { LValue, RValue };
diff --git a/libjulia/backends/evm/EVMAssembly.cpp b/libjulia/backends/evm/EVMAssembly.cpp
index a8019e86..a24d9779 100644
--- a/libjulia/backends/evm/EVMAssembly.cpp
+++ b/libjulia/backends/evm/EVMAssembly.cpp
@@ -134,12 +134,12 @@ void EVMAssembly::appendJumpsub(AbstractAssembly::LabelID _labelId, int _argumen
m_stackHeight += _returns - _arguments;
}
-void EVMAssembly::appendReturnsub(int _returns)
+void EVMAssembly::appendReturnsub(int _returns, int _stackDiffAfter)
{
solAssert(m_evm15, "RETURNSUB used for EVM 1.0");
solAssert(_returns >= 0, "");
m_bytecode.push_back(byte(solidity::Instruction::RETURNSUB));
- m_stackHeight -= _returns;
+ m_stackHeight += _stackDiffAfter - _returns;
}
eth::LinkerObject EVMAssembly::finalize()
diff --git a/libjulia/backends/evm/EVMAssembly.h b/libjulia/backends/evm/EVMAssembly.h
index 003eeaf5..4b0076dd 100644
--- a/libjulia/backends/evm/EVMAssembly.h
+++ b/libjulia/backends/evm/EVMAssembly.h
@@ -68,7 +68,7 @@ public:
/// Call a subroutine.
virtual void appendJumpsub(LabelID _label, int _arguments, int _returns) override;
/// Return from a subroutine.
- virtual void appendReturnsub(int _returns) override;
+ virtual void appendReturnsub(int _returns, int _stackDiffAfter) override;
/// Resolves references inside the bytecode and returns the linker object.
diff --git a/libjulia/backends/evm/EVMCodeTransform.cpp b/libjulia/backends/evm/EVMCodeTransform.cpp
index c9624f82..43bd5a44 100644
--- a/libjulia/backends/evm/EVMCodeTransform.cpp
+++ b/libjulia/backends/evm/EVMCodeTransform.cpp
@@ -347,7 +347,7 @@ void CodeTransform::operator()(FunctionDefinition const& _function)
}
if (m_evm15)
- m_assembly.appendReturnsub(_function.returns.size());
+ m_assembly.appendReturnsub(_function.returns.size(), stackHeightBefore);
else
m_assembly.appendJump(stackHeightBefore - _function.returns.size());
m_stackAdjustment -= localStackAdjustment;
diff --git a/libsolidity/inlineasm/AsmCodeGen.cpp b/libsolidity/inlineasm/AsmCodeGen.cpp
index 875d7ce4..dd91673b 100644
--- a/libsolidity/inlineasm/AsmCodeGen.cpp
+++ b/libsolidity/inlineasm/AsmCodeGen.cpp
@@ -115,7 +115,7 @@ public:
}
/// Return from a subroutine.
- virtual void appendReturnsub(int) override
+ virtual void appendReturnsub(int, int) override
{
// TODO we could emulate that, though
solAssert(false, "RETURNSUB not implemented for EVM 1.0");