aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-06-29 16:48:53 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-07-28 04:52:58 +0800
commit7d37eba4ba5e11a59bd201fde91bef7510510b0f (patch)
tree18c9b51a029e9a79fda705a78c6a4753ccd82bfe
parentd4e44ecb46df58ff21690c28098d20e3c5dfe307 (diff)
downloaddexon-solidity-7d37eba4ba5e11a59bd201fde91bef7510510b0f.tar
dexon-solidity-7d37eba4ba5e11a59bd201fde91bef7510510b0f.tar.gz
dexon-solidity-7d37eba4ba5e11a59bd201fde91bef7510510b0f.tar.bz2
dexon-solidity-7d37eba4ba5e11a59bd201fde91bef7510510b0f.tar.lz
dexon-solidity-7d37eba4ba5e11a59bd201fde91bef7510510b0f.tar.xz
dexon-solidity-7d37eba4ba5e11a59bd201fde91bef7510510b0f.tar.zst
dexon-solidity-7d37eba4ba5e11a59bd201fde91bef7510510b0f.zip
Remove the need of jumping out of the fallback
-rw-r--r--Changelog.md1
-rw-r--r--libsolidity/codegen/ContractCompiler.cpp12
2 files changed, 5 insertions, 8 deletions
diff --git a/Changelog.md b/Changelog.md
index 18fd00ea..cedb5859 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -2,6 +2,7 @@
Features:
* C API (``jsonCompiler``): Export the ``license`` method.
+ * Code Generator: Optimise the fallback function, by removing a useless jump.
* Inline Assembly: Show useful error message if trying to access calldata variables.
* Inline Assembly: Support variable declaration without initial value (defaults to 0).
* Metadata: Only include files which were used to compile the given contract.
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;
}