Index: vm/port/src/lil/em64t/pim/lil_code_generator_em64t.cpp =================================================================== --- vm/port/src/lil/em64t/pim/lil_code_generator_em64t.cpp (revision 513709) +++ vm/port/src/lil/em64t/pim/lil_code_generator_em64t.cpp (working copy) @@ -1547,7 +1547,9 @@ void call(LilOperand * target, LilCallKind kind) { switch (kind) { - case LCK_TailCall: { + case LCK_TailCall: +#ifndef _WIN64 + { // restore input FR & GR unmove_inputs(); // unwind current stack frame @@ -1585,8 +1587,12 @@ } break; } +#endif case LCK_Call: case LCK_CallNoRet: { +#ifdef _WIN64 + buf = alu(buf, add_opc, rsp_opnd, Imm_Opnd(-SHADOW), size_64); +#endif if (lil_operand_is_immed(target)) { // check if we can perform relative call int64 target_value = lil_operand_get_immed(target); @@ -1618,12 +1624,20 @@ const LcgEM64TLoc * loc = get_op_loc(target, false); buf = ::call(buf, get_rm_opnd(loc), size_64); } +#ifdef _WIN64 + buf = alu(buf, add_opc, rsp_opnd, Imm_Opnd(SHADOW), size_64); +#endif take_inputs_from_stack = true; break; } default: ASSERT(0, "Unknown kind"); } +#ifdef _WIN64 + if(kind == LCK_TailCall) { + ret(); + } +#endif } void ret() { Index: vm/port/src/lil/lil.cpp =================================================================== --- vm/port/src/lil/lil.cpp (revision 513709) +++ vm/port/src/lil/lil.cpp (working copy) @@ -2035,7 +2035,14 @@ if (cs->sig.arbitrary) ERR("in2out in arbitrary code stub"); break; case LIT_Call: - if (i->u.call.k!=LCK_TailCall && !c->out_sig) ERR("call not dominated by out or in2out"); + if ( +#ifndef _WIN64 + i->u.call.k!=LCK_TailCall && +#endif + !c->out_sig) + { + ERR("call not dominated by out or in2out"); + } if (!lil_is_valid_operand(cs, c, &(i->u.call.target))) ERR("invalid operand in call"); if (lil_ic_get_type(cs, c, &i->u.call.target)!=LT_PInt) ERR("operand not platform int in call"); break; @@ -2549,8 +2556,11 @@ // (tailcall implies return!) bool LilBb::is_ret() { return (end != NULL && - (end->tag == LIT_Ret || - (end->tag == LIT_Call && end->u.call.k == LCK_TailCall))); + (end->tag == LIT_Ret +#ifndef _WIN64 + || (end->tag == LIT_Call && end->u.call.k == LCK_TailCall) +#endif + )); }