This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

i386 gcc trampoline improvement



Any objection to my installing this in egcs?


*** i386.h	1998/08/25 12:23:49	1.31
--- i386.h	1998/09/05 01:47:55
*************** do {						\
*** 1532,1556 ****
  /* Output assembler code for a block containing the constant parts
     of a trampoline, leaving space for the variable parts.  */
  
! /* On the 386, the trampoline contains three instructions:
       mov #STATIC,ecx
!      mov #FUNCTION,eax
!      jmp @eax  */
! #define TRAMPOLINE_TEMPLATE(FILE)			\
! {							\
!   ASM_OUTPUT_CHAR (FILE, GEN_INT (0xb9));		\
!   ASM_OUTPUT_SHORT (FILE, const0_rtx);			\
!   ASM_OUTPUT_SHORT (FILE, const0_rtx);			\
!   ASM_OUTPUT_CHAR (FILE, GEN_INT (0xb8));		\
!   ASM_OUTPUT_SHORT (FILE, const0_rtx);			\
!   ASM_OUTPUT_SHORT (FILE, const0_rtx);			\
!   ASM_OUTPUT_CHAR (FILE, GEN_INT (0xff));		\
!   ASM_OUTPUT_CHAR (FILE, GEN_INT (0xe0));		\
! }
  
  /* Length in units of the trampoline for entering a nested function.  */
  
! #define TRAMPOLINE_SIZE 12
  
  /* Emit RTL insns to initialize the variable parts of a trampoline.
     FNADDR is an RTX for the address of the function's pure code.
--- 1532,1547 ----
  /* Output assembler code for a block containing the constant parts
     of a trampoline, leaving space for the variable parts.  */
  
! /* On the 386, the trampoline contains two instructions:
       mov #STATIC,ecx
!      jmp FUNCTION
!    The trampoline is generated entirely at runtime.  The operand of JMP
!    is the address of FUNCTION relative to the instruction following the
!    JMP (which is 5 bytes long).  */
  
  /* Length in units of the trampoline for entering a nested function.  */
  
! #define TRAMPOLINE_SIZE 10
  
  /* Emit RTL insns to initialize the variable parts of a trampoline.
     FNADDR is an RTX for the address of the function's pure code.
*************** do {						\
*** 1558,1565 ****
  
  #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT)			\
  {									\
    emit_move_insn (gen_rtx_MEM (SImode, plus_constant (TRAMP, 1)), CXT); \
!   emit_move_insn (gen_rtx_MEM (SImode, plus_constant (TRAMP, 6)), FNADDR); \
  }
  
  /* Definitions for register eliminations.
--- 1549,1562 ----
  
  #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT)			\
  {									\
+   /* Compute offset from the end of the jmp to the target function.  */	\
+   rtx disp = expand_binop (SImode, sub_optab, FNADDR,			\
+ 			   plus_constant (TRAMP, 10),			\
+ 			   NULL_RTX, 1, OPTAB_DIRECT);			\
+   emit_move_insn (gen_rtx_MEM (QImode, TRAMP), GEN_INT (0xb9));		\
    emit_move_insn (gen_rtx_MEM (SImode, plus_constant (TRAMP, 1)), CXT); \
!   emit_move_insn (gen_rtx_MEM (QImode, plus_constant (TRAMP, 5)), GEN_INT (0xe9));\
!   emit_move_insn (gen_rtx_MEM (SImode, plus_constant (TRAMP, 6)), disp); \
  }
  
  /* Definitions for register eliminations.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]