--- a/Array.st Thu Mar 30 17:25:19 2000 +0200
+++ b/Array.st Sat Apr 01 12:40:15 2000 +0200
@@ -10,6 +10,8 @@
hereby transferred.
"
+"{ Package: 'stx:libbasic' }"
+
ArrayedCollection variableSubclass:#Array
instanceVariableNames:''
classVariableNames:''
@@ -777,205 +779,202 @@
static struct inlineCache val = _ILC1;
int indexHigh;
OBJ myClass;
- OBJ __start, __stop;
slf = self;
myClass = __qClass(slf);
-
- __start = start;
- __stop = stop;
- if ( __bothSmallInteger(__start, __stop)
- && ((index = __intVal(__start)) > 0) ) {
- indexHigh = __intVal(__stop);
- nIndex = __BYTES2OBJS__(__qSize(slf) - OHDR_SIZE);
- if (myClass != @global(Array)) {
- nInsts = __intVal(__ClassInstPtr(myClass)->c_ninstvars);
- index += nInsts;
- indexHigh += nInsts;
- }
- if (indexHigh <= nIndex) {
- OBJ __aBlock = aBlock;
- int n;
+
+ if ( __bothSmallInteger(start, stop)
+ && ((index = __intVal(start)) > 0) ) {
+ indexHigh = __intVal(stop);
+ nIndex = __BYTES2OBJS__(__qSize(slf) - OHDR_SIZE);
+ if (myClass != @global(Array)) {
+ nInsts = __intVal(__ClassInstPtr(myClass)->c_ninstvars);
+ index += nInsts;
+ indexHigh += nInsts;
+ }
+ if (indexHigh <= nIndex) {
+ OBJ __aBlock = aBlock;
+ int n;
- index--; /* 0-based */
- n = indexHigh - index;
+ index--; /* 0-based */
+ n = indexHigh - index;
- if (__isBlockLike(__aBlock)
- && (__BlockInstPtr(__aBlock)->b_nargs == __MKSMALLINT(1))) {
- {
- /*
- * the most common case: a static compiled block, with home on the stack ...
- */
- REGISTER OBJFUNC codeVal;
+ if (__isBlockLike(__aBlock)
+ && (__BlockInstPtr(__aBlock)->b_nargs == __MKSMALLINT(1))) {
+ {
+ /*
+ * 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
- ) {
+ ) {
#ifdef NEW_BLOCK_CALL
# 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
- {
- REGISTER OBJ el;
+ {
+ REGISTER OBJ el;
#if defined(UNROLL_LOOPS)
- /*
- * boy; what an ugly looking piece of code ...
- * however, this software pipelined thing has no taken conditional
- * branches in the normal case and is almost twice as fast to even
- * what an unrolling optimizing compiler produces from the loop below ...
- * notice, that those gotos expand to forward branches (which are predicted
- * as NOT taken by most machines ... which is exactly what we want)
- */
- {
- while ( n >= 8) {
- el = __InstPtr(self)->i_instvars[index];
- if (InterruptPending != nil) goto interrupt0;
- continue0:
- (*codeVal)(BLOCK_ARG, el);
- el = __InstPtr(self)->i_instvars[index+1];
- if (InterruptPending != nil) goto interrupt1;
- continue1:
- (*codeVal)(BLOCK_ARG, el);
- el = __InstPtr(self)->i_instvars[index+2];
- if (InterruptPending != nil) goto interrupt2;
- continue2:
- (*codeVal)(BLOCK_ARG, el);
- el = __InstPtr(self)->i_instvars[index+3];
- if (InterruptPending != nil) goto interrupt3;
- continue3:
- (*codeVal)(BLOCK_ARG, el);
- el = __InstPtr(self)->i_instvars[index+4];
- if (InterruptPending != nil) goto interrupt4;
- continue4:
- (*codeVal)(BLOCK_ARG, el);
- el = __InstPtr(self)->i_instvars[index+5];
- if (InterruptPending != nil) goto interrupt5;
- continue5:
- (*codeVal)(BLOCK_ARG, el);
- el = __InstPtr(self)->i_instvars[index+6];
- if (InterruptPending != nil) goto interrupt6;
- continue6:
- (*codeVal)(BLOCK_ARG, el);
- el = __InstPtr(self)->i_instvars[index+7];
- if (InterruptPending != nil) goto interrupt7;
- continue7:
- (*codeVal)(BLOCK_ARG, el);
- n -= 8;
- index += 8;
- }
+ /*
+ * boy; what an ugly looking piece of code ...
+ * however, this software pipelined thing has no taken conditional
+ * branches in the normal case and is almost twice as fast to even
+ * what an unrolling optimizing compiler produces from the loop below ...
+ * notice, that those gotos expand to forward branches (which are predicted
+ * as NOT taken by most machines ... which is exactly what we want)
+ */
+ {
+ while ( n >= 8) {
+ el = __InstPtr(self)->i_instvars[index];
+ if (InterruptPending != nil) goto interrupt0;
+ continue0:
+ (*codeVal)(BLOCK_ARG, el);
+ el = __InstPtr(self)->i_instvars[index+1];
+ if (InterruptPending != nil) goto interrupt1;
+ continue1:
+ (*codeVal)(BLOCK_ARG, el);
+ el = __InstPtr(self)->i_instvars[index+2];
+ if (InterruptPending != nil) goto interrupt2;
+ continue2:
+ (*codeVal)(BLOCK_ARG, el);
+ el = __InstPtr(self)->i_instvars[index+3];
+ if (InterruptPending != nil) goto interrupt3;
+ continue3:
+ (*codeVal)(BLOCK_ARG, el);
+ el = __InstPtr(self)->i_instvars[index+4];
+ if (InterruptPending != nil) goto interrupt4;
+ continue4:
+ (*codeVal)(BLOCK_ARG, el);
+ el = __InstPtr(self)->i_instvars[index+5];
+ if (InterruptPending != nil) goto interrupt5;
+ continue5:
+ (*codeVal)(BLOCK_ARG, el);
+ el = __InstPtr(self)->i_instvars[index+6];
+ if (InterruptPending != nil) goto interrupt6;
+ continue6:
+ (*codeVal)(BLOCK_ARG, el);
+ el = __InstPtr(self)->i_instvars[index+7];
+ if (InterruptPending != nil) goto interrupt7;
+ continue7:
+ (*codeVal)(BLOCK_ARG, el);
+ n -= 8;
+ index += 8;
+ }
# ifdef UNROLL_LOOPS2 /* this makes small loops slower */
- if (n >= 4) {
- el = __InstPtr(self)->i_instvars[index];
- if (InterruptPending != nil) goto interrupt0b;
- continue0b:
- (*codeVal)(BLOCK_ARG, el);
- el = __InstPtr(self)->i_instvars[index+1];
- if (InterruptPending != nil) goto interrupt1b;
- continue1b:
- (*codeVal)(BLOCK_ARG, el);
- el = __InstPtr(self)->i_instvars[index+2];
- if (InterruptPending != nil) goto interrupt2b;
- continue2b:
- (*codeVal)(BLOCK_ARG, el);
- el = __InstPtr(self)->i_instvars[index+3];
- if (InterruptPending != nil) goto interrupt3b;
- continue3b:
- (*codeVal)(BLOCK_ARG, el);
- n -= 4;
- index += 4;
- }
- if (n >= 2) {
- el = __InstPtr(self)->i_instvars[index];
- if (InterruptPending != nil) goto interrupt0c;
- continue0c:
- (*codeVal)(BLOCK_ARG, el);
- el = __InstPtr(self)->i_instvars[index+1];
- if (InterruptPending != nil) goto interrupt1c;
- continue1c:
- (*codeVal)(BLOCK_ARG, el);
- n -= 2;
- index += 2;
- }
+ if (n >= 4) {
+ el = __InstPtr(self)->i_instvars[index];
+ if (InterruptPending != nil) goto interrupt0b;
+ continue0b:
+ (*codeVal)(BLOCK_ARG, el);
+ el = __InstPtr(self)->i_instvars[index+1];
+ if (InterruptPending != nil) goto interrupt1b;
+ continue1b:
+ (*codeVal)(BLOCK_ARG, el);
+ el = __InstPtr(self)->i_instvars[index+2];
+ if (InterruptPending != nil) goto interrupt2b;
+ continue2b:
+ (*codeVal)(BLOCK_ARG, el);
+ el = __InstPtr(self)->i_instvars[index+3];
+ if (InterruptPending != nil) goto interrupt3b;
+ continue3b:
+ (*codeVal)(BLOCK_ARG, el);
+ n -= 4;
+ index += 4;
+ }
+ if (n >= 2) {
+ el = __InstPtr(self)->i_instvars[index];
+ if (InterruptPending != nil) goto interrupt0c;
+ continue0c:
+ (*codeVal)(BLOCK_ARG, el);
+ el = __InstPtr(self)->i_instvars[index+1];
+ if (InterruptPending != nil) goto interrupt1c;
+ continue1c:
+ (*codeVal)(BLOCK_ARG, el);
+ n -= 2;
+ index += 2;
+ }
# endif /* UNROLL_LOOPS2 */
- }
+ }
#endif /* UNROLL_LOOPS */
- while (n > 0) {
- el = __InstPtr(self)->i_instvars[index];
- if (InterruptPending != nil) goto interruptX;
- continueX:
- (*codeVal)(BLOCK_ARG, el);
- n--;
- index++;
- }
- RETURN (self);
+ while (n > 0) {
+ el = __InstPtr(self)->i_instvars[index];
+ if (InterruptPending != nil) goto interruptX;
+ continueX:
+ (*codeVal)(BLOCK_ARG, el);
+ n--;
+ index++;
+ }
+ RETURN (self);
#if defined(UNROLL_LOOPS)
- interrupt0:
- __interruptL(@line); el = __InstPtr(self)->i_instvars[index];
- goto continue0;
- interrupt1:
- __interruptL(@line); el = __InstPtr(self)->i_instvars[index+1];
- goto continue1;
- interrupt2:
- __interruptL(@line); el = __InstPtr(self)->i_instvars[index+2];
- goto continue2;
- interrupt3:
- __interruptL(@line); el = __InstPtr(self)->i_instvars[index+3];
- goto continue3;
- interrupt4:
- __interruptL(@line); el = __InstPtr(self)->i_instvars[index+4];
- goto continue4;
- interrupt5:
- __interruptL(@line); el = __InstPtr(self)->i_instvars[index+5];
- goto continue5;
- interrupt6:
- __interruptL(@line); el = __InstPtr(self)->i_instvars[index+6];
- goto continue6;
- interrupt7:
- __interruptL(@line); el = __InstPtr(self)->i_instvars[index+7];
- goto continue7;
+ interrupt0:
+ __interruptL(@line); el = __InstPtr(self)->i_instvars[index];
+ goto continue0;
+ interrupt1:
+ __interruptL(@line); el = __InstPtr(self)->i_instvars[index+1];
+ goto continue1;
+ interrupt2:
+ __interruptL(@line); el = __InstPtr(self)->i_instvars[index+2];
+ goto continue2;
+ interrupt3:
+ __interruptL(@line); el = __InstPtr(self)->i_instvars[index+3];
+ goto continue3;
+ interrupt4:
+ __interruptL(@line); el = __InstPtr(self)->i_instvars[index+4];
+ goto continue4;
+ interrupt5:
+ __interruptL(@line); el = __InstPtr(self)->i_instvars[index+5];
+ goto continue5;
+ interrupt6:
+ __interruptL(@line); el = __InstPtr(self)->i_instvars[index+6];
+ goto continue6;
+ interrupt7:
+ __interruptL(@line); el = __InstPtr(self)->i_instvars[index+7];
+ goto continue7;
# ifdef UNROLL_LOOPS2
- interrupt0b:
- __interruptL(@line); el = __InstPtr(self)->i_instvars[index];
- goto continue0b;
- interrupt1b:
- __interruptL(@line); el = __InstPtr(self)->i_instvars[index+1];
- goto continue1b;
- interrupt2b:
- __interruptL(@line); el = __InstPtr(self)->i_instvars[index+2];
- goto continue2b;
- interrupt3b:
- __interruptL(@line); el = __InstPtr(self)->i_instvars[index+3];
- goto continue3b;
+ interrupt0b:
+ __interruptL(@line); el = __InstPtr(self)->i_instvars[index];
+ goto continue0b;
+ interrupt1b:
+ __interruptL(@line); el = __InstPtr(self)->i_instvars[index+1];
+ goto continue1b;
+ interrupt2b:
+ __interruptL(@line); el = __InstPtr(self)->i_instvars[index+2];
+ goto continue2b;
+ interrupt3b:
+ __interruptL(@line); el = __InstPtr(self)->i_instvars[index+3];
+ goto continue3b;
- interrupt0c:
- __interruptL(@line); el = __InstPtr(self)->i_instvars[index];
- goto continue0c;
- interrupt1c:
- __interruptL(@line); el = __InstPtr(self)->i_instvars[index+1];
- goto continue1c;
+ interrupt0c:
+ __interruptL(@line); el = __InstPtr(self)->i_instvars[index];
+ goto continue0c;
+ interrupt1c:
+ __interruptL(@line); el = __InstPtr(self)->i_instvars[index+1];
+ goto continue1c;
# endif /* UNROLL_LOOPS2 */
#endif /* UNROLL_LOOPS */
- interruptX:
- __interruptL(@line); el = __InstPtr(self)->i_instvars[index];
- goto continueX;
- }
- }
- }
+ interruptX:
+ __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
@@ -985,64 +984,65 @@
# define IBLOCK_ARG (__BlockInstPtr(aBlock)->b_home)
#endif
- while (n) {
- REGISTER OBJFUNC codeVal;
- OBJ el;
+ while (n > 0) {
+ REGISTER OBJFUNC codeVal;
+ OBJ el;
- el = __InstPtr(self)->i_instvars[index];
- if (InterruptPending != nil) {
- __interruptL(@line);
- el = __InstPtr(self)->i_instvars[index];
- }
+ el = __InstPtr(self)->i_instvars[index];
+ if (InterruptPending != nil) {
+ __interruptL(@line);
+ el = __InstPtr(self)->i_instvars[index];
+ }
- if ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) {
- (*codeVal)(BLOCK_ARG, el);
- } else {
- if (__BlockInstPtr(aBlock)->b_bytecodes != nil) {
- /*
- * arg is a compiled block with bytecode -
- * directly call interpreter without going through Block>>value
- */
+ if ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) {
+ (*codeVal)(BLOCK_ARG, el);
+ } else {
+ 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
- __interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, &el);
+ __interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, &el);
#else
- __interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, el);
+ __interpret(aBlock, 1, nil, IBLOCK_ARG, nil, nil, el);
#endif
- } else {
- (*val.ilc_func)(aBlock,
- @symbol(value:),
- nil, &val,
- el);
- }
- }
- n--;
- index++;
- }
+ } else {
+ (*val.ilc_func)(aBlock,
+ @symbol(value:),
+ nil, &val,
+ el);
+ }
+ }
+ n--;
+ index++;
+ }
# undef BLOCK_ARG
# undef IBLOCK_ARG
- RETURN (self );
- }
+ RETURN (self );
+ }
- /*
- * not a block - send it #value:
- */
- while (n > 0) {
- if (InterruptPending != nil) __interruptL(@line);
+ /*
+ * not a block - send it #value:
+ */
+ while (n > 0) {
+ if (InterruptPending != nil) __interruptL(@line);
- (*val.ilc_func)(aBlock,
- @symbol(value:),
- nil, &val,
- __InstPtr(self)->i_instvars[index]);
- n--;
- index++;
- }
- RETURN ( self );
- }
+ (*val.ilc_func)(aBlock,
+ @symbol(value:),
+ nil, &val,
+ __InstPtr(self)->i_instvars[index]);
+ n--;
+ index++;
+ }
+ RETURN ( self );
+ }
}
%}.
^ super from:start to:stop do:aBlock
+
!
from:start to:stop reverseDo:aBlock
@@ -2408,5 +2408,5 @@
!Array class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.121 1999-12-02 11:22:55 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.122 2000-04-01 10:40:15 cg Exp $'
! !