MCPcopy Create free account
hub / github.com/argotorg/solidity / calculateCacheKey

Method calculateCacheKey

libyul/ObjectOptimizer.cpp:123–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121}
122
123std::optional<h256> ObjectOptimizer::calculateCacheKey(
124 Block const& _ast,
125 ObjectDebugData const& _debugData,
126 Settings const& _settings,
127 bool _isCreation
128)
129{
130 AsmPrinter asmPrinter(
131 EVMDialect::strictAssemblyForEVMObjects(_settings.evmVersion, _settings.eofVersion),
132 _debugData.sourceNames,
133 DebugInfoSelection::All()
134 );
135
136 bytes rawKey;
137 // NOTE: AsmPrinter never prints nativeLocations included in debug data, so ASTs differing only
138 // in that regard are considered equal here. This is fine because the optimizer does not keep
139 // them up to date across AST transformations anyway so in any use where they need to be reliable,
140 // we just regenerate them by reparsing the object.
141 rawKey += keccak256(asmPrinter(_ast)).asBytes();
142 rawKey += keccak256(_debugData.formatUseSrcComment()).asBytes();
143 static_assert(static_cast<uint8_t>(static_cast<bool>(2)) == 1);
144 rawKey += FixedHash<1>(static_cast<uint8_t>(_settings.optimizeStackAllocation)).asBytes();
145 rawKey += h256(u256(_settings.expectedExecutionsPerDeployment)).asBytes();
146 rawKey += FixedHash<1>(static_cast<uint8_t>(_isCreation)).asBytes();
147 rawKey += keccak256(_settings.evmVersion.name()).asBytes();
148 yulAssert(!_settings.eofVersion.has_value() || *_settings.eofVersion > 0);
149 rawKey += FixedHash<1>(static_cast<uint8_t>(_settings.eofVersion ? *_settings.eofVersion : 0)).asBytes();
150 rawKey += keccak256(_settings.yulOptimiserSteps).asBytes();
151 rawKey += keccak256(_settings.yulOptimiserCleanupSteps).asBytes();
152
153 return h256(keccak256(rawKey));
154}

Callers

nothing calls this directly

Calls 4

asBytesMethod · 0.80
formatUseSrcCommentMethod · 0.80
keccak256Function · 0.50
nameMethod · 0.45

Tested by

no test coverage detected