CompiledCode.st
changeset 20292 632f0956cd1e
parent 19447 44be407eaf89
child 20342 219a5a47e8b1
child 20407 940164393f2f
--- a/CompiledCode.st	Mon Aug 22 11:26:48 2016 +0200
+++ b/CompiledCode.st	Mon Aug 22 11:27:01 2016 +0200
@@ -994,11 +994,11 @@
      With a normal send, this error cannot happen."
 
     ^ WrongNumberOfArgumentsError
-        raiseRequestWith:self
-        errorString:(' - %1 got %2 arg(s) where %3 expected'
-                        bindWith:self printString "/ self class name
-                        with:numArgsGiven
-                        with:self argumentCount)
+	raiseRequestWith:self
+	errorString:(' - %1 got %2 arg(s) where %3 expected'
+			bindWith:self printString "/ self class name
+			with:numArgsGiven
+			with:self argumentCount)
 
     "
      2 perform:#+
@@ -1108,30 +1108,30 @@
 %{
 #ifdef __SCHTEAM__
     {
-        int numArgs = 0;
-        STVector v = null;
+	int numArgs = 0;
+	STVector v = null;
 
-        if (argArray != STObject.Nil) {
-            v = argArray.asSTVector();
-            numArgs = v.vectorLength();
-        }
+	if (argArray != STObject.Nil) {
+	    v = argArray.asSTVector();
+	    numArgs = v.vectorLength();
+	}
 
-        STCallable me = (STCompiledMethod)self.smalltalkCheckNumberOfArgs(1+numArgs);
+	STCallable me = (STCompiledMethod)self.smalltalkCheckNumberOfArgs(1+numArgs);
 
-        __c__.push(anObject);
-        for (int i=0; i<numArgs; i++) {
-            __c__.push( v.vectorRef(i) );
-        }
-        // the selector and searchClass args are not needed/passed
-        // the virtualSender is (currently) not supported
-        // (this is cosmetics only; therefore it's done later)
-        return __c__.TAILCALL_nPUSHED( me, 1+numArgs);
+	__c__.push(anObject);
+	for (int i=0; i<numArgs; i++) {
+	    __c__.push( v.vectorRef(i) );
+	}
+	// the selector and searchClass args are not needed/passed
+	// the virtualSender is (currently) not supported
+	// (this is cosmetics only; therefore it's done later)
+	return __c__.TAILCALL_nPUSHED( me, 1+numArgs);
     }
     /* NOT REACHED */
 #else
     OBJFUNC code;
     OBJ searchClass;
-    static struct inlineCache dummy = _DUMMYILC0;
+    static struct inlineCache dummy = __DUMMYILC0(0);
     int nargs;
     OBJ *ap;
 
@@ -1139,286 +1139,286 @@
      * args must be an array, or nil
      */
     if (__isArrayLike(argArray)) {
-        nargs = __arraySize(argArray);
-        ap = __ArrayInstPtr(argArray)->a_element;
+	nargs = __arraySize(argArray);
+	ap = __ArrayInstPtr(argArray)->a_element;
     } else {
-        if (argArray != nil) {
-            goto badArgs;
-        }
-        nargs = 0;
-        ap = (OBJ *)0;
+	if (argArray != nil) {
+	    goto badArgs;
+	}
+	nargs = 0;
+	ap = (OBJ *)0;
     }
 
 # ifdef F_NARGS
     if (((__intVal(__INST(flags)) & F_NARGS) >> F_NARGSHIFT) == nargs)
 # endif
     {
-        code = __MethodInstPtr(self)->m_code;
-        if (aClass == nil) {
-            searchClass = dummy.ilc_class = __Class(anObject);
-        } else {
-            searchClass = dummy.ilc_class = aClass;
-        }
+	code = __MethodInstPtr(self)->m_code;
+	if (aClass == nil) {
+	    searchClass = dummy.ilc_class = __Class(anObject);
+	} else {
+	    searchClass = dummy.ilc_class = aClass;
+	}
 
-        if (nargs <= 15) {
-          OBJ rslt;
+	if (nargs <= 15) {
+	  OBJ rslt;
 # ifdef CONTEXT_DEBUG
-          OBJ sav = __thisContext;
+	  OBJ sav = __thisContext;
 # endif
 
-          /*
-           * add virtual sender (unwinding) here later,
-           * to allow hiding contexts in lazy methods.
-           * (this is cosmetics only; therefore its done later)
-           */
-          if (code) {
-            /* compiled code */
-            switch (nargs) {
-                case 0:
-                    rslt = (*code)(anObject, aSymbol, searchClass, &dummy);
-                    break;
+	  /*
+	   * add virtual sender (unwinding) here later,
+	   * to allow hiding contexts in lazy methods.
+	   * (this is cosmetics only; therefore its done later)
+	   */
+	  if (code) {
+	    /* compiled code */
+	    switch (nargs) {
+		case 0:
+		    rslt = (*code)(anObject, aSymbol, searchClass, &dummy);
+		    break;
 
-                case 1:
-                    rslt = (*code)(anObject, aSymbol, searchClass, &dummy, ap[0]);
-                    break;
+		case 1:
+		    rslt = (*code)(anObject, aSymbol, searchClass, &dummy, ap[0]);
+		    break;
 
-                case 2:
-                    rslt = (*code)(anObject, aSymbol, searchClass, &dummy, ap[0], ap[1]);
-                    break;
+		case 2:
+		    rslt = (*code)(anObject, aSymbol, searchClass, &dummy, ap[0], ap[1]);
+		    break;
 
-                case 3:
-                    rslt = (*code)(anObject, aSymbol, searchClass, &dummy, ap[0], ap[1], ap[2]);
-                    break;
+		case 3:
+		    rslt = (*code)(anObject, aSymbol, searchClass, &dummy, ap[0], ap[1], ap[2]);
+		    break;
 
-                case 4:
-                    rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
-                                 ap[0], ap[1], ap[2], ap[3]);
-                    break;
+		case 4:
+		    rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
+				 ap[0], ap[1], ap[2], ap[3]);
+		    break;
 
-                case 5:
-                    rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
-                                 ap[0], ap[1], ap[2], ap[3], ap[4]);
-                    break;
+		case 5:
+		    rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
+				 ap[0], ap[1], ap[2], ap[3], ap[4]);
+		    break;
 
-                case 6:
-                    rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
-                                 ap[0], ap[1], ap[2], ap[3], ap[4], ap[5]);
-                    break;
+		case 6:
+		    rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
+				 ap[0], ap[1], ap[2], ap[3], ap[4], ap[5]);
+		    break;
 
-                case 7:
-                    rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
-                                 ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6]);
-                    break;
+		case 7:
+		    rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
+				 ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6]);
+		    break;
 
-                case 8:
-                    rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
-                                 ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7]);
-                    break;
+		case 8:
+		    rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
+				 ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7]);
+		    break;
 
-                case 9:
-                    rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
-                                 ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8]);
-                    break;
+		case 9:
+		    rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
+				 ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8]);
+		    break;
 
-                case 10:
-                    rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
-                                 ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8],
-                                 ap[9]);
-                    break;
+		case 10:
+		    rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
+				 ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8],
+				 ap[9]);
+		    break;
 
-                case 11:
-                    rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
-                                 ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8],
-                                 ap[9], ap[10]);
-                    break;
+		case 11:
+		    rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
+				 ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8],
+				 ap[9], ap[10]);
+		    break;
 
-                case 12:
-                    rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
-                                 ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8],
-                                 ap[9], ap[10], ap[11]);
-                    break;
+		case 12:
+		    rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
+				 ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8],
+				 ap[9], ap[10], ap[11]);
+		    break;
 
-                case 13:
-                    rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
-                                 ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8],
-                                 ap[9], ap[10], ap[11], ap[12]);
-                    break;
+		case 13:
+		    rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
+				 ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8],
+				 ap[9], ap[10], ap[11], ap[12]);
+		    break;
 
-                case 14:
-                    rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
-                                 ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8],
-                                 ap[9], ap[10], ap[11], ap[12], ap[13]);
-                    break;
+		case 14:
+		    rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
+				 ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8],
+				 ap[9], ap[10], ap[11], ap[12], ap[13]);
+		    break;
 
-                case 15:
-                    rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
-                                 ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8],
-                                 ap[9], ap[10], ap[11], ap[12], ap[13], ap[14]);
-                    break;
-            }
-          } else {
-            /* interpreted code */
+		case 15:
+		    rslt = (*code)(anObject, aSymbol, searchClass, &dummy,
+				 ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8],
+				 ap[9], ap[10], ap[11], ap[12], ap[13], ap[14]);
+		    break;
+	    }
+	  } else {
+	    /* interpreted code */
 # ifdef PASS_ARG_POINTER
-            rslt = __interpret(self, nargs, anObject, aSymbol, searchClass, &dummy, ap);
+	    rslt = __interpret(self, nargs, anObject, aSymbol, searchClass, &dummy, ap);
 # else
-            switch (nargs) {
-                case 0:
-                    rslt = __interpret(self, 0, anObject, aSymbol, searchClass, &dummy);
-                    break;
+	    switch (nargs) {
+		case 0:
+		    rslt = __interpret(self, 0, anObject, aSymbol, searchClass, &dummy);
+		    break;
 
-                case 1:
-                    rslt = __interpret(self, 1, anObject, aSymbol, searchClass, &dummy,
-                                   ap[0]);
-                    break;
+		case 1:
+		    rslt = __interpret(self, 1, anObject, aSymbol, searchClass, &dummy,
+				   ap[0]);
+		    break;
 
-                case 2:
-                    rslt = __interpret(self, 2, anObject, aSymbol, searchClass, &dummy,
-                                   ap[0], ap[1]);
-                    break;
+		case 2:
+		    rslt = __interpret(self, 2, anObject, aSymbol, searchClass, &dummy,
+				   ap[0], ap[1]);
+		    break;
 
-                case 3:
-                    rslt = __interpret(self, 3, anObject, aSymbol, searchClass, &dummy,
-                                   ap[0], ap[1], ap[2]);
-                    break;
+		case 3:
+		    rslt = __interpret(self, 3, anObject, aSymbol, searchClass, &dummy,
+				   ap[0], ap[1], ap[2]);
+		    break;
 
-                case 4:
-                    rslt = __interpret(self, 4, anObject, aSymbol, searchClass, &dummy,
-                                   ap[0], ap[1], ap[2], ap[3]);
-                    break;
+		case 4:
+		    rslt = __interpret(self, 4, anObject, aSymbol, searchClass, &dummy,
+				   ap[0], ap[1], ap[2], ap[3]);
+		    break;
 
-                case 5:
-                    rslt = __interpret(self, 5, anObject, aSymbol, searchClass, &dummy,
-                                   ap[0], ap[1], ap[2], ap[3], ap[4]);
-                    break;
+		case 5:
+		    rslt = __interpret(self, 5, anObject, aSymbol, searchClass, &dummy,
+				   ap[0], ap[1], ap[2], ap[3], ap[4]);
+		    break;
 
-                case 6:
-                    rslt = __interpret(self, 6, anObject, aSymbol, searchClass, &dummy,
-                                   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5]);
-                    break;
+		case 6:
+		    rslt = __interpret(self, 6, anObject, aSymbol, searchClass, &dummy,
+				   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5]);
+		    break;
 
-                case 7:
-                    rslt = __interpret(self, 7, anObject, aSymbol, searchClass, &dummy,
-                                   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6]);
-                    break;
+		case 7:
+		    rslt = __interpret(self, 7, anObject, aSymbol, searchClass, &dummy,
+				   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6]);
+		    break;
 
-                case 8:
-                    rslt = __interpret(self, 8, anObject, aSymbol, searchClass, &dummy,
-                                   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
-                                   ap[7]);
-                    break;
+		case 8:
+		    rslt = __interpret(self, 8, anObject, aSymbol, searchClass, &dummy,
+				   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
+				   ap[7]);
+		    break;
 
-                case 9:
-                    rslt = __interpret(self, 9, anObject, aSymbol, searchClass, &dummy,
-                                   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
-                                   ap[7], ap[8]);
-                    break;
+		case 9:
+		    rslt = __interpret(self, 9, anObject, aSymbol, searchClass, &dummy,
+				   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
+				   ap[7], ap[8]);
+		    break;
 
-                case 10:
-                    rslt = __interpret(self, 10, anObject, aSymbol, searchClass, &dummy,
-                                   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
-                                   ap[7], ap[8], ap[9]);
-                    break;
+		case 10:
+		    rslt = __interpret(self, 10, anObject, aSymbol, searchClass, &dummy,
+				   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
+				   ap[7], ap[8], ap[9]);
+		    break;
 
-                case 11:
-                    rslt = __interpret(self, 11, anObject, aSymbol, searchClass, &dummy,
-                                   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
-                                   ap[7], ap[8], ap[9], ap[10]);
-                    break;
+		case 11:
+		    rslt = __interpret(self, 11, anObject, aSymbol, searchClass, &dummy,
+				   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
+				   ap[7], ap[8], ap[9], ap[10]);
+		    break;
 
-                case 12:
-                    rslt = __interpret(self, 12, anObject, aSymbol, searchClass, &dummy,
-                                   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
-                                   ap[7], ap[8], ap[9], ap[10], ap[11]);
-                    break;
+		case 12:
+		    rslt = __interpret(self, 12, anObject, aSymbol, searchClass, &dummy,
+				   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
+				   ap[7], ap[8], ap[9], ap[10], ap[11]);
+		    break;
 
-                case 13:
-                    rslt = __interpret(self, 13, anObject, aSymbol, searchClass, &dummy,
-                                   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
-                                   ap[7], ap[8], ap[9], ap[10], ap[11], ap[12]);
-                    break;
+		case 13:
+		    rslt = __interpret(self, 13, anObject, aSymbol, searchClass, &dummy,
+				   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
+				   ap[7], ap[8], ap[9], ap[10], ap[11], ap[12]);
+		    break;
 
-                case 14:
-                    rslt = __interpret(self, 14, anObject, aSymbol, searchClass, &dummy,
-                                   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
-                                   ap[7], ap[8], ap[9], ap[10], ap[11], ap[12], ap[13]);
-                    break;
+		case 14:
+		    rslt = __interpret(self, 14, anObject, aSymbol, searchClass, &dummy,
+				   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
+				   ap[7], ap[8], ap[9], ap[10], ap[11], ap[12], ap[13]);
+		    break;
 
-                case 15:
-                    rslt = __interpret(self, 15, anObject, aSymbol, searchClass, &dummy,
-                                   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
-                                   ap[7], ap[8], ap[9], ap[10], ap[11], ap[12], ap[13], ap[14]);
-                    break;
-            }
+		case 15:
+		    rslt = __interpret(self, 15, anObject, aSymbol, searchClass, &dummy,
+				   ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6],
+				   ap[7], ap[8], ap[9], ap[10], ap[11], ap[12], ap[13], ap[14]);
+		    break;
+	    }
 # endif
-          }
+	  }
 # ifdef CONTEXT_DEBUG
-          if (sav != __thisContext) {
-              if (code) {
-                  printf("CONTEXT BOTCH after execution of %x\n", code);
-              } else {
-                  printf("CONTEXT BOTCH after execution of interpreted method\n");
-                  printf("code now: %x\n", __MethodInstPtr(self)->m_code);
-              }
-              printf("context before:\n");
-              __dumpObject__(sav, __LINE__);
-              printf("context now:\n");
-              __dumpObject__(__thisContext, __LINE__);
-          }
+	  if (sav != __thisContext) {
+	      if (code) {
+		  printf("CONTEXT BOTCH after execution of %x\n", code);
+	      } else {
+		  printf("CONTEXT BOTCH after execution of interpreted method\n");
+		  printf("code now: %x\n", __MethodInstPtr(self)->m_code);
+	      }
+	      printf("context before:\n");
+	      __dumpObject__(sav, __LINE__);
+	      printf("context now:\n");
+	      __dumpObject__(__thisContext, __LINE__);
+	  }
 # endif
-          RETURN (rslt);
-        }
+	  RETURN (rslt);
+	}
     }
     badArgs: ;
 #endif /* not SCHTEAM */
 %}.
     (argArray isArray) ifFalse:[
-        (self argumentCount ~~ 0
-         or:[argArray notNil]) ifTrue:[
-            "
-             arguments must be either nil or an array
-            "
-            ^ self badArgumentArray:argArray
-        ]
+	(self argumentCount ~~ 0
+	 or:[argArray notNil]) ifTrue:[
+	    "
+	     arguments must be either nil or an array
+	    "
+	    ^ self badArgumentArray:argArray
+	]
     ].
 
     (argArray size ~~ self numArgs) ifTrue:[
-        "
-         the method expects a different number of arguments
-        "
-        ^ self wrongNumberOfArguments:argArray size
+	"
+	 the method expects a different number of arguments
+	"
+	^ self wrongNumberOfArguments:argArray size
     ].
 
     "/ if the VM only supports a limited number of arguments in sends (ST/X: 15)
     argArray size > self class maxNumberOfArguments ifTrue:[
-        ^ self tooManyArguments
+	^ self tooManyArguments
     ].
     ^ self primitiveFailed
 
     "
      (Float compiledMethodAt:#+)
-        valueWithReceiver:1.0 arguments:#(2.0)
+	valueWithReceiver:1.0 arguments:#(2.0)
 
      'the next example is a wrong one - which is detected by True's method ...'.
      (True compiledMethodAt:#printString)
-        valueWithReceiver:false arguments:nil
+	valueWithReceiver:false arguments:nil
 
      'the next example is a wrong one - it is nowhere detected
       and a wrong value returned ...'.
      (Point compiledMethodAt:#x)
-        valueWithReceiver:(1->2) arguments:nil
+	valueWithReceiver:(1->2) arguments:nil
 
      'the next example is VERY bad one - it is nowhere detected
       and may crash the system WARNING: save your work before doing this ...'.
      (Point compiledMethodAt:#x)
-        valueWithReceiver:(Object new) arguments:nil
+	valueWithReceiver:(Object new) arguments:nil
 
      'the next example is a wrong one - which is detected here ...'.
      (Object compiledMethodAt:#printOn:)
-        valueWithReceiver:false arguments:nil
+	valueWithReceiver:false arguments:nil
 
      'the next example is a wrong one - which is detected here ...'.
      (Object compiledMethodAt:#printOn:)
-        valueWithReceiver:false arguments:#()
+	valueWithReceiver:false arguments:#()
     "
 
     "Modified: / 07-10-2011 / 13:58:21 / cg"