summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Benkard <code@mail.matthias.benkard.de>2008-03-19 12:44:39 +0100
committerMatthias Benkard <code@mail.matthias.benkard.de>2008-03-19 12:44:39 +0100
commit4b98e8d6f54256810b243afe9ea9abf5ad6d445b (patch)
treee81dfc256ec064af0e9140221fb4624fba8f51ff
parentf9180cd67505f16a8588a83da82f263bc395b347 (diff)
Move (OBJECT-GET-CLASS RECEIVER) from INVOKE-BY-NAME-SUPER-V to RETRIEVE-METHOD-SIGNATURE-INFO.
darcs-hash:1fd46a3dbdb3a5e2ec284be3255dd08b2b074414
-rw-r--r--JOURNAL28
-rw-r--r--Lisp/libobjcl.lisp4
-rw-r--r--Lisp/method-invocation.lisp22
3 files changed, 37 insertions, 17 deletions
diff --git a/JOURNAL b/JOURNAL
index 0ac5324..be51f1f 100644
--- a/JOURNAL
+++ b/JOURNAL
@@ -3,7 +3,7 @@
#title Objective-CL Development Diary
#desc News from the Objective-CL lab
-; Time-stamp: <2008-03-19 03:19:55 mulk>
+; Time-stamp: <2008-03-19 12:44:21 mulk>
;
; C-c i t insert-time-stamp
; C-c C-t muse-project-publish-this-file
@@ -18,6 +18,27 @@ Context: [[http://matthias.benkard.de/objective-cl][The Objective-CL Project]].
----
+* 2008-03-19, 12:38:56 CET
+
+** Evil Microoptimisation
+
+After moving **(object-get-class receiver)** from **invoke-by-name-super-v** to
+**retrieve-method-signature-info**:
+
+<example>
+Evaluation took:
+ 3.764 seconds of real time
+ 3.760235 seconds of user run time
+ 0.012001 seconds of system run time
+ [Run times include 0.096 seconds GC run time.]
+ 0 calls to %EVAL
+ 0 page faults and
+ 72,809,568 bytes consed.
+</example>
+
+Finally, an excuse to use the **&aux** lambda list keyword. Hooray!
+
+
* 2008-03-19, 03:03:50 CET
** Optimising INVOKE
@@ -78,6 +99,11 @@ Evaluation took:
That's gonna be it for now. I'll call it a night.
+(By the way, this is using CFFI 0.9.2. The Darcs version is
+significantly slower. Remember the CFFI speed hack I mentioned sometime
+way back in the beginning? It's needed for a Darcs CFFI, but I don't
+think it's needed for CFFI 0.9.2.)
+
* 2008-03-18, 15:31:30 CET
diff --git a/Lisp/libobjcl.lisp b/Lisp/libobjcl.lisp
index 38b244f..fab195e 100644
--- a/Lisp/libobjcl.lisp
+++ b/Lisp/libobjcl.lisp
@@ -731,10 +731,6 @@ separating parts by hyphens works nicely in all of the `:INVERT`,
(%objcl-object-is-meta-class (pointer obj)))
(defun object-get-class (obj)
- ;; OPTIMISE: Both find-objc-class-by-name and %objcl-class-name are
- ;; slow and mostly unneeded. We can simply retrieve classes by class
- ;; pointer if they have already been registered in a hash table
- ;; somewhere.
(intern-pointer-wrapper 'objective-c-class
:pointer (%objcl-object-get-class (pointer obj))))
diff --git a/Lisp/method-invocation.lisp b/Lisp/method-invocation.lisp
index c4ba3fc..29ad3c6 100644
--- a/Lisp/method-invocation.lisp
+++ b/Lisp/method-invocation.lisp
@@ -215,17 +215,13 @@ easier to use with __apply__.
;; TODO: Support varargs.
(let* ((selector (if (typep method-name 'selector)
method-name
- (find-selector method-name)))
- (class (object-get-class receiver)))
+ (find-selector method-name))))
(multiple-value-bind (argc
method-return-typestring
method-return-type
method-arg-typestrings
method-arg-types)
- (retrieve-method-signature-info class selector
- (if (object-is-class-p receiver)
- :class
- :instance))
+ (retrieve-method-signature-info receiver selector)
(assert (= argc (+ 2 (length args)))
(args)
"Wrong number of arguments (expected ~A, got ~A)."
@@ -296,17 +292,19 @@ easier to use with __apply__.
(define-cached-function retrieve-method-signature-info
- (class selector &optional (instance-or-class :instance))
- (cons (cffi:pointer-address (pointer-to class))
+ (receiver selector
+ &aux (class-ptr (%objcl-object-get-class (pointer receiver))))
+ (cons (cffi:pointer-address class-ptr)
(cffi:pointer-address (pointer-to selector)))
- (let* ((signature
- (objc-or (if (eq instance-or-class :instance)
+ (let* ((class (object-get-class receiver))
+ (signature
+ (objc-or (if (object-is-class-p receiver)
(primitive-invoke class
- "instanceMethodSignatureForSelector:"
+ "methodSignatureForSelector:"
'id
selector)
(primitive-invoke class
- "methodSignatureForSelector:"
+ "instanceMethodSignatureForSelector:"
'id
selector))
(error (make-condition 'message-not-understood