|
From: <sv...@va...> - 2005-10-02 22:53:48
|
Author: njn
Date: 2005-10-02 15:48:09 +0100 (Sun, 02 Oct 2005)
New Revision: 4843
Log:
Make the dispatch files platform-specific, not just arch-specific,
as requested by Greg Parker. (The ppc32/Darwin dispatch loop is
different to the ppc32/Linux one, for example.)
Added:
trunk/coregrind/m_dispatch/dispatch-amd64-linux.S
trunk/coregrind/m_dispatch/dispatch-ppc32-linux.S
trunk/coregrind/m_dispatch/dispatch-x86-linux.S
Removed:
trunk/coregrind/m_dispatch/dispatch-amd64.S
trunk/coregrind/m_dispatch/dispatch-ppc32.S
trunk/coregrind/m_dispatch/dispatch-x86.S
Modified:
trunk/coregrind/Makefile.am
Modified: trunk/coregrind/Makefile.am
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/Makefile.am 2005-10-02 13:10:41 UTC (rev 4842)
+++ trunk/coregrind/Makefile.am 2005-10-02 14:48:09 UTC (rev 4843)
@@ -18,7 +18,7 @@
=20
# Remember to include all the arch-specific files in the distribution.
EXTRA_DIST =3D \
- $(addsuffix .S,$(addprefix m_dispatch/dispatch-,$(VG_ARCH_ALL)))=
\
+ $(addsuffix .S,$(addprefix m_dispatch/dispatch-,$(VG_PLATFORM_AL=
L))) \
$(addsuffix .c,$(addprefix m_sigframe/sigframe-,$(VG_PLATFORM_AL=
L))) \
$(addsuffix .S,$(addprefix m_syswrap/syscall-,$(VG_PLATFORM_ALL)=
)) \
$(addsuffix .c,$(addprefix m_syswrap/syswrap-,$(VG_OS_ALL))) \
@@ -142,7 +142,7 @@
m_demangle/demangle.c \
m_demangle/dyn-string.c \
m_demangle/safe-ctype.c \
- m_dispatch/dispatch-@VG_ARCH@.S \
+ m_dispatch/dispatch-@VG_PLATFORM@.S \
m_replacemalloc/replacemalloc_core.c \
m_scheduler/scheduler.c \
m_scheduler/sema.c \
@@ -156,9 +156,9 @@
libreplacemalloc_toolpreload_a_SOURCES =3D m_replacemalloc/vg_replace_ma=
lloc.c
libreplacemalloc_toolpreload_a_CFLAGS =3D $(PIC_AM_CFLAGS)
=20
-m_dispatch/dispatch-@VG_ARCH@.S: libvex_guest_offsets.h
-m_syswrap/syscall-@VG_PLATFORM@.S: libvex_guest_offsets.h
-m_syswrap/syswrap-main.c: libvex_guest_offsets.h
+m_dispatch/dispatch-@VG_PLATFORM@.S: libvex_guest_offsets.h
+m_syswrap/syscall-@VG_PLATFORM@.S: libvex_guest_offsets.h
+m_syswrap/syswrap-main.c: libvex_guest_offsets.h
=20
libvex_guest_offsets.h:
$(MAKE) -C @VEX_DIR@ pub/libvex_guest_offsets.h
Copied: trunk/coregrind/m_dispatch/dispatch-amd64-linux.S (from rev 4842,=
trunk/coregrind/m_dispatch/dispatch-amd64.S)
Deleted: trunk/coregrind/m_dispatch/dispatch-amd64.S
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_dispatch/dispatch-amd64.S 2005-10-02 13:10:41 UTC (=
rev 4842)
+++ trunk/coregrind/m_dispatch/dispatch-amd64.S 2005-10-02 14:48:09 UTC (=
rev 4843)
@@ -1,217 +0,0 @@
-
-##--------------------------------------------------------------------##
-##--- The core dispatch loop, for jumping to a code address. ---##
-##--- dispatch-amd64.S ---##
-##--------------------------------------------------------------------##
-
-/*
- This file is part of Valgrind, a dynamic binary instrumentation
- framework.
-
- Copyright (C) 2000-2005 Julian Seward=20
- js...@ac...
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307, USA.
-
- The GNU General Public License is contained in the file COPYING.
-*/
-
-#include "pub_core_basics_asm.h"
-#include "pub_core_dispatch_asm.h"
-#include "pub_core_transtab_asm.h"
-#include "libvex_guest_offsets.h" /* for OFFSET_amd64_RIP */
-
-
-/*------------------------------------------------------------*/
-/*--- The dispatch loop. ---*/
-/*------------------------------------------------------------*/
-
-/* signature: UWord VG_(run_innerloop) ( void* guest_state ) */
-
-.globl VG_(run_innerloop)
-VG_(run_innerloop):
- /* %rdi holds guest_state */
-=09
- /* ----- entry point to VG_(run_innerloop) ----- */
- pushq %rbx
- pushq %rcx
- pushq %rdx
- pushq %rsi
- pushq %rbp
- pushq %r8
- pushq %r9
- pushq %r10
- pushq %r11
- pushq %r12
- pushq %r13
- pushq %r14
- pushq %r15
- pushq %rdi
-
- movq VG_(dispatch_ctr)@GOTPCREL(%rip), %rsi
- pushq (%rsi)
-
- /* 8(%rsp) holds cached copy of guest_state */
- /* 0(%rsp) holds cached copy of VG_(dispatch_ctr) */
-
- /* Set up the guest state pointer */
- movq %rdi, %rbp
-=09
- /* fetch %RIP into %rax */
- movq OFFSET_amd64_RIP(%rbp), %rax
-
- /* set host FPU control word to the default mode expected=20
- by VEX-generated code. See comments in libvex.h for
- more info. */
- finit
- pushq $0x027F
- fldcw (%rsp)
- addq $8, %rsp
-=09
- /* set host SSE control word to the default mode expected=20
- by VEX-generated code. */
- pushq $0x1F80
- ldmxcsr (%rsp)
- addq $8, %rsp
-
- /* set dir flag to known value */
- cld
-
- /* fall into main loop */
-
- /* Here, %rax 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 */
- movq %rax, OFFSET_amd64_RIP(%rbp)
-
- /* Are we out of timeslice? If yes, defer to scheduler. */
- subl $1, 0(%rsp)
- jz counter_is_zero
-
- /* try a fast lookup in the translation cache */
- movq %rax, %rbx
- andq $VG_TT_FAST_MASK, %rbx
- movq VG_(tt_fast)@GOTPCREL(%rip), %rcx
- movq (%rcx,%rbx,8), %rcx
- cmpq %rax, (%rcx)
- jnz fast_lookup_failed
- /* increment bb profile counter */
- movq VG_(tt_fastN)@GOTPCREL(%rip), %rdx
- movq (%rdx,%rbx,8), %rdx
- incl (%rdx)
-
- /* Found a match. Call tce[1], which is 8 bytes along, since
- each tce element is a 64-bit int. */
- addq $8, %rcx
- call *%rcx
-
- /*=20
- %rax holds destination (original) address.
- %rbp indicates further details of the control transfer
- requested to the address in %rax.
-=09
- If rbp is unchanged (=3D=3D * 8(%rsp)), just jump next to %rax.
-
- Otherwise fall out, back to the scheduler, and let it
- figure out what to do next.
- */
-
- cmpq 8(%rsp), %rbp
- jz dispatch_boring
-
- jmp dispatch_exceptional
-
-
-
-/* All exits from the dispatcher go through here. %rax holds
- the return value.=20
-*/
-run_innerloop_exit:=20
- /* We're leaving. Check that nobody messed with
- %mxcsr or %fpucw. We can't mess with %rax here as it
- holds the tentative return value, but any other is OK. */
- pushq $0
- fstcw (%rsp)
- cmpl $0x027F, (%rsp)
- popq %r11 /* get rid of the word without trashing %eflags */
- jnz invariant_violation
- pushq $0
- stmxcsr (%rsp)
- andl $0xFFFFFFC0, (%rsp) /* mask out status flags */
- cmpl $0x1F80, (%rsp)
- popq %r11
- jnz invariant_violation
- /* otherwise we're OK */
- jmp run_innerloop_exit_REALLY
-
-invariant_violation:
- movq $VG_TRC_INVARIANT_FAILED, %rax
- jmp run_innerloop_exit_REALLY
-
-run_innerloop_exit_REALLY:
- movq VG_(dispatch_ctr)@GOTPCREL(%rip), %rsi
- popq (%rsi)
- popq %rdi
- popq %r15
- popq %r14
- popq %r13
- popq %r12
- popq %r11
- popq %r10
- popq %r9
- popq %r8
- popq %rbp
- popq %rsi
- popq %rdx
- popq %rcx
- popq %rbx
- ret=09
-
-=09
-=09
-/* Other ways of getting out of the inner loop. Placed out-of-line to
- make it look cleaner.=20
-*/
-dispatch_exceptional:
- /* this is jumped to only, not fallen-through from above */
-
- /* save %rax in %RIP and defer to sched */
- movq 8(%rsp), %rdi
- movq %rax, OFFSET_amd64_RIP(%rdi)
- movq %rbp, %rax
- jmp run_innerloop_exit
-
-fast_lookup_failed:
- /* %RIP is up to date here since dispatch_boring dominates */
- addl $1, 0(%rsp)
- movq $VG_TRC_INNER_FASTMISS, %rax
- jmp run_innerloop_exit
-
-counter_is_zero:
- /* %RIP is up to date here since dispatch_boring dominates */
- addl $1, 0(%rsp)
- movq $VG_TRC_INNER_COUNTERZERO, %rax
- jmp run_innerloop_exit
-
-
-/* Let the linker know we don't need an executable stack */
-.section .note.GNU-stack,"",@progbits
-
-##--------------------------------------------------------------------##
-##--- end ---##
-##--------------------------------------------------------------------##
Copied: trunk/coregrind/m_dispatch/dispatch-ppc32-linux.S (from rev 4842,=
trunk/coregrind/m_dispatch/dispatch-ppc32.S)
Deleted: trunk/coregrind/m_dispatch/dispatch-ppc32.S
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_dispatch/dispatch-ppc32.S 2005-10-02 13:10:41 UTC (=
rev 4842)
+++ trunk/coregrind/m_dispatch/dispatch-ppc32.S 2005-10-02 14:48:09 UTC (=
rev 4843)
@@ -1,276 +0,0 @@
-
-##--------------------------------------------------------------------##
-##--- The core dispatch loop, for jumping to a code address. ---##
-##--- dispatch-ppc32.S ---##
-##--------------------------------------------------------------------##
-
-/*
- This file is part of Valgrind, a dynamic binary instrumentation
- framework.
-
- Copyright (C) 2005 Cerion Armour-Brown <ce...@op...>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307, USA.
-
- The GNU General Public License is contained in the file COPYING.
-*/
-
-#include "pub_core_basics_asm.h"
-#include "pub_core_dispatch_asm.h"
-#include "pub_core_transtab_asm.h"
-#include "libvex_guest_offsets.h" /* for OFFSET_ppc32_CIA */
-
-
-/*------------------------------------------------------------*/
-/*--- The dispatch loop. ---*/
-/*------------------------------------------------------------*/
-
-/* signature: UWord VG_(run_innerloop) ( void* guest_state ) */
-
- .globl VG_(run_innerloop)
-VG_(run_innerloop):
- /* ----- entry point to VG_(run_innerloop) ----- */
-
- /* Save lr, sp */
- mflr 0
- stw 0,4(1)
-
- /* New stack frame: save callee-saved regs */
- stwu 1,-88(1)
- stw 31,84(1)
- stw 30,80(1)
- stw 29,76(1)
- stw 28,72(1)
- stw 27,68(1)
- stw 26,64(1)
- stw 25,60(1)
- stw 24,56(1)
- stw 23,52(1)
- stw 22,48(1)
- stw 21,44(1)
- stw 20,40(1)
- stw 19,36(1)
- stw 18,32(1)
- stw 17,28(1)
- stw 16,24(1)
- stw 15,20(1)
- stw 14,16(1)
-
- /* r3 holds guest_state */
- mr 31,3
- stw 3,12(1) /* spill orig guest_state ptr */
-
-// CAB TODO: Use a caller-saved reg for orig guest_state ptr
-// - rem to set non-allocateable in isel.c
-
- /* hold dispach_ctr in ctr reg */
- lis 17,VG_(dispatch_ctr)@ha
- lwz 17,VG_(dispatch_ctr)@l(17)
- mtctr 17
-
- /* fetch %CIA into r30 */
- lwz 30,OFFSET_ppc32_CIA(31)
-
- /* set host FPU control word to the default mode expected=20
- by VEX-generated code. See comments in libvex.h for
- more info. */
- fsub 3,3,3 /* generate zero */
- mtfsf 0xFF,3
-
- /* set host AltiVec control word to the default mode expected=20
- by VEX-generated code. */
- lis 3,VG_(have_altivec_ppc32)@ha
- lwz 3,VG_(have_altivec_ppc32)@l(3)
- cmplwi 3,0
- beq L1
- /* generate vector {0x0,0x0,0x0,0x00010000} */
- vspltisw 3,0x1 /* 4x 0x00000001 */
- vspltisw 4,0x0 /* generate zero */
- vsldoi 3,4,3,0x6 /* v3 =3D v3 >> 10 bytes */
- mtvscr 3
-L1:
- /* make a stack frame for the code we are calling */
- stwu 1,-16(1)
-
- /* fall into main loop */
-
-/* Live regs:
- r1 (=3Dsp)
- r30 (=3DCIA =3D jump address)
- r31 (=3Dguest_state)
- ctr (=3Ddispatch_ctr)
- Stack state:
- 28(r1) (=3Dorig guest_state)
-*/
-
-dispatch_boring:
- /* save the jump address in the guest state */
- stw 30,OFFSET_ppc32_CIA(31)
-
- /* Are we out of timeslice? If yes, defer to scheduler. */
- bdz counter_is_zero /* decrements ctr reg */
-
- /* try a fast lookup in the translation cache */
- rlwinm 4,30,2,VG_TT_FAST_MASK<<2 /* r4=3D((r30<<2) & (MASK<<2)=
) */
-// CAB: use a caller-saved reg for this ?
- addis 5,4,VG_(tt_fast)@ha
- lwz 5,VG_(tt_fast)@l(5)
- lwz 6,4(5) /* big-endian, so comparing 2nd 32bit word */
- cmpw 30,6
- bne fast_lookup_failed
-
- /* increment bb profile counter */
-// CAB: use a caller-saved reg for this ?
- addis 6,4,VG_(tt_fastN)@ha
- lwz 7,VG_(tt_fastN)@l(6)
- lwz 8,0(7)
- addi 8,8,1
- stw 8,0(7)
-
- /* Found a match. Call tce[1], which is 8 bytes along, since
- each tce element is a 64-bit int. */
- addi 8,5,8
- mtlr 8
-
- /* stop ctr being clobbered */
-// CAB: use a caller-saved reg for this ?
-// but then (bdz) =3D> (decr, cmp, bc)... still better than a stw?
- mfctr 9
- stw 9,24(1)
-
- blrl
-
-
- /* On return from guest code:
- r3 holds destination (original) address.
-
- r31 may be unchanged (guest_state), or may indicate further
- details of the control transfer requested to *r3.
-
- If r31 is unchanged (=3D=3D 28(r1)), just jump next to r3.
-
- Otherwise fall out, back to the scheduler, and let it
- figure out what to do next.
- */
-
- /* reinstate clobbered ctr */
- lwz 9,24(1)
- mtctr 9
-
- mr 30,3 /* put CIA (=3Dr3) in r30 */
- lwz 16,28(1) /* original guest_state ptr */
- cmpw 16,31
- beq dispatch_boring /* r31 unchanged... */
-
- mr 3,31 /* put return val (=3Dr31) in r3 */
- b dispatch_exceptional
-
-/* All exits from the dispatcher go through here.
- r3 holds the return value.=20
-*/
-run_innerloop_exit:=20
- /* We're leaving. Check that nobody messed with
- %mxcsr or %fpucw. We can't mess with %eax here as it
- holds the tentative return value, but any other is OK. */
-// CAB: TODO
-=09
-//.. pushl $0
-//.. fstcw (%esp)
-//.. cmpl $0x027F, (%esp)
-//.. popl %esi /* get rid of the word without trashing %eflags */
-//.. jnz invariant_violation
-
-//.. pushl $0
-//.. stmxcsr (%esp)
-//.. andl $0xFFFFFFC0, (%esp) /* mask out status flags */
-//.. cmpl $0x1F80, (%esp)
-//.. popl %esi
-//.. jnz invariant_violation
-=09
- /* otherwise we're OK */
- b run_innerloop_exit_REALLY
-
-
-invariant_violation:
- li 3,VG_TRC_INVARIANT_FAILED
- b run_innerloop_exit_REALLY
-
-run_innerloop_exit_REALLY:
- /* r3 holds VG_TRC_* value to return */
-
- addi 1,1,16
-
- mfctr 17
- lis 18,VG_(dispatch_ctr)@ha
- stw 17,VG_(dispatch_ctr)@l(18)
-
- lwz 14,16(1)
- lwz 15,20(1)
- lwz 16,24(1)
- lwz 17,28(1)
- lwz 18,32(1)
- lwz 19,36(1)
- lwz 20,40(1)
- lwz 21,44(1)
- lwz 22,48(1)
- lwz 23,52(1)
- lwz 24,56(1)
- lwz 25,60(1)
- lwz 26,64(1)
- lwz 27,68(1)
- lwz 28,72(1)
- lwz 29,76(1)
- lwz 30,80(1)
- lwz 31,84(1)
- lwz 0,92(1)
- mtlr 0
- addi 1,1,88
- blr
-
-
-/* Other ways of getting out of the inner loop. Placed out-of-line to
- make it look cleaner.=20
-*/
-dispatch_exceptional:
- /* this is jumped to only, not fallen-through from above */
- /* save r30 in %CIA and defer to sched */
- lwz 16,28(1)
- stw 30,OFFSET_ppc32_CIA(16)
- b run_innerloop_exit
-
-fast_lookup_failed:
- /* %CIA is up to date here since dispatch_boring dominates */
- mfctr 17
- addi 17,17,1
- mtctr 17
- li 3,VG_TRC_INNER_FASTMISS
- b run_innerloop_exit
- =20
-
-counter_is_zero:
- /* %CIA is up to date here since dispatch_boring dominates */
- mfctr 17
- addi 17,17,1
- mtctr 17
- li 3,VG_TRC_INNER_COUNTERZERO
- b run_innerloop_exit
-
-/* Let the linker know we don't need an executable stack */
-.section .note.GNU-stack,"",@progbits
-
-##--------------------------------------------------------------------##
-##--- end ---##
-##--------------------------------------------------------------------##
Copied: trunk/coregrind/m_dispatch/dispatch-x86-linux.S (from rev 4842, t=
runk/coregrind/m_dispatch/dispatch-x86.S)
Deleted: trunk/coregrind/m_dispatch/dispatch-x86.S
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_dispatch/dispatch-x86.S 2005-10-02 13:10:41 UTC (re=
v 4842)
+++ trunk/coregrind/m_dispatch/dispatch-x86.S 2005-10-02 14:48:09 UTC (re=
v 4843)
@@ -1,200 +0,0 @@
-
-##--------------------------------------------------------------------##
-##--- The core dispatch loop, for jumping to a code address. ---##
-##--- dispatch-x86.S ---##
-##--------------------------------------------------------------------##
-
-/*
- This file is part of Valgrind, a dynamic binary instrumentation
- framework.
-
- Copyright (C) 2000-2005 Julian Seward=20
- js...@ac...
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307, USA.
-
- The GNU General Public License is contained in the file COPYING.
-*/
-
-#include "pub_core_basics_asm.h"
-#include "pub_core_dispatch_asm.h"
-#include "pub_core_transtab_asm.h"
-#include "libvex_guest_offsets.h" /* for OFFSET_x86_EIP */
-
-
-/*------------------------------------------------------------*/
-/*--- The dispatch loop. ---*/
-/*------------------------------------------------------------*/
-
-/* signature: UWord VG_(run_innerloop) ( void* guest_state ) */
-
-.globl VG_(run_innerloop)
-VG_(run_innerloop):
- /* 4(%esp) holds guest_state */
-=09
- /* ----- entry point to VG_(run_innerloop) ----- */
- pushl %ebx
- pushl %ecx
- pushl %edx
- pushl %esi
- pushl %edi
- pushl %ebp
-=09
- /* 28(%esp) holds guest_state */
-
- /* Set up the guest state pointer */
- movl 28(%esp), %ebp
-=09
- /* fetch %EIP into %eax */
- movl OFFSET_x86_EIP(%ebp), %eax
-
- /* set host FPU control word to the default mode expected=20
- by VEX-generated code. See comments in libvex.h for
- more info. */
- finit
- pushl $0x027F
- fldcw (%esp)
- addl $4, %esp
-=09
- /* set host SSE control word to the default mode expected=20
- by VEX-generated code. */
- cmpl $0, VG_(have_mxcsr_x86)
- jz L1
- pushl $0x1F80
- ldmxcsr (%esp)
- addl $4, %esp
-L1:
- /* set dir flag to known value */
- cld
-=09
- /* 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 %eax, OFFSET_x86_EIP(%ebp)
-
- /* Are we out of timeslice? If yes, defer to scheduler. */
- subl $1, VG_(dispatch_ctr)
- jz counter_is_zero
-
- /* try a fast lookup in the translation cache */
- movl %eax, %ebx
- andl $VG_TT_FAST_MASK, %ebx
- movl VG_(tt_fast)(,%ebx,4), %ecx
- cmpl %eax, (%ecx)
- jnz fast_lookup_failed
- /* increment bb profile counter */
- movl VG_(tt_fastN)(,%ebx,4), %edx
- incl (%edx)
-
- /* Found a match. Call tce[1], which is 8 bytes along, since
- each tce element is a 64-bit int. */
- addl $8, %ecx
- call *%ecx
-=09
- /*=20
- %eax holds destination (original) address.
- %ebp indicates further details of the control transfer
- requested to the address in %eax.
-=09
- If ebp is unchanged (=3D=3D * 28(%esp)), just jump next to %eax.
-
- Otherwise fall out, back to the scheduler, and let it
- figure out what to do next.
- */
-
- cmpl 28(%esp), %ebp
- jz dispatch_boring
-
- jmp dispatch_exceptional
-
-=09
-
-/* All exits from the dispatcher go through here. %eax holds
- the return value.=20
-*/
-run_innerloop_exit:=20
- /* We're leaving. Check that nobody messed with
- %mxcsr or %fpucw. We can't mess with %eax here as it
- holds the tentative return value, but any other is OK. */
-/* This fails for self-hosting, so skip in that case */
-#ifndef ENABLE_INNER
- pushl $0
- fstcw (%esp)
- cmpl $0x027F, (%esp)
- popl %esi /* get rid of the word without trashing %eflags */
- jnz invariant_violation
- cmpl $0, VG_(have_mxcsr_x86)
- jz L2
-#endif
- pushl $0
- stmxcsr (%esp)
- andl $0xFFFFFFC0, (%esp) /* mask out status flags */
- cmpl $0x1F80, (%esp)
- popl %esi
- jnz invariant_violation
-L2: /* otherwise we're OK */
- jmp run_innerloop_exit_REALLY
-
-invariant_violation:
- movl $VG_TRC_INVARIANT_FAILED, %eax
- jmp run_innerloop_exit_REALLY
-
-run_innerloop_exit_REALLY:
- popl %ebp
- popl %edi
- popl %esi
- popl %edx
- popl %ecx
- popl %ebx
- ret=09
-
-
-
-/* Other ways of getting out of the inner loop. Placed out-of-line to
- make it look cleaner.=20
-*/
-dispatch_exceptional:
- /* this is jumped to only, not fallen-through from above */
-
- /* save %eax in %EIP and defer to sched */
- movl 28(%esp), %edi
- movl %eax, OFFSET_x86_EIP(%edi)
- movl %ebp, %eax
- jmp run_innerloop_exit
-
-fast_lookup_failed:
- /* %EIP is up to date here since dispatch_boring dominates */
- addl $1, VG_(dispatch_ctr)
- movl $VG_TRC_INNER_FASTMISS, %eax
- jmp run_innerloop_exit
-
-counter_is_zero:
- /* %EIP is up to date here since dispatch_boring dominates */
- addl $1, VG_(dispatch_ctr)
- movl $VG_TRC_INNER_COUNTERZERO, %eax
- jmp run_innerloop_exit
-
-=09
-/* Let the linker know we don't need an executable stack */
-.section .note.GNU-stack,"",@progbits
-
-##--------------------------------------------------------------------##
-##--- end ---##
-##--------------------------------------------------------------------##
|