aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-08-19 01:41:47 +0800
committerchriseth <c@ethdev.com>2015-08-19 03:22:43 +0800
commit34986ee4fcbea4d4f3609d9227864b640f021ffa (patch)
tree282fc2193a37c2269698e2689a5fc92fd90ce3da
parent8fbecb9c27a457f4704f5b354cf780808b8948ab (diff)
downloaddexon-solidity-34986ee4fcbea4d4f3609d9227864b640f021ffa.tar.gz
dexon-solidity-34986ee4fcbea4d4f3609d9227864b640f021ffa.tar.zst
dexon-solidity-34986ee4fcbea4d4f3609d9227864b640f021ffa.zip
Detect unavailable items and do not optimise the chunk in that case.
-rw-r--r--Assembly.cpp5
-rw-r--r--CommonSubexpressionEliminator.cpp11
-rw-r--r--Exceptions.h1
3 files changed, 17 insertions, 0 deletions
diff --git a/Assembly.cpp b/Assembly.cpp
index c96b6f40..a9b70eb4 100644
--- a/Assembly.cpp
+++ b/Assembly.cpp
@@ -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
// 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)
{
diff --git a/CommonSubexpressionEliminator.cpp b/CommonSubexpressionEliminator.cpp
index 8fb4625a..6c095595 100644
--- a/CommonSubexpressionEliminator.cpp
+++ b/CommonSubexpressionEliminator.cpp
@@ -220,6 +220,12 @@ void CSECodeGenerator::addDependencies(Id _c)
if (m_neededBy.count(_c))
return; // we already computed the dependencies for _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)
{
addDependencies(argument);
@@ -317,6 +323,11 @@ void CSECodeGenerator::generateClassElement(Id _c, bool _allowSequenced)
"Sequence constrained operation requested out of sequence."
);
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;
for (Id arg: boost::adaptors::reverse(arguments))
generateClassElement(arg);
diff --git a/Exceptions.h b/Exceptions.h
index 7cc190e4..03b8afde 100644
--- a/Exceptions.h
+++ b/Exceptions.h
@@ -31,6 +31,7 @@ namespace eth
struct AssemblyException: virtual Exception {};
struct OptimizerException: virtual AssemblyException {};
struct StackTooDeepException: virtual OptimizerException {};
+struct ItemNotAvailableException: virtual OptimizerException {};
}
}