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

Method getOptimizedItems

libevmasm/CommonSubexpressionEliminator.cpp:38–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36using namespace solidity::langutil;
37
38std::vector<AssemblyItem> CommonSubexpressionEliminator::getOptimizedItems()
39{
40 optimizeBreakingItem();
41
42 KnownState nextInitialState = m_state;
43 if (m_breakingItem)
44 nextInitialState.feedItem(*m_breakingItem);
45 KnownState nextState = nextInitialState;
46
47 ScopeGuard reset([&]()
48 {
49 m_breakingItem = nullptr;
50 m_storeOperations.clear();
51 m_initialState = std::move(nextInitialState);
52 m_state = std::move(nextState);
53 });
54
55 std::map<int, Id> initialStackContents;
56 std::map<int, Id> targetStackContents;
57 int minHeight = m_state.stackHeight() + 1;
58 if (!m_state.stackElements().empty())
59 minHeight = std::min(minHeight, m_state.stackElements().begin()->first);
60 for (int height = minHeight; height <= m_initialState.stackHeight(); ++height)
61 initialStackContents[height] = m_initialState.stackElement(height, langutil::DebugData::create());
62 for (int height = minHeight; height <= m_state.stackHeight(); ++height)
63 targetStackContents[height] = m_state.stackElement(height, langutil::DebugData::create());
64
65 AssemblyItems items = CSECodeGenerator(m_state.expressionClasses(), m_storeOperations, m_evmVersion).generateCode(
66 m_initialState.sequenceNumber(),
67 m_initialState.stackHeight(),
68 initialStackContents,
69 targetStackContents
70 );
71 if (m_breakingItem)
72 items.push_back(*m_breakingItem);
73
74 return items;
75}
76
77void CommonSubexpressionEliminator::feedItem(AssemblyItem const& _item, bool _copyItem)
78{

Callers 4

CSEFunction · 0.80
fullCSEFunction · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80
Assembly.cppFile · 0.80

Calls 9

CSECodeGeneratorClass · 0.85
stackElementMethod · 0.80
generateCodeMethod · 0.80
sequenceNumberMethod · 0.80
feedItemMethod · 0.45
clearMethod · 0.45
stackHeightMethod · 0.45
emptyMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected