Exemple #1
0
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler, sljit_si args, sljit_si scratches, sljit_si saveds, sljit_si local_size)
{
	sljit_si locals_offset;

	CHECK_ERROR_VOID();
	check_sljit_set_context(compiler, args, scratches, saveds, local_size);

	compiler->scratches = scratches;
	compiler->saveds = saveds;
	compiler->args = args;
#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
	compiler->logical_local_size = local_size;
#endif

#if (defined SLJIT_X86_32_FASTCALL && SLJIT_X86_32_FASTCALL)
	locals_offset = 2 * sizeof(sljit_uw);
#else
	locals_offset = FIXED_LOCALS_OFFSET;
#endif
	compiler->scratches_start = locals_offset;
	if (scratches > 3)
		locals_offset += (scratches - 3) * sizeof(sljit_uw);
	compiler->saveds_start = locals_offset;
	if (saveds > 3)
		locals_offset += (saveds - 3) * sizeof(sljit_uw);
	compiler->locals_offset = locals_offset;
	compiler->local_size = locals_offset + ((local_size + sizeof(sljit_uw) - 1) & ~(sizeof(sljit_uw) - 1));
}
Exemple #2
0
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_set_context(struct sljit_compiler *compiler,
    sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
    sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
{
    sljit_si saved_register_size;

    CHECK_ERROR();
    CHECK(check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
    set_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);

    /* Including the return address saved by the call instruction. */
    saved_register_size = GET_SAVED_REGISTERS_SIZE(scratches, saveds, 1);
    compiler->local_size = ((local_size + SLJIT_LOCALS_OFFSET + saved_register_size + 15) & ~15) - saved_register_size;
    return SLJIT_SUCCESS;
}
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler, sljit_si args, sljit_si scratches, sljit_si saveds, sljit_si local_size)
{
	sljit_si pushed_size;

	CHECK_ERROR_VOID();
	check_sljit_set_context(compiler, args, scratches, saveds, local_size);

	compiler->scratches = scratches;
	compiler->saveds = saveds;
#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
	compiler->logical_local_size = local_size;
#endif

	/* Including the return address saved by the call instruction. */
	pushed_size = (saveds + 1) * sizeof(sljit_sw);
#ifdef _WIN64
	if (scratches >= 5)
		pushed_size += sizeof(sljit_sw);
#endif
	compiler->local_size = ((local_size + FIXED_LOCALS_OFFSET + pushed_size + 16 - 1) & ~(16 - 1)) - pushed_size;
}
Exemple #4
0
SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_set_context(struct sljit_compiler *compiler,
    sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
    sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
{
    CHECK_ERROR();
    CHECK(check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
    set_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);

    compiler->args = args;

#if defined(__APPLE__)
    saveds = (2 + (scratches > 7 ? (scratches - 7) : 0) + (saveds <= 3 ? saveds : 3)) * sizeof(sljit_uw);
    compiler->local_size = ((SLJIT_LOCALS_OFFSET + saveds + local_size + 15) & ~15) - saveds;
#else
    if (options & SLJIT_DOUBLE_ALIGNMENT)
        compiler->local_size = SLJIT_LOCALS_OFFSET + ((local_size + 7) & ~7);
    else
        compiler->local_size = SLJIT_LOCALS_OFFSET + ((local_size + 3) & ~3);
#endif
    return SLJIT_SUCCESS;
}
SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_set_context(struct sljit_compiler *compiler,
	sljit_s32 options, sljit_s32 args, sljit_s32 scratches, sljit_s32 saveds,
	sljit_s32 fscratches, sljit_s32 fsaveds, sljit_s32 local_size)
{
	sljit_s32 saved_register_size;

	CHECK_ERROR();
	CHECK(check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
	set_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);

#ifdef _WIN64
	/* Two/four register slots for parameters plus space for xmm6 register if needed. */
	if (fscratches >= 6 || fsaveds >= 1)
		compiler->locals_offset = 6 * sizeof(sljit_sw);
	else
		compiler->locals_offset = ((scratches > 2) ? 4 : 2) * sizeof(sljit_sw);
#endif

	/* Including the return address saved by the call instruction. */
	saved_register_size = GET_SAVED_REGISTERS_SIZE(scratches, saveds, 1);
	compiler->local_size = ((local_size + SLJIT_LOCALS_OFFSET + saved_register_size + 15) & ~15) - saved_register_size;
	return SLJIT_SUCCESS;
}
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler, int args, int temporaries, int saveds, int local_size)
{
	int pushed_size;

	CHECK_ERROR_VOID();
	check_sljit_set_context(compiler, args, temporaries, saveds, local_size);

	compiler->temporaries = temporaries;
	compiler->saveds = saveds;
	/* Including the return address saved by the call instruction. */
	pushed_size = (saveds + 1) * sizeof(sljit_w);
#ifdef _WIN64
	compiler->has_locals = local_size > 0;
	if (local_size > 0)
		pushed_size += sizeof(sljit_w);
	if (temporaries >= 5)
		pushed_size += sizeof(sljit_w);
#endif
	compiler->local_size = ((local_size + pushed_size + 16 - 1) & ~(16 - 1)) - pushed_size;
#ifdef _WIN64
	compiler->local_size += 4 * sizeof(sljit_w);
#endif
}