From: Stas Boukarev Date: Wed, 5 Jun 2013 19:28:44 +0000 (+0400) Subject: Factor out read-var-integer into a function. X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=09a00b3120e7dd6d040cf70fbaaa1af32b890ee3;p=sbcl.git Factor out read-var-integer into a function. read-var-integer macro is used quite a number of times, expand the macro into a SETF, which calls %read-var-integer, which does actual reading. Reduces the core size by 65KB on x86-64. --- diff --git a/src/code/debug-var-io.lisp b/src/code/debug-var-io.lisp index 2d489d2..94a59ce 100644 --- a/src/code/debug-var-io.lisp +++ b/src/code/debug-var-io.lisp @@ -21,28 +21,29 @@ ;;; Given a byte vector VEC and an index variable INDEX, read a ;;; variable length integer and advance index. -;;; -;;; FIXME: This is called O(20) times. It should be reimplemented -;;; with much of its logic in a single service function which can -;;; be called by the macro expansion: -;;; `(SETF ,INDEX (%READ-VAR-INTEGER ,VEC ,INDEX)). +(defun %read-var-integer (vec index) + (let ((val (aref vec index))) + (cond ((<= val 253) + (values val (1+ index))) + ((= val 254) + (values + (logior (aref vec (+ index 1)) + (ash (aref vec (+ index 2)) 8)) + (+ index 3))) + (t + (values + (logior (aref vec (+ index 1)) + (ash (aref vec (+ index 2)) 8) + (ash (aref vec (+ index 3)) 16) + (ash (aref vec (+ index 4)) 24)) + (+ index 5)))))) + (defmacro read-var-integer (vec index) - (once-only ((val `(aref ,vec ,index))) - `(cond ((<= ,val 253) - (incf ,index) - ,val) - ((= ,val 254) - (prog1 - (logior (aref ,vec (+ ,index 1)) - (ash (aref ,vec (+ ,index 2)) 8)) - (incf ,index 3))) - (t - (prog1 - (logior (aref ,vec (+ ,index 1)) - (ash (aref ,vec (+ ,index 2)) 8) - (ash (aref ,vec (+ ,index 3)) 16) - (ash (aref ,vec (+ ,index 4)) 24)) - (incf ,index 5)))))) + (once-only ((vec vec)) + `(multiple-value-bind (vector new-index) + (%read-var-integer ,vec ,index) + (setf ,index new-index) + vector))) ;;; Take an adjustable vector VEC with a fill pointer and push the ;;; variable length representation of INT on the end. diff --git a/src/compiler/target-disassem.lisp b/src/compiler/target-disassem.lisp index 4723c64..aeaa79e 100644 --- a/src/compiler/target-disassem.lisp +++ b/src/compiler/target-disassem.lisp @@ -2012,7 +2012,7 @@ (car (svref sb!c:*backend-internal-errors* errnum))) (defun get-sc-name (sc-offs) - (sb!c::location-print-name + (sb!c:location-print-name ;; FIXME: This seems like an awful lot of computation just to get a name. ;; Couldn't we just use lookup in *BACKEND-SC-NAMES*, without having to cons ;; up a new object?