Browse Source

Start of pinhole optimiser. Minor fix for debugger.

cl-refactor
Gav Wood 11 years ago
parent
commit
6657fa7a63
  1. 3
      alethzero/MainWin.cpp
  2. 41
      libethereum/Executive.cpp
  3. 2
      liblll/Assembly.cpp
  4. 4
      liblll/Assembly.h

3
alethzero/MainWin.cpp

@ -840,11 +840,12 @@ void Main::on_data_textChanged()
if (isCreation())
{
vector<string> errors;
auto asmcode = eth::compileLLLToAsm(ui->data->toPlainText().toStdString());
m_data = compileLLL(ui->data->toPlainText().toStdString(), &errors);
for (auto const& i: errors)
cwarn << i;
ui->code->setHtml("<h4>Code</h4>" + QString::fromStdString(disassemble(m_data)).toHtmlEscaped());
ui->code->setHtml("<h4>Code</h4>" + QString::fromStdString(disassemble(m_data)).toHtmlEscaped() + "<p/><pre>" + QString::fromStdString(asmcode).toHtmlEscaped() + "</pre>");
ui->gas->setMinimum((qint64)state().createGas(m_data.size(), 0));
if (!ui->gas->isEnabled())
ui->gas->setValue(m_backupGas);

41
libethereum/Executive.cpp

@ -161,27 +161,30 @@ bool Executive::go(uint64_t _steps)
try
{
#if ETH_VMTRACE
for (uint64_t s = 0;; ++s)
{
ostringstream o;
o << endl << " STACK" << endl;
for (auto i: vm().stack())
o << (h256)i << endl;
o << " MEMORY" << endl << memDump(vm().memory());
o << " STORAGE" << endl;
for (auto const& i: state().storage(ext().myAddress))
o << showbase << hex << i.first << ": " << i.second << endl;
eth::LogOutputStream<VMTraceChannel, false>(true) << o.str();
eth::LogOutputStream<VMTraceChannel, false>(false) << dec << " | #" << s << " | " << hex << setw(4) << setfill('0') << vm().curPC() << " : " << c_instructionInfo.at((Instruction)ext().getCode(vm().curPC())).name << " | " << dec << vm().gas() << " ]";
if (s >= _steps)
break;
try
if (_steps == (uint64_t)0 - 1)
for (uint64_t s = 0;; ++s)
{
m_out = m_vm->go(*m_ext, 1);
break;
ostringstream o;
o << endl << " STACK" << endl;
for (auto i: vm().stack())
o << (h256)i << endl;
o << " MEMORY" << endl << memDump(vm().memory());
o << " STORAGE" << endl;
for (auto const& i: state().storage(ext().myAddress))
o << showbase << hex << i.first << ": " << i.second << endl;
eth::LogOutputStream<VMTraceChannel, false>(true) << o.str();
eth::LogOutputStream<VMTraceChannel, false>(false) << dec << " | #" << s << " | " << hex << setw(4) << setfill('0') << vm().curPC() << " : " << c_instructionInfo.at((Instruction)ext().getCode(vm().curPC())).name << " | " << dec << vm().gas() << " ]";
if (s >= _steps)
break;
try
{
m_out = m_vm->go(*m_ext, 1);
break;
}
catch (StepsDone const&) {}
}
catch (StepsDone const&) {}
}
else
m_out = m_vm->go(*m_ext, _steps);
#else
m_out = m_vm->go(*m_ext, _steps);
#endif

2
liblll/Assembly.cpp

@ -144,6 +144,8 @@ AssemblyItem const& Assembly::append(AssemblyItem const& _i)
void Assembly::optimise()
{
std::vector<pair< vector<int>, function< vector<AssemblyItem>(vector<AssemblyItem>) > >> rules;
// rules.insert(make_pair({(int)Instruction::ADD, (int)Instruction::ADD, -(int)Push}, []() {}));
}
bytes Assembly::assemble() const

4
liblll/Assembly.h

@ -51,11 +51,15 @@ public:
int deposit() const;
bool operator==(int _mask) const { return -_mask == (int)m_type || (m_type == Operation && _mask == (int)m_data); }
private:
AssemblyItemType m_type;
u256 m_data;
};
inline bool operator==(int _i, AssemblyItem _ai) { return _ai.operator==(_i); }
class Assembly
{
public:

Loading…
Cancel
Save