added a 2-slot cache to #perform: / #perform:with:* methods.
authorClaus Gittinger <cg@exept.de>
Wed, 10 Jul 1996 12:12:48 +0200
changeset 1533 179ce527e383
parent 1532 6b4c38b9090c
child 1534 3aac2f9ef96c
added a 2-slot cache to #perform: / #perform:with:* methods. Obsolete ifdefs cleaned up.
Object.st
--- a/Object.st	Tue Jul 09 10:20:50 1996 +0200
+++ b/Object.st	Wed Jul 10 12:12:48 1996 +0200
@@ -2992,45 +2992,37 @@
 perform:aSelector
     "send the message aSelector to the receiver"
 
-%{  /* NOCONTEXT */
-
-    OBJ l;
-#ifdef PRE_2_11
-    static struct inlineCache ilc = _ILC0;
-    struct inlineCache lilc = _DUMMYILC0;
-#else
-    static struct inlineCache ilc = _DUMMYILC0;
-    struct inlineCache lilc;
-#endif
-    static OBJ lastSelector = nil;
-
-#if defined(THIS_CONTEXT)
-    /*
-     * must set lineno in sender by hand here ... (because of NOCONTEXT)
-     */
-    if ((l = __ILC_LNO_AS_OBJ(__pilc)) != __MKSMALLINT(0)) {
-        _ContextInstPtr(__thisContext)->c_lineno = l;
+%{
+    struct inlineCache *pIlc;
+    static struct inlineCache ilc_0 = _DUMMYILC0;
+    static struct inlineCache ilc_1 = _DUMMYILC0;
+    static OBJ last_0 = nil;
+    static OBJ last_1 = nil;
+    static flip = 0;
+
+    if (aSelector != last_0) {
+        if (aSelector != last_1) {
+            if (flip) {
+                pIlc = &ilc_0;
+                flip = 0;
+                last_0 = aSelector;
+            } else {
+                pIlc = &ilc_1;
+                flip = 1;
+                last_1 = aSelector;
+            }
+            pIlc->ilc_func = __SEND0ADDR__;
+            if (pIlc->ilc_poly) {
+                __flushPolyCache(pIlc->ilc_poly);
+                pIlc->ilc_poly = 0;
+            }
+        } else {
+            pIlc = &ilc_1;
+        }
+    } else {
+        pIlc = &ilc_0;
     }
-#endif
-
-#ifdef PRE_2_11
-    if (aSelector != lastSelector) {
-        ilc.ilc_func = __SEND0ADDR__;
-        lastSelector = aSelector;
-    }
-#else
-    lilc = ilc;
-#endif
-
-#if !defined(TRADITIONAL_STACK_FRAME)
-    lilc.ilc_lineNo = __pilc->ilc_lineNo;
-#endif
-
-#ifdef PRE_2_11
-    RETURN ( (*ilc.ilc_func)(self, aSelector, CON_COMMA nil, &ilc) );
-#else
-    RETURN ( (*ilc.ilc_func)(self, aSelector, CON_COMMA nil, &lilc) );
-#endif
+    RETURN ( (*(pIlc->ilc_func))(self, aSelector, CON_COMMA nil, pIlc) );
 %}
 !
 
@@ -3163,152 +3155,115 @@
 perform:aSelector with:anObject
     "send the one-arg-message aSelector to the receiver"
 
-%{  /* NOCONTEXT */
-
-    OBJ l;
-#ifdef PRE_2_11
-    static struct inlineCache ilc = _ILC1;
-    struct inlineCache lilc = _DUMMYILC1;
-    static OBJ lastSelector = nil;
-
-# if defined(THIS_CONTEXT)
-    /*
-     * must set lineno in sender by hand here ... (because of NOCONTEXT)
-     */
-    if ((l = __ILC_LNO_AS_OBJ(__pilc)) != __MKSMALLINT(0)) {
-        _ContextInstPtr(__thisContext)->c_lineno = l;
-    }
-# endif
-
-    if (aSelector != lastSelector) {
-        ilc.ilc_func = __SEND1ADDR__;
-        lastSelector = aSelector;
-    }
-    ilc.ilc_lineNo = __pilc->ilc_lineNo;
-    RETURN ( (*ilc.ilc_func)(self, aSelector, CON_COMMA nil, &ilc, anObject) );
-#else
-    static struct inlineCache ilc = _DUMMYILC1;
-    struct inlineCache lilc;
-
-# if defined(THIS_CONTEXT)
-    /*
-     * must set lineno in sender by hand here ... (because of NOCONTEXT)
-     */
-    if ((l = __ILC_LNO_AS_OBJ(__pilc)) != __MKSMALLINT(0)) {
-        _ContextInstPtr(__thisContext)->c_lineno = l;
-    }
-# endif
-
-    lilc = ilc;
-    lilc.ilc_lineNo = __pilc->ilc_lineNo;
-    RETURN ( (*ilc.ilc_func)(self, aSelector, CON_COMMA nil, &lilc, anObject) );
-#endif
-%}
-!
-
-perform:aSelector with:firstObject with:secondObject
-    "send the two-arg-message aSelector to the receiver"
-
-%{  /* NOCONTEXT */
-
-    OBJ l;
-#ifdef PRE_2_11
-    static struct inlineCache ilc = _ILC2;
-    struct inlineCache lilc = _DUMMYILC2;
-#else
-    static struct inlineCache ilc = _DUMMYILC2;
-    struct inlineCache lilc;
-#endif
-    static OBJ lastSelector = nil;
-
-#if defined(THIS_CONTEXT)
-    /*
-     * must set lineno in sender by hand here ... (because of NOCONTEXT)
-     */
-    if ((l = __ILC_LNO_AS_OBJ(__pilc)) != __MKSMALLINT(0)) {
-        _ContextInstPtr(__thisContext)->c_lineno = l;
-    }
-#endif
-
-#ifdef PRE_2_11
-    if (aSelector != lastSelector) {
-        ilc.ilc_func = __SEND2ADDR__;
-        lastSelector = aSelector;
+%{
+    struct inlineCache *pIlc;
+    static struct inlineCache ilc_0 = _DUMMYILC1;
+    static struct inlineCache ilc_1 = _DUMMYILC1;
+    static OBJ last_0 = nil;
+    static OBJ last_1 = nil;
+    static flip = 0;
+
+    if (aSelector != last_0) {
+        if (aSelector != last_1) {
+            if (flip) {
+                pIlc = &ilc_0;
+                flip = 0;
+                last_0 = aSelector;
+            } else {
+                pIlc = &ilc_1;
+                flip = 1;
+                last_1 = aSelector;
+            }
+            pIlc->ilc_func = __SEND1ADDR__;
+            if (pIlc->ilc_poly) {
+                __flushPolyCache(pIlc->ilc_poly);
+                pIlc->ilc_poly = 0;
+            }
+        } else {
+            pIlc = &ilc_1;
+        }
+    } else {
+        pIlc = &ilc_0;
     }
-#else
-    lilc = ilc;
-#endif
-
-#if !defined(TRADITIONAL_STACK_FRAME)
-    lilc.ilc_lineNo = __pilc->ilc_lineNo;
-#endif
-
-#if defined(xxTHIS_CONTEXT)
-# ifdef PRE_2_11
-    ilc.ilc_lineNo = __pilc->ilc_lineNo;
-# else
-    lilc.ilc_lineNo = __pilc->ilc_lineNo;
-# endif
-#endif
-
-# ifdef PRE_2_11
-    RETURN ((*ilc.ilc_func)(self, aSelector, CON_COMMA nil, &ilc, firstObject, secondObject));
-# else
-    RETURN ((*ilc.ilc_func)(self, aSelector, CON_COMMA nil, &lilc, firstObject, secondObject));
-# endif
+    RETURN ( (*(pIlc->ilc_func))(self, aSelector, CON_COMMA nil, pIlc, anObject) );
 %}
-!
-
-perform:aSelector with:firstObject with:secondObject with:thirdObject
+
+!
+
+perform:aSelector with:arg1 with:arg2
+    "send the two-arg-message aSelector to the receiver"
+
+%{
+    struct inlineCache *pIlc;
+    static struct inlineCache ilc_0 = _DUMMYILC2;
+    static struct inlineCache ilc_1 = _DUMMYILC2;
+    static OBJ last_0 = nil;
+    static OBJ last_1 = nil;
+    static flip = 0;
+
+    if (aSelector != last_0) {
+        if (aSelector != last_1) {
+            if (flip) {
+                pIlc = &ilc_0;
+                flip = 0;
+                last_0 = aSelector;
+            } else {
+                pIlc = &ilc_1;
+                flip = 1;
+                last_1 = aSelector;
+            }
+            pIlc->ilc_func = __SEND2ADDR__;
+            if (pIlc->ilc_poly) {
+                __flushPolyCache(pIlc->ilc_poly);
+                pIlc->ilc_poly = 0;
+            }
+        } else {
+            pIlc = &ilc_1;
+        }
+    } else {
+        pIlc = &ilc_0;
+    }
+    RETURN ( (*(pIlc->ilc_func))(self, aSelector, CON_COMMA nil, pIlc, arg1, arg2) );
+%}
+
+!
+
+perform:aSelector with:arg1 with:arg2 with:arg3
     "send the three-arg-message aSelector to the receiver"
 
-%{  /* NOCONTEXT */
-
-    OBJ l;
-#ifdef PRE_2_11
-    static struct inlineCache ilc = _ILC3;
-    struct inlineCache lilc = _DUMMYILC3;
-#else
-    static struct inlineCache ilc = _DUMMYILC3;
-    struct inlineCache lilc;
-#endif
-    static OBJ lastSelector = nil;
-
-#if defined(THIS_CONTEXT)
-    /*
-     * must set lineno in sender by hand here ... (because of NOCONTEXT)
-     */
-    if ((l = __ILC_LNO_AS_OBJ(__pilc)) != __MKSMALLINT(0)) {
-        _ContextInstPtr(__thisContext)->c_lineno = l;
+%{
+    struct inlineCache *pIlc;
+    static struct inlineCache ilc_0 = _DUMMYILC3;
+    static struct inlineCache ilc_1 = _DUMMYILC3;
+    static OBJ last_0 = nil;
+    static OBJ last_1 = nil;
+    static flip = 0;
+
+    if (aSelector != last_0) {
+        if (aSelector != last_1) {
+            if (flip) {
+                pIlc = &ilc_0;
+                flip = 0;
+                last_0 = aSelector;
+            } else {
+                pIlc = &ilc_1;
+                flip = 1;
+                last_1 = aSelector;
+            }
+            pIlc->ilc_func = __SEND3ADDR__;
+            if (pIlc->ilc_poly) {
+                __flushPolyCache(pIlc->ilc_poly);
+                pIlc->ilc_poly = 0;
+            }
+        } else {
+            pIlc = &ilc_1;
+        }
+    } else {
+        pIlc = &ilc_0;
     }
-#endif
-
-#ifdef PRE_2_11
-    if (aSelector != lastSelector) {
-        ilc.ilc_func = __SEND3ADDR__;
-        lastSelector = aSelector;
-    }
-#else
-    lilc = ilc;
-# if !defined(TRADITIONAL_STACK_FRAME)
-    lilc.ilc_lineNo = __pilc->ilc_lineNo;
-# endif
-#endif
-
-#if defined(xxTHIS_CONTEXT)
-# ifdef PRE_2_11
-    ilc.ilc_lineNo = __pilc->ilc_lineNo;
-# else
-    lilc.ilc_lineNo = __pilc->ilc_lineNo;
-# endif
-#endif
-
-# ifdef PRE_2_11
-    RETURN ((*ilc.ilc_func)(self, aSelector, CON_COMMA nil, &ilc, firstObject, secondObject, thirdObject));
-# else
-    RETURN ((*ilc.ilc_func)(self, aSelector, CON_COMMA nil, &lilc, firstObject, secondObject, thirdObject));
-# endif
+    RETURN ( (*(pIlc->ilc_func))(self, aSelector, CON_COMMA nil, pIlc, arg1, arg2, arg3) );
 %}
+
 !
 
 perform:aSelector withArguments:argArray
@@ -5226,6 +5181,6 @@
 !Object  class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Object.st,v 1.126 1996-07-06 21:55:45 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Object.st,v 1.127 1996-07-10 10:12:48 cg Exp $'
 ! !
 Object initialize!