mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Output runtime object in IR
This commit is contained in:
parent
a993ab4db7
commit
953d18c6cb
@ -1226,7 +1226,7 @@ void CompilerStack::compileContract(
|
||||
}
|
||||
|
||||
// Throw a warning if EIP-170 limits are exceeded:
|
||||
// If contract creation initialization returns data with length of more than 0x6000 (214 + 213) bytes,
|
||||
// If contract creation returns data with length greater than 0x6000 (214 + 213) bytes,
|
||||
// contract creation fails with an out of gas error.
|
||||
if (
|
||||
m_evmVersion >= langutil::EVMVersion::spuriousDragon() &&
|
||||
@ -1299,12 +1299,30 @@ void CompilerStack::generateEVMFromIR(ContractDefinition const& _contract)
|
||||
//cout << yul::AsmPrinter{}(*stack.parserResult()->code) << endl;
|
||||
|
||||
// TODO: support passing metadata
|
||||
auto result = stack.assemble(yul::AssemblyStack::Machine::EVM);
|
||||
compiledContract.object = std::move(*result.bytecode);
|
||||
// TODO: support runtimeObject
|
||||
// TODO: add EIP-170 size check for runtimeObject
|
||||
// TODO: use stack.assemble here!
|
||||
yul::MachineAssemblyObject init;
|
||||
yul::MachineAssemblyObject runtime;
|
||||
std::tie(init, runtime) = stack.assembleAndGuessRuntime();
|
||||
compiledContract.object = std::move(*init.bytecode);
|
||||
compiledContract.runtimeObject = std::move(*runtime.bytecode);
|
||||
// TODO: refactor assemblyItems, runtimeAssemblyItems, generatedSources,
|
||||
// assemblyString, assemblyJSON, and functionEntryPoints to work with this code path
|
||||
|
||||
// Throw a warning if EIP-170 limits are exceeded:
|
||||
// If contract creation returns data with length greater than 0x6000 (214 + 213) bytes,
|
||||
// contract creation fails with an out of gas error.
|
||||
if (
|
||||
m_evmVersion >= langutil::EVMVersion::spuriousDragon() &&
|
||||
compiledContract.runtimeObject.bytecode.size() > 0x6000
|
||||
)
|
||||
m_errorReporter.warning(
|
||||
9609_error,
|
||||
_contract.location(),
|
||||
"Contract code size exceeds 24576 bytes (a limit introduced in Spurious Dragon). "
|
||||
"This contract may not be deployable on mainnet. "
|
||||
"Consider enabling the optimizer (with a low \"runs\" value!), "
|
||||
"turning off revert strings, or using libraries."
|
||||
);
|
||||
}
|
||||
|
||||
void CompilerStack::generateEwasm(ContractDefinition const& _contract)
|
||||
|
@ -225,7 +225,7 @@ def examine_id_coverage(top_dir, source_id_to_file_names, new_ids_only=False):
|
||||
"3893", "3996", "4010", "4802",
|
||||
"5073", "5272", "5622", "7128",
|
||||
"7589", "7593", "7653", "8065", "8084", "8140",
|
||||
"8312", "8592", "9085", "9390"
|
||||
"8312", "8592", "9085", "9390", "9609",
|
||||
}
|
||||
|
||||
new_source_only_ids = source_only_ids - old_source_only_ids
|
||||
|
@ -1,4 +1,4 @@
|
||||
{"contracts":{"A":{"C":{"evm":{"bytecode":{"generatedSources":[],"object":"<BYTECODE REMOVED>"},"deployedBytecode":{"object":""}},"ir":"/*******************************************************
|
||||
{"contracts":{"A":{"C":{"evm":{"bytecode":{"generatedSources":[],"object":"<BYTECODE REMOVED>"},"deployedBytecode":{"object":"<BYTECODE REMOVED>"}},"ir":"/*******************************************************
|
||||
* WARNING *
|
||||
* Solidity to Yul compilation is still EXPERIMENTAL *
|
||||
* It can result in LOSS OF FUNDS or worse *
|
||||
@ -49,7 +49,7 @@ object \"C_3\" {
|
||||
|
||||
}
|
||||
|
||||
"},"D":{"evm":{"bytecode":{"generatedSources":[],"object":"<BYTECODE REMOVED>"},"deployedBytecode":{"object":""}},"ir":"/*******************************************************
|
||||
"},"D":{"evm":{"bytecode":{"generatedSources":[],"object":"<BYTECODE REMOVED>"},"deployedBytecode":{"object":"<BYTECODE REMOVED>"}},"ir":"/*******************************************************
|
||||
* WARNING *
|
||||
* Solidity to Yul compilation is still EXPERIMENTAL *
|
||||
* It can result in LOSS OF FUNDS or worse *
|
||||
|
@ -3,7 +3,7 @@
|
||||
Binary:
|
||||
60806040523415600f5760006000fd5b600a80601e600039806000f350fe608060405260006000fd
|
||||
Binary of the runtime part:
|
||||
|
||||
608060405260006000fd
|
||||
Optimized IR:
|
||||
/*******************************************************
|
||||
* WARNING *
|
||||
@ -37,7 +37,7 @@ object "C_3" {
|
||||
Binary:
|
||||
608060405234156100105760006000fd5b61010680610021600039806000f350fe6080604052600436101515610088576000803560e01c6326121ff0141561008657341561002a578081fd5b806003193601121561003a578081fd5b6028806080016080811067ffffffffffffffff8211171561005e5761005d6100c4565b5b50806100de60803980608083f01515610079573d82833e3d82fd5b508061008482610092565bf35b505b60006000fd6100dc565b6000604051905081810181811067ffffffffffffffff821117156100b9576100b86100c4565b5b80604052505b919050565b634e487b7160e01b600052604160045260246000fd5b565bfe60806040523415600f5760006000fd5b600a80601e600039806000f350fe608060405260006000fd
|
||||
Binary of the runtime part:
|
||||
|
||||
6080604052600436101515610088576000803560e01c6326121ff0141561008657341561002a578081fd5b806003193601121561003a578081fd5b6028806080016080811067ffffffffffffffff8211171561005e5761005d6100c4565b5b50806100de60803980608083f01515610079573d82833e3d82fd5b508061008482610092565bf35b505b60006000fd6100dc565b6000604051905081810181811067ffffffffffffffff821117156100b9576100b86100c4565b5b80604052505b919050565b634e487b7160e01b600052604160045260246000fd5b565bfe60806040523415600f5760006000fd5b600a80601e600039806000f350fe608060405260006000fd
|
||||
Optimized IR:
|
||||
/*******************************************************
|
||||
* WARNING *
|
||||
|
Loading…
Reference in New Issue
Block a user