| 99 | } |
| 100 | |
| 101 | void ObjectOptimizer::overwriteWithOptimizedObject(util::h256 _cacheKey, Object& _object) const |
| 102 | { |
| 103 | yulAssert(m_cachedObjects.count(_cacheKey) != 0); |
| 104 | CachedObject const& cachedObject = m_cachedObjects.at(_cacheKey); |
| 105 | |
| 106 | yulAssert(cachedObject.optimizedAST); |
| 107 | yulAssert(cachedObject.dialect); |
| 108 | _object.setCode(std::make_shared<AST>(*cachedObject.dialect, ASTCopier{}.translate(*cachedObject.optimizedAST))); |
| 109 | yulAssert(_object.code()); |
| 110 | yulAssert(_object.dialect()); |
| 111 | |
| 112 | // There's no point in caching AnalysisInfo because it references AST nodes. It can't be shared |
| 113 | // by multiple ASTs and it's easier to recalculate it than properly clone it. |
| 114 | _object.analysisInfo = std::make_shared<AsmAnalysisInfo>( |
| 115 | AsmAnalyzer::analyzeStrictAssertCorrect( |
| 116 | _object |
| 117 | ) |
| 118 | ); |
| 119 | |
| 120 | // NOTE: Source name index is included in the key so it must be identical. No need to store and restore it. |
| 121 | } |
| 122 | |
| 123 | std::optional<h256> ObjectOptimizer::calculateCacheKey( |
| 124 | Block const& _ast, |