[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Optimization of slot access in default argument expressions
- To: iexist!att!ai.sri!slug@ai.sri.com
- Subject: Optimization of slot access in default argument expressions
- From: lgm@iexist.att.com
- Date: Tue, 8 Jan 1991 11:51:00 -0500
- Character-type-mappings: (1 0 (NIL 0) (NIL :BOLD NIL) "CPTFONTCB")
- Fonts: CPTFONT, CPTFONTCB
- Original-from: Larry Mayka <iexist!lgm>
I've noticed that Symbolics CLOS does not optimize slot access in
expressions given as default argument values. For example, consider the
following definitions:
(defclass 1class-a 0() (slot-a))
(defmethod 1method-a 0((self class-a)
&aux (var (slot-value self 'slot-a)))
var
)
(defmethod 1method-b 0((self class-a))
(let ((var (slot-value self 'slot-a)))
var
)
)
A disassembly of (METHOD METHOD-A (CLASS-A)) gives:
0 ENTRY: 3 REQUIRED, 0 OPTIONAL
1 PUSH-LOCAL FP|0 ;SELF
2 PUSH-CONSTANT 'SLOT-A
3 CALL-2-STACK #'SLOT-VALUE ;creating VAR(FP|3)
4 RETURN-STACK
A disassembly of (METHOD METHOD-B (CLASS-A)) gives:
0 ENTRY: 3 REQUIRED, 0 OPTIONAL
1 BUILTIN PUSH-INSTANCE-VARIABLE STACK 3 ;SLOT SELF SLOT-A creating VAR(FP|3)
2 RETURN-STACK
Notice that when SLOT-A is accessed in the default value expression for
VAR, the Symbolics compiler generates an actual call to the SLOT-VALUE
function; whereas when SLOT-A is accessed within the method body, the
compiler generates a single PUSH-INSTANCE-VARIABLE instruction.
Is this difference somehow required by the ANSI Common Lisp spec, or is
this simply a minor case that Symbolics has not yet gotten around to
optimizing?
Lawrence G. Mayka
AT&T Bell Laboratories
lgm@iexist.att.com
Standard disclaimer.