mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Correct stack height adjustment after returnsub.
This commit is contained in:
parent
ba5ee71b7f
commit
0185f3cbf6
@ -83,7 +83,7 @@ public:
|
|||||||
/// Call a subroutine.
|
/// Call a subroutine.
|
||||||
virtual void appendJumpsub(LabelID _label, int _arguments, int _returns) = 0;
|
virtual void appendJumpsub(LabelID _label, int _arguments, int _returns) = 0;
|
||||||
/// Return from a subroutine.
|
/// Return from a subroutine.
|
||||||
virtual void appendReturnsub(int _returns) = 0;
|
virtual void appendReturnsub(int _returns, int _stackDiffAfter = 0) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class IdentifierContext { LValue, RValue };
|
enum class IdentifierContext { LValue, RValue };
|
||||||
|
@ -134,12 +134,12 @@ void EVMAssembly::appendJumpsub(AbstractAssembly::LabelID _labelId, int _argumen
|
|||||||
m_stackHeight += _returns - _arguments;
|
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(m_evm15, "RETURNSUB used for EVM 1.0");
|
||||||
solAssert(_returns >= 0, "");
|
solAssert(_returns >= 0, "");
|
||||||
m_bytecode.push_back(byte(solidity::Instruction::RETURNSUB));
|
m_bytecode.push_back(byte(solidity::Instruction::RETURNSUB));
|
||||||
m_stackHeight -= _returns;
|
m_stackHeight += _stackDiffAfter - _returns;
|
||||||
}
|
}
|
||||||
|
|
||||||
eth::LinkerObject EVMAssembly::finalize()
|
eth::LinkerObject EVMAssembly::finalize()
|
||||||
|
@ -68,7 +68,7 @@ public:
|
|||||||
/// Call a subroutine.
|
/// Call a subroutine.
|
||||||
virtual void appendJumpsub(LabelID _label, int _arguments, int _returns) override;
|
virtual void appendJumpsub(LabelID _label, int _arguments, int _returns) override;
|
||||||
/// Return from a subroutine.
|
/// 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.
|
/// Resolves references inside the bytecode and returns the linker object.
|
||||||
|
@ -347,7 +347,7 @@ void CodeTransform::operator()(FunctionDefinition const& _function)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_evm15)
|
if (m_evm15)
|
||||||
m_assembly.appendReturnsub(_function.returns.size());
|
m_assembly.appendReturnsub(_function.returns.size(), stackHeightBefore);
|
||||||
else
|
else
|
||||||
m_assembly.appendJump(stackHeightBefore - _function.returns.size());
|
m_assembly.appendJump(stackHeightBefore - _function.returns.size());
|
||||||
m_stackAdjustment -= localStackAdjustment;
|
m_stackAdjustment -= localStackAdjustment;
|
||||||
|
@ -115,7 +115,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Return from a subroutine.
|
/// Return from a subroutine.
|
||||||
virtual void appendReturnsub(int) override
|
virtual void appendReturnsub(int, int) override
|
||||||
{
|
{
|
||||||
// TODO we could emulate that, though
|
// TODO we could emulate that, though
|
||||||
solAssert(false, "RETURNSUB not implemented for EVM 1.0");
|
solAssert(false, "RETURNSUB not implemented for EVM 1.0");
|
||||||
|
Loading…
Reference in New Issue
Block a user