mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge remote-tracking branch 'origin/develop' into breaking
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Analyzer part of inline assembly.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Analysis part of inline assembly.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Information generated during analyzer part of inline assembly.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @author Christian <c@ethdev.com>
|
||||
* @date 2016
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @author Christian <c@ethdev.com>
|
||||
* @date 2016
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @date 2019
|
||||
* Converts inline assembly AST to JSON format
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @date 2019
|
||||
* @author julius <djudju@protonmail.com>
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @author Christian <c@ethdev.com>
|
||||
* @date 2016
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @author Christian <c@ethdev.com>
|
||||
* @date 2016
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @author Christian <c@ethdev.com>
|
||||
* @date 2017
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @author Christian <c@ethdev.com>
|
||||
* @date 2017
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Scopes for identifiers.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Scopes for identifiers.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Module responsible for registering identifiers inside their scopes.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Module responsible for registering identifiers inside their scopes.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Full assembly stack that can support EVM-assembly and Yul as input and EVM, EVM1.5 and
|
||||
* Ewasm as output.
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Full assembly stack that can support EVM-assembly and Yul as input and EVM, EVM1.5 and
|
||||
* Ewasm as output.
|
||||
|
||||
@@ -59,14 +59,7 @@ map<YulString, int> CompilabilityChecker::run(
|
||||
builtinContext,
|
||||
_optimizeStackAllocation
|
||||
);
|
||||
try
|
||||
{
|
||||
transform(*_object.code);
|
||||
}
|
||||
catch (StackTooDeepError const&)
|
||||
{
|
||||
yulAssert(!transform.stackErrors().empty(), "Got stack too deep exception that was not stored.");
|
||||
}
|
||||
transform(*_object.code);
|
||||
|
||||
std::map<YulString, int> functions;
|
||||
for (StackTooDeepError const& error: transform.stackErrors())
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Component that checks whether all variables are reachable on the stack.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Yul dialect.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Yul dialect.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Exceptions in Yul.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Yul code and data object container.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Yul code and data object container.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Parser for Yul code and data object container.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Parser for Yul code and data object container.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Some useful snippets for the optimiser.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Small useful snippets for the optimiser.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* String abstraction that avoids copies.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* @date 2017
|
||||
* Abstract assembly interface, subclasses of which are to be used with the generic
|
||||
@@ -111,6 +112,9 @@ public:
|
||||
virtual void appendImmutable(std::string const& _identifier) = 0;
|
||||
/// Appends an assignment to an immutable variable.
|
||||
virtual void appendImmutableAssignment(std::string const& _identifier) = 0;
|
||||
|
||||
/// Mark this assembly as invalid. Any attempt to request bytecode from it should throw.
|
||||
virtual void markAsInvalid() = 0;
|
||||
};
|
||||
|
||||
enum class IdentifierContext { LValue, RValue, VariableDeclaration };
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Adaptor between the abstract assembly and eth assembly.
|
||||
*/
|
||||
@@ -182,6 +183,11 @@ void EthAssemblyAdapter::appendImmutableAssignment(std::string const& _identifie
|
||||
m_assembly.appendImmutableAssignment(_identifier);
|
||||
}
|
||||
|
||||
void EthAssemblyAdapter::markAsInvalid()
|
||||
{
|
||||
m_assembly.markAsInvalid();
|
||||
}
|
||||
|
||||
EthAssemblyAdapter::LabelID EthAssemblyAdapter::assemblyTagToIdentifier(evmasm::AssemblyItem const& _tag)
|
||||
{
|
||||
u256 id = _tag.data();
|
||||
@@ -231,18 +237,12 @@ void CodeGenerator::assemble(
|
||||
_identifierAccess,
|
||||
_useNamedLabelsForFunctions
|
||||
);
|
||||
try
|
||||
{
|
||||
transform(_parsedData);
|
||||
}
|
||||
catch (StackTooDeepError const& _e)
|
||||
{
|
||||
transform(_parsedData);
|
||||
if (!transform.stackErrors().empty())
|
||||
assertThrow(
|
||||
false,
|
||||
langutil::StackTooDeepError,
|
||||
"Stack too deep when compiling inline assembly" +
|
||||
(_e.comment() ? ": " + *_e.comment() : ".")
|
||||
(transform.stackErrors().front().comment() ? ": " + *transform.stackErrors().front().comment() : ".")
|
||||
);
|
||||
}
|
||||
yulAssert(transform.stackErrors().empty(), "Stack errors present but not thrown.");
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Adaptor between the abstract assembly and eth assembly.
|
||||
*/
|
||||
@@ -64,6 +65,8 @@ public:
|
||||
void appendImmutable(std::string const& _identifier) override;
|
||||
void appendImmutableAssignment(std::string const& _identifier) override;
|
||||
|
||||
void markAsInvalid() override;
|
||||
|
||||
private:
|
||||
static LabelID assemblyTagToIdentifier(evmasm::AssemblyItem const& _tag);
|
||||
void appendJumpInstruction(evmasm::Instruction _instruction, JumpType _jumpType);
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Optimisation stage that replaces constants by expressions that compute them.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Optimisation stage that replaces constants by expressions that compute them.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Assembly interface for EVM and EVM1.5.
|
||||
*/
|
||||
@@ -156,6 +157,7 @@ void EVMAssembly::appendReturnsub(int _returns, int _stackDiffAfter)
|
||||
|
||||
evmasm::LinkerObject EVMAssembly::finalize()
|
||||
{
|
||||
yulAssert(!m_invalid, "Attempted to finalize invalid assembly object.");
|
||||
size_t bytecodeSize = m_bytecode.size();
|
||||
for (auto const& ref: m_assemblySizePositions)
|
||||
updateReference(ref, assemblySizeReferenceSize, u256(bytecodeSize));
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Assembly interface for EVM and EVM1.5.
|
||||
*/
|
||||
@@ -86,6 +87,8 @@ public:
|
||||
void appendImmutable(std::string const& _identifier) override;
|
||||
void appendImmutableAssignment(std::string const& _identifier) override;
|
||||
|
||||
void markAsInvalid() override { m_invalid = true; }
|
||||
|
||||
/// Resolves references inside the bytecode and returns the linker object.
|
||||
evmasm::LinkerObject finalize();
|
||||
|
||||
@@ -102,6 +105,7 @@ private:
|
||||
std::map<LabelID, size_t> m_labelPositions;
|
||||
std::map<size_t, LabelID> m_labelReferences;
|
||||
std::vector<size_t> m_assemblySizePositions;
|
||||
bool m_invalid = false;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Common code generator for translating Yul / inline assembly to EVM and EVM1.5.
|
||||
*/
|
||||
@@ -237,6 +238,7 @@ void CodeTransform::stackError(StackTooDeepError _error, int _targetStackHeight)
|
||||
m_assembly.appendConstant(u256(0));
|
||||
// Store error.
|
||||
m_stackErrors.emplace_back(std::move(_error));
|
||||
m_assembly.markAsInvalid();
|
||||
}
|
||||
|
||||
void CodeTransform::operator()(Assignment const& _assignment)
|
||||
@@ -435,31 +437,28 @@ void CodeTransform::operator()(FunctionDefinition const& _function)
|
||||
m_context->functionExitPoints.push(
|
||||
CodeTransformContext::JumpInfo{m_assembly.newLabelId(), m_assembly.stackHeight()}
|
||||
);
|
||||
try
|
||||
CodeTransform subTransform(
|
||||
m_assembly,
|
||||
m_info,
|
||||
_function.body,
|
||||
m_allowStackOpt,
|
||||
m_dialect,
|
||||
m_builtinContext,
|
||||
m_evm15,
|
||||
m_identifierAccess,
|
||||
m_useNamedLabelsForFunctions,
|
||||
m_context
|
||||
);
|
||||
subTransform(_function.body);
|
||||
if (!subTransform.m_stackErrors.empty())
|
||||
{
|
||||
CodeTransform(
|
||||
m_assembly,
|
||||
m_info,
|
||||
_function.body,
|
||||
m_allowStackOpt,
|
||||
m_dialect,
|
||||
m_builtinContext,
|
||||
m_evm15,
|
||||
m_identifierAccess,
|
||||
m_useNamedLabelsForFunctions,
|
||||
m_context
|
||||
)(_function.body);
|
||||
}
|
||||
catch (StackTooDeepError const& _error)
|
||||
{
|
||||
// This exception will be re-thrown after the end of the surrounding block.
|
||||
// It enables us to see which functions compiled successfully and which did not.
|
||||
// Even if we emit actual code, add an illegal instruction to make sure that tests
|
||||
// will catch it.
|
||||
StackTooDeepError error(_error);
|
||||
if (error.functionName.empty())
|
||||
error.functionName = _function.name;
|
||||
stackError(std::move(error), static_cast<int>(height));
|
||||
m_assembly.markAsInvalid();
|
||||
for (StackTooDeepError& stackError: subTransform.m_stackErrors)
|
||||
{
|
||||
if (stackError.functionName.empty())
|
||||
stackError.functionName = _function.name;
|
||||
m_stackErrors.emplace_back(std::move(stackError));
|
||||
}
|
||||
}
|
||||
|
||||
m_assembly.appendLabel(m_context->functionExitPoints.top().label);
|
||||
@@ -605,9 +604,6 @@ void CodeTransform::operator()(Block const& _block)
|
||||
|
||||
finalizeBlock(_block, blockStartStackHeight);
|
||||
m_scope = originalScope;
|
||||
|
||||
if (!m_stackErrors.empty())
|
||||
BOOST_THROW_EXCEPTION(m_stackErrors.front());
|
||||
}
|
||||
|
||||
AbstractAssembly::LabelID CodeTransform::functionEntryID(YulString _name, Scope::Function const& _function)
|
||||
@@ -728,7 +724,8 @@ size_t CodeTransform::variableHeightDiff(Scope::Variable const& _var, YulString
|
||||
to_string(heightDiff - limit) +
|
||||
" slot(s) too deep inside the stack."
|
||||
);
|
||||
BOOST_THROW_EXCEPTION(m_stackErrors.back());
|
||||
m_assembly.markAsInvalid();
|
||||
return _forSwap ? 2 : 1;
|
||||
}
|
||||
return heightDiff;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Common code generator for translating Yul / inline assembly to EVM and EVM1.5.
|
||||
*/
|
||||
@@ -201,6 +202,8 @@ private:
|
||||
/// Determines the stack height difference to the given variables. Throws
|
||||
/// if it is not yet in scope or the height difference is too large. Returns
|
||||
/// the (positive) stack height difference otherwise.
|
||||
/// @param _forSwap if true, produces stack error if the difference is invalid for a swap
|
||||
/// opcode, otherwise checks for validity for a dup opcode.
|
||||
size_t variableHeightDiff(Scope::Variable const& _var, YulString _name, bool _forSwap);
|
||||
|
||||
void expectDeposit(int _deposit, int _oldHeight) const;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Yul dialects for EVM.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Yul dialects for EVM.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Module providing metrics for the EVM optimizer.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Module providing metrics for the optimizer.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Compiler that transforms Yul Objects to EVM bytecode objects.
|
||||
*/
|
||||
@@ -59,5 +60,6 @@ void EVMObjectCompiler::run(Object& _object, bool _optimize)
|
||||
// which should be native to this part of the code.
|
||||
CodeTransform transform{m_assembly, *_object.analysisInfo, *_object.code, m_dialect, context, _optimize, m_evm15};
|
||||
transform(*_object.code);
|
||||
yulAssert(transform.stackErrors().empty(), "Stack errors present but not thrown.");
|
||||
if (!transform.stackErrors().empty())
|
||||
BOOST_THROW_EXCEPTION(transform.stackErrors().front());
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Compiler that transforms Yul Objects to EVM bytecode objects.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Assembly interface that ignores everything. Can be used as a backend for a compilation dry-run.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Assembly interface that ignores everything. Can be used as a backend for a compilation dry-run.
|
||||
*/
|
||||
@@ -74,6 +75,8 @@ public:
|
||||
void appendImmutable(std::string const& _identifier) override;
|
||||
void appendImmutableAssignment(std::string const& _identifier) override;
|
||||
|
||||
void markAsInvalid() override {}
|
||||
|
||||
private:
|
||||
bool m_evm15 = false; ///< if true, switch to evm1.5 mode
|
||||
int m_stackHeight = 0;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Component that transforms internal Wasm representation to binary.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Component that transforms internal Wasm representation to binary.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Translates Yul code from EVM dialect to Ewasm dialect.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Translates Yul code from EVM dialect to Ewasm dialect.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Component that transforms internal Wasm representation to text.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Component that transforms internal Wasm representation to text.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Simplified in-memory representation of a Wasm AST.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Common code generator for translating Yul / inline assembly to Wasm.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Common code generator for translating Yul / inline assembly to Wasm.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Dialects for Wasm.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Dialects for Wasm.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Compiler that transforms Yul Objects to Wasm text and binary representation (Ewasm flavoured).
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Compiler that transforms Yul Objects to Wasm text and binary representation (Ewasm flavoured).
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
|
||||
#include <libyul/AsmData.h>
|
||||
#include <libyul/backends/wasm/WordSizeTransform.h>
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Replace every u256 variable with four u64 variables.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Creates an independent copy of an AST, renaming identifiers to be unique.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Creates an independent copy of an AST, renaming identifiers to be unique.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Generic AST walker.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Generic AST walker.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
#include <libyul/optimiser/BlockFlattener.h>
|
||||
#include <libyul/AsmData.h>
|
||||
#include <libsolutil/Visitor.h>
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
#pragma once
|
||||
|
||||
#include <libyul/optimiser/ASTWalker.h>
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Optimiser component that calculates hash values for block prefixes.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Optimiser component that calculates hash values for blocks.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Specific AST walker that generates the call graph.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Specific AST walker that generates the call graph.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
#include <libyul/optimiser/CircularReferencesPruner.h>
|
||||
|
||||
#include <libyul/optimiser/CallGraphGenerator.h>
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Optimization stage that removes functions that call each other but are
|
||||
* otherwise unreferenced.
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Optimisation stage that replaces expressions known to be the current value of a variable
|
||||
* in scope by a reference to that variable.
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
#include <libyul/optimiser/ConditionalSimplifier.h>
|
||||
#include <libyul/optimiser/Semantics.h>
|
||||
#include <libyul/AsmData.h>
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
#pragma once
|
||||
|
||||
#include <libyul/optimiser/ASTWalker.h>
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
#include <libyul/optimiser/ConditionalUnsimplifier.h>
|
||||
#include <libyul/optimiser/Semantics.h>
|
||||
#include <libyul/AsmData.h>
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
#pragma once
|
||||
|
||||
#include <libyul/optimiser/ASTWalker.h>
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
#include <libyul/optimiser/ControlFlowSimplifier.h>
|
||||
#include <libyul/optimiser/Semantics.h>
|
||||
#include <libyul/optimiser/OptimiserStep.h>
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
#pragma once
|
||||
|
||||
#include <libyul/optimiser/ASTWalker.h>
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Base class to perform data flow analysis during AST walks.
|
||||
* Tracks assignments and is used as base class for both Rematerialiser and
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Optimisation stage that removes unreachable code.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Optimisation stage that removes unused variables and functions.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Optimiser component that makes all identifiers unique.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Optimiser component that makes all identifiers unique.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Optimiser component that combines syntactically equivalent functions.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Optimiser component that combines syntactically equivalent functions.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Optimiser component that combines syntactically equivalent functions.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Optimiser component that combines syntactically equivalent functions.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Optimiser component that performs function inlining inside expressions.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Optimiser component that performs function inlining.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Optimiser component that undoes what the ExpressionSplitter did, i.e.
|
||||
* it more or less inlines variable declarations.
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Optimiser component that undoes what the ExpressionSplitter did, i.e.
|
||||
* it more or less inlines variable declarations.
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Optimiser component that uses the simplification rules to simplify expressions.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Optimiser component that uses the simplification rules to simplify expressions.
|
||||
*/
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Optimiser component that turns complex expressions into multiple variable
|
||||
* declarations.
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
/**
|
||||
* Optimiser component that turns complex expressions into multiple variable
|
||||
* declarations.
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
|
||||
#include <libyul/optimiser/ForLoopConditionIntoBody.h>
|
||||
#include <libyul/optimiser/OptimiserStep.h>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user