mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Detect unavailable items and do not optimise the chunk in that case.
This commit is contained in:
parent
8fbecb9c27
commit
34986ee4fc
@ -337,6 +337,11 @@ Assembly& Assembly::optimise(bool _enable, bool _isCreation, size_t _runs)
|
|||||||
// This might happen if the opcode reconstruction is not as efficient
|
// This might happen if the opcode reconstruction is not as efficient
|
||||||
// as the hand-crafted code.
|
// as the hand-crafted code.
|
||||||
}
|
}
|
||||||
|
catch (ItemNotAvailableException const&)
|
||||||
|
{
|
||||||
|
// This might happen if e.g. associativity and commutativity rules
|
||||||
|
// reorganise the expression tree, but not all leaves are available.
|
||||||
|
}
|
||||||
|
|
||||||
if (shouldReplace)
|
if (shouldReplace)
|
||||||
{
|
{
|
||||||
|
@ -220,6 +220,12 @@ void CSECodeGenerator::addDependencies(Id _c)
|
|||||||
if (m_neededBy.count(_c))
|
if (m_neededBy.count(_c))
|
||||||
return; // we already computed the dependencies for _c
|
return; // we already computed the dependencies for _c
|
||||||
ExpressionClasses::Expression expr = m_expressionClasses.representative(_c);
|
ExpressionClasses::Expression expr = m_expressionClasses.representative(_c);
|
||||||
|
if (expr.item->type() == UndefinedItem)
|
||||||
|
BOOST_THROW_EXCEPTION(
|
||||||
|
// If this exception happens, we need to find a different way to generate the
|
||||||
|
// compound expression.
|
||||||
|
ItemNotAvailableException() << errinfo_comment("Undefined item requested but not available.")
|
||||||
|
);
|
||||||
for (Id argument: expr.arguments)
|
for (Id argument: expr.arguments)
|
||||||
{
|
{
|
||||||
addDependencies(argument);
|
addDependencies(argument);
|
||||||
@ -317,6 +323,11 @@ void CSECodeGenerator::generateClassElement(Id _c, bool _allowSequenced)
|
|||||||
"Sequence constrained operation requested out of sequence."
|
"Sequence constrained operation requested out of sequence."
|
||||||
);
|
);
|
||||||
assertThrow(expr.item, OptimizerException, "Non-generated expression without item.");
|
assertThrow(expr.item, OptimizerException, "Non-generated expression without item.");
|
||||||
|
assertThrow(
|
||||||
|
expr.item->type() != UndefinedItem,
|
||||||
|
OptimizerException,
|
||||||
|
"Undefined item requested but not available."
|
||||||
|
);
|
||||||
vector<Id> const& arguments = expr.arguments;
|
vector<Id> const& arguments = expr.arguments;
|
||||||
for (Id arg: boost::adaptors::reverse(arguments))
|
for (Id arg: boost::adaptors::reverse(arguments))
|
||||||
generateClassElement(arg);
|
generateClassElement(arg);
|
||||||
|
@ -31,6 +31,7 @@ namespace eth
|
|||||||
struct AssemblyException: virtual Exception {};
|
struct AssemblyException: virtual Exception {};
|
||||||
struct OptimizerException: virtual AssemblyException {};
|
struct OptimizerException: virtual AssemblyException {};
|
||||||
struct StackTooDeepException: virtual OptimizerException {};
|
struct StackTooDeepException: virtual OptimizerException {};
|
||||||
|
struct ItemNotAvailableException: virtual OptimizerException {};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user