Пример #1
0
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw)
{
    sljit_ub *inst;

    CHECK_ERROR();
    CHECK(check_sljit_emit_fast_enter(compiler, dst, dstw));
    ADJUST_LOCAL_OFFSET(dst, dstw);

    CHECK_EXTRA_REGS(dst, dstw, (void)0);

    /* For UNUSED dst. Uncommon, but possible. */
    if (dst == SLJIT_UNUSED)
        dst = TMP_REG1;

    if (FAST_IS_REG(dst)) {
        /* Unused dest is possible here. */
        inst = (sljit_ub*)ensure_buf(compiler, 1 + 1);
        FAIL_IF(!inst);

        INC_SIZE(1);
        POP_REG(reg_map[dst]);
        return SLJIT_SUCCESS;
    }

    /* Memory. */
    inst = emit_x86_instruction(compiler, 1, 0, 0, dst, dstw);
    FAIL_IF(!inst);
    *inst++ = POP_rm;
    return SLJIT_SUCCESS;
}
Пример #2
0
int sljit_emit_return(struct sljit_compiler *compiler, int src, sljit_w srcw)
{
	int size;
	sljit_ub *buf;

	CHECK_ERROR();
	check_sljit_emit_return(compiler, src, srcw);
	SLJIT_ASSERT(compiler->args >= 0);

	compiler->flags_saved = 0;
	CHECK_EXTRA_REGS(src, srcw, (void)0);

	if (src != SLJIT_UNUSED && src != SLJIT_RETURN_REG)
		FAIL_IF(emit_mov(compiler, SLJIT_RETURN_REG, 0, src, srcw));

	if (compiler->local_size > 0)
		FAIL_IF(emit_cum_binary(compiler, 0x03, 0x01, 0x0 << 3, 0x05,
				SLJIT_LOCALS_REG, 0, SLJIT_LOCALS_REG, 0, SLJIT_IMM, compiler->local_size));

	size = 2 + (compiler->generals <= 3 ? compiler->generals : 3);
#if (defined SLJIT_X86_32_FASTCALL && SLJIT_X86_32_FASTCALL)
	if (compiler->args > 2)
		size += 2;
#else
	if (compiler->args > 0)
		size += 2;
#endif
	buf = (sljit_ub*)ensure_buf(compiler, 1 + size);
	FAIL_IF(!buf);

	INC_SIZE(size);

	if (compiler->generals > 0)
		POP_REG(reg_map[SLJIT_GENERAL_REG1]);
	if (compiler->generals > 1)
		POP_REG(reg_map[SLJIT_GENERAL_REG2]);
	if (compiler->generals > 2)
		POP_REG(reg_map[SLJIT_GENERAL_REG3]);
	POP_REG(reg_map[TMP_REGISTER]);
#if (defined SLJIT_X86_32_FASTCALL && SLJIT_X86_32_FASTCALL)
	if (compiler->args > 2)
		RETN(sizeof(sljit_w));
	else
		RET();
#else
	if (compiler->args > 0)
		RETN(compiler->args * sizeof(sljit_w));
	else
		RET();
#endif

	return SLJIT_SUCCESS;
}
Пример #3
0
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_return(struct sljit_compiler *compiler, sljit_si src, sljit_sw srcw)
{
    sljit_ub *inst;

    CHECK_ERROR();
    CHECK(check_sljit_emit_fast_return(compiler, src, srcw));
    ADJUST_LOCAL_OFFSET(src, srcw);

    CHECK_EXTRA_REGS(src, srcw, (void)0);

    if (FAST_IS_REG(src)) {
        inst = (sljit_ub*)ensure_buf(compiler, 1 + 1 + 1);
        FAIL_IF(!inst);

        INC_SIZE(1 + 1);
        PUSH_REG(reg_map[src]);
    }
    else if (src & SLJIT_MEM) {
        inst = emit_x86_instruction(compiler, 1, 0, 0, src, srcw);
        FAIL_IF(!inst);
        *inst++ = GROUP_FF;
        *inst |= PUSH_rm;

        inst = (sljit_ub*)ensure_buf(compiler, 1 + 1);
        FAIL_IF(!inst);
        INC_SIZE(1);
    }
    else {
        /* SLJIT_IMM. */
        inst = (sljit_ub*)ensure_buf(compiler, 1 + 5 + 1);
        FAIL_IF(!inst);

        INC_SIZE(5 + 1);
        *inst++ = PUSH_i32;
        *(sljit_sw*)inst = srcw;
        inst += sizeof(sljit_sw);
    }

    RET();
    return SLJIT_SUCCESS;
}