diff options
author | chriseth <chris@ethereum.org> | 2017-07-28 21:31:39 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-28 21:31:39 +0800 |
commit | 7e40def689db37658a03a53a6e02f3392823ed62 (patch) | |
tree | 18c9b51a029e9a79fda705a78c6a4753ccd82bfe /libsolidity/codegen/ContractCompiler.cpp | |
parent | 53f747b7ded3610802582448257b25e87442bebb (diff) | |
parent | 7d37eba4ba5e11a59bd201fde91bef7510510b0f (diff) | |
download | dexon-solidity-7e40def689db37658a03a53a6e02f3392823ed62.tar dexon-solidity-7e40def689db37658a03a53a6e02f3392823ed62.tar.gz dexon-solidity-7e40def689db37658a03a53a6e02f3392823ed62.tar.bz2 dexon-solidity-7e40def689db37658a03a53a6e02f3392823ed62.tar.lz dexon-solidity-7e40def689db37658a03a53a6e02f3392823ed62.tar.xz dexon-solidity-7e40def689db37658a03a53a6e02f3392823ed62.tar.zst dexon-solidity-7e40def689db37658a03a53a6e02f3392823ed62.zip |
Merge pull request #2478 from ethereum/fallback-dispatcher
Optimise the fallback dispatcher by removing a useless jump
Diffstat (limited to 'libsolidity/codegen/ContractCompiler.cpp')
-rw-r--r-- | libsolidity/codegen/ContractCompiler.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp index cad388df..fd0998d4 100644 --- a/libsolidity/codegen/ContractCompiler.cpp +++ b/libsolidity/codegen/ContractCompiler.cpp @@ -267,18 +267,13 @@ void ContractCompiler::appendFunctionSelector(ContractDefinition const& _contrac m_context << notFound; if (fallback) { - m_context.setStackOffset(0); if (!fallback->isPayable()) appendCallValueCheck(); - // Return tag is used to jump out of the function. - eth::AssemblyItem returnTag = m_context.pushNewTag(); - fallback->accept(*this); - m_context << returnTag; + solAssert(fallback->isFallback(), ""); solAssert(FunctionType(*fallback).parameterTypes().empty(), ""); solAssert(FunctionType(*fallback).returnParameterTypes().empty(), ""); - // Return tag gets consumed. - m_context.adjustStackOffset(-1); + fallback->accept(*this); m_context << Instruction::STOP; } else @@ -536,7 +531,8 @@ bool ContractCompiler::visit(FunctionDefinition const& _function) m_context.adjustStackOffset(-(int)c_returnValuesSize); - if (!_function.isConstructor()) + /// The constructor and the fallback function doesn't to jump out. + if (!_function.isConstructor() && !_function.isFallback()) m_context.appendJump(eth::AssemblyItem::JumpType::OutOfFunction); return false; } |