Array.st
branchjv
changeset 20344 152b525b5c63
parent 20244 20922299fd44
parent 20308 9110f117d260
child 20579 9add81aadb7a
--- a/Array.st	Thu Aug 25 11:28:17 2016 +0100
+++ b/Array.st	Wed Aug 31 22:45:49 2016 +0100
@@ -135,11 +135,11 @@
 
 	    nInstVars += nindexedinstvars;
 	    instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars);
-	    if (__CanDoQuickAlignedNew(instsize)) {     /* OBJECT ALLOCATION */
+	    if (__CanDoQuickNew(instsize)) {     /* OBJECT ALLOCATION */
 		/*
 		 * the most common case
 		 */
-		__qCheckedAlignedNew(newobj, instsize);
+		__qCheckedNew(newobj, instsize);
 	ok: ;
 		__InstPtr(newobj)->o_class = self;
 		__qSTORE(newobj, self);
@@ -567,59 +567,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);
+	__qNew(nObj, sz);        /* OBJECT ALLOCATION */
+	__UNPROTECT2__(self, something);
 
-        if (nObj) {
-            __InstPtr(nObj)->o_class = Array;
-            __qSTORE(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
@@ -636,10 +636,10 @@
 
     stop := self size.
     1 to:stop do:[:idx |
-        each := self at:idx.
-        each notNil ifTrue:[
-            aCollection add:each.
-        ].
+	each := self at:idx.
+	each notNil ifTrue:[
+	    aCollection add:each.
+	].
     ].
     ^ aCollection
 
@@ -1628,138 +1628,138 @@
     OBJ myClass;
 
     if (
-        (__ClassInstPtr((myClass = __qClass(self)))->c_ninstvars == __mkSmallInteger(0))
+	(__ClassInstPtr((myClass = __qClass(self)))->c_ninstvars == __mkSmallInteger(0))
      && __isNonNilObject(aCollection)
      && (((t = __qClass(aCollection)) == Array) || t == ImmutableArray || (t == myClass))
      && __bothSmallInteger(start, stop)
      && __isSmallInteger(repStart)
     ) {
-        startIndex = __intVal(start) - 1;
-        if (startIndex >= 0) {
-            nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
-            stopIndex = __intVal(stop) - 1;
-            count = stopIndex - startIndex + 1;
+	startIndex = __intVal(start) - 1;
+	if (startIndex >= 0) {
+	    nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
+	    stopIndex = __intVal(stop) - 1;
+	    count = stopIndex - startIndex + 1;
 
-            if ((count > 0) && (stopIndex < nIndex)) {
-                repStartIndex = __intVal(repStart) - 1;
-                if (repStartIndex >= 0) {
-                    repNIndex = __BYTES2OBJS__(__qSize(aCollection)-OHDR_SIZE);
-                    repStopIndex = repStartIndex + (stopIndex - startIndex);
-                    if (repStopIndex < repNIndex) {
-                        src = &(__InstPtr(aCollection)->i_instvars[repStartIndex]);
-                        dst = &(__InstPtr(self)->i_instvars[startIndex]);
-                        if (aCollection == self) {
-                            /*
-                             * no need to check stores if copying
-                             * from myself
-                             */
+	    if ((count > 0) && (stopIndex < nIndex)) {
+		repStartIndex = __intVal(repStart) - 1;
+		if (repStartIndex >= 0) {
+		    repNIndex = __BYTES2OBJS__(__qSize(aCollection)-OHDR_SIZE);
+		    repStopIndex = repStartIndex + (stopIndex - startIndex);
+		    if (repStopIndex < repNIndex) {
+			src = &(__InstPtr(aCollection)->i_instvars[repStartIndex]);
+			dst = &(__InstPtr(self)->i_instvars[startIndex]);
+			if (aCollection == self) {
+			    /*
+			     * no need to check stores if copying
+			     * from myself
+			     */
 
-                            if (src < dst) {
-                                /*
-                                 * take care of overlapping copy
-                                 * memcpy() is not smart enough by definition for overlkapping copies
-                                 * memmove() is!
-                                 */
+			    if (src < dst) {
+				/*
+				 * take care of overlapping copy
+				 * memcpy() is not smart enough by definition for overlkapping copies
+				 * memmove() is!
+				 */
 #if defined(FAST_MEMCPY)
-                                memmove(dst, src, __OBJS2BYTES__(count));
+				memmove(dst, src, __OBJS2BYTES__(count));
 #else
-                                /* must do a reverse copy */
-                                src += count;
-                                dst += count;
+				/* must do a reverse copy */
+				src += count;
+				dst += count;
 # ifdef __UNROLL_LOOPS__
-                                while (count > 8) {
-                                    dst[-1] = src[-1];
-                                    dst[-2] = src[-2];
-                                    dst[-3] = src[-3];
-                                    dst[-4] = src[-4];
-                                    dst[-5] = src[-5];
-                                    dst[-6] = src[-6];
-                                    dst[-7] = src[-7];
-                                    dst[-8] = src[-8];
-                                    dst -= 8; src -= 8;
-                                    count -= 8;
-                                }
+				while (count > 8) {
+				    dst[-1] = src[-1];
+				    dst[-2] = src[-2];
+				    dst[-3] = src[-3];
+				    dst[-4] = src[-4];
+				    dst[-5] = src[-5];
+				    dst[-6] = src[-6];
+				    dst[-7] = src[-7];
+				    dst[-8] = src[-8];
+				    dst -= 8; src -= 8;
+				    count -= 8;
+				}
 # endif // __UNROLL_LOOPS__
-                                while (count-- > 0) {
-                                    *--dst = *--src;
-                                }
+				while (count-- > 0) {
+				    *--dst = *--src;
+				}
 #endif // ! FAST_MEMCPY
-                                RETURN ( self );
-                            }
+				RETURN ( self );
+			    }
 #ifdef SOFTWARE_PIPELINE
-                            {
-                                /*
-                                 * the loop below fetches one longWord behind
-                                 * this should not be a problem
-                                 */
-                                OBJ t1 = src[0];
-                                count--;
-                                if (count) {
-                                    dst++; src++;
-                                    do {
-                                        dst[-1] = t1;
-                                        t1 = src[0];
-                                        src++;
-                                        dst++;
-                                    } while (count--);
-                                } else {
-                                    dst[0] = t1;
-                                }
-                            }
+			    {
+				/*
+				 * the loop below fetches one longWord behind
+				 * this should not be a problem
+				 */
+				OBJ t1 = src[0];
+				count--;
+				if (count) {
+				    dst++; src++;
+				    do {
+					dst[-1] = t1;
+					t1 = src[0];
+					src++;
+					dst++;
+				    } while (count--);
+				} else {
+				    dst[0] = t1;
+				}
+			    }
 #elif defined(bcopy4)
-                            count = __OBJS2BYTES__(count) / 4;
-                            bcopy4(src, dst, count);
+			    count = __OBJS2BYTES__(count) / 4;
+			    bcopy4(src, dst, count);
 #elif defined(FAST_MEMCPY)
-                            memmove(dst, src, __OBJS2BYTES__(count));
+			    memmove(dst, src, __OBJS2BYTES__(count));
 #else
 # if defined(__UNROLL_LOOPS__)
-                            while (count >= 8) {
-                                dst[0] = src[0];
-                                dst[1] = src[1];
-                                dst[2] = src[2];
-                                dst[3] = src[3];
-                                dst[4] = src[4];
-                                dst[5] = src[5];
-                                dst[6] = src[6];
-                                dst[7] = src[7];
-                                dst += 8; src += 8;
-                                count -= 8;
-                            }
+			    while (count >= 8) {
+				dst[0] = src[0];
+				dst[1] = src[1];
+				dst[2] = src[2];
+				dst[3] = src[3];
+				dst[4] = src[4];
+				dst[5] = src[5];
+				dst[6] = src[6];
+				dst[7] = src[7];
+				dst += 8; src += 8;
+				count -= 8;
+			    }
 # endif // __UNROLL_LOOPS__
-                            while (count--) {
-                                *dst++ = *src++;
-                            }
+			    while (count--) {
+				*dst++ = *src++;
+			    }
 #endif
-                        } else {
-                            // not copying into the same object
-                            REGISTER int spc = __qSpace(self);
+			} else {
+			    // not copying into the same object
+			    REGISTER int spc = __qSpace(self);
 #ifdef __UNROLL_LOOPS__
-                            while (count >= 8) {
-                                t = src[0]; dst[0] = t; __STORE_SPC(self, t, spc);
-                                t = src[1]; dst[1] = t; __STORE_SPC(self, t, spc);
-                                t = src[2]; dst[2] = t; __STORE_SPC(self, t, spc);
-                                t = src[3]; dst[3] = t; __STORE_SPC(self, t, spc);
-                                t = src[4]; dst[4] = t; __STORE_SPC(self, t, spc);
-                                t = src[5]; dst[5] = t; __STORE_SPC(self, t, spc);
-                                t = src[6]; dst[6] = t; __STORE_SPC(self, t, spc);
-                                t = src[7]; dst[7] = t; __STORE_SPC(self, t, spc);
-                                count -= 8; src += 8; dst += 8;
-                            }
+			    while (count >= 8) {
+				t = src[0]; dst[0] = t; __STORE_SPC(self, t, spc);
+				t = src[1]; dst[1] = t; __STORE_SPC(self, t, spc);
+				t = src[2]; dst[2] = t; __STORE_SPC(self, t, spc);
+				t = src[3]; dst[3] = t; __STORE_SPC(self, t, spc);
+				t = src[4]; dst[4] = t; __STORE_SPC(self, t, spc);
+				t = src[5]; dst[5] = t; __STORE_SPC(self, t, spc);
+				t = src[6]; dst[6] = t; __STORE_SPC(self, t, spc);
+				t = src[7]; dst[7] = t; __STORE_SPC(self, t, spc);
+				count -= 8; src += 8; dst += 8;
+			    }
 #endif
-                            while (count-- > 0) {
-                                *dst++ = t = *src++;
-                                __STORE_SPC(self, t, spc);
-                            }
-                        }
-                        RETURN ( self );
-                    }
-                }
-            }
+			    while (count-- > 0) {
+				*dst++ = t = *src++;
+				__STORE_SPC(self, t, spc);
+			    }
+			}
+			RETURN ( self );
+		    }
+		}
+	    }
 
-            if (count == 0) {
-                RETURN ( self );
-            }
-        }
+	    if (count == 0) {
+		RETURN ( self );
+	    }
+	}
     }
 %}.
     ^ super replaceFrom:start to:stop with:aCollection startingAt:repStart
@@ -1775,7 +1775,7 @@
     |cls|
 
     ((cls := self class) == Array or:[cls == ImmutableArray]) ifTrue:[
-        ^ '#'
+	^ '#'
     ].
     ^ super displayStringName.
 !