Received: from eggs.gnu.org ([2001:4830:134:3::10]:55991) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afTSI-0006rW-2d for qemu-devel@nongnu.org; Mon, 14 Mar 2016 10:26:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1afTSD-0007yk-VE for qemu-devel@nongnu.org; Mon, 14 Mar 2016 10:26:45 -0400 Received: from roura.ac.upc.es ([147.83.33.10]:57591) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afTSD-0007ya-Jj for qemu-devel@nongnu.org; Mon, 14 Mar 2016 10:26:41 -0400 From: =?utf-8?Q?Llu=C3=ADs_Vilanova?= References: <87r3fjpvgx.fsf@fimbulvetr.bsc.es> <56E046D3.2080709@twiddle.net> <56E6AD2B.7060304@greensocs.com> Date: Mon, 14 Mar 2016 15:26:37 +0100 In-Reply-To: <56E6AD2B.7060304@greensocs.com> (KONRAD Frederic's message of "Mon, 14 Mar 2016 13:23:07 +0100") Message-ID: <87egbdf84i.fsf@fimbulvetr.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [RFC] [tcg] Idea on refactoring target code generation loop (gen_intermediate_code) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: KONRAD Frederic Cc: Paolo Bonzini , Peter Crosthwaite , qemu-devel@nongnu.org, Richard Henderson KONRAD Frederic writes: > Hi, > Le 09/03/2016 16:52, Richard Henderson a =C3=A9crit : >> On 03/09/2016 09:38 AM, Llu=C3=ADs Vilanova wrote: >>> Hi, >>>=20 >>> NOTE: I won't be throwing patches anytime soon, I just want to know if >>> there's >>> interest in this for the future. >>>=20 >>> While adding events for tracing guest instructions, I've found that the >>> per-target "gen_intermediate_code()" function is very similar but not e= xactly >>> the same for each of the targets. This makes architecture-agnostic feat= ures >>> harder to maintain across targets, specially when it comes to their rel= ative >>> order. >>>=20 >>> So, would it be worth it if I generalized part of that code into an >>> architecture-agnostic function that calls into target-specific hooks wh= erever >>> it >>> needs extending? There are many ways to do it that we can discuss later. >>=20 >> It's worth talking about, since I do believe it would make long-term >> maintenance across the targets easier. >>=20 >> These "target-specific hooks" probably ought not be "hooks" in the >> traditional sense of attaching them to CPUState. I'd be more comfortabl= e with >> a refactoring that used include files -- maybe .h or maybe .inc.c. If w= e do >> the normal sort of hook, then we've got to either expose DisasContext in >> places we shouldn't, or dynamically allocate it. Neither seems particul= arly >> appealing. >>=20 >>=20 >> r~ >>=20 > On the other side I think attaching them to CPUState would make heterogen= ous > system emulation easier? Yes, that's something to take into account too. But for this I think that "gen_intermediate_code()" would suffice. Still, abstracting it into the level of KVM vs. TCG would be even more interesting, since we could switch between backends, or even have different= CPUs using different backends (e.g., trace a TCG vCPU while another runs at full speed using KVM). For example, there could be a virtual "exec()" method, although reality is not that straightforward since each KVM vCPU runs on a different thread, while in TCG this is not necessarily so (even with MTTCG). Cheers, Lluis