From 46c716f45f169665bfec096fb0378f913834da46 Mon Sep 17 00:00:00 2001 From: "Guillermo J. Rozas" Date: Sun, 16 Feb 1992 02:07:10 +0000 Subject: [PATCH] Remove far calls and jumps. They are not necessary (at least under Mach). --- v7/src/compiler/machines/i386/lapgen.scm | 14 ++++++++--- v7/src/compiler/machines/i386/rules3.scm | 32 +++++++++++------------- v7/src/compiler/machines/i386/rules4.scm | 10 ++++---- v7/src/microcode/cmpauxmd/i386.m4 | 12 ++------- v7/src/microcode/cmpintmd/i386.h | 28 ++++++++++----------- 5 files changed, 45 insertions(+), 51 deletions(-) diff --git a/v7/src/compiler/machines/i386/lapgen.scm b/v7/src/compiler/machines/i386/lapgen.scm index 9722af0b8..b118c439e 100644 --- a/v7/src/compiler/machines/i386/lapgen.scm +++ b/v7/src/compiler/machines/i386/lapgen.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/compiler/machines/i386/lapgen.scm,v 1.15 1992/02/15 16:16:57 jinx Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/compiler/machines/i386/lapgen.scm,v 1.16 1992/02/16 02:06:41 jinx Exp $ $MC68020-Header: /scheme/compiler/bobcat/RCS/lapgen.scm,v 4.42 1991/05/28 19:14:26 jinx Exp $ Copyright (c) 1992 Massachusetts Institute of Technology @@ -422,13 +422,19 @@ MIT in each case. |# set! define lookup-apply primitive-error quotient remainder modulo)) +(define-integrable (invoke-hook entry) + (LAP (JMP ,entry))) + +(define-integrable (invoke-hook/call entry) + (LAP (CALL ,entry))) + (define-integrable (invoke-interface code) (LAP (MOV B (R ,eax) (& ,code)) - (JMP F ,entry:compiler-scheme-to-interface))) + ,@(invoke-hook entry:compiler-scheme-to-interface))) (define-integrable (invoke-interface/call code) (LAP (MOV B (R ,eax) (& ,code)) - (CALL F ,entry:compiler-scheme-to-interface/call))) + ,@(invoke-hook/call entry:compiler-scheme-to-interface/call))) (let-syntax ((define-entries (macro (start . names) @@ -440,7 +446,7 @@ MIT in each case. |# (car names)) (byte-offset-reference regnum:regs-pointer ,index)) - (loop (cdr names) (+ index 8))))) + (loop (cdr names) (+ index 4))))) `(BEGIN ,@(loop names start))))) (define-entries #x40 ; (* 16 4) scheme-to-interface ; Main entry point (only one necessary) diff --git a/v7/src/compiler/machines/i386/rules3.scm b/v7/src/compiler/machines/i386/rules3.scm index beb94425f..0716eefa9 100644 --- a/v7/src/compiler/machines/i386/rules3.scm +++ b/v7/src/compiler/machines/i386/rules3.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/compiler/machines/i386/rules3.scm,v 1.14 1992/02/15 14:34:45 jinx Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/compiler/machines/i386/rules3.scm,v 1.15 1992/02/16 02:06:29 jinx Exp $ $MC68020-Header: /scheme/compiler/bobcat/RCS/rules3.scm,v 4.31 1991/05/28 19:14:55 jinx Exp $ Copyright (c) 1992 Massachusetts Institute of Technology @@ -55,17 +55,17 @@ MIT in each case. |# (LAP ,@(clear-map!) #| ,@(case frame-size - ((1) (LAP (JMP F ,entry:compiler-shortcircuit-apply-size-1))) - ((2) (LAP (JMP F ,entry:compiler-shortcircuit-apply-size-2))) - ((3) (LAP (JMP F ,entry:compiler-shortcircuit-apply-size-3))) - ((4) (LAP (JMP F ,entry:compiler-shortcircuit-apply-size-4))) - ((5) (LAP (JMP F ,entry:compiler-shortcircuit-apply-size-5))) - ((6) (LAP (JMP F ,entry:compiler-shortcircuit-apply-size-6))) - ((7) (LAP (JMP F ,entry:compiler-shortcircuit-apply-size-7))) - ((8) (LAP (JMP F ,entry:compiler-shortcircuit-apply-size-8))) + ((1) (invoke-hook entry:compiler-shortcircuit-apply-size-1)) + ((2) (invoke-hook entry:compiler-shortcircuit-apply-size-2)) + ((3) (invoke-hook entry:compiler-shortcircuit-apply-size-3)) + ((4) (invoke-hook entry:compiler-shortcircuit-apply-size-4)) + ((5) (invoke-hook entry:compiler-shortcircuit-apply-size-5)) + ((6) (invoke-hook entry:compiler-shortcircuit-apply-size-6)) + ((7) (invoke-hook entry:compiler-shortcircuit-apply-size-7)) + ((8) (invoke-hook entry:compiler-shortcircuit-apply-size-8)) (else (LAP (MOV W (R ,ecx) (& ,frame-size)) - (JMP F ,entry:compiler-shortcircuit-apply)))) + ,@(invoke-hook entry:compiler-shortcircuit-apply)))) |# (MOV W (R ,ecx) (& ,frame-size)) ,@(invoke-interface code:compiler-apply))) @@ -151,8 +151,6 @@ MIT in each case. |# (define-rule statement (INVOCATION:PRIMITIVE (? frame-size) (? continuation) (? primitive)) continuation ; ignored - (define-integrable (invoke-entry entry) - (LAP (JMP F ,entry))) (let-syntax ((invoke (macro (code entry) `(invoke-interface ,code)))) @@ -229,7 +227,7 @@ MIT in each case. |# (define (optimized-primitive-invocation entry) (LAP ,@(clear-map!) - (JMP F ,entry))) + ,@(invoke-hook entry))) ;;; Invocation Prefixes @@ -365,7 +363,7 @@ MIT in each case. |# (define-integrable (simple-procedure-header code-word label entry) (let ((gc-label (generate-label))) (LAP (LABEL ,gc-label) - (CALL F ,entry) + ,@(invoke-hook/call entry) ,@(make-external-label code-word label) (CMP W (R ,regnum:free-pointer) ,reg:compiled-memtop) (JGE (@PCR ,gc-label))))) @@ -504,7 +502,7 @@ MIT in each case. |# ,@(if (zero? entry) (LAP) (LAP (ADD W (@R ,esp) (& ,(* 10 entry))))) - (JMP F ,entry:compiler-interrupt-closure) + ,@(invoke-hook entry:compiler-interrupt-closure) ,@(make-external-label internal-entry-code-word external-label) (ADD W (@R ,esp) @@ -568,7 +566,7 @@ MIT in each case. |# (LEA (R ,ebx) (@RO W ,eax (- ,free-ref-label ,pc-label))) (MOV W ,reg:utility-arg-4 (& ,n-sections)) #| - (CALL F ,entry:compiler-link) + ,@(invoke-hook/call entry:compiler-link) |# ,@(invoke-interface/call code:compiler-link) ,@(make-external-label (continuation-code-word false) @@ -588,7 +586,7 @@ MIT in each case. |# (MOV W (@RO W ,edx ,environment-offset) (R ,ecx)) (MOV W ,reg:utility-arg-4 (& ,n-sections)) #| - (CALL F ,entry:compiler-link) + ,@(invoke-hook/call entry:compiler-link) |# ,@(invoke-interface/call code:compiler-link) ,@(make-external-label (continuation-code-word false) diff --git a/v7/src/compiler/machines/i386/rules4.scm b/v7/src/compiler/machines/i386/rules4.scm index 252b9fd40..f9a0b5356 100644 --- a/v7/src/compiler/machines/i386/rules4.scm +++ b/v7/src/compiler/machines/i386/rules4.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/compiler/machines/i386/rules4.scm,v 1.3 1992/02/15 14:17:10 jinx Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/compiler/machines/i386/rules4.scm,v 1.4 1992/02/16 02:06:50 jinx Exp $ $mc68020-Header: rules4.scm,v 4.12 90/05/03 15:17:38 GMT jinx Exp $ Copyright (c) 1992 Massachusetts Institute of Technology @@ -100,9 +100,9 @@ MIT in each case. |# (LAP ,@set-extension ,@(clear-map!) #| - (CALL F ,(if safe? - entry:compiler-safe-reference-trap - entry:compiler-reference-trap)) + ,@(invoke-hook/call (if safe? + entry:compiler-safe-reference-trap + entry:compiler-reference-trap)) |# ,@(invoke-interface/call (if safe? @@ -120,7 +120,7 @@ MIT in each case. |# ,@set-value ,@(clear-map!) #| - (CALL F ,entry:compiler-assignment-trap) + ,@(invoke-hook/call entry:compiler-assignment-trap) |# ,@(invoke-interface/call code:compiler-assignment-trap)))) diff --git a/v7/src/microcode/cmpauxmd/i386.m4 b/v7/src/microcode/cmpauxmd/i386.m4 index a377b3d06..98e068947 100644 --- a/v7/src/microcode/cmpauxmd/i386.m4 +++ b/v7/src/microcode/cmpauxmd/i386.m4 @@ -1,6 +1,6 @@ ### -*-Midas-*- ### -### $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/cmpauxmd/i386.m4,v 1.8 1992/02/16 00:12:38 jinx Exp $ +### $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/cmpauxmd/i386.m4,v 1.9 1992/02/16 02:07:10 jinx Exp $ ### ### Copyright (c) 1992 Massachusetts Institute of Technology ### @@ -204,18 +204,10 @@ define_c_label(interface_to_scheme) movl REGBLOCK_VAL()(regs),%eax # Value/dynamic link movl IMMEDIATE(ADDRESS_MASK),rmask # = %ebp movl external_reference(Ext_Stack_Pointer),%esp - movl %edx,(rfree) # Far pointer offset - xorl %ecx,%ecx # Far pointer segment - movw %ds,%ecx - movl %ecx,4(rfree) movl %eax,%ecx # Preserve if used andl rmask,%ecx # Restore potential movl %ecx,REGBLOCK_DLINK()(regs) # dynamic link -# Apparently gas does not understand the following instruction -# even though gdb disassembles the word into that format. -# ljmp *(rfree) -# .word 0x2fff - ljmp 0(rfree) + jmp *%edx define_c_label(interface_to_C) movl %edx,%eax # Set up result diff --git a/v7/src/microcode/cmpintmd/i386.h b/v7/src/microcode/cmpintmd/i386.h index 6a51e6ba1..0fa05f0ae 100644 --- a/v7/src/microcode/cmpintmd/i386.h +++ b/v7/src/microcode/cmpintmd/i386.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/cmpintmd/i386.h,v 1.9 1992/02/16 00:10:40 jinx Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/cmpintmd/i386.h,v 1.10 1992/02/16 02:07:02 jinx Exp $ Copyright (c) 1992 Massachusetts Institute of Technology @@ -38,7 +38,7 @@ MIT in each case. */ * * See cmpint.txt for a description of these fields. * - * Specialized for the Intel 386 (and successor) architecture. + * Specialized for the Intel 386 (and successors) architecture. */ #ifndef CMPINT2_H_INCLUDED @@ -168,13 +168,13 @@ entry 0 CALL opcode 0xE8 - Trampoline encoding: entry 0 MOV AL,code 0xB0, code-byte - 2 LCALL n(ESI) 0xFF 0x9e n-longword + 2 CALL n(ESI) 0xFF 0x96 n-longword 8 - GC & interrupt check at procedure/continuation entry: -gc_lab -7 LCALL n(ESI) 0xFF 0x5e n-byte +gc_lab -7 CALL n(ESI) 0xFF 0x56 n-byte -4 -2 entry 0 CMP EDI,(ESI) 0x39 0x3e @@ -185,7 +185,7 @@ entry 0 CMP EDI,(ESI) 0x39 0x3e - GC & interrupt check at closure entry: gc_lab -11 ADD (ESP),&offset 0x83 0x04 0x24 offset-byte - -7 LJMP n(ESI) 0xFF 0x6e n-byte + -7 JMP n(ESI) 0xFF 0x66 n-byte -4 -2 entry 0 ADD (ESP),&magic 0x81 0x04 0x24 magic-longword @@ -326,8 +326,8 @@ do { \ \ *PC++ = 0xb0; /* MOV AL,byte */ \ *PC++ = (index); /* byte value */ \ - *PC++ = 0xff; /* LCALL */ \ - *PC++ = 0x9e; /* /3 disp32(ESI) */ \ + *PC++ = 0xff; /* CALL */ \ + *PC++ = 0x96; /* /2 disp32(ESI) */ \ (* ((unsigned long *) PC)) = ESI_TRAMPOLINE_TO_INTERFACE_OFFSET; \ } while (0) @@ -341,10 +341,10 @@ do { \ #define COMPILER_REGBLOCK_N_FIXED 16 #define COMPILER_REGBLOCK_N_HOOKS 80 - /* A hook is a 48-bit address (segment + offset) for a far-indirect - CALL/JMP instruction. Pad to 64 bits. - */ -#define COMPILER_HOOK_SIZE 2 + + /* A hook is the address (offset) of an assembly-language routine. */ + +#define COMPILER_HOOK_SIZE 1 #define COMPILER_REGBLOCK_EXTRA_SIZE \ (COMPILER_REGBLOCK_N_HOOKS * COMPILER_HOOK_SIZE) @@ -371,11 +371,9 @@ long i386_pc_displacement_relocation = 0; #define SETUP_REGISTER(hook) do \ { \ extern void hook (); \ - unsigned long * far_pointer = \ - ((unsigned long *) (esi_value + offset)); \ \ - *far_pointer++ = ((unsigned long) hook); \ - *far_pointer = ((unsigned long) code_segment); \ + (* ((unsigned long *) (esi_value + offset))) = \ + ((unsigned long) hook); \ offset += (COMPILER_HOOK_SIZE * (sizeof (SCHEME_OBJECT))); \ } while (0) -- 2.25.1