-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Introduce subassembly offset output artifact #15710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,6 +89,15 @@ struct LinkerObject | |
/// Bytecode offsets of named tags like function entry points. | ||
std::map<std::string, FunctionDebugData> functionDebugData; | ||
|
||
struct Structure { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe |
||
size_t start; | ||
size_t length; | ||
bool isCreation; | ||
std::vector<Structure> subAssemblies {}; | ||
}; | ||
|
||
std::vector<Structure> subAssemblyData; | ||
|
||
/// Appends the bytecode of @a _other and incorporates its link references. | ||
void append(LinkerObject const& _other); | ||
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add the feature to the CLI too. We should keep them at parity (and it's a pain for testing/development if the only way to access a feature is through StandardJSON). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, Yul compilation is not covered. Aside from general inconsistency, this makes two-step compilation less powerful, which may be a problem for future parallelization. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,6 +137,7 @@ static std::string const g_strSrcMapRuntime = "srcmap-runtime"; | |
static std::string const g_strStorageLayout = "storage-layout"; | ||
static std::string const g_strTransientStorageLayout = "transient-storage-layout"; | ||
static std::string const g_strVersion = "version"; | ||
static std::string const g_strAssemblyStructure = "assembly-structure"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: options are in alphabetical order here. |
||
|
||
static bool needsHumanTargetedStdout(CommandLineOptions const& _options) | ||
{ | ||
|
@@ -159,7 +160,8 @@ static bool needsHumanTargetedStdout(CommandLineOptions const& _options) | |
_options.compiler.outputs.opcodes || | ||
_options.compiler.outputs.signatureHashes || | ||
_options.compiler.outputs.storageLayout || | ||
_options.compiler.outputs.transientStorageLayout; | ||
_options.compiler.outputs.transientStorageLayout || | ||
_options.compiler.outputs.assemblyStructure; | ||
} | ||
|
||
static bool coloredOutput(CommandLineOptions const& _options) | ||
|
@@ -210,7 +212,6 @@ void CommandLineInterface::handleBinary(std::string const& _contract) | |
binary = objectWithLinkRefsHex(m_assemblyStack->object(_contract)); | ||
if (m_options.compiler.outputs.binaryRuntime) | ||
binaryRuntime = objectWithLinkRefsHex(m_assemblyStack->runtimeObject(_contract)); | ||
|
||
if (m_options.compiler.outputs.binary) | ||
{ | ||
if (!m_options.output.dir.empty()) | ||
|
@@ -591,6 +592,22 @@ void CommandLineInterface::handleEthdebug(std::string const& _contract) | |
} | ||
} | ||
|
||
void CommandLineInterface::handleAssemblyStructure(std::string const& _contract) | ||
{ | ||
solAssert(CompilerInputModes.count(m_options.input.mode) == 1); | ||
solAssert(m_compiler->compilationSuccessful()); | ||
|
||
if (!m_options.compiler.outputs.assemblyStructure) | ||
return; | ||
|
||
solAssert(m_assemblyStack); | ||
std::string const data = jsonPrint( | ||
removeNullMembers(StandardCompiler::formatAssemblyStructure(m_assemblyStack->object(_contract).subAssemblyData)), | ||
m_options.formatting.json | ||
); | ||
sout() << "Assembly structure:" << std::endl << data << std::endl; | ||
} | ||
|
||
void CommandLineInterface::readInputFiles() | ||
{ | ||
solAssert(!m_standardJsonInput.has_value()); | ||
|
@@ -960,6 +977,7 @@ void CommandLineInterface::compile() | |
m_options.compiler.outputs.binaryRuntime || | ||
m_options.compiler.outputs.ethdebug || | ||
m_options.compiler.outputs.ethdebugRuntime || | ||
m_options.compiler.outputs.assemblyStructure || | ||
(m_options.compiler.combinedJsonRequests && ( | ||
m_options.compiler.combinedJsonRequests->binary || | ||
m_options.compiler.combinedJsonRequests->binaryRuntime || | ||
|
@@ -970,7 +988,8 @@ void CommandLineInterface::compile() | |
m_options.compiler.combinedJsonRequests->srcMap || | ||
m_options.compiler.combinedJsonRequests->srcMapRuntime || | ||
m_options.compiler.combinedJsonRequests->funDebug || | ||
m_options.compiler.combinedJsonRequests->funDebugRuntime | ||
m_options.compiler.combinedJsonRequests->funDebugRuntime || | ||
m_options.compiler.combinedJsonRequests->assemblyStructure | ||
)); | ||
|
||
m_compiler->selectContracts({{"", {{"", pipelineConfig}}}}); | ||
|
@@ -1105,6 +1124,10 @@ void CommandLineInterface::handleCombinedJSON() | |
contractData[g_strFunDebugRuntime] = StandardCompiler::formatFunctionDebugData( | ||
m_assemblyStack->runtimeObject(contractName).functionDebugData | ||
); | ||
if (m_options.compiler.combinedJsonRequests->assemblyStructure) | ||
contractData[g_strAssemblyStructure] = StandardCompiler::formatAssemblyStructure( | ||
m_assemblyStack->object(contractName).subAssemblyData | ||
); | ||
} | ||
} | ||
|
||
|
@@ -1467,6 +1490,7 @@ void CommandLineInterface::outputCompilationResults() | |
handleNatspec(true, contract); | ||
handleNatspec(false, contract); | ||
handleEthdebug(contract); | ||
handleAssemblyStructure(contract); | ||
} // end of contracts iteration | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--assembly-structure --pretty-json --json-indent 4 --no-cbor-metadata |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be implemented for EOF as well (i.e. in
assembleEOF()
, or, if possible, just inassemble()
covering both with the same code).Since we're at the stage where EOF is passing semantic tests (and they will be enabled by default quite soon), we should start requiring all new features for work on EOF as well.