| 5509 | } |
| 5510 | |
| 5511 | U8* JitX86CodeGen::createStartJITCode() { |
| 5512 | #ifdef BOXEDWINE_64 |
| 5513 | for (int i = 0; i < NUMBER_OF_REGS; i++) { |
| 5514 | if (!isVolitile[i]) { |
| 5515 | compiler.mov(Mem(params[0], offsetof(CPU, storedRegs[0]) + sizeof(U64) * i), R64(i)); |
| 5516 | } |
| 5517 | } |
| 5518 | RegPtr tmpReg = getTmpReg(); |
| 5519 | compiler.mov(R64(tmpReg), R64(4)); |
| 5520 | compiler.and_(R64(tmpReg), 0xf); |
| 5521 | IfNot(JitWidth::b32, tmpReg); { |
| 5522 | compiler.push(asmjit::x86::rax); |
| 5523 | } EndIf(); |
| 5524 | compiler.mov(HOST_MMU, (U64)getMemData(KThread::currentThread()->memory)->mmu); |
| 5525 | |
| 5526 | compiler.mov(HOST_CPU, params[0]); |
| 5527 | compiler.mov(RN(tmpReg), Mem(params[1], offsetof(DecodedOp, pfnJitCode))); |
| 5528 | |
| 5529 | loadCache(); |
| 5530 | |
| 5531 | // jmp ((DecodedOp*)rdx)->pfn |
| 5532 | If(DYN_PTR, tmpReg); { |
| 5533 | compiler.call(RN(tmpReg)); |
| 5534 | }; EndIf(); |
| 5535 | |
| 5536 | #else |
| 5537 | compiler.push(regEbx); |
| 5538 | compiler.push(regEdi); |
| 5539 | compiler.push(regEsi); |
| 5540 | compiler.push(regEbp); |
| 5541 | // on win32 ecx contains cpu |
| 5542 | compiler.mov(HOST_CPU, regEcx); |
| 5543 | |
| 5544 | loadCache(); |
| 5545 | |
| 5546 | // :TODO: what about other x86 platforms that use a different calling convention |
| 5547 | // |
| 5548 | // jmp ((DecodedOp*)edx)->pfn |
| 5549 | RegPtr tmpReg = getTmpReg(); |
| 5550 | compiler.mov(RN(tmpReg), Mem(regEdx, offsetof(DecodedOp, pfnJitCode))); |
| 5551 | If(DYN_PTR, tmpReg); { |
| 5552 | compiler.call(RN(tmpReg)); |
| 5553 | } EndIf(); |
| 5554 | #endif |
| 5555 | |
| 5556 | writeCache(); |
| 5557 | |
| 5558 | #ifdef BOXEDWINE_64 |
| 5559 | compiler.mov(R64(0), HOST_CPU); |
| 5560 | for (int i = 0; i < NUMBER_OF_REGS; i++) { |
| 5561 | if (!isVolitile[i]) { |
| 5562 | compiler.mov(R64(i), Mem(R64(0), offsetof(CPU, storedRegs[0]) + sizeof(U64) * i)); |
| 5563 | } |
| 5564 | } |
| 5565 | #else |
| 5566 | compiler.pop(regEbp); |
| 5567 | compiler.pop(regEsi); |
| 5568 | compiler.pop(regEdi); |