| 2578 | } |
| 2579 | |
| 2580 | void JitX86CodeGen::callHostFunctionWithResult(RegPtr result, void* address, const std::vector<DynParam>& params) { |
| 2581 | U32 stackAdjust = 0; // if 64-bit stack isn't aligned to 16-bytes, things like FPU::F2XM1() |
| 2582 | std::vector<U8> pushedRegs; |
| 2583 | |
| 2584 | for (int i = 0; i < NUMBER_OF_REGS; i++) { |
| 2585 | if (isVolitile[i] && isTmp[i] && regUsed[i] && result->hardwareReg() != i) { |
| 2586 | compiler.push(RN(i)); |
| 2587 | pushedRegs.push_back(i); |
| 2588 | } |
| 2589 | } |
| 2590 | |
| 2591 | callWriteCache(); |
| 2592 | setParams(params); |
| 2593 | |
| 2594 | #ifdef BOXEDWINE_64 |
| 2595 | if ((pushedRegs.size() % 2) == 1) { |
| 2596 | stackAdjust = 8; |
| 2597 | } |
| 2598 | // part of the x64 windows ABI, shadow store |
| 2599 | #ifdef BOXEDWINE_MSVC |
| 2600 | compiler.sub(asmjit::x86::rsp, 32 + stackAdjust); |
| 2601 | #else |
| 2602 | if (stackAdjust) { |
| 2603 | compiler.push(PARAM_CALL_TMP); |
| 2604 | } |
| 2605 | #endif |
| 2606 | compiler.mov(PARAM_CALL_TMP, (U64)address); |
| 2607 | compiler.call(PARAM_CALL_TMP); |
| 2608 | #ifdef BOXEDWINE_MSVC |
| 2609 | compiler.add(asmjit::x86::rsp, 32 + stackAdjust); |
| 2610 | #else |
| 2611 | if (stackAdjust) { |
| 2612 | compiler.pop(PARAM_CALL_TMP); |
| 2613 | } |
| 2614 | #endif |
| 2615 | #else |
| 2616 | compiler.call(address); |
| 2617 | |
| 2618 | if (params.size()) { |
| 2619 | compiler.add(regEsp, sizeof(void*) * params.size()); |
| 2620 | } |
| 2621 | #endif |
| 2622 | compiler.mov(RN(result), RN(0)); |
| 2623 | for (int i = (int)pushedRegs.size() - 1; i >= 0; i--) { |
| 2624 | compiler.pop(RN(pushedRegs[i])); |
| 2625 | } |
| 2626 | callLoadCache(); |
| 2627 | } |
| 2628 | |
| 2629 | void JitX86CodeGen::If(JitWidth regWidth, RegPtr reg) { |
| 2630 | Label label = compiler.new_label(); |