Have to call __STORE(), when assigning class.
authorStefan Vogel <sv@exept.de>
Thu, 29 Jan 2004 14:21:27 +0100
changeset 7859 837f47feba96
parent 7858 65d77eb25fda
child 7860 d08a47772aa1
Have to call __STORE(), when assigning class. (Just to be prepared, when class or subclass appears in new space, which does not happen normally).
Array.st
ByteArray.st
Fraction.st
Point.st
Rectangle.st
--- a/Array.st	Thu Jan 29 14:18:50 2004 +0100
+++ b/Array.st	Thu Jan 29 14:21:27 2004 +0100
@@ -448,59 +448,59 @@
     REGISTER int spc;
 
     if (__qClass(self) == Array) {
-	sz = __qSize(self) + sizeof(OBJ);
-	__PROTECT2__(something, self);
-	__qAlignedNew(nObj, sz);        /* OBJECT ALLOCATION */
-	__UNPROTECT2__(self, something);
+        sz = __qSize(self) + sizeof(OBJ);
+        __PROTECT2__(something, self);
+        __qAlignedNew(nObj, sz);        /* OBJECT ALLOCATION */
+        __UNPROTECT2__(self, something);
 
-	if (nObj) {
-	    __InstPtr(nObj)->o_class = Array;
-	    __STORE(nObj, Array);
+        if (nObj) {
+            __InstPtr(nObj)->o_class = Array;
+            __qSTORE(nObj, Array);
 
-	    nIndex = __BYTES2OBJS__(sz - OHDR_SIZE - sizeof(OBJ));
-	    /* 
-	     * sorry: 
-	     *   cannot use bcopy, since we must take care of stores ... 
-	     *   could check for: notRemembered + inOld + notLifoRem
-	     *                  + not incrGCRunning
-	     * but: copyWith is not heavily used by real programmers ...
-	     */
-	    spc = __qSpace(nObj);
-	    srcP = __arrayVal(self);
-	    dstP = __arrayVal(nObj);
+            nIndex = __BYTES2OBJS__(sz - OHDR_SIZE - sizeof(OBJ));
+            /* 
+             * sorry: 
+             *   cannot use bcopy, since we must take care of stores ... 
+             *   could check for: notRemembered + inOld + notLifoRem
+             *                  + not incrGCRunning
+             * but: copyWith is not heavily used by real programmers ...
+             */
+            spc = __qSpace(nObj);
+            srcP = __arrayVal(self);
+            dstP = __arrayVal(nObj);
 
 #ifdef UNROLL_LOOPS
-	    while (nIndex >= 4) {
-		OBJ element;
+            while (nIndex >= 4) {
+                OBJ element;
 
-		element = srcP[0];
-		dstP[0] = element;
-		__STORE_SPC(nObj, element, spc);
-		element = srcP[1];
-		dstP[1] = element;
-		__STORE_SPC(nObj, element, spc);
-		element = srcP[2];
-		dstP[2] = element;
-		__STORE_SPC(nObj, element, spc);
-		element = srcP[3];
-		dstP[3] = element;
-		__STORE_SPC(nObj, element, spc);
-		srcP += 4;
-		dstP += 4;
-		nIndex -= 4;
-	    }
+                element = srcP[0];
+                dstP[0] = element;
+                __STORE_SPC(nObj, element, spc);
+                element = srcP[1];
+                dstP[1] = element;
+                __STORE_SPC(nObj, element, spc);
+                element = srcP[2];
+                dstP[2] = element;
+                __STORE_SPC(nObj, element, spc);
+                element = srcP[3];
+                dstP[3] = element;
+                __STORE_SPC(nObj, element, spc);
+                srcP += 4;
+                dstP += 4;
+                nIndex -= 4;
+            }
 #endif
-	    while (nIndex--) {
-		OBJ element;
+            while (nIndex--) {
+                OBJ element;
 
-		element = *srcP++;
-		*dstP++ = element;
-		__STORE_SPC(nObj, element, spc);
-	    }
-	    *dstP = something;
-	    __STORE_SPC(nObj, something, spc);
-	    RETURN ( nObj );
-	}
+                element = *srcP++;
+                *dstP++ = element;
+                __STORE_SPC(nObj, element, spc);
+            }
+            *dstP = something;
+            __STORE_SPC(nObj, something, spc);
+            RETURN ( nObj );
+        }
     }
 %}.
     ^ super copyWith:something
@@ -2429,5 +2429,5 @@
 !Array class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.131 2003-09-03 16:00:04 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.132 2004-01-29 13:20:52 stefan Exp $'
 ! !
--- a/ByteArray.st	Thu Jan 29 14:18:50 2004 +0100
+++ b/ByteArray.st	Thu Jan 29 14:21:27 2004 +0100
@@ -230,6 +230,7 @@
                 if (__CanDoQuickNew(instsize)) {        /* OBJECT ALLOCATION */
                     __qCheckedNew(newobj, instsize);
                     __InstPtr(newobj)->o_class = self;
+                    __qSTORE(newobj, self);
                     RETURN (newobj );
                 }
             }
@@ -1303,78 +1304,79 @@
 
     if (__isByteArray(self)
      && __bothSmallInteger(start, stop)) {
-	len = __byteArraySize(self);
-	index1 = __intVal(start);
-	index2 = __intVal(stop);
-
-	if ((index1 <= index2) && (index1 > 0)) {
-	    if (index2 <= len) {
-		count = index2 - index1 + 1;
-		__PROTECT_CONTEXT__
-		sz = OHDR_SIZE + count;
-		__qNew(newByteArray, sz);       /* OBJECT ALLOCATION */
-		__UNPROTECT_CONTEXT__
-		if (newByteArray != nil) {
-		    __InstPtr(newByteArray)->o_class = ByteArray;
-		    dstp = __ByteArrayInstPtr(newByteArray)->ba_element;
-		    srcp = __ByteArrayInstPtr(self)->ba_element + index1 - 1;
+        len = __byteArraySize(self);
+        index1 = __intVal(start);
+        index2 = __intVal(stop);
+
+        if ((index1 <= index2) && (index1 > 0)) {
+            if (index2 <= len) {
+                count = index2 - index1 + 1;
+                __PROTECT_CONTEXT__
+                sz = OHDR_SIZE + count;
+                __qNew(newByteArray, sz);       /* OBJECT ALLOCATION */
+                __UNPROTECT_CONTEXT__
+                if (newByteArray != nil) {
+                    __InstPtr(newByteArray)->o_class = ByteArray;
+                    __qSTORE(newByteArray, ByteArray);
+                    dstp = __ByteArrayInstPtr(newByteArray)->ba_element;
+                    srcp = __ByteArrayInstPtr(self)->ba_element + index1 - 1;
 
 #ifdef bcopy4
-		    if (((unsigned INT)srcp & 3) == ((unsigned INT)dstp & 3)) {
-			int nW;
-
-			/* copy unaligned part */
-			while (count && (((unsigned INT)srcp & 3) != 0)) {
-			    *dstp++ = *srcp++;
-			    count--;
-			}
-			if (count) {
-			    /* copy aligned part */
-			    nW = count >> 2;
-			    if (count & 3) {
-				nW++;
-			    }
-			    bcopy4(srcp, dstp, nW);
-			}
-			RETURN ( newByteArray );
-		    }
+                    if (((unsigned INT)srcp & 3) == ((unsigned INT)dstp & 3)) {
+                        int nW;
+
+                        /* copy unaligned part */
+                        while (count && (((unsigned INT)srcp & 3) != 0)) {
+                            *dstp++ = *srcp++;
+                            count--;
+                        }
+                        if (count) {
+                            /* copy aligned part */
+                            nW = count >> 2;
+                            if (count & 3) {
+                                nW++;
+                            }
+                            bcopy4(srcp, dstp, nW);
+                        }
+                        RETURN ( newByteArray );
+                    }
 #endif /* bcopy4 */
 #ifdef alpha64
-		    if (((unsigned INT)srcp & 7) == ((unsigned INT)dstp & 7)) {
-			int nW;
-
-			/* copy unaligned part */
-			while (count && (((unsigned INT)srcp & 7) != 0)) {
-			    *dstp++ = *srcp++;
-			    count--;
-			}
-			/* copy aligned part */
-			while (count >= 8) {
-			    ((unsigned INT *)dstp)[0] = ((unsigned INT *)srcp)[0];
-			    dstp += 8;
-			    srcp += 8;
-			    count -= 8;
-			}
-			/* copy remaining part */
-			while (count) {
-			    *dstp++ = *srcp++;
-			    count--;
-			}
-			RETURN ( newByteArray );
-		    }
+                    if (((unsigned INT)srcp & 7) == ((unsigned INT)dstp & 7)) {
+                        int nW;
+
+                        /* copy unaligned part */
+                        while (count && (((unsigned INT)srcp & 7) != 0)) {
+                            *dstp++ = *srcp++;
+                            count--;
+                        }
+                        /* copy aligned part */
+                        while (count >= 8) {
+                            ((unsigned INT *)dstp)[0] = ((unsigned INT *)srcp)[0];
+                            dstp += 8;
+                            srcp += 8;
+                            count -= 8;
+                        }
+                        /* copy remaining part */
+                        while (count) {
+                            *dstp++ = *srcp++;
+                            count--;
+                        }
+                        RETURN ( newByteArray );
+                    }
 #endif /* bcopy4 */
 
 #ifdef FAST_MEMCPY
-		    bcopy(srcp, dstp, count);
+                    bcopy(srcp, dstp, count);
 #else
-		    while (count--) {
-			*dstp++ = *srcp++;
-		    }
+                    while (count--) {
+                        *dstp++ = *srcp++;
+                    }
 #endif
-		    RETURN ( newByteArray );
-		}
-	    }
-	}
+                    RETURN ( newByteArray );
+                }
+            }
+        }
     }
 %}.
     "
@@ -3310,5 +3312,5 @@
 !ByteArray class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ByteArray.st,v 1.160 2004-01-07 12:50:57 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ByteArray.st,v 1.161 2004-01-29 13:21:27 stefan Exp $'
 ! !
--- a/Fraction.st	Thu Jan 29 14:18:50 2004 +0100
+++ b/Fraction.st	Thu Jan 29 14:21:27 2004 +0100
@@ -95,6 +95,7 @@
 
                 __qCheckedAlignedNew(newFraction, sizeof(struct __Fraction));
                 __InstPtr(newFraction)->o_class = self;
+                __qSTORE(newFraction, self);
                 iDen = __intVal(den);
                 if (iDen != 0) {
                     if (iDen < 0) {
@@ -1094,7 +1095,7 @@
 !Fraction class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Fraction.st,v 1.68 2003-10-30 16:15:01 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Fraction.st,v 1.69 2004-01-29 13:20:14 stefan Exp $'
 ! !
 
 Fraction initialize!
--- a/Point.st	Thu Jan 29 14:18:50 2004 +0100
+++ b/Point.st	Thu Jan 29 14:21:27 2004 +0100
@@ -187,21 +187,22 @@
      * claus: I am no longer certain, if this primitive is worth the effort
      */
     if (__CanDoQuickNew(sizeof(struct __Point))) {      /* OBJECT ALLOCATION */
-	if (self == @global(Point)) {
-	    OBJ newPoint;
-	    int spc;
+        if (self == @global(Point)) {
+            OBJ newPoint;
+            int spc;
 
-	    __qCheckedAlignedNew(newPoint, sizeof(struct __Point));
-	    __InstPtr(newPoint)->o_class = self;
-	    __PointInstPtr(newPoint)->p_x = newX;
-	    __PointInstPtr(newPoint)->p_y = newY;
-	    if (! __bothSmallInteger(newX, newY)) {
-		spc = __qSpace(newPoint);
-		__STORE_SPC(newPoint, newX, spc);
-		__STORE_SPC(newPoint, newY, spc);
-	    }
-	    RETURN ( newPoint );
-	}
+            __qCheckedAlignedNew(newPoint, sizeof(struct __Point));
+            __InstPtr(newPoint)->o_class = self;
+            __qSTORE(newPoint, self);
+            __PointInstPtr(newPoint)->p_x = newX;
+            __PointInstPtr(newPoint)->p_y = newY;
+            if (! __bothSmallInteger(newX, newY)) {
+                spc = __qSpace(newPoint);
+                __STORE_SPC(newPoint, newX, spc);
+                __STORE_SPC(newPoint, newY, spc);
+            }
+            RETURN ( newPoint );
+        }
     }
 %}.
     ^ (self basicNew) x:newX y:newY
@@ -1152,7 +1153,7 @@
 !Point class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Point.st,v 1.61 2003-07-10 11:54:27 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Point.st,v 1.62 2004-01-29 13:20:28 stefan Exp $'
 ! !
 
 Point initialize!
--- a/Rectangle.st	Thu Jan 29 14:18:50 2004 +0100
+++ b/Rectangle.st	Thu Jan 29 14:21:27 2004 +0100
@@ -146,30 +146,32 @@
     OBJ t;
     int spc;
 
-    if (__CanDoQuickNew(OHDR_SIZE + 4*sizeof(OBJ))) {	/* OBJECT ALLOCATION */
-	if (self == Rectangle) {
-	    /*
-	     * short cut - rectangles are created so often ...
-	     */
-	    __qCheckedAlignedNew(newRect, OHDR_SIZE + 4*sizeof(OBJ));
+    if (__CanDoQuickNew(OHDR_SIZE + 4*sizeof(OBJ))) {   /* OBJECT ALLOCATION */
+        if (self == Rectangle) {
+            /*
+             * short cut - rectangles are created so often ...
+             */
+            __qCheckedAlignedNew(newRect, OHDR_SIZE + 4*sizeof(OBJ));
+
+            __InstPtr(newRect)->o_class = Rectangle;
+            __qSTORE(newRect, Rectangle);
 
-	    __InstPtr(newRect)->o_class = Rectangle;
-	    __InstPtr(newRect)->i_instvars[0] = left;
-	    __InstPtr(newRect)->i_instvars[1] = top;
-	    __InstPtr(newRect)->i_instvars[2] = w;
-	    __InstPtr(newRect)->i_instvars[3] = h;
+            __InstPtr(newRect)->i_instvars[0] = left;
+            __InstPtr(newRect)->i_instvars[1] = top;
+            __InstPtr(newRect)->i_instvars[2] = w;
+            __InstPtr(newRect)->i_instvars[3] = h;
 
-	    if (! (__bothSmallInteger(left, top) && 
-		   __bothSmallInteger(w, h))) {
-		spc = __qSpace(newRect);
-		__STORE_SPC(newRect, left, spc);
-		__STORE_SPC(newRect, top, spc);
-		__STORE_SPC(newRect, w, spc);
-		__STORE_SPC(newRect, h, spc);
-	    }
+            if (! (__bothSmallInteger(left, top) && 
+                   __bothSmallInteger(w, h))) {
+                spc = __qSpace(newRect);
+                __STORE_SPC(newRect, left, spc);
+                __STORE_SPC(newRect, top, spc);
+                __STORE_SPC(newRect, w, spc);
+                __STORE_SPC(newRect, h, spc);
+            }
 
-	    RETURN ( newRect );
-	}
+            RETURN ( newRect );
+        }
     }
 %}.
     ^ (self basicNew) left:left top:top width:w height:h
@@ -208,34 +210,35 @@
     OBJ t;
     int spc;
 
-    if (__CanDoQuickNew(OHDR_SIZE + 4*sizeof(OBJ))) {	/* OBJECT ALLOCATION */
+    if (__CanDoQuickNew(OHDR_SIZE + 4*sizeof(OBJ))) {   /* OBJECT ALLOCATION */
         /*
-	 * short cut - rectangles are created so often ...
-	 */
-	if (self == Rectangle) {
-	    if (__isPoint(origin) && __isPoint(extent)) {
-		__qCheckedAlignedNew(newRect, OHDR_SIZE + 4*sizeof(OBJ));
-		__InstPtr(newRect)->o_class = Rectangle;
-		spc = __qSpace(newRect);
+         * short cut - rectangles are created so often ...
+         */
+        if (self == Rectangle) {
+            if (__isPoint(origin) && __isPoint(extent)) {
+                __qCheckedAlignedNew(newRect, OHDR_SIZE + 4*sizeof(OBJ));
+                __InstPtr(newRect)->o_class = Rectangle;
+                __qSTORE(newRect, Rectangle);
+                spc = __qSpace(newRect);
 
-		t = __PointInstPtr(origin)->p_x;
-		__InstPtr(newRect)->i_instvars[0] = t;
-		__STORE_SPC(newRect, t, spc);
+                t = __PointInstPtr(origin)->p_x;
+                __InstPtr(newRect)->i_instvars[0] = t;
+                __STORE_SPC(newRect, t, spc);
 
-		t = __PointInstPtr(origin)->p_y;
-		__InstPtr(newRect)->i_instvars[1] = t;
-		__STORE_SPC(newRect, t, spc);
+                t = __PointInstPtr(origin)->p_y;
+                __InstPtr(newRect)->i_instvars[1] = t;
+                __STORE_SPC(newRect, t, spc);
 
-		t = __PointInstPtr(extent)->p_x;
-		__InstPtr(newRect)->i_instvars[2] = t;
-		__STORE_SPC(newRect, t, spc);
+                t = __PointInstPtr(extent)->p_x;
+                __InstPtr(newRect)->i_instvars[2] = t;
+                __STORE_SPC(newRect, t, spc);
 
-		t = __PointInstPtr(extent)->p_y;
-		__InstPtr(newRect)->i_instvars[3] = t;
-		__STORE_SPC(newRect, t, spc);
-		RETURN ( newRect );
-	    }
-	}
+                t = __PointInstPtr(extent)->p_y;
+                __InstPtr(newRect)->i_instvars[3] = t;
+                __STORE_SPC(newRect, t, spc);
+                RETURN ( newRect );
+            }
+        }
     }
 %}.
     ^ (self basicNew) origin:origin extent:extent
@@ -1774,5 +1777,5 @@
 !Rectangle class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Rectangle.st,v 1.77 2003-08-29 17:32:04 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Rectangle.st,v 1.78 2004-01-29 13:20:00 stefan Exp $'
 ! !