Chromium Code Reviews| Index: src/IceTargetLoweringX8632.cpp |
| diff --git a/src/IceTargetLoweringX8632.cpp b/src/IceTargetLoweringX8632.cpp |
| index ebc0bae319fc44d9d509e67999f088e905586076..94682a2fcb709c06adb4c595b587bf13325c20ff 100644 |
| --- a/src/IceTargetLoweringX8632.cpp |
| +++ b/src/IceTargetLoweringX8632.cpp |
| @@ -128,6 +128,9 @@ const uint32_t X86_CHAR_BIT = 8; |
| const uint32_t X86_STACK_ALIGNMENT_BYTES = 16; |
| // Size of the return address on the stack |
| const uint32_t X86_RET_IP_SIZE_BYTES = 4; |
| +// The maximum supported length of a NOP instruction (all smaller |
| +// lengths are also supported) |
| +const uint32_t X86_MAX_NOP_LEN = 9; |
|
jvoung (off chromium)
2014/08/14 15:17:17
Does it actually help to add nops of up to 9 bytes
wala
2014/08/14 23:29:50
Thanks for the link.
That paper makes it clear th
|
| // Value is a size in bytes. Return Value adjusted to the next highest |
| // multiple of the stack alignment. |
| @@ -392,6 +395,11 @@ void TargetX8632::translateO2() { |
| return; |
| T_genFrame.printElapsedUs(Context, "genFrame()"); |
| Func->dump("After stack frame mapping"); |
| + |
| + // Nop insertion |
| + if (shouldDoNopInsertion()) { |
| + Func->doNopInsertion(); |
| + } |
| } |
| void TargetX8632::translateOm1() { |
| @@ -430,6 +438,11 @@ void TargetX8632::translateOm1() { |
| return; |
| T_genFrame.printElapsedUs(Context, "genFrame()"); |
| Func->dump("After stack frame mapping"); |
| + |
| + // Nop insertion |
| + if (shouldDoNopInsertion()) { |
| + Func->doNopInsertion(); |
| + } |
| } |
| IceString TargetX8632::RegNames[] = { |
| @@ -3597,6 +3610,13 @@ void TargetX8632::doAddressOptLoad() { |
| } |
| } |
| +void TargetX8632::randomlyInsertNop(float Probability) { |
| + RandomNumberGeneratorWrapper RNG = Ctx->getRNG(); |
| + if (RNG.getTrueWithProbability(Probability)) { |
| + _nop(1 + RNG.next(X86_MAX_NOP_LEN)); |
| + } |
| +} |
| + |
| void TargetX8632::lowerPhi(const InstPhi * /*Inst*/) { |
| Func->setError("Phi found in regular instruction list"); |
| } |