From: Nicholas Nethercote Date: Tue, 30 Nov 2004 17:27:21 +0000 (+0000) Subject: Move VG_(have_ssestate) out of core and into coregrind/x86/. X-Git-Tag: svn/VALGRIND_3_0_0~1151 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c4b75e59c98653a53205c0a1ee679ef7739e28ac;p=thirdparty%2Fvalgrind.git Move VG_(have_ssestate) out of core and into coregrind/x86/. Also fixed up out-of-date comments for run_innerloop. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3167 --- diff --git a/coregrind/core.h b/coregrind/core.h index e8cf7cd1ba..e14519cd77 100644 --- a/coregrind/core.h +++ b/coregrind/core.h @@ -1178,12 +1178,6 @@ extern Addr VG_(code_redirect) ( Addr orig ); Exports of vg_main.c ------------------------------------------------------------------ */ -/* Is this a SSE/SSE2-capable CPU? If so, we had better save/restore - the SSE state all over the place. This is set up very early, in - main(). We have to determine it early since we can't even - correctly snapshot the startup machine state without it. */ -extern Bool VG_(have_ssestate); - /* Tell the logging mechanism whether we are logging to a file descriptor or a socket descriptor. */ extern Bool VG_(logging_to_filedes); @@ -1747,9 +1741,19 @@ extern void VG_(sigreturn)(void); Exports of vg_dispatch.S ------------------------------------------------------------------ */ -/* Run a thread for a (very short) while, until some event happens - which means we need to defer to the scheduler. This is passed - a pointer to the VEX guest state (arch.vex). */ +/* This subroutine is called from the C world. It is passed + a pointer to the VEX guest state (arch.vex). It must run code + from the instruction pointer in the guest state, and exit when + VG_(dispatch_ctr) reaches zero, or we need to defer to the scheduler. + The return value must indicate why it returned back to the scheduler. + It can also be exited if the executing code throws a non-resumable + signal, for example SIGSEGV, in which case control longjmp()s back past + here. + + This code simply handles the common case fast -- when the translation + address is found in the translation cache. For anything else, the + scheduler does the work. +*/ extern UInt VG_(run_innerloop) ( void* guest_state ); /* --------------------------------------------------------------------- diff --git a/coregrind/vg_main.c b/coregrind/vg_main.c index d0db0bcf1b..598b642543 100644 --- a/coregrind/vg_main.c +++ b/coregrind/vg_main.c @@ -109,10 +109,6 @@ Addr VG_(valgrind_last); struct vki_rlimit VG_(client_rlimit_data); struct vki_rlimit VG_(client_rlimit_stack); -/* This is set early to indicate whether this CPU has the - SSE/fxsave/fxrestor features. */ -Bool VG_(have_ssestate); - /* stage1 (main) executable */ static Int vgexecfd = -1; diff --git a/coregrind/x86/dispatch.S b/coregrind/x86/dispatch.S index 4e4c827008..b6f5c533f0 100644 --- a/coregrind/x86/dispatch.S +++ b/coregrind/x86/dispatch.S @@ -34,23 +34,9 @@ /*------------------------------------------------------------*/ -/*--- The normal-case dispatch machinery. ---*/ +/*--- The dispatch loop. ---*/ /*------------------------------------------------------------*/ -/* To transfer to an (original) code address, load it into %eax and - jump to vg_dispatch. This fragment of code tries to find the - address of the corresponding translation by searching the translation - table. If it fails, a new translation is made, added to the - translation table, and then jumped to. Almost all the hard - work is done by C routines; this code simply handles the - common case fast -- when the translation address is found in - the translation cache. - - At entry, %eax is the only live (real-machine) register; the - entire simulated state is tidily saved in vg_m_state. -*/ - - #define TT_LOOKUP(reg, fail) \ movl %eax, reg; \ andl $VG_TT_FAST_MASK, reg; \ @@ -58,13 +44,6 @@ cmpl %eax, (reg); \ jnz fail -/* The C world needs a way to get started simulating. So we provide - a function void vg_run_innerloop ( void ), which starts running - from vg_m_eip, and exits when the counter reaches zero. This loop - can also exit if vg_oursignalhandler() catches a non-resumable - signal, for example SIGSEGV. It then longjmp()s back past here. -*/ - /* signature: UInt VG_(run_innerloop) ( void* guest_state ) */ .globl VG_(run_innerloop) @@ -84,12 +63,15 @@ VG_(run_innerloop): /* Set up the guest state pointer */ movl 28(%esp), %ebp - /* fetch m_eip into %eax */ + /* fetch %EIP into %eax */ movl VG_(instr_ptr_offset), %esi movl (%ebp, %esi, 1), %eax /* fall into main loop */ + /* Here, %eax is the only live (real) register. The entire + simulated state is saved in the ThreadState. */ + dispatch_boring: /* save the jump address in the guest state */ movl VG_(instr_ptr_offset), %esi diff --git a/coregrind/x86/state.c b/coregrind/x86/state.c index 3b6df20535..f8c7cc4932 100644 --- a/coregrind/x86/state.c +++ b/coregrind/x86/state.c @@ -34,6 +34,10 @@ #include "libvex_guest_x86.h" +/* This is set early to indicate whether this CPU has the + SSE/fxsave/fxrestor features. */ +Bool VG_(have_ssestate); + /*------------------------------------------------------------*/ /*--- Initialising the first thread ---*/ /*------------------------------------------------------------*/ diff --git a/coregrind/x86/x86_private.h b/coregrind/x86/x86_private.h index 548232f6dc..0a92fa26fb 100644 --- a/coregrind/x86/x86_private.h +++ b/coregrind/x86/x86_private.h @@ -35,6 +35,15 @@ #include "x86_private_asm.h" // private arch-specific asm stuff #include "tool_arch.h" // arch-specific tool stuff +/* --------------------------------------------------------------------- + Exports of state.c that are not core-visible + ------------------------------------------------------------------ */ + +/* Is this a SSE/SSE2-capable CPU? If so, we had better save/restore + the SSE state all over the place. This is set up very early, since we + can't even correctly snapshot the startup machine state without it. */ +extern Bool VG_(have_ssestate); + /* --------------------------------------------------------------------- Exports of vg_ldt.c ------------------------------------------------------------------ */