示例#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
SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_s32 dst, sljit_sw dstw)
{
	sljit_u8 *inst;

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

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

	if (FAST_IS_REG(dst)) {
		if (reg_map[dst] < 8) {
			inst = (sljit_u8*)ensure_buf(compiler, 1 + 1);
			FAIL_IF(!inst);
			INC_SIZE(1);
			POP_REG(reg_lmap[dst]);
			return SLJIT_SUCCESS;
		}

		inst = (sljit_u8*)ensure_buf(compiler, 1 + 2);
		FAIL_IF(!inst);
		INC_SIZE(2);
		*inst++ = REX_B;
		POP_REG(reg_lmap[dst]);
		return SLJIT_SUCCESS;
	}

	/* REX_W is not necessary (src is not immediate). */
	compiler->mode32 = 1;
	inst = emit_x86_instruction(compiler, 1, 0, 0, dst, dstw);
	FAIL_IF(!inst);
	*inst++ = POP_rm;
	return SLJIT_SUCCESS;
}