Revert "generate_jit: Refactor to deduplicate custom call generation"

This reverts commit fcbaea9cc989961adffa64b30afcde9579dcaab0.
This commit is contained in:
Amaan Cheval 2018-02-26 10:25:09 +05:30 committed by Fabian
parent b1787e5a0f
commit a09ace9c95

View file

@ -150,21 +150,6 @@ function get_nonfaulting_mem_reg_postfix(encoding)
};
}
function gen_custom_call(encoding, size, args)
{
console.assert(!encoding.nonfaulting, "Prefix/custom instructions cannot be marked as nonfaulting.");
const instruction_name = make_instruction_name(encoding, size) + "_jit";
const imm_read = gen_read_imm_call(encoding, size);
if(imm_read)
{
args.push(imm_read);
}
return gen_call(instruction_name, args);
}
function gen_instruction_body(encodings, size)
{
const encoding = encodings[0];
@ -222,11 +207,19 @@ function gen_instruction_body(encodings, size)
const instruction_postfix = case_.jump ? ["instr_flags |= JIT_INSTR_JUMP_FLAG;"] : [];
if(case_.custom)
{
const custom_call = gen_custom_call(case_, size, ["modrm_byte"]);
console.assert(!case_.nonfaulting, "Unsupported: custom fixed_g instruction as nonfaulting");
const instruction_name = make_instruction_name(case_, size) + "_jit";
const imm_read = gen_read_imm_call(case_, size);
const args = ["modrm_byte"];
if(imm_read)
{
args.push(imm_read);
}
return {
conditions: [fixed_g],
body: [custom_call].concat(instruction_postfix),
body: [gen_call(instruction_name, args)].concat(instruction_postfix),
};
}
@ -424,10 +417,20 @@ function gen_instruction_body(encodings, size)
}
else if(encoding.prefix || encoding.custom)
{
const custom_call = gen_custom_call(encoding, size, []);
console.assert(!encoding.nonfaulting, "Prefix/custom instructions cannot be marked as nonfaulting.");
const instruction_name = make_instruction_name(encoding, size) + "_jit";
const imm_read = gen_read_imm_call(encoding, size);
const args = [];
if(imm_read)
{
args.push(imm_read);
}
const call_prefix = encoding.prefix ? "instr_flags |= " : "";
// Prefix calls can add to the return flags
return [call_prefix + custom_call].concat(instruction_postfix);
return [call_prefix + gen_call(instruction_name, args)].concat(instruction_postfix);
}
else
{