[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 20/22] tcg: Save insn data and use it in cpu_
From: |
Richard Henderson |
Subject: |
Re: [Qemu-devel] [PATCH v2 20/22] tcg: Save insn data and use it in cpu_restore_state_from_tb |
Date: |
Fri, 18 Sep 2015 19:05:17 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 |
On 09/18/2015 03:44 PM, Peter Maydell wrote:
Well, if we're going to add a margin we need to add the worst-case margin.
I guess the worst case is that deltas of the insn_data words between each insn
are useless, and we need full 64-bit values to represent them -- 9 bytes for
the sleb128. The deltas between sequential guest pc values will always be
small -- 1 byte. The deltas between the host insns implementing guest pc
values could be moderate (think move-multiple type insns performing 16 guest
loads); two byte sleb128 gives us 16k range.
So worst case is (1 + 9*TARGET_INSN_START_EXTRA_WORDS + 2) * TCG_MAX_INSNS.
Which is 10k for mips; 6k for sparc and some others; 1.5k for alpha and all
others that have no extra words.
However it occurred to me that the reason we use a margin for the codegen
is that we don't want to do a check for overrun every time we write
code to the buffer. For the datatable it seems more feasible to do
buffer length checks as we write the data. If we run out of space then
we just throw away the TB we generated (along with everything else in
the buffer) and start again.
Yeah, I guess we could do that.
Would the idea with the guard page be to catch the segfault and use
that as our trigger to clear the codegen buffer and start again?
Well, my idea was simply to use a guard page instead of asserts. But seeing a
write to the known guard page and causing code gen to restart after flushing
the buffer is an awesome idea.
It does have implications for a theoretic host that can't set page permissions.
But I'm not sure we support such a host even now, so discarding all of the
non-mmap, non-win32 alternatives for allocating the code_gen_buffer doesn't
strike me as the worst of ideas.
r~
- [Qemu-devel] [PATCH v2 14/22] target-sparc: Remove gen_opc_jump_pc, (continued)
- [Qemu-devel] [PATCH v2 14/22] target-sparc: Remove gen_opc_jump_pc, Richard Henderson, 2015/09/18
- [Qemu-devel] [PATCH v2 16/22] tcg: Merge cpu_gen_code into tb_gen_code, Richard Henderson, 2015/09/18
- [Qemu-devel] [PATCH v2 13/22] target-sparc: Split out gen_branch_n, Richard Henderson, 2015/09/18
- [Qemu-devel] [PATCH v2 17/22] target-*: Drop cpu_gen_code define, Richard Henderson, 2015/09/18
- [Qemu-devel] [PATCH v2 18/22] tcg: Add TCG_MAX_INSNS, Richard Henderson, 2015/09/18
- [Qemu-devel] [PATCH v2 19/22] tcg: Pass data argument to restore_state_to_opc, Richard Henderson, 2015/09/18
- [Qemu-devel] [PATCH v2 20/22] tcg: Save insn data and use it in cpu_restore_state_from_tb, Richard Henderson, 2015/09/18
- Re: [Qemu-devel] [PATCH v2 20/22] tcg: Save insn data and use it in cpu_restore_state_from_tb, Richard Henderson, 2015/09/19
- Re: [Qemu-devel] [PATCH v2 20/22] tcg: Save insn data and use it in cpu_restore_state_from_tb, Peter Maydell, 2015/09/19
[Qemu-devel] [PATCH v2 22/22] tcg: Remove tcg_gen_code_search_pc, Richard Henderson, 2015/09/18
[Qemu-devel] [PATCH v2 21/22] tcg: Remove gen_intermediate_code_pc, Richard Henderson, 2015/09/18
Re: [Qemu-devel] [PATCH v2 00/22] Do away with TB retranslation, Leon Alrae, 2015/09/18