Skip to content

Commit

Permalink
Remove EWASM backend.
Browse files Browse the repository at this point in the history
  • Loading branch information
aarlt committed May 11, 2023
1 parent 0a0c389 commit c567327
Show file tree
Hide file tree
Showing 1,042 changed files with 97 additions and 10,946 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Language Features:


Compiler Features:
* EWasm: Remove EWasm backend.


Bugfixes:
Expand Down
13 changes: 0 additions & 13 deletions cmake/templates/ewasm_polyfill.in

This file was deleted.

11 changes: 2 additions & 9 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ Prerequisites

For running all compiler tests you may want to optionally install a few
dependencies (`evmone <https://github.com/ethereum/evmone/releases>`_,
`libz3 <https://github.com/Z3Prover/z3>`_, and
`libhera <https://github.com/ewasm/hera>`_).
`libz3 <https://github.com/Z3Prover/z3>`_).

On macOS systems, some of the testing scripts expect GNU coreutils to be installed.
This can be easiest accomplished using Homebrew: ``brew install coreutils``.
Expand Down Expand Up @@ -129,13 +128,7 @@ for the ``evmone`` shared object can be specified via the ``ETH_EVMONE`` environ
If you do not have it installed, you can skip these tests by passing the ``--no-semantic-tests``
flag to ``scripts/soltest.sh``.

Running Ewasm tests is disabled by default and can be explicitly enabled
via ``./scripts/soltest.sh --ewasm`` and requires `hera <https://github.com/ewasm/hera>`_
to be found by ``soltest``.
The mechanism for locating the ``hera`` library is the same as for ``evmone``, except that the
variable for specifying an explicit location is called ``ETH_HERA``.

The ``evmone`` and ``hera`` libraries should both end with the file name
The ``evmone`` library should both end with the file name
extension ``.so`` on Linux, ``.dll`` on Windows systems and ``.dylib`` on macOS.

For running SMT tests, the ``libz3`` library must be installed and locatable
Expand Down
13 changes: 2 additions & 11 deletions docs/using-the-compiler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,8 @@ Input Description
// evm.deployedBytecode.immutableReferences - Map from AST ids to bytecode ranges that reference immutables
// evm.methodIdentifiers - The list of function hashes
// evm.gasEstimates - Function gas estimates
// ewasm.wast - Ewasm in WebAssembly S-expressions format
// ewasm.wasm - Ewasm in WebAssembly binary format
//
// Note that using a using `evm`, `evm.bytecode`, `ewasm`, etc. will select every
// Note that using a using `evm`, `evm.bytecode`, etc. will select every
// target part of that output. Additionally, `*` can be used as a wildcard to request everything.
//
"outputSelection": {
Expand Down Expand Up @@ -501,7 +499,7 @@ Output Description
// Mandatory: Error type, such as "TypeError", "InternalCompilerError", "Exception", etc.
// See below for complete list of types.
"type": "TypeError",
// Mandatory: Component where the error originated, such as "general", "ewasm", etc.
// Mandatory: Component where the error originated, such as "general" etc.
"component": "general",
// Mandatory ("error", "warning" or "info", but please note that this may be extended in the future)
"severity": "error",
Expand Down Expand Up @@ -617,13 +615,6 @@ Output Description
"heavyLifting()": "infinite"
}
}
},
// Ewasm related outputs
"ewasm": {
// S-expressions format
"wast": "",
// Binary format (hex string)
"wasm": ""
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions docs/yul.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1194,8 +1194,7 @@ An example Yul Object is shown below:
// executing code is the constructor code)
size := datasize("Contract1_deployed")
offset := allocate(size)
// This will turn into a memory->memory copy for Ewasm and
// a codecopy for EVM
// This will turn into a codecopy for EVM
datacopy(offset, dataoffset("Contract1_deployed"), size)
return(offset, size)
}
Expand Down
57 changes: 1 addition & 56 deletions libsolidity/interface/CompilerStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,6 @@ void CompilerStack::reset(bool _keepSettings)
m_evmVersion = langutil::EVMVersion();
m_modelCheckerSettings = ModelCheckerSettings{};
m_generateIR = false;
m_generateEwasm = false;
m_revertStrings = RevertStrings::Default;
m_optimiserSettings = OptimiserSettings::minimal();
m_metadataLiteralSources = false;
Expand Down Expand Up @@ -681,7 +680,7 @@ bool CompilerStack::compile(State _stopAfter)
{
try
{
if (m_viaIR || m_generateIR || m_generateEwasm)
if (m_viaIR || m_generateIR)
generateIR(*contract);
if (m_generateEvmBytecode)
{
Expand All @@ -690,8 +689,6 @@ bool CompilerStack::compile(State _stopAfter)
else
compileContract(*contract, otherCompilers);
}
if (m_generateEwasm)
generateEwasm(*contract);
}
catch (Error const& _error)
{
Expand Down Expand Up @@ -892,22 +889,6 @@ string const& CompilerStack::yulIROptimized(string const& _contractName) const
return contract(_contractName).yulIROptimized;
}

string const& CompilerStack::ewasm(string const& _contractName) const
{
if (m_stackState != CompilationSuccessful)
solThrow(CompilerError, "Compilation was not successful.");

return contract(_contractName).ewasm;
}

evmasm::LinkerObject const& CompilerStack::ewasmObject(string const& _contractName) const
{
if (m_stackState != CompilationSuccessful)
solThrow(CompilerError, "Compilation was not successful.");

return contract(_contractName).ewasmObject;
}

evmasm::LinkerObject const& CompilerStack::object(string const& _contractName) const
{
if (m_stackState != CompilationSuccessful)
Expand Down Expand Up @@ -1479,42 +1460,6 @@ void CompilerStack::generateEVMFromIR(ContractDefinition const& _contract)
assembleYul(_contract, compiledContract.evmAssembly, compiledContract.evmRuntimeAssembly);
}

void CompilerStack::generateEwasm(ContractDefinition const& _contract)
{
solAssert(m_stackState >= AnalysisPerformed, "");
if (m_hasError)
solThrow(CompilerError, "Called generateEwasm with errors.");

if (!_contract.canBeDeployed())
return;

Contract& compiledContract = m_contracts.at(_contract.fullyQualifiedName());
solAssert(!compiledContract.yulIROptimized.empty(), "");
if (!compiledContract.ewasm.empty())
return;

// Re-parse the Yul IR in EVM dialect
yul::YulStack stack(
m_evmVersion,
m_eofVersion,
yul::YulStack::Language::StrictAssembly,
m_optimiserSettings,
m_debugInfoSelection
);
stack.parseAndAnalyze("", compiledContract.yulIROptimized);

stack.optimize();
stack.translate(yul::YulStack::Language::Ewasm);
stack.optimize();

//cout << yul::AsmPrinter{}(*stack.parserResult()->code) << endl;

// Turn into Ewasm text representation.
auto result = stack.assemble(yul::YulStack::Machine::Ewasm);
compiledContract.ewasm = std::move(result.assembly);
compiledContract.ewasmObject = std::move(*result.bytecode);
}

CompilerStack::Contract const& CompilerStack::contract(string const& _contractName) const
{
solAssert(m_stackState >= AnalysisPerformed, "");
Expand Down
16 changes: 0 additions & 16 deletions libsolidity/interface/CompilerStack.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,6 @@ class CompilerStack: public langutil::CharStreamProvider
/// Enable generation of Yul IR code.
void enableIRGeneration(bool _enable = true) { m_generateIR = _enable; }

/// Enable experimental generation of Ewasm code. If enabled, IR is also generated.
void enableEwasmGeneration(bool _enable = true) { m_generateEwasm = _enable; }

/// @arg _metadataLiteralSources When true, store sources as literals in the contract metadata.
/// Must be set before parsing.
void useMetadataLiteralSources(bool _metadataLiteralSources);
Expand Down Expand Up @@ -282,12 +279,6 @@ class CompilerStack: public langutil::CharStreamProvider
/// @returns the optimized IR representation of a contract.
std::string const& yulIROptimized(std::string const& _contractName) const;

/// @returns the Ewasm text representation of a contract.
std::string const& ewasm(std::string const& _contractName) const;

/// @returns the Ewasm representation of a contract.
evmasm::LinkerObject const& ewasmObject(std::string const& _contractName) const;

/// @returns the assembled object for a contract.
evmasm::LinkerObject const& object(std::string const& _contractName) const;

Expand Down Expand Up @@ -389,8 +380,6 @@ class CompilerStack: public langutil::CharStreamProvider
evmasm::LinkerObject runtimeObject; ///< Runtime object.
std::string yulIR; ///< Yul IR code.
std::string yulIROptimized; ///< Optimized Yul IR code.
std::string ewasm; ///< Experimental Ewasm text representation
evmasm::LinkerObject ewasmObject; ///< Experimental Ewasm code
util::LazyInit<std::string const> metadata; ///< The metadata json that will be hashed into the chain.
util::LazyInit<Json::Value const> abi;
util::LazyInit<Json::Value const> storageLayout;
Expand Down Expand Up @@ -448,10 +437,6 @@ class CompilerStack: public langutil::CharStreamProvider
/// Depends on output generated by generateIR.
void generateEVMFromIR(ContractDefinition const& _contract);

/// Generate Ewasm representation for a single contract.
/// Depends on output generated by generateIR.
void generateEwasm(ContractDefinition const& _contract);

/// Links all the known library addresses in the available objects. Any unknown
/// library will still be kept as an unlinked placeholder in the objects.
void link();
Expand Down Expand Up @@ -510,7 +495,6 @@ class CompilerStack: public langutil::CharStreamProvider
std::map<std::string, std::set<std::string>> m_requestedContractNames;
bool m_generateEvmBytecode = true;
bool m_generateIR = false;
bool m_generateEwasm = false;
std::map<std::string, util::h160> m_libraries;
ImportRemapper m_importRemapper;
std::map<std::string const, Source> m_sources;
Expand Down
31 changes: 2 additions & 29 deletions libsolidity/interface/StandardCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ bool hashMatchesContent(string const& _hash, string const& _content)

bool isArtifactRequested(Json::Value const& _outputSelection, string const& _artifact, bool _wildcardMatchesExperimental)
{
static set<string> experimental{"ir", "irOptimized", "wast", "ewasm", "ewasm.wast"};
static set<string> experimental{"ir", "irOptimized"};
for (auto const& selectedArtifactJson: _outputSelection)
{
string const& selectedArtifact = selectedArtifactJson.asString();
Expand All @@ -190,7 +190,7 @@ bool isArtifactRequested(Json::Value const& _outputSelection, string const& _art
return true;
else if (selectedArtifact == "*")
{
// "ir", "irOptimized", "wast" and "ewasm.wast" can only be matched by "*" if activated.
// "ir", "irOptimized" can only be matched by "*" if activated.
if (experimental.count(_artifact) == 0 || _wildcardMatchesExperimental)
return true;
}
Expand Down Expand Up @@ -264,7 +264,6 @@ bool isBinaryRequested(Json::Value const& _outputSelection)
static vector<string> const outputsThatRequireBinaries = vector<string>{
"*",
"ir", "irOptimized",
"wast", "wasm", "ewasm.wast", "ewasm.wasm",
"evm.gasEstimates", "evm.legacyAssembly", "evm.assembly"
} + evmObjectComponents("bytecode") + evmObjectComponents("deployedBytecode");

Expand Down Expand Up @@ -295,29 +294,10 @@ bool isEvmBytecodeRequested(Json::Value const& _outputSelection)
return false;
}

/// @returns true if any Ewasm code was requested. Note that as an exception, '*' does not
/// yet match "ewasm.wast" or "ewasm"
bool isEwasmRequested(Json::Value const& _outputSelection)
{
if (!_outputSelection.isObject())
return false;

for (auto const& fileRequests: _outputSelection)
for (auto const& requests: fileRequests)
for (auto const& request: requests)
if (request == "ewasm" || request == "ewasm.wast")
return true;

return false;
}

/// @returns true if any Yul IR was requested. Note that as an exception, '*' does not
/// yet match "ir" or "irOptimized"
bool isIRRequested(Json::Value const& _outputSelection)
{
if (isEwasmRequested(_outputSelection))
return true;

if (!_outputSelection.isObject())
return false;

Expand Down Expand Up @@ -1175,7 +1155,6 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting

compilerStack.enableEvmBytecodeGeneration(isEvmBytecodeRequested(_inputsAndSettings.outputSelection));
compilerStack.enableIRGeneration(isIRRequested(_inputsAndSettings.outputSelection));
compilerStack.enableEwasmGeneration(isEwasmRequested(_inputsAndSettings.outputSelection));

Json::Value errors = std::move(_inputsAndSettings.errors);

Expand Down Expand Up @@ -1374,12 +1353,6 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting
if (compilationSuccess && isArtifactRequested(_inputsAndSettings.outputSelection, file, name, "irOptimized", wildcardMatchesExperimental))
contractData["irOptimized"] = compilerStack.yulIROptimized(contractName);

// Ewasm
if (compilationSuccess && isArtifactRequested(_inputsAndSettings.outputSelection, file, name, "ewasm.wast", wildcardMatchesExperimental))
contractData["ewasm"]["wast"] = compilerStack.ewasm(contractName);
if (compilationSuccess && isArtifactRequested(_inputsAndSettings.outputSelection, file, name, "ewasm.wasm", wildcardMatchesExperimental))
contractData["ewasm"]["wasm"] = compilerStack.ewasmObject(contractName).toHex();

// EVM
Json::Value evmData(Json::objectValue);
if (compilationSuccess && isArtifactRequested(_inputsAndSettings.outputSelection, file, name, "evm.assembly", wildcardMatchesExperimental))
Expand Down
30 changes: 0 additions & 30 deletions libyul/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
# This will re-generate the polyfill headers, if any file within libyul/backends/wasm/polyfill/ was modified.
set_directory_properties(PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_SOURCE_DIR}/libyul/backends/wasm/polyfill/)

set(POLYFILLS Arithmetic Bitwise Comparison Conversion Interface Keccak Logical Memory)
set(GENERATED_POLYFILL_HEADERS)
foreach(polyfill IN LISTS POLYFILLS)
set(POLYFILL_FILE ${CMAKE_SOURCE_DIR}/libyul/backends/wasm/polyfill/${polyfill}.yul)
file(READ ${POLYFILL_FILE} EWASM_POLYFILL_CONTENT HEX)
string(REGEX MATCHALL ".." EWASM_POLYFILL_CONTENT "${EWASM_POLYFILL_CONTENT}")
string(REGEX REPLACE ";" ",\n\t0x" EWASM_POLYFILL_CONTENT "${EWASM_POLYFILL_CONTENT}")
set(EWASM_POLYFILL_CONTENT "0x${EWASM_POLYFILL_CONTENT}")
set(EWASM_POLYFILL_NAME ${polyfill})
configure_file("${CMAKE_SOURCE_DIR}/cmake/templates/ewasm_polyfill.in" ${CMAKE_BINARY_DIR}/include/ewasmPolyfills/${polyfill}.h @ONLY)
list(APPEND GENERATED_POLYFILL_HEADERS ${CMAKE_BINARY_DIR}/include/ewasmPolyfills/${polyfill}.h)
endforeach()

add_library(yul
${GENERATED_POLYFILL_HEADERS}

Expand Down Expand Up @@ -80,20 +64,6 @@ add_library(yul
backends/evm/StackLayoutGenerator.h
backends/evm/VariableReferenceCounter.h
backends/evm/VariableReferenceCounter.cpp
backends/wasm/EVMToEwasmTranslator.cpp
backends/wasm/EVMToEwasmTranslator.h
backends/wasm/BinaryTransform.cpp
backends/wasm/BinaryTransform.h
backends/wasm/TextTransform.cpp
backends/wasm/TextTransform.h
backends/wasm/WasmCodeTransform.cpp
backends/wasm/WasmCodeTransform.h
backends/wasm/WasmDialect.cpp
backends/wasm/WasmDialect.h
backends/wasm/WasmObjectCompiler.cpp
backends/wasm/WasmObjectCompiler.h
backends/wasm/WordSizeTransform.cpp
backends/wasm/WordSizeTransform.h
optimiser/ASTCopier.cpp
optimiser/ASTCopier.h
optimiser/ASTWalker.cpp
Expand Down
Loading

0 comments on commit c567327

Please sign in to comment.