| 658 | } |
| 659 | |
| 660 | void JitCodeGen::doJIT(U32 address, DecodedOp* op) { |
| 661 | BOXEDWINE_CRITICAL_SECTION_WITH_MUTEX(cpu->memory->mutex); |
| 662 | if (!cpu->thread->process->startJITOp) { |
| 663 | JitCodeGen* jit = startNewJIT(cpu); |
| 664 | cpu->thread->process->syncToHost = jit->createSyncToHost(); |
| 665 | delete jit; |
| 666 | jit = startNewJIT(cpu); |
| 667 | cpu->thread->process->syncFromHost = jit->createSyncFromHost(); |
| 668 | delete jit; |
| 669 | jit = startNewJIT(cpu); |
| 670 | cpu->thread->process->blockExit = jit->createBlockExit(); |
| 671 | delete jit; |
| 672 | jit = startNewJIT(cpu); |
| 673 | cpu->thread->process->emulateSingleOp = jit->createEmulateSingleOp(); |
| 674 | delete jit; |
| 675 | jit = startNewJIT(cpu); |
| 676 | cpu->thread->process->startJITOp = (OpCallback)jit->createStartJITCode(); |
| 677 | delete jit; |
| 678 | #if defined(BOXEDWINE_POSIX) && defined(BOXEDWINE_HOST_EXCEPTIONS) |
| 679 | jit = startNewJIT(cpu); |
| 680 | cpu->thread->process->signalHandler = jit->createSignalHandler(); |
| 681 | delete jit; |
| 682 | #endif |
| 683 | createHelpers(); |
| 684 | for (U32 i = 0; i < FLAGS_NULL; i++) { |
| 685 | jit = startNewJIT(cpu); |
| 686 | jit->disableTmps = true; // the functions created should not call getTmp since the caller won't know what tmps are in use |
| 687 | cpu->thread->process->calculateCF[i] = jit->createCalculationCF((LazyFlagType)i); |
| 688 | delete jit; |
| 689 | } |
| 690 | } |
| 691 | if (!cpu->calculateCF[0]) { |
| 692 | if (!cpu->thread->process->calculateCF[0]) { |
| 693 | kpanic("JitCodeGen::doJIT"); |
| 694 | } |
| 695 | memcpy(cpu->calculateCF, cpu->thread->process->calculateCF, sizeof(cpu->thread->process->calculateCF)); |
| 696 | } |
| 697 | // did another thread beat us to JITing this block? |
| 698 | if (op->flags & OP_FLAG_JIT) { |
| 699 | // this will get triggered a few times, especially during shutdown |
| 700 | // I have see this in firefight installer at the end and opentdd start up |
| 701 | return; |
| 702 | } |
| 703 | this->currentEip = address; |
| 704 | this->startingEip = address; |
| 705 | |
| 706 | initDynamicOps(); |
| 707 | |
| 708 | if (!calculateLongestBlock(op)) { |
| 709 | return; |
| 710 | } |
| 711 | if (!compileOps(op)) { |
| 712 | return; |
| 713 | } |
| 714 | onBlockPreCommit(op); |
| 715 | commitJIT(op); |
| 716 | } |
| 717 |
no test coverage detected