forked from lmcad-unicamp/oi-dbt
-
Notifications
You must be signed in to change notification settings - Fork 1
/
machineModel.cpp
54 lines (37 loc) · 1.52 KB
/
machineModel.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <machineModel.hpp>
double dbt::MachineModel::runOnMachine(std::vector<uint16_t> Genes, unsigned RegionID,
const std::string &AOSPath, const std::string &BinPath, const std::string &BinArgs) {
int LoadStatus = TheMachine->loadELF(BinPath);
if (!LoadStatus) {
std::cerr << "Can't find or process ELF file" << std::endl;
return 2;
}
std::shared_ptr<dbt::AOS> TheAOS = std::make_shared<dbt::AOS>(true, AOSPath, BinPath, BinArgs);
dbt::Manager TheManager(*(TheMachine.get()), TheAOS, false, false);
TheManager.setDataMemOffset(TheMachine->getDataMemOffset());
TheManager.setOptPolicy(dbt::Manager::OptPolitic::Normal);
TheManager.startCompilationThr();
std::unique_ptr<dbt::SyscallManager> SyscallM;
ROIInfo ROI;
ROI.RegionID = RegionID;
ROI.Opts = std::move(Genes);
TheManager.setROI(ROI);
TheManager.setROIMode();
TheManager.setLockMode(true);
dbt::Timer GlobalTimer;
LoadStatus = TheMachine->loadELF(BinPath);
if (!LoadStatus) {
std::cerr << "Can't find or process ELF file" << std::endl;
return 2;
}
RftDefault = std::make_unique<dbt::NETPlus>(TheManager, true);
SyscallM = std::make_unique<dbt::LinuxSyscallManager>(true);
TheMachine->setCommandLineArguments(BinArgs);
GlobalTimer.startClock();
dbt::ITDInterpreter I(*SyscallM.get(), *RftDefault.get());
I.executeAll((*TheMachine.get()));
GlobalTimer.stopClock();
std::cerr.flush();
std::cout.flush();
return TheManager.getRegionTime();
}