* Tactic T2: evict the successor instruction. */
| 520 | * Tactic T2: evict the successor instruction. |
| 521 | */ |
| 522 | static Patch *tactic_T2(Binary &B, Instr *I, const Trampoline *T) |
| 523 | { |
| 524 | if (I->size >= JMP_SIZE || !option_tactic_T2 || !canPatch(I)) |
| 525 | return nullptr; |
| 526 | |
| 527 | // Step (1): Evict the successor instruction: |
| 528 | Instr *J = I->succ(); |
| 529 | if (J == nullptr || !canPatch(J)) |
| 530 | return nullptr; |
| 531 | const Trampoline *U = evicteeTrampoline; |
| 532 | Patch *Q = nullptr; |
| 533 | Q = (Q == nullptr? tactic_B2(B, J, U, TACTIC_T2): Q); |
| 534 | Q = (Q == nullptr? tactic_T1(B, J, U, TACTIC_T2): Q); |
| 535 | if (Q == nullptr) |
| 536 | return nullptr; |
| 537 | |
| 538 | // Step (2): Patch the instruction: |
| 539 | Patch *P = nullptr; |
| 540 | P = (P == nullptr? tactic_B2(B, I, T, TACTIC_T2): P); |
| 541 | P = (P == nullptr? tactic_T1(B, I, T, TACTIC_T2): P); |
| 542 | |
| 543 | if (P == nullptr) |
| 544 | { |
| 545 | undo(B, Q); |
| 546 | return nullptr; |
| 547 | } |
| 548 | P->tactic = TACTIC_T2; |
| 549 | P->next = Q; |
| 550 | |
| 551 | return P; |
| 552 | } |
| 553 | |
| 554 | /* |
| 555 | * Tactic T3 (single-byte instruction): evict a neighbour instruction. |