gcl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gcl-devel] auto-proclamation


From: Camm Maguire
Subject: [Gcl-devel] auto-proclamation
Date: 17 May 2006 18:03:43 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Greetings!

Just a quick note on the progress here thus far.

1) For simplicity, I'm working with a simple callee/caller hash table
   with the signature stored as the 'sfun argd' integer.  This limits
   things to 15 args at the moment:

=============================================================================
(defvar *call-hash-table* (make-hash-table :test 'eq))
(defvar *needs-recompile* (make-array 10 :fill-pointer 0 :adjustable t))

(defstruct call
  (sig 0 :type fixnum)
  callees
  callers)

(defun add-hash (fn sig callees)
  (let ((h (or (gethash fn *call-hash-table*)
               (setf (gethash fn *call-hash-table*) (make-call :sig sig)))))
    (when (and (not (zerop sig)) (/= sig (call-sig h)))
      (setf (call-sig h) sig)
      (dolist (l (call-callers h))
        (unless (eq l fn)
          (add-recompile l))))
    (dolist (l callees)
      (pushnew (car l) (call-callees h))
      (let ((h (or (gethash (car l) *call-hash-table*)
                   (setf (gethash (car l) *call-hash-table*) (make-call :sig 
(cdr l) :callers (list fn))))))
        (pushnew fn (call-callers h))
        (unless (or (eq fn (car l)) (= (cdr l) (call-sig h)))
          (add-recompile fn))))))

(defun add-recompile (fn)
  (unless (find fn *needs-recompile*)
    (vector-push-extend fn *needs-recompile*)
    (sort *needs-recompile* 
          (lambda (x y) 
            (let ((h (gethash y *call-hash-table*)))
              (cond ((member x (call-callees h)) nil)
                    ((member x (call-callers h)))
                    ((string>= (symbol-name x) (symbol-name y)))))))))

(defun clr-call nil 
  (clrhash *call-hash-table*)
  (setf (fill-pointer *needs-recompile*) 0))

(defvar *top-level-recompile* t)

(defun do-recompile nil
  (when *top-level-recompile*
    (let ((*top-level-recompile* nil))
      (dotimes (i (length *needs-recompile*))
        (let ((fn (aref *needs-recompile* i)))
          (unless (eq fn 'si::typep-int)
            (setf (symbol-function fn) `(lambda-block ,fn ,@(cdr (get fn 
'si::function-lambda))))
                                        ;         (eval `(defun ,fn ,@(cdr (get 
fn 'si::function-lambda))))
            (eval `(compile ',fn)))));'(lambda ,@(cdr (get fn 
'si::function-lambda))))))))
      (setf (fill-pointer *needs-recompile*) 0))))
=============================================================================

2) Function compilation calls add-hash for each callee found in pass1
   with a 0 sig for the calling function, then once with nil callees
   and the correct signature at the end of pass1.  In pass2, an
   appropriate add-hash call is placed in the data file. (To get this
   to work, of course, signature conflicts must be detected at load
   time, not compile time, given the specified behavior of
   compile-file).  At the end of the data file, 'do-recompile is
   called. The source is added to the function name plist under
   'si::function-lambda in the data file.  This gets big, but we'll
   see how it goes.

3) This is working on simple examples, and even self-build at least up
   to the saved_gcl stage.  But it does now pre-suppose that the
   compiler is functional at load time, which is not traditionally the
   case with our image bootstrapping setup.  Furthermore, something
   needs to be done to support platforms where native image relocation
   is not supported (ia64 and hppa at present), as the strategy here
   must avoid 'compile followed by 'save-system.  Indeed, this is the
   primary reason for the current image bootstrap -- portability --
   all linking is done with ld.  So again we have choices:

        a) obviate the recompile on bootstrap by effectively compiling
        the system files twice, but might as well use sys-proclaim in
        such a case.

        b) rework the unixport/sys_*.c bootstrapping process to load
        the full interpreter before initializing the .o files, coming
        up with something clever for non-native-reloc systems and
        going through the recompile at each intermediary image stage.

        c) probably others...

Thoughts appreciated as always.

=============================================================================
/tmp/y.l:
=============================================================================
(defun foo (x) (declare (fixnum x)) (1+ x))
=============================================================================
/tmp/y1.l:
=============================================================================
(defun bar (x) (+ 2 (foo x)))
=============================================================================
address@hidden:/fix/t1/camm/debian/gcl/tmp/tmp/foo1/unixport$ ./saved_pre_gcl
GCL (GNU Common Lisp)  2.7.0 CLtL1    May 15 2006 15:14:02
Source License: LGPL(gcl,gmp,pargcl), GPL(unexec,bfd)
Binary License:  GPL due to GPL'ed components: (READLINE BFD UNEXEC)
Modifications of this banner must retain notice of a compatible license
Dedicated to the memory of W. Schelter

Use (help) to get some basic information on how to use GCL.
Temporary directory for compiler files set to /tmp/

>(compile-file "/tmp/y.l")

;; Compiling /tmp/y.l.
;; End of Pass 1.  
;; End of Pass 2.  
;; OPTIMIZE levels: Safety=0 (No runtime error checking), Space=0, Speed=3, 
(Debug quality ignored)
;; Finished compiling /tmp/y.o.
#P"/tmp/y.o"
NIL
NIL

>
address@hidden:/fix/t1/camm/debian/gcl/tmp/tmp/foo1/unixport$ 
address@hidden:/fix/t1/camm/debian/gcl/tmp/tmp/foo1/unixport$ ./saved_pre_gcl
GCL (GNU Common Lisp)  2.7.0 CLtL1    May 15 2006 15:14:02
Source License: LGPL(gcl,gmp,pargcl), GPL(unexec,bfd)
Binary License:  GPL due to GPL'ed components: (READLINE BFD UNEXEC)
Modifications of this banner must retain notice of a compatible license
Dedicated to the memory of W. Schelter

Use (help) to get some basic information on how to use GCL.
Temporary directory for compiler files set to /tmp/

>(compile-file "/tmp/y1.l")

;; Compiling /tmp/y1.l.
;; End of Pass 1.  
;; End of Pass 2.  
;; OPTIMIZE levels: Safety=0 (No runtime error checking), Space=0, Speed=3, 
(Debug quality ignored)
;; Finished compiling /tmp/y1.o.
#P"/tmp/y1.o"
NIL
NIL

>
address@hidden:/fix/t1/camm/debian/gcl/tmp/tmp/foo1/unixport$ 
address@hidden:/fix/t1/camm/debian/gcl/tmp/tmp/foo1/unixport$ ./saved_pre_gcl
GCL (GNU Common Lisp)  2.7.0 CLtL1    May 15 2006 15:14:02
Source License: LGPL(gcl,gmp,pargcl), GPL(unexec,bfd)
Binary License:  GPL due to GPL'ed components: (READLINE BFD UNEXEC)
Modifications of this banner must retain notice of a compatible license
Dedicated to the memory of W. Schelter

Use (help) to get some basic information on how to use GCL.
Temporary directory for compiler files set to /tmp/

>(load "/tmp/y.o")

Loading /tmp/y.o
start address -T 0x85a7bf8 Finished loading /tmp/y.o
164

>(load "/tmp/y1.o")

Loading /tmp/y1.o
;; Compiling /tmp/gazonk_23929_0.lsp.
;; End of Pass 1.  
;; End of Pass 2.  
;; OPTIMIZE levels: Safety=0 (No runtime error checking), Space=0, Speed=3, 
(Debug quality ignored)
;; Finished compiling /tmp/gazonk_23929_0.o.
Loading /tmp/gazonk_23929_0.o
start address -T 0x85d3da8 Finished loading /tmp/gazonk_23929_0.o
start address -T 0x85f1810 Finished loading /tmp/y1.o
272

>
address@hidden:/fix/t1/camm/debian/gcl/tmp/tmp/foo1/unixport$ 
address@hidden:/fix/t1/camm/debian/gcl/tmp/tmp/foo1/unixport$ 
=============================================================================  

Take care,
-- 
Camm Maguire                                            address@hidden
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah




reply via email to

[Prev in Thread] Current Thread [Next in Thread]