diff -r 5902784fe3b6 -r fdfc6c64bf60 Array.st --- a/Array.st Mon Sep 15 22:04:19 1997 +0200 +++ b/Array.st Mon Sep 15 22:17:24 1997 +0200 @@ -107,7 +107,7 @@ nInstVars += nindexedinstvars; instsize = OHDR_SIZE + __OBJS2BYTES__(nInstVars); - if (__CanDoQuickAlignedNew(instsize)) { /* OBJECT ALLOCATION */ + if (__CanDoQuickAlignedNew(instsize)) { /* OBJECT ALLOCATION */ /* * the most common case */ @@ -452,7 +452,7 @@ if (__qClass(self) == Array) { sz = __qSize(self) + sizeof(OBJ); __PROTECT2__(something, self); - __qAlignedNew(nObj, sz); /* OBJECT ALLOCATION */ + __qAlignedNew(nObj, sz); /* OBJECT ALLOCATION */ __UNPROTECT2__(self, something); if (nObj) { @@ -546,14 +546,14 @@ if (__isBlockLike(aBlock) && (__BlockInstPtr(aBlock)->b_nargs == __MKSMALLINT(1))) { { - /* - * the most common case: a static compiled block, with home on the stack ... + /* + * the most common case: a static compiled block, with home on the stack ... */ REGISTER OBJFUNC codeVal; - if (((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) + if (((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) #ifdef PARANOIA - && (! ((INT)(__BlockInstPtr(aBlock)->b_flags) & __MASKSMALLINT(F_DYNAMIC))) + && (! ((INT)(__BlockInstPtr(aBlock)->b_flags) & __MASKSMALLINT(F_DYNAMIC))) #endif ) { @@ -625,7 +625,7 @@ for (; index < nIndex; index++) { el = __InstPtr(self)->i_instvars[index]; if (InterruptPending != nil) goto interruptX; - continueX: + continueX: (*codeVal)(BLOCK_ARG, el); } RETURN (self); @@ -776,9 +776,9 @@ */ REGISTER OBJFUNC codeVal; - if (((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) + if (((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) #ifdef PARANOIA - && (! ((INT)(__BlockInstPtr(aBlock)->b_flags) & __MASKSMALLINT(F_DYNAMIC))) + && (! ((INT)(__BlockInstPtr(aBlock)->b_flags) & __MASKSMALLINT(F_DYNAMIC))) #endif ) { #ifdef NEW_BLOCK_CALL @@ -1049,21 +1049,21 @@ myClass = __qClass(self); if ((__ClassInstPtr(myClass)->c_ninstvars) == __MKSMALLINT(0)) { - actualSize = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); - index = 0; + actualSize = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); + index = 0; - if (index < actualSize) { + if (index < actualSize) { if (__isBlockLike(aBlock) && (__BlockInstPtr(aBlock)->b_nargs == __MKSMALLINT(2))) { - { + { /* * the most common case: a static compiled block, with home on the stack ... */ REGISTER OBJFUNC codeVal; - if (((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) + if (((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) #ifdef PARANOIA - && (! ((INT)(__BlockInstPtr(aBlock)->b_flags) & __MASKSMALLINT(F_DYNAMIC))) + && (! ((INT)(__BlockInstPtr(aBlock)->b_flags) & __MASKSMALLINT(F_DYNAMIC))) #endif ) { @@ -1071,21 +1071,21 @@ # define BLOCK_ARG aBlock #else # define BLOCK_ARG rHome - REGISTER OBJ rHome; + REGISTER OBJ rHome; - rHome = __BlockInstPtr(aBlock)->b_home; - if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE)) + rHome = __BlockInstPtr(aBlock)->b_home; + if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE)) #endif - { + { OBJ el; while (index < actualSize) { el = __InstPtr(self)->i_instvars[index]; - if (InterruptPending != nil) goto interruptX; + if (InterruptPending != nil) goto interruptX; continueX: - index++; - (*codeVal)(BLOCK_ARG, __MKSMALLINT(index), el); + index++; + (*codeVal)(BLOCK_ARG, __MKSMALLINT(index), el); } RETURN (self); @@ -1093,14 +1093,14 @@ __interruptL(@line); el = __InstPtr(self)->i_instvars[index]; goto continueX; - } + } } - } + } - /* - * sorry, must check code-pointer in the loop - * it could be recompiled or flushed - */ + /* + * sorry, must check code-pointer in the loop + * it could be recompiled or flushed + */ # undef BLOCK_ARG #ifdef NEW_BLOCK_CALL # define BLOCK_ARG aBlock @@ -1110,7 +1110,7 @@ # define IBLOCK_ARG (__BlockInstPtr(aBlock)->b_home) #endif - while (index < actualSize) { + while (index < actualSize) { REGISTER OBJFUNC codeVal; OBJ el; @@ -1119,39 +1119,39 @@ el = __InstPtr(self)->i_instvars[index]; index++; if ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) { - (*codeVal)(BLOCK_ARG, __MKSMALLINT(index), el); + (*codeVal)(BLOCK_ARG, __MKSMALLINT(index), el); } else { - if (__BlockInstPtr(aBlock)->b_bytecodes != nil) { + if (__BlockInstPtr(aBlock)->b_bytecodes != nil) { /* * arg is a compiled block with bytecode - * directly call interpreter without going through Block>>value */ #ifdef PASS_ARG_POINTER { - OBJ t[2]; + OBJ t[2]; - t[0] = __MKSMALLINT(index); - t[1] = el; + t[0] = __MKSMALLINT(index); + t[1] = el; - __interpret(aBlock, 2, nil, IBLOCK_ARG, nil, nil, t); + __interpret(aBlock, 2, nil, IBLOCK_ARG, nil, nil, t); } #else __interpret(aBlock, 2, nil, IBLOCK_ARG, nil, nil, __MKSMALLINT(index), el); #endif - } else { + } else { (*val2.ilc_func)(aBlock, - @symbol(value:value:), - nil, &val2, - __MKSMALLINT(index), - el); - } + @symbol(value:value:), + nil, &val2, + __MKSMALLINT(index), + el); + } } - } + } # undef BLOCK_ARG # undef IBLOCK_ARG - RETURN (self ); + RETURN (self ); } /* @@ -1160,18 +1160,18 @@ while (index < actualSize) { OBJ el; - if (InterruptPending != nil) __interruptL(@line); + if (InterruptPending != nil) __interruptL(@line); el = __InstPtr(self)->i_instvars[index]; - index++; - (*val2.ilc_func)(aBlock, + index++; + (*val2.ilc_func)(aBlock, @symbol(value:value:), nil, &val2, __MKSMALLINT(index), el); } RETURN ( self ); - } + } } %}. ^ super keysAndValuesDo:aBlock @@ -1525,7 +1525,7 @@ displayString "return a printed representation of the receiver for displaying" - |s sz| + |s| (self isLiteral) ifTrue:[ s := WriteStream on:String new. @@ -1536,11 +1536,9 @@ s nextPutAll:' ...' ] do:[ s nextPutAll:'#('. - sz := self size. - self keysAndValuesDo:[:idx :element | - s nextPutAll:element displayString. - idx ~~ sz ifTrue:[s space] - ]. + self + do:[:each | s nextPutAll:each displayString.] + separatedBy:[s space] ]. s writeLimit:nil. s nextPutAll:')'. @@ -1550,11 +1548,11 @@ " #(1 2 3 4) displayString - #(1 2 3 4) printString + #(1 2 3 4) printString (Array new:10000) displayString " - "Modified: 30.6.1996 / 13:00:08 / cg" + "Modified: 12.9.1997 / 22:03:18 / cg" ! storeOn:aStream @@ -1694,93 +1692,93 @@ int nInsts; if (__isSmallInteger(start)) { - index = __intVal(start) - 1; - if (index >= 0) { - nInsts = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars); - index += nInsts; - nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); - el = anElement; - op = & (__InstPtr(self)->i_instvars[index]); + index = __intVal(start) - 1; + if (index >= 0) { + nInsts = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars); + index += nInsts; + nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); + el = anElement; + op = & (__InstPtr(self)->i_instvars[index]); #if defined(memsrch4) - if (index < nIndex) { - OBJ *p; + if (index < nIndex) { + OBJ *p; - p = memsrch4(op, (INT)el, (nIndex - index)); - if (p) { - index += (p - op + 1); - RETURN ( __MKSMALLINT(index) ); - } - } + p = memsrch4(op, (INT)el, (nIndex - index)); + if (p) { + index += (p - op + 1); + RETURN ( __MKSMALLINT(index) ); + } + } #else # if defined(UNROLL_LOOPS) - { - /* - * dont argue about those gotos below - they speed up that thing by 30%; - * its better to exit the loops below with a goto, - * since the generated code will then be: - * compare - * branch-on-equal found - * - * otherwise (with return as if-statement), we get: - * compare - * branch-on-not-equal skipLabel - * move-to-return-register true - * goto return-label - * skipLabel - * - * therefore, WITH the so-much-blamed goto, we only branch - * when found; without the goto, we branch always. - * Pipelined CPUs do usually not like taken branches. - */ + { + /* + * dont argue about those gotos below - they speed up that thing by 30%; + * its better to exit the loops below with a goto, + * since the generated code will then be: + * compare + * branch-on-equal found + * + * otherwise (with return as if-statement), we get: + * compare + * branch-on-not-equal skipLabel + * move-to-return-register true + * goto return-label + * skipLabel + * + * therefore, WITH the so-much-blamed goto, we only branch + * when found; without the goto, we branch always. + * Pipelined CPUs do usually not like taken branches. + */ - unsigned int i8; + unsigned int i8; - while ((i8 = index + 8) < nIndex) { - if (op[0] == el) goto found1; - if (op[1] == el) goto found2; - if (op[2] == el) goto found3; - if (op[3] == el) goto found4; - if (op[4] == el) goto found5; - if (op[5] == el) goto found6; - if (op[6] == el) goto found7; - if (op[7] == el) goto found8; - index = i8; - op += 8; - } + while ((i8 = index + 8) < nIndex) { + if (op[0] == el) goto found1; + if (op[1] == el) goto found2; + if (op[2] == el) goto found3; + if (op[3] == el) goto found4; + if (op[4] == el) goto found5; + if (op[5] == el) goto found6; + if (op[6] == el) goto found7; + if (op[7] == el) goto found8; + index = i8; + op += 8; + } if (0) { - found1: - RETURN ( __MKSMALLINT(index + 1 - nInsts) ); - found2: - RETURN ( __MKSMALLINT(index + 2 - nInsts) ); - found3: - RETURN ( __MKSMALLINT(index + 3 - nInsts) ); - found4: - RETURN ( __MKSMALLINT(index + 4 - nInsts) ); - found5: - RETURN ( __MKSMALLINT(index + 5 - nInsts) ); - found6: - RETURN ( __MKSMALLINT(index + 6 - nInsts) ); - found7: - RETURN ( __MKSMALLINT(index + 7 - nInsts) ); - found8: - RETURN ( __MKSMALLINT(index + 8 - nInsts) ); + found1: + RETURN ( __MKSMALLINT(index + 1 - nInsts) ); + found2: + RETURN ( __MKSMALLINT(index + 2 - nInsts) ); + found3: + RETURN ( __MKSMALLINT(index + 3 - nInsts) ); + found4: + RETURN ( __MKSMALLINT(index + 4 - nInsts) ); + found5: + RETURN ( __MKSMALLINT(index + 5 - nInsts) ); + found6: + RETURN ( __MKSMALLINT(index + 6 - nInsts) ); + found7: + RETURN ( __MKSMALLINT(index + 7 - nInsts) ); + found8: + RETURN ( __MKSMALLINT(index + 8 - nInsts) ); } - } + } # endif /* UNROLLED_LOOPS */ - while (index++ < nIndex) { - if (*op++ == el) goto found0; - } + while (index++ < nIndex) { + if (*op++ == el) goto found0; + } - if (0) { - found0: - RETURN ( __MKSMALLINT(index - nInsts) ); - } + if (0) { + found0: + RETURN ( __MKSMALLINT(index - nInsts) ); + } #endif /* no memsrch */ - } - RETURN ( __MKSMALLINT(0) ); + } + RETURN ( __MKSMALLINT(0) ); } %}. ^ self indexNotInteger @@ -1801,79 +1799,79 @@ int nInsts; if (__bothSmallInteger(start, stop)) { - index = __intVal(start) - 1; - if (index >= 0) { - nInsts = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars); - index += nInsts; - lastIndex = nInsts + __intVal(stop); - nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); - if (nIndex < lastIndex) { - lastIndex = nIndex; - } - el = anElement; - op = & (__InstPtr(self)->i_instvars[index]); + index = __intVal(start) - 1; + if (index >= 0) { + nInsts = __intVal(__ClassInstPtr(__qClass(self))->c_ninstvars); + index += nInsts; + lastIndex = nInsts + __intVal(stop); + nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); + if (nIndex < lastIndex) { + lastIndex = nIndex; + } + el = anElement; + op = & (__InstPtr(self)->i_instvars[index]); #if defined(memsrch4) - if (index < lastIndex) { - OBJ *p; + if (index < lastIndex) { + OBJ *p; - p = memsrch4(op, (INT)el, (lastIndex - index)); - if (p) { - index += (p - op + 1); - RETURN ( __MKSMALLINT(index) ); - } - } + p = memsrch4(op, (INT)el, (lastIndex - index)); + if (p) { + index += (p - op + 1); + RETURN ( __MKSMALLINT(index) ); + } + } #else # if defined(UNROLL_LOOPS) - { - unsigned int i8; + { + unsigned int i8; - while ((i8 = index + 8) < lastIndex) { - if (op[0] == el) goto found1; - if (op[1] == el) goto found2; - if (op[2] == el) goto found3; - if (op[3] == el) goto found4; - if (op[4] == el) goto found5; - if (op[5] == el) goto found6; - if (op[6] == el) goto found7; - if (op[7] == el) goto found8; - index = i8; - op += 8; - } + while ((i8 = index + 8) < lastIndex) { + if (op[0] == el) goto found1; + if (op[1] == el) goto found2; + if (op[2] == el) goto found3; + if (op[3] == el) goto found4; + if (op[4] == el) goto found5; + if (op[5] == el) goto found6; + if (op[6] == el) goto found7; + if (op[7] == el) goto found8; + index = i8; + op += 8; + } if (0) { - found1: - RETURN ( __MKSMALLINT(index + 1 - nInsts) ); - found2: - RETURN ( __MKSMALLINT(index + 2 - nInsts) ); - found3: - RETURN ( __MKSMALLINT(index + 3 - nInsts) ); - found4: - RETURN ( __MKSMALLINT(index + 4 - nInsts) ); - found5: - RETURN ( __MKSMALLINT(index + 5 - nInsts) ); - found6: - RETURN ( __MKSMALLINT(index + 6 - nInsts) ); - found7: - RETURN ( __MKSMALLINT(index + 7 - nInsts) ); - found8: - RETURN ( __MKSMALLINT(index + 8 - nInsts) ); + found1: + RETURN ( __MKSMALLINT(index + 1 - nInsts) ); + found2: + RETURN ( __MKSMALLINT(index + 2 - nInsts) ); + found3: + RETURN ( __MKSMALLINT(index + 3 - nInsts) ); + found4: + RETURN ( __MKSMALLINT(index + 4 - nInsts) ); + found5: + RETURN ( __MKSMALLINT(index + 5 - nInsts) ); + found6: + RETURN ( __MKSMALLINT(index + 6 - nInsts) ); + found7: + RETURN ( __MKSMALLINT(index + 7 - nInsts) ); + found8: + RETURN ( __MKSMALLINT(index + 8 - nInsts) ); } - } + } # endif /* UNROLL_LOOPS */ - while (index++ < lastIndex) { - if (*op++ == el) goto found0; - } + while (index++ < lastIndex) { + if (*op++ == el) goto found0; + } - if (0) { - found0: - RETURN ( __MKSMALLINT(index - nInsts) ); - } + if (0) { + found0: + RETURN ( __MKSMALLINT(index - nInsts) ); + } #endif - } - RETURN ( __MKSMALLINT(0) ); + } + RETURN ( __MKSMALLINT(0) ); } %}. ^ self indexNotInteger @@ -2215,5 +2213,5 @@ !Array class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.98 1997-09-02 20:51:59 cg Exp $' + ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.99 1997-09-15 20:17:22 cg Exp $' ! !