Fix undefined function errors on PPC and MIPS.
authorStas Boukarev <stassats@gmail.com>
Tue, 6 Aug 2013 17:11:16 +0000 (21:11 +0400)
committerStas Boukarev <stassats@gmail.com>
Tue, 6 Aug 2013 17:11:16 +0000 (21:11 +0400)
undefined_tramp hardcodes the register in which FDEFN resides, but the
format was recently changed (f69e89d..).

Other platforms can be susceptible to this.
A proper fix would avoid hardcoding this by exporting
sc-offset-scn-byte/sc-offset-offset-byte, and register offsets.

Thanks to the GCC Compile Farm project for providing machines for
testing and uncovering this.

NEWS
src/code/sc-offset.lisp
src/runtime/mips-assem.S
src/runtime/ppc-assem.S
tests/compiler.pure.lisp

diff --git a/NEWS b/NEWS
index c90875e..912f5b9 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,8 @@
 changes relative to sbcl-1.1.10
   * enhancement: support building the manual under texinfo version 5.
     (lp#1189146)
+  * bug fix: undefined function errors are now properly reported on PPC and MIPS.
+    (regression since 1.1.9)
 
 changes in sbcl-1.1.10 relative to sbcl-1.1.9:
   * enhancement: ASDF has been updated to 3.0.2.
index 1811dd6..0f20089 100644 (file)
@@ -16,6 +16,9 @@
 ;;;; We represent the place where some value is stored with a SC-OFFSET,
 ;;;; which is the SC number and offset encoded as an integer.
 
+;;;; FIXME: this layout is hardcoded in some .S files,
+;;;; undefined_tramp in at least ppc-assem.S and mips-assem.S uses it.
+;;;; Ideally, it shouldn't be hardcoded.
 (defconstant-eqx sc-offset-scn-byte (byte 6 0) #'equalp)
 (defconstant-eqx sc-offset-offset-byte (byte 21 6) #'equalp)
 (def!type sc-offset () '(unsigned-byte 27))
index 1982ee8..62b3672 100644 (file)
@@ -392,8 +392,8 @@ lra:        .word   RETURN_PC_HEADER_WIDETAG
           See debug-var-io.lisp. */
        .byte   254
        /* reg_FDEFN is #14. */
-       .byte   ((14 << 5) + sc_DescriptorReg) % 0x100
-       .byte   ((14 << 5) + sc_DescriptorReg) / 0x100
+       .byte   ((14 << 6) + sc_DescriptorReg) % 0x100
+       .byte   ((14 << 6) + sc_DescriptorReg) / 0x100
        .align  2
        .set    reorder
 1:     lw      reg_CODE, FDEFN_FUN_OFFSET(reg_FDEFN)
index 51b6b32..3b6e53f 100644 (file)
@@ -654,7 +654,7 @@ CSYMBOL(undefined_tramp):
        twllei reg_ZERO,trap_Cerror
        .byte 4
        .byte UNDEFINED_FUN_ERROR
-       .byte 254, sc_DescriptorReg+0x40, 1 /* 140?  sparc says sc_descriptorReg */
+       .byte 254, sc_DescriptorReg+0x80, 0x2 /* 280 */
        /* This stuff is for the continuable error.  I don't think there's
         * any support for it on the lisp side */
        .align 2
index aa8861d..16436ff 100644 (file)
 
 ;;; on the PPC, we got the magic numbers in undefined_tramp wrong for
 ;;; a while; fixed by CSR 2002-07-18
-(multiple-value-bind (value error)
-    (ignore-errors (some-undefined-function))
-  (assert (null value))
-  (assert (eq (cell-error-name error) 'some-undefined-function)))
+(with-test (:name :undefined-function-error)
+  (multiple-value-bind (value error)
+      (ignore-errors (some-undefined-function))
+    (assert (null value))
+    (assert (eq (cell-error-name error) 'some-undefined-function))))
 
 ;;; Non-symbols shouldn't be allowed as VARs in lambda lists. (Where VAR
 ;;; is a variable name, as in section 3.4.1 of the ANSI spec.)