mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Remove the need of jumping out of the fallback
This commit is contained in:
parent
d4e44ecb46
commit
7d37eba4ba
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
Features:
|
Features:
|
||||||
* C API (``jsonCompiler``): Export the ``license`` method.
|
* 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: Show useful error message if trying to access calldata variables.
|
||||||
* Inline Assembly: Support variable declaration without initial value (defaults to 0).
|
* Inline Assembly: Support variable declaration without initial value (defaults to 0).
|
||||||
* Metadata: Only include files which were used to compile the given contract.
|
* Metadata: Only include files which were used to compile the given contract.
|
||||||
|
@ -267,18 +267,13 @@ void ContractCompiler::appendFunctionSelector(ContractDefinition const& _contrac
|
|||||||
m_context << notFound;
|
m_context << notFound;
|
||||||
if (fallback)
|
if (fallback)
|
||||||
{
|
{
|
||||||
m_context.setStackOffset(0);
|
|
||||||
if (!fallback->isPayable())
|
if (!fallback->isPayable())
|
||||||
appendCallValueCheck();
|
appendCallValueCheck();
|
||||||
|
|
||||||
// Return tag is used to jump out of the function.
|
solAssert(fallback->isFallback(), "");
|
||||||
eth::AssemblyItem returnTag = m_context.pushNewTag();
|
|
||||||
fallback->accept(*this);
|
|
||||||
m_context << returnTag;
|
|
||||||
solAssert(FunctionType(*fallback).parameterTypes().empty(), "");
|
solAssert(FunctionType(*fallback).parameterTypes().empty(), "");
|
||||||
solAssert(FunctionType(*fallback).returnParameterTypes().empty(), "");
|
solAssert(FunctionType(*fallback).returnParameterTypes().empty(), "");
|
||||||
// Return tag gets consumed.
|
fallback->accept(*this);
|
||||||
m_context.adjustStackOffset(-1);
|
|
||||||
m_context << Instruction::STOP;
|
m_context << Instruction::STOP;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -536,7 +531,8 @@ bool ContractCompiler::visit(FunctionDefinition const& _function)
|
|||||||
|
|
||||||
m_context.adjustStackOffset(-(int)c_returnValuesSize);
|
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);
|
m_context.appendJump(eth::AssemblyItem::JumpType::OutOfFunction);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user