MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / tryDirect

Method tryDirect

source/emulation/cpu/jit/jitCodeGen.cpp:495–579  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

493};
494
495void JitCodeGen::tryDirect(DecodedOp* op, std::function<void()> callback, std::function<void()> fallback) {
496 DecodedOp* nextOp = op->next;
497 U32 skipped = 0;
498 DirectType directType = DirectType::None;
499 JitConditional cond = JitConditional::O;
500
501 for (int i = 0; i < 8 && nextOp; i++) {
502 if (nextOp->jumpTargetFlags & JUMP_TARGET) {
503 break;
504 }
505 if (nextOp->isJumpCC()) {
506 cond = getJumpConditionFromOp(nextOp);
507 directType = DirectType::Jump;
508 break;
509 }
510 /*
511 if (nextOp->isCMovCC() && instructionInfo[nextOp->inst].readMemWidth == 0) {
512 cond = getCmovConditionFromOp(nextOp);
513 directType = DirectType::CMov;
514 break;
515 }
516 if (nextOp->isSetCC() && instructionInfo[nextOp->inst].writeMemWidth == 0) {
517 cond = getSetConditionFromOp(nextOp);
518 directType = DirectType::SetCC;
519 break;
520 }
521 */
522 if (instructionInfo[nextOp->inst].flagsSets) {
523 break;
524 }
525 if (directDoesAffectFlags(nextOp)) {
526 break;
527 }
528 skipped++;
529 nextOp = nextOp->next;
530 }
531 if (directType != DirectType::None && !nextOp->getNeededFlagsAfter(FMASK_TEST) && supportsDirectCondition(cond)) {
532 DecodedOp* nextOp = op->next;
533 U32 opEip = currentEip + op->len;
534
535 for (U32 i = 0; i < skipped; i++) {
536 opEip += nextOp->len;
537 nextOp = nextOp->next;
538 }
539 if (directType == DirectType::Jump && !canJumpInBlock(opEip, nextOp)) {
540 fallback();
541 return;
542 }
543 callback();
544 postCompile(op);
545
546 nextOp = op->next;
547 for (U32 i = 0; i < skipped; i++) {
548 preCompile(nextOp, true);
549 compile(nextOp);
550 postCompile(nextOp);
551 nextOp = nextOp->next;
552 }

Callers

nothing calls this directly

Calls 5

callbackFunction · 0.85
readFunction · 0.85
kpanicFunction · 0.85
isJumpCCMethod · 0.80
getNeededFlagsAfterMethod · 0.80

Tested by

no test coverage detected