mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #12983 from ethereum/hint-via-ir
Recommend `via-ir` whenever a stack too deep error is encountered.
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
|
||||
#include <libsolutil/FunctionSelector.h>
|
||||
#include <libsolutil/Whiskers.h>
|
||||
#include <libsolutil/StackTooDeepString.h>
|
||||
|
||||
#include <libevmasm/Instruction.h>
|
||||
#include <liblangutil/Exceptions.h>
|
||||
@@ -242,7 +243,7 @@ void ArrayUtils::copyArrayToStorage(ArrayType const& _targetType, ArrayType cons
|
||||
assertThrow(
|
||||
2 + byteOffsetSize + sourceBaseType->sizeOnStack() <= 16,
|
||||
StackTooDeepError,
|
||||
"Stack too deep, try removing local variables."
|
||||
util::stackTooDeepString
|
||||
);
|
||||
// fetch target storage reference
|
||||
_context << dupInstruction(2 + byteOffsetSize + sourceBaseType->sizeOnStack());
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
|
||||
#include <libsolutil/Whiskers.h>
|
||||
#include <libsolutil/FunctionSelector.h>
|
||||
#include <libsolutil/StackTooDeepString.h>
|
||||
|
||||
#include <liblangutil/ErrorReporter.h>
|
||||
#include <liblangutil/Scanner.h>
|
||||
@@ -422,7 +423,7 @@ void CompilerContext::appendInlineAssembly(
|
||||
BOOST_THROW_EXCEPTION(
|
||||
StackTooDeepError() <<
|
||||
errinfo_sourceLocation(nativeLocationOf(_identifier)) <<
|
||||
util::errinfo_comment("Stack too deep (" + to_string(stackDiff) + "), try removing local variables.")
|
||||
util::errinfo_comment(util::stackTooDeepString)
|
||||
);
|
||||
if (_context == yul::IdentifierContext::RValue)
|
||||
_assembly.appendInstruction(dupInstruction(static_cast<unsigned>(stackDiff)));
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <libsolutil/FunctionSelector.h>
|
||||
#include <libevmasm/Instruction.h>
|
||||
#include <libsolutil/Whiskers.h>
|
||||
#include <libsolutil/StackTooDeepString.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace solidity;
|
||||
@@ -476,7 +477,7 @@ void CompilerUtils::encodeToMemory(
|
||||
assertThrow(
|
||||
(argSize + dynPointers) < 16,
|
||||
StackTooDeepError,
|
||||
"Stack too deep, try using fewer variables."
|
||||
util::stackTooDeepString
|
||||
);
|
||||
}
|
||||
else
|
||||
@@ -537,7 +538,7 @@ void CompilerUtils::encodeToMemory(
|
||||
assertThrow(
|
||||
(2 + dynPointers) <= 16,
|
||||
StackTooDeepError,
|
||||
"Stack too deep(" + to_string(2 + dynPointers) + "), try using fewer variables."
|
||||
util::stackTooDeepString
|
||||
);
|
||||
m_context << dupInstruction(2 + dynPointers) << Instruction::DUP2;
|
||||
m_context << Instruction::SUB;
|
||||
@@ -1418,7 +1419,7 @@ void CompilerUtils::moveToStackVariable(VariableDeclaration const& _variable)
|
||||
BOOST_THROW_EXCEPTION(
|
||||
StackTooDeepError() <<
|
||||
errinfo_sourceLocation(_variable.location()) <<
|
||||
util::errinfo_comment("Stack too deep, try removing local variables.")
|
||||
util::errinfo_comment(util::stackTooDeepString)
|
||||
);
|
||||
for (unsigned i = 0; i < size; ++i)
|
||||
m_context << swapInstruction(stackPosition - size + 1) << Instruction::POP;
|
||||
@@ -1429,7 +1430,7 @@ void CompilerUtils::copyToStackTop(unsigned _stackDepth, unsigned _itemSize)
|
||||
assertThrow(
|
||||
_stackDepth <= 16,
|
||||
StackTooDeepError,
|
||||
"Stack too deep, try removing local variables."
|
||||
util::stackTooDeepString
|
||||
);
|
||||
for (unsigned i = 0; i < _itemSize; ++i)
|
||||
m_context << dupInstruction(_stackDepth);
|
||||
@@ -1455,7 +1456,7 @@ void CompilerUtils::rotateStackUp(unsigned _items)
|
||||
assertThrow(
|
||||
_items - 1 <= 16,
|
||||
StackTooDeepError,
|
||||
"Stack too deep, try removing local variables."
|
||||
util::stackTooDeepString
|
||||
);
|
||||
for (unsigned i = 1; i < _items; ++i)
|
||||
m_context << swapInstruction(_items - i);
|
||||
@@ -1466,7 +1467,7 @@ void CompilerUtils::rotateStackDown(unsigned _items)
|
||||
assertThrow(
|
||||
_items - 1 <= 16,
|
||||
StackTooDeepError,
|
||||
"Stack too deep, try removing local variables."
|
||||
util::stackTooDeepString
|
||||
);
|
||||
for (unsigned i = 1; i < _items; ++i)
|
||||
m_context << swapInstruction(i);
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
|
||||
#include <libsolutil/Whiskers.h>
|
||||
#include <libsolutil/FunctionSelector.h>
|
||||
#include <libsolutil/StackTooDeepString.h>
|
||||
|
||||
#include <range/v3/view/reverse.hpp>
|
||||
|
||||
@@ -672,7 +673,7 @@ bool ContractCompiler::visit(FunctionDefinition const& _function)
|
||||
BOOST_THROW_EXCEPTION(
|
||||
StackTooDeepError() <<
|
||||
errinfo_sourceLocation(_function.location()) <<
|
||||
util::errinfo_comment("Stack too deep, try removing local variables.")
|
||||
util::errinfo_comment(util::stackTooDeepString)
|
||||
);
|
||||
while (!stackLayout.empty() && stackLayout.back() != static_cast<int>(stackLayout.size() - 1))
|
||||
if (stackLayout.back() < 0)
|
||||
@@ -842,7 +843,7 @@ bool ContractCompiler::visit(InlineAssembly const& _inlineAssembly)
|
||||
BOOST_THROW_EXCEPTION(
|
||||
StackTooDeepError() <<
|
||||
errinfo_sourceLocation(_inlineAssembly.location()) <<
|
||||
util::errinfo_comment("Stack too deep, try removing local variables.")
|
||||
util::errinfo_comment(util::stackTooDeepString)
|
||||
);
|
||||
_assembly.appendInstruction(dupInstruction(stackDiff));
|
||||
}
|
||||
@@ -916,7 +917,7 @@ bool ContractCompiler::visit(InlineAssembly const& _inlineAssembly)
|
||||
BOOST_THROW_EXCEPTION(
|
||||
StackTooDeepError() <<
|
||||
errinfo_sourceLocation(_inlineAssembly.location()) <<
|
||||
util::errinfo_comment("Stack too deep(" + to_string(stackDiff) + "), try removing local variables.")
|
||||
util::errinfo_comment(util::stackTooDeepString)
|
||||
);
|
||||
_assembly.appendInstruction(swapInstruction(stackDiff));
|
||||
_assembly.appendInstruction(Instruction::POP);
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <libsolutil/FunctionSelector.h>
|
||||
#include <libsolutil/Keccak256.h>
|
||||
#include <libsolutil/Whiskers.h>
|
||||
#include <libsolutil/StackTooDeepString.h>
|
||||
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <numeric>
|
||||
@@ -268,7 +269,7 @@ void ExpressionCompiler::appendStateVariableAccessor(VariableDeclaration const&
|
||||
BOOST_THROW_EXCEPTION(
|
||||
StackTooDeepError() <<
|
||||
errinfo_sourceLocation(_varDecl.location()) <<
|
||||
util::errinfo_comment("Stack too deep.")
|
||||
util::errinfo_comment(util::stackTooDeepString)
|
||||
);
|
||||
m_context << dupInstruction(retSizeOnStack + 1);
|
||||
m_context.appendJump(evmasm::AssemblyItem::JumpType::OutOfFunction);
|
||||
@@ -350,7 +351,7 @@ bool ExpressionCompiler::visit(Assignment const& _assignment)
|
||||
BOOST_THROW_EXCEPTION(
|
||||
StackTooDeepError() <<
|
||||
errinfo_sourceLocation(_assignment.location()) <<
|
||||
util::errinfo_comment("Stack too deep, try removing local variables.")
|
||||
util::errinfo_comment(util::stackTooDeepString)
|
||||
);
|
||||
// value [lvalue_ref] updated_value
|
||||
for (unsigned i = 0; i < itemSize; ++i)
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include <libsolidity/codegen/CompilerUtils.h>
|
||||
#include <libevmasm/Instruction.h>
|
||||
|
||||
#include <libsolutil/StackTooDeepString.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace solidity;
|
||||
using namespace solidity::evmasm;
|
||||
@@ -50,7 +52,7 @@ void StackVariable::retrieveValue(SourceLocation const& _location, bool) const
|
||||
BOOST_THROW_EXCEPTION(
|
||||
StackTooDeepError() <<
|
||||
errinfo_sourceLocation(_location) <<
|
||||
util::errinfo_comment("Stack too deep, try removing local variables.")
|
||||
util::errinfo_comment(util::stackTooDeepString)
|
||||
);
|
||||
solAssert(stackPos + 1 >= m_size, "Size and stack pos mismatch.");
|
||||
for (unsigned i = 0; i < m_size; ++i)
|
||||
@@ -64,7 +66,7 @@ void StackVariable::storeValue(Type const&, SourceLocation const& _location, boo
|
||||
BOOST_THROW_EXCEPTION(
|
||||
StackTooDeepError() <<
|
||||
errinfo_sourceLocation(_location) <<
|
||||
util::errinfo_comment("Stack too deep, try removing local variables.")
|
||||
util::errinfo_comment(util::stackTooDeepString)
|
||||
);
|
||||
else if (stackDiff > 0)
|
||||
for (unsigned i = 0; i < m_size; ++i)
|
||||
|
||||
Reference in New Issue
Block a user