From: Taylor R Campbell Date: Fri, 18 Jan 2019 06:23:00 +0000 (+0000) Subject: Fix passage of dynamic-link. Only machine register, not regblock. X-Git-Tag: mit-scheme-pucked-10.1.20~11^2~66^2~71 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=56fde00c4a7b70eccb87298c4d33d3616c05fc05;p=mit-scheme.git Fix passage of dynamic-link. Only machine register, not regblock. --- diff --git a/src/compiler/machines/aarch64/lapgen.scm b/src/compiler/machines/aarch64/lapgen.scm index a016fc79e..82b330f9c 100644 --- a/src/compiler/machines/aarch64/lapgen.scm +++ b/src/compiler/machines/aarch64/lapgen.scm @@ -465,7 +465,6 @@ USA. (define reg:memtop (regblock-ea register-block/memtop-offset)) (define reg:environment (regblock-ea register-block/environment-offset)) -(define reg:dynamic-link (regblock-ea register-block/dynamic-link-offset)) (define reg:lexpr-primitive-arity (regblock-ea register-block/lexpr-primitive-arity-offset)) (define reg:stack-guard (regblock-ea register-block/stack-guard-offset)) diff --git a/src/compiler/machines/aarch64/machine.scm b/src/compiler/machines/aarch64/machine.scm index 22e5df9b4..47dd5c8c5 100644 --- a/src/compiler/machines/aarch64/machine.scm +++ b/src/compiler/machines/aarch64/machine.scm @@ -300,7 +300,6 @@ USA. (define-integrable register-block/int-mask-offset 1) (define-integrable register-block/value-offset 2) (define-integrable register-block/environment-offset 3) -(define-integrable register-block/dynamic-link-offset 4) ; compiler temp (define-integrable register-block/lexpr-primitive-arity-offset 7) (define-integrable register-block/stack-guard-offset 11) (define-integrable register-block/int-code-offset 12) diff --git a/src/compiler/machines/aarch64/rules3.scm b/src/compiler/machines/aarch64/rules3.scm index 8afe6b979..ac258e334 100644 --- a/src/compiler/machines/aarch64/rules3.scm +++ b/src/compiler/machines/aarch64/rules3.scm @@ -452,8 +452,7 @@ USA. code-word label (lambda () - ;; Save the dynamic link to an interpreter register, and then ask - ;; for help from the microcode. + ;; Pass the dynamic link as utility argument 2. ;; ;; XXX The goal of sharing here is to reduce code size; it would ;; be nice if we could ask the assembler to not share if we're so @@ -468,7 +467,8 @@ USA. (LAP (B (@PCR ,subroutine ,regnum:scratch-0)))) (lambda (subroutine) (LAP (LABEL ,subroutine) - (STR X ,regnum:dynamic-link ,reg:dynamic-link) + ,@(register->register-transfer regnum:dynamic-link + regnum:utility-arg2) ,@(invoke-interface code:compiler-interrupt-dlink))))) (define-rule statement diff --git a/src/microcode/cmpauxmd/aarch64.m4 b/src/microcode/cmpauxmd/aarch64.m4 index 2c7dea567..d7fc694ec 100644 --- a/src/microcode/cmpauxmd/aarch64.m4 +++ b/src/microcode/cmpauxmd/aarch64.m4 @@ -53,6 +53,7 @@ define(ADRL,` // Scheme machine registers. Must agree with // aarch64/machine.scm, aarch64/lapgen.scm. + VAL .req x0 UARG1 .req x1 UARG2 .req x2 UARG3 .req x3 @@ -69,7 +70,6 @@ define(ADRL,` // Interpreter register block offsets. Must agree with // const.h. .equiv REGBLOCK_VAL, 2 - .equiv REGBLOCK_DYNLINK, 4 // REGBLOCK_CC_TEMP /////////////////////////////////////////////////////////////////////////////// // Entering Scheme from C @@ -170,14 +170,15 @@ END(interface_to_C) // Steps: // // 1. Save value, Free, and stack_pointer. - // => No need to save REGS because it's callee-saves. + // => No need to save REGS or HOOKS because callee-saves. + // => If DYNLINK is active, will be utility argument 2. // 2. Allocate a struct on the stack for return values in x0. // 3. Call the function in utility_table. // 4. Go to wherever the microcode directed us. // GLOBAL(scheme_to_interface) // Save value, Free, and stack_pointer. - str x0, [REGS,#REGBLOCK_VAL] + str VAL, [REGS,#(REGBLOCK_VAL*8)] ADRL(ip0,Free) // address of Free pointer str FREE, [ip0] // store current Free pointer ADRL(ip0,stack_pointer) // address of stack pointer @@ -253,6 +254,8 @@ END(interface_to_scheme_return) // entry or returning to a Scheme return address. // // - Sets x0 to be the preserved return value, if any. + // - Sets x21 to be the preserved dynamic link, if any. + // (Both were in REGBLOCK_VAL.) // - Sets up x20 (FREE) and x28 (Scheme SP). // - Preserves x1 (APPLICAND) and x17 (APPLICAND_PC). // - Does not touch REGS (x19) or HOOKS (x23) because @@ -264,8 +267,10 @@ END(interface_to_scheme_return) // interface_to_scheme_return. // LOCAL(interface_to_scheme_setup) - // Restore value, Free, and stack_pointer. - ldr x0, [REGS,#REGBLOCK_VAL] + // Restore value if it was in use, dynamic link if it was in + // use, Free, and stack_pointer. + ldr VAL, [REGS,#(REGBLOCK_VAL*8)] + mov DYNLINK, VAL ADRL(FREE,Free) // address of Free pointer ldr FREE, [FREE] // load current Free pointer ADRL(SSP,stack_pointer) // address of stack pointer @@ -344,8 +349,11 @@ $1: // UTILITY_HOOK(name, number) // // Hook that jumps to the utility with the specified - // number. Reduces caller code size. The number must - // match utility_table in cmpint.c. + // number. Does not reduce caller code size, so use this + // only as an interim for cases where we are likely to + // add some extra logic here soon that would help to + // reduce caller code size. The number must match + // utility_table in cmpint.c. // define(UTILITY_HOOK, ` $1: