Re: [PATCH 07/10] tcg: implement bulletproof JIT

2020-10-14 Thread Joelle van Dyne
There's about 40 instances of *code_ptr or code_ptr[i] changed to TCG_CODE_PTR_RW(s, code_ptr). It's around 2 instances per function, so if I go with a local variable, that would be ~20 extra LOC. Another alternative is two separate functions: tcg_code_ptr_insn_rw() which returns tcg_insn_unit *

Re: [PATCH 07/10] tcg: implement bulletproof JIT

2020-10-14 Thread Richard Henderson
On 10/14/20 1:58 PM, Joelle van Dyne wrote: > Much of the code that uses the macro is like the following (from > aarch64/tcg-include.inc.c) > > *TCG_CODE_PTR_RW(s, code_ptr) = > deposit32(*TCG_CODE_PTR_RW(s, code_ptr), 0, 26, offset); > > Before the change, it was just

Re: [PATCH 07/10] tcg: implement bulletproof JIT

2020-10-14 Thread Richard Henderson
On 10/14/20 1:54 PM, BALATON Zoltan wrote: >> static inline void *tcg_code_ptr_rw(TCGContext *s, void *rx) >> { >> #ifdef CONFIG_IOS_JIT >>    return rx + s->code_rw_mirror_diff; > > This looks better but can you add to void *? I think some compilers may > complain about that so may need to cast

Re: [PATCH 07/10] tcg: implement bulletproof JIT

2020-10-14 Thread BALATON Zoltan via
On Wed, 14 Oct 2020, Joelle van Dyne wrote: Much of the code that uses the macro is like the following (from aarch64/tcg-include.inc.c) *TCG_CODE_PTR_RW(s, code_ptr) = deposit32(*TCG_CODE_PTR_RW(s, code_ptr), 0, 26, offset); Before the change, it was just *code_ptr. I'm

Re: [PATCH 07/10] tcg: implement bulletproof JIT

2020-10-14 Thread Joelle van Dyne
Much of the code that uses the macro is like the following (from aarch64/tcg-include.inc.c) *TCG_CODE_PTR_RW(s, code_ptr) = deposit32(*TCG_CODE_PTR_RW(s, code_ptr), 0, 26, offset); Before the change, it was just *code_ptr. I'm saying the alternative was to have to write

Re: [PATCH 07/10] tcg: implement bulletproof JIT

2020-10-14 Thread BALATON Zoltan via
On Wed, 14 Oct 2020, Richard Henderson wrote: On 10/14/20 9:03 AM, Joelle van Dyne wrote: static int encode_search(TranslationBlock *tb, uint8_t *block) { -uint8_t *highwater = tcg_ctx->code_gen_highwater; -uint8_t *p = block; +uint8_t *highwater; +uint8_t *p; int i, j, n;

Re: [PATCH 07/10] tcg: implement bulletproof JIT

2020-10-14 Thread Richard Henderson
On 10/14/20 9:03 AM, Joelle van Dyne wrote: >>> static int encode_search(TranslationBlock *tb, uint8_t *block) >>> { >>> -uint8_t *highwater = tcg_ctx->code_gen_highwater; >>> -uint8_t *p = block; >>> +uint8_t *highwater; >>> +uint8_t *p; >>> int i, j, n; >>> >>> +highwater

Re: [PATCH 07/10] tcg: implement bulletproof JIT

2020-10-14 Thread Joelle van Dyne
Hi Philippe, Will work on splitting the patch for v2. Thanks for the tip on git.orderfile Hi Balaton, Reply inline. -j On Tue, Oct 13, 2020 at 7:58 AM BALATON Zoltan wrote: > > On Mon, 12 Oct 2020, Joelle van Dyne wrote: > > From: osy > > > > On iOS, we cannot allocate RWX pages without

Re: [PATCH 07/10] tcg: implement bulletproof JIT

2020-10-13 Thread BALATON Zoltan via
On Mon, 12 Oct 2020, Joelle van Dyne wrote: From: osy On iOS, we cannot allocate RWX pages without special entitlements. As a workaround, we can a RX region and then mirror map it to a separate RX Missing a verb here: "we can a RX region" region. Then we can write to one region and execute

Re: [PATCH 07/10] tcg: implement bulletproof JIT

2020-10-13 Thread Philippe Mathieu-Daudé
Hi Joelle, On 10/13/20 1:29 AM, Joelle van Dyne wrote: From: osy On iOS, we cannot allocate RWX pages without special entitlements. As a workaround, we can a RX region and then mirror map it to a separate RX region. Then we can write to one region and execute from the other one. To better

[PATCH 07/10] tcg: implement bulletproof JIT

2020-10-12 Thread Joelle van Dyne
From: osy On iOS, we cannot allocate RWX pages without special entitlements. As a workaround, we can a RX region and then mirror map it to a separate RX region. Then we can write to one region and execute from the other one. To better keep track of pointers to RW/RX memory, we mark any