Bugfix for ALUInstr
git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1743 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
@ -92,14 +92,14 @@ bool BochsALUInstructions::isALUInstruction(bxInstruction_c const *src) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void BochsALUInstructions::randomEquivalent(bxInstruction_c &result,
|
||||
int BochsALUInstructions::randomEquivalent(bxInstruction_c &result,
|
||||
std::string &details) const {
|
||||
// find a random member of the same equivalence class
|
||||
X86AluClass equClassID = lastInstr.aluClass;
|
||||
if (equClassID == ALU_UNDEF) {
|
||||
// something went wrong - just return the original instruction
|
||||
result = lastOrigInstr;
|
||||
return;
|
||||
return 10;
|
||||
}
|
||||
|
||||
InstrList const &destList = equivalenceClasses.at(equClassID);
|
||||
@ -108,7 +108,7 @@ void BochsALUInstructions::randomEquivalent(bxInstruction_c &result,
|
||||
do {
|
||||
int index = rand() % destList.size();
|
||||
dest = destList[index];
|
||||
} while (memcmp(&dest, &lastInstr, sizeof(BochsALUInstr)) == 0);
|
||||
} while (dest == lastInstr);
|
||||
|
||||
// alternative chosen -- now store the necessary details
|
||||
std::ostringstream oss;
|
||||
@ -136,6 +136,13 @@ void BochsALUInstructions::randomEquivalent(bxInstruction_c &result,
|
||||
if (dest.opcodeRegisterOffset < BochsALUInstr::REG_COUNT) {
|
||||
result.setRm(dest.opcodeRegisterOffset);
|
||||
}
|
||||
|
||||
if (memcmp(&result, &lastOrigInstr, sizeof(bxInstruction_c)) == 0) {
|
||||
fprintf(stderr,"randomEquivalent failed\n");
|
||||
scanf("%*s");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
@ -76,6 +76,24 @@ struct BochsALUInstr {
|
||||
* the count of registers
|
||||
*/
|
||||
static const unsigned REG_COUNT = 8;
|
||||
/**
|
||||
* returns true if obj equals this object
|
||||
* the Bochs opcode is generated dynamically and thus not relevant for comparison
|
||||
*/
|
||||
bool operator==(BochsALUInstr const &obj) const
|
||||
{
|
||||
return opcode == obj.opcode &&
|
||||
reg == obj.reg &&
|
||||
opcodeRegisterOffset == obj.opcodeRegisterOffset &&
|
||||
aluClass == obj.aluClass;
|
||||
}
|
||||
/**
|
||||
* returns false if obj equals this object
|
||||
* \see operator==
|
||||
*/
|
||||
bool operator!=(BochsALUInstr const &obj) const {
|
||||
return !(*this == obj);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -325,7 +343,7 @@ public:
|
||||
* @param result the resulting bxInstruction_c object as described above
|
||||
* @param details after completion contains details about \c result
|
||||
*/
|
||||
void randomEquivalent(bxInstruction_c &result, std::string &details) const;
|
||||
int randomEquivalent(bxInstruction_c &result, std::string &details) const;
|
||||
protected:
|
||||
/**
|
||||
* Convert a bxInstruction_c object into its matching BochsALUInstr object.
|
||||
|
||||
@ -162,10 +162,10 @@ void L4SysExperiment::injectInstruction(bxInstruction_c *oldInstr, bxInstruction
|
||||
memcpy(oldInstr, &backupInstr, sizeof(bxInstruction_c));
|
||||
}
|
||||
|
||||
unsigned L4SysExperiment::calculateTimeout() {
|
||||
unsigned L4SysExperiment::calculateTimeout(unsigned instr_left) {
|
||||
// the timeout in seconds, plus one backup second (avoids rounding overhead)
|
||||
// [instr] / [instr / s] = [s]
|
||||
unsigned seconds = L4SYS_NUMINSTR / L4SYS_BOCHS_IPS + 1;
|
||||
unsigned seconds = instr_left / L4SYS_BOCHS_IPS + 1;
|
||||
// 1.1 (+10 percent) * 1000 ms/s * [s]
|
||||
return 1100 * seconds;
|
||||
}
|
||||
@ -600,7 +600,7 @@ bool L4SysExperiment::run() {
|
||||
// now exchange it with a random equivalent
|
||||
bxInstruction_c newInstr;
|
||||
string details;
|
||||
aluInstrObject.randomEquivalent(newInstr, details);
|
||||
int result = aluInstrObject.randomEquivalent(newInstr, details);
|
||||
if (memcmp(&newInstr, currInstr, sizeof(bxInstruction_c)) == 0) {
|
||||
// something went wrong - exit experiment
|
||||
param.msg.set_resulttype(param.msg.UNKNOWN);
|
||||
@ -627,10 +627,12 @@ bool L4SysExperiment::run() {
|
||||
// aftermath
|
||||
BPSingleListener ev_done(L4SYS_FUNC_EXIT, L4SYS_ADDRESS_SPACE);
|
||||
simulator.addListener(&ev_done);
|
||||
unsigned instr_left = L4SYS_NUMINSTR - instr_offset;
|
||||
BPSingleListener ev_incomplete(ANY_ADDR, L4SYS_ADDRESS_SPACE);
|
||||
ev_incomplete.setCounter(static_cast<unsigned>(L4SYS_NUMINSTR * 1.1));
|
||||
ev_incomplete.setCounter(
|
||||
static_cast<unsigned>(instr_left * 1.1));
|
||||
simulator.addListener(&ev_incomplete);
|
||||
TimerListener ev_timeout(calculateTimeout());
|
||||
TimerListener ev_timeout(calculateTimeout(instr_left));
|
||||
simulator.addListener(&ev_timeout);
|
||||
|
||||
//do not discard output recorded so far
|
||||
|
||||
@ -73,7 +73,7 @@ private:
|
||||
/**
|
||||
* Calculate the timeout of the current workload in milliseconds.
|
||||
*/
|
||||
unsigned calculateTimeout();
|
||||
unsigned calculateTimeout(unsigned instr_left);
|
||||
};
|
||||
|
||||
#endif // __L4SYS_EXPERIMENT_HPP__
|
||||
|
||||
Reference in New Issue
Block a user