[commit][2660] CogVM source as per VMMaker.oscog-eem.250.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[commit][2660] CogVM source as per VMMaker.oscog-eem.250.

commits-3
 
Revision: 2660
Author:   eliot
Date:     2013-01-07 13:54:37 -0800 (Mon, 07 Jan 2013)
Log Message:
-----------
CogVM source as per VMMaker.oscog-eem.250.

Fix (old) bug in ssAllocateRequiredRegMask:upThrough:
that would flush entire stack if allocating any register.

Implement absent receiver sends in the Cogit.
Refactor pushImplicitReceiver into genGetImplicitReceiverFor: and
clients and use genGetImplicitReceiverFor: for absent receiver sends.
Use Arg1Reg in place of Arg0Reg in ceImplicitReceiverTrampoline.
Fix CurrentImageCoInterpreterFacade for Newspeak methods.

Modified Paths:
--------------
    branches/Cog/nscogsrc/vm/cogit.c
    branches/Cog/nscogsrc/vm/cogit.h
    branches/Cog/nscogsrc/vm/cogmethod.h
    branches/Cog/src/vm/cogit.c
    branches/Cog/src/vm/cogit.h
    branches/Cog/src/vm/cogmethod.h

Property Changed:
----------------
    branches/Cog/platforms/Cross/vm/sqSCCSVersion.h

Modified: branches/Cog/nscogsrc/vm/cogit.c
===================================================================
--- branches/Cog/nscogsrc/vm/cogit.c 2013-01-05 15:10:09 UTC (rev 2659)
+++ branches/Cog/nscogsrc/vm/cogit.c 2013-01-07 21:54:37 UTC (rev 2660)
@@ -1,9 +1,9 @@
 /* Automatically generated by
- CCodeGenerator VMMaker.oscog-eem.248 uuid: 325b96ad-3c25-438e-af36-04a93839f195
+ CCodeGenerator VMMaker.oscog-eem.250 uuid: e0de5572-7682-4c5e-b5a0-ca2f32cf0c81
    from
- StackToRegisterMappingCogit VMMaker.oscog-eem.248 uuid: 325b96ad-3c25-438e-af36-04a93839f195
+ StackToRegisterMappingCogit VMMaker.oscog-eem.250 uuid: e0de5572-7682-4c5e-b5a0-ca2f32cf0c81
  */
-static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.248 uuid: 325b96ad-3c25-438e-af36-04a93839f195 " __DATE__ ;
+static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.250 uuid: e0de5572-7682-4c5e-b5a0-ca2f32cf0c81 " __DATE__ ;
 char *__cogitBuildInfo = __buildInfo;
 
 
@@ -628,6 +628,7 @@
 static sqInt genGetDoubleValueOfinto(sqInt srcReg, sqInt destFPReg);
 static sqInt genGetFixedFieldsOfPointerNonIntintoscratchReg(sqInt instReg, sqInt destReg, sqInt scratchReg);
 static sqInt genGetHashFieldNonIntOfasSmallIntegerInto(sqInt instReg, sqInt destReg);
+static sqInt genGetImplicitReceiverFor(sqInt selector);
 static sqInt genGetLeafCallStackPointer(void);
 static void genGetLeafCallStackPointerFunction(AbstractInstruction * self_in_genGetLeafCallStackPointerFunction);
 static sqInt genInnerPICAbortTrampoline(char *name);
@@ -752,6 +753,7 @@
 static sqInt genSaveStackPointers(void);
 static sqInt genSecondExtendedSendBytecode(void);
 static sqInt genSendAbsentImplicit0ArgsBytecode(void);
+static sqInt genSendAbsentImplicitnumArgs(sqInt selector, sqInt numArgs);
 static sqInt genSendLiteralSelector0ArgsBytecode(void);
 static sqInt genSendLiteralSelector1ArgBytecode(void);
 static sqInt genSendLiteralSelector2ArgsBytecode(void);
@@ -888,6 +890,7 @@
 void markMethodAndReferents(CogBlockMethod *aCogMethod);
 static sqInt markNSYoungObjectspcmethod(sqInt annotation, char *mcpc, sqInt cogMethod);
 static sqInt markYoungObjectspcmethod(sqInt annotation, char *mcpc, sqInt cogMethod);
+static void marshallImplicitReceiverSendArguments(sqInt numArgs);
 static void marshallSendArguments(sqInt numArgs);
 usqInt maxCogMethodAddress(void);
 static sqInt maybeFreeCogMethodDoesntLookKosher(CogMethod *cogMethod);
@@ -909,6 +912,7 @@
 static sqInt noCogMethodsMaximallyMarked(void);
 static void nopsFromto(AbstractInstruction * self_in_nopsFromto, sqInt startAddr, sqInt endAddr);
 static sqInt noTargetsFreeInClosedPIC(CogMethod *cPIC);
+static sqInt numberOfSpillsInTopNItems(sqInt n);
 static sqInt numCheckFeaturesOpcodes(AbstractInstruction * self_in_numCheckFeaturesOpcodes);
 static sqInt numICacheFlushOpcodes(AbstractInstruction * self_in_numICacheFlushOpcodes);
 static sqInt numLowLevelLockOpcodes(AbstractInstruction * self_in_numLowLevelLockOpcodes);
@@ -8992,8 +8996,14 @@
 static sqInt
 genExtSendAbsentImplicitBytecode(void)
 {
- error("shouldBeImplemented");
- return EncounteredUnknownBytecode;
+    sqInt litIndex;
+    sqInt nArgs;
+
+ litIndex = (((usqInt) byte1) >> 3) + (extA << 5);
+ extA = 0;
+ nArgs = (byte1 & 7) + (extB << 3);
+ extB = 0;
+ return genSendAbsentImplicitnumArgs(literalofMethod(litIndex, methodObj), nArgs);
 }
 
 
@@ -9546,9 +9556,9 @@
  genoperandoperandoperand(MoveMwrR, 0, SPReg, TempReg);
  /* begin MoveMw:r:R: */
  offset = jumpShortByteSize(backEnd);
- genoperandoperandoperand(MoveMwrR, offset, TempReg, Arg0Reg);
+ genoperandoperandoperand(MoveMwrR, offset, TempReg, Arg1Reg);
  /* begin CmpR:R: */
- genoperandoperand(CmpRR, ClassReg, Arg0Reg);
+ genoperandoperand(CmpRR, ClassReg, Arg1Reg);
  /* begin JumpNonZero: */
  jumpMiss = genoperand(JumpNonZero, ((sqInt)0));
  /* begin MoveMw:r:R: */
@@ -9961,6 +9971,53 @@
 }
 
 
+/* Cached implicit receiver implementation. Caller looks like
+ mov selector, ClassReg
+ call cePushImplicitReceiver
+ br continue
+ Lclass .word
+ Lmixin: .word
+ continue:
+ If class matches class of receiver then mixin contains either 0 or the
+ implicit receiver.
+ If 0, answer the actual receiver. This is done in the trampoline.
+ See generateNewspeakRuntime. */
+/* Cached implicit receiver implementation. Caller looks like
+ mov selector, ClassReg
+ call cePushImplicitReceiver
+ br continue
+ Lclass .word
+ Lmixin: .word
+ continue:
+ If class matches class of receiver then mixin contains either 0 or the
+ implicit receiver.
+ If 0, answer the actual receiver. This is done in the trampoline.
+ See generateNewspeakRuntime. */
+
+static sqInt
+genGetImplicitReceiverFor(sqInt selector)
+{
+    AbstractInstruction *skip;
+
+ ssAllocateCallRegandandand(SendNumArgsReg, ReceiverResultReg, ClassReg, Arg1Reg);
+ if (isYoung(selector)) {
+ hasYoungReferent = 1;
+ }
+ assert(needsFrame);
+ /* begin MoveCw:R: */
+ genoperandoperand(MoveCwR, selector, SendNumArgsReg);
+ CallNewspeakSend(ceImplicitReceiverTrampoline);
+ /* begin Jump: */
+ skip = genoperand(Jump, ((sqInt)0));
+ /* begin Fill32: */
+ genoperand(Fill32, 0);
+ /* begin Fill32: */
+ genoperand(Fill32, 0);
+ jmpTarget(skip, gLabel());
+ return 0;
+}
+
+
 /* Generate a routine that answers the stack pointer immedately
  after a leaf call, used for checking stack pointer alignment. */
 
@@ -11805,40 +11862,15 @@
  return ssPushRegister(ReceiverResultReg);
 }
 
-
-/* Cached push implicit receiver implementation. Caller looks like
- mov selector, ClassReg
- call cePushImplicitReceiver
- br continue
- Lclass .word
- Lmixin: .word
- continue:
- If class matches class of receiver then mixin contains either 0 or the
- implicit receiver.
- If 0, push the actual receiver. */
-
 static sqInt
 genPushImplicitReceiverBytecode(void)
 {
-    sqInt selector;
-    AbstractInstruction *skip;
+    sqInt result;
 
- ssAllocateCallRegandandand(SendNumArgsReg, ReceiverResultReg, ClassReg, Arg0Reg);
- selector = literalofMethod(byte1, methodObj);
- if (isYoung(selector)) {
- hasYoungReferent = 1;
+ result = genGetImplicitReceiverFor(literalofMethod(byte1, methodObj));
+ if (result != 0) {
+ return result;
  }
- assert(needsFrame);
- /* begin MoveCw:R: */
- genoperandoperand(MoveCwR, selector, SendNumArgsReg);
- CallNewspeakSend(ceImplicitReceiverTrampoline);
- /* begin Jump: */
- skip = genoperand(Jump, ((sqInt)0));
- /* begin Fill32: */
- genoperand(Fill32, 0);
- /* begin Fill32: */
- genoperand(Fill32, 0);
- jmpTarget(skip, gLabel());
  return ssPushRegister(ReceiverResultReg);
 }
 
@@ -12395,17 +12427,33 @@
 
 
 /* 160-175 1010 i i i i Send To Absent Implicit Receiver Literal Selector
- #iiii With 0 Arguments
+ #iiii With 0 Arguments.
  */
 
 static sqInt
 genSendAbsentImplicit0ArgsBytecode(void)
 {
- error("shouldBeImplemented");
- return EncounteredUnknownBytecode;
+ return genSendAbsentImplicitnumArgs(literalofMethod(byte0 & 15, methodObj), 0);
 }
 
+
+/* Get the implicit receiver and marshall arguments, shuffling the
+ stack to push the implicit receiver if necessary. Then send. */
+
 static sqInt
+genSendAbsentImplicitnumArgs(sqInt selector, sqInt numArgs)
+{
+    sqInt result;
+
+ result = genGetImplicitReceiverFor(selector);
+ if (result != 0) {
+ return result;
+ }
+ marshallImplicitReceiverSendArguments(numArgs);
+ return genMarshalledSendnumArgs(selector, numArgs);
+}
+
+static sqInt
 genSendLiteralSelector0ArgsBytecode(void)
 {
  return genSendnumArgs(literalofMethod(byte0 & 15, methodObj), 0);
@@ -15408,6 +15456,70 @@
 
 
 /* Spill everything on the simulated stack that needs spilling (that below
+ arguments). Marshall arguments to stack and/or registers depending on arg
+ count. If the args don't fit in registers push receiver and args (spill
+ everything). Assume
+ receiver already in ResultReceiverReg so shuffle args and push it if
+ necessary.  */
+
+static void
+marshallImplicitReceiverSendArguments(sqInt numArgs)
+{
+    sqInt index;
+    sqInt numSpilled;
+
+ if (numArgs > (numRegArgs())) {
+
+ /* The arguments must be pushed to the stack, and hence the receiver
+   must be inserted beneath the args.  Reduce or eliminate the argument
+   shuffle by only moving already spilled items. */
+
+ numSpilled = numberOfSpillsInTopNItems(numArgs);
+ if (numSpilled > 0) {
+ /* begin MoveMw:r:R: */
+ genoperandoperandoperand(MoveMwrR, 0, SPReg, TempReg);
+ /* begin PushR: */
+ genoperand(PushR, TempReg);
+ for (index = 2; index <= numSpilled; index += 1) {
+ /* begin MoveMw:r:R: */
+ genoperandoperandoperand(MoveMwrR, index * BytesPerWord, SPReg, TempReg);
+ /* begin MoveR:Mw:r: */
+ genoperandoperandoperand(MoveRMwr, TempReg, (index - 1) * BytesPerWord, SPReg);
+ }
+ /* begin MoveR:Mw:r: */
+ genoperandoperandoperand(MoveRMwr, ReceiverResultReg, numSpilled * BytesPerWord, SPReg);
+ }
+ else {
+ /* begin PushR: */
+ genoperand(PushR, ReceiverResultReg);
+ }
+ ssFlushTo(simStackPtr);
+ }
+ else {
+ ssFlushTo((simStackPtr - numArgs) - 1);
+ if (numArgs > 0) {
+ if (((numRegArgs()) > 1)
+ && (numArgs > 1)) {
+ ssAllocateRequiredRegupThrough(Arg0Reg, simStackPtr - 2);
+ ssAllocateRequiredRegupThrough(Arg1Reg, simStackPtr - 1);
+ }
+ else {
+ ssAllocateRequiredRegupThrough(Arg0Reg, simStackPtr - 1);
+ }
+ }
+ if (((numRegArgs()) > 1)
+ && (numArgs > 1)) {
+ popToReg(simStackAt(simStackPtr), Arg1Reg);
+ }
+ if (numArgs > 0) {
+ popToReg(simStackAt((simStackPtr - numArgs) + 1), Arg0Reg);
+ }
+ }
+ ssPop(numArgs);
+}
+
+
+/* Spill everything on the simulated stack that needs spilling (that below
  receiver and arguments).
  Marshall receiver and arguments to stack and/or registers depending on arg
  count. If the args don't fit in registers push receiver and args (spill
@@ -15717,7 +15829,20 @@
  return 1;
 }
 
+static sqInt
+numberOfSpillsInTopNItems(sqInt n)
+{
+    sqInt i;
 
+ for (i = simStackPtr; i >= ((simStackPtr - n) + 1); i += -1) {
+ if (((simStackAt(i)->type)) == SSSpill) {
+ return n - (simStackPtr - i);
+ }
+ }
+ return 0;
+}
+
+
 /* Answer the number of opcodes required to compile the CPUID call to extract
  the extended features information.
  */
@@ -17361,7 +17486,7 @@
  liveRegs = registerMaskForand(FPReg, SPReg);
  for (i = (((simSpillBase < 0) ? 0 : simSpillBase)); i <= stackPtr; i += 1) {
  liveRegs = liveRegs | (registerMask(simStackAt(i)));
- if ((liveRegs & requiredRegsMask) != 0) {
+ if (((registerMask(simStackAt(i))) & requiredRegsMask) != 0) {
  lastRequired = i;
  }
  }

Modified: branches/Cog/nscogsrc/vm/cogit.h
===================================================================
--- branches/Cog/nscogsrc/vm/cogit.h 2013-01-05 15:10:09 UTC (rev 2659)
+++ branches/Cog/nscogsrc/vm/cogit.h 2013-01-07 21:54:37 UTC (rev 2660)
@@ -1,5 +1,5 @@
 /* Automatically generated by
- CCodeGenerator VMMaker.oscog-eem.248 uuid: 325b96ad-3c25-438e-af36-04a93839f195
+ CCodeGenerator VMMaker.oscog-eem.250 uuid: e0de5572-7682-4c5e-b5a0-ca2f32cf0c81
  */
 
 

Modified: branches/Cog/nscogsrc/vm/cogmethod.h
===================================================================
--- branches/Cog/nscogsrc/vm/cogmethod.h 2013-01-05 15:10:09 UTC (rev 2659)
+++ branches/Cog/nscogsrc/vm/cogmethod.h 2013-01-07 21:54:37 UTC (rev 2660)
@@ -1,5 +1,5 @@
 /* Automatically generated by
- CCodeGenerator VMMaker.oscog-eem.248 uuid: 325b96ad-3c25-438e-af36-04a93839f195
+ CCodeGenerator VMMaker.oscog-eem.250 uuid: e0de5572-7682-4c5e-b5a0-ca2f32cf0c81
  */
 
 typedef struct {


Property changes on: branches/Cog/platforms/Cross/vm/sqSCCSVersion.h
___________________________________________________________________
Modified: checkindate
   - Fri Jan  4 12:43:14 PST 2013
   + Mon Jan  7 13:52:47 PST 2013

Modified: branches/Cog/src/vm/cogit.c
===================================================================
--- branches/Cog/src/vm/cogit.c 2013-01-05 15:10:09 UTC (rev 2659)
+++ branches/Cog/src/vm/cogit.c 2013-01-07 21:54:37 UTC (rev 2660)
@@ -1,9 +1,9 @@
 /* Automatically generated by
- CCodeGenerator VMMaker.oscog-eem.248 uuid: 325b96ad-3c25-438e-af36-04a93839f195
+ CCodeGenerator VMMaker.oscog-eem.250 uuid: e0de5572-7682-4c5e-b5a0-ca2f32cf0c81
    from
- StackToRegisterMappingCogit VMMaker.oscog-eem.248 uuid: 325b96ad-3c25-438e-af36-04a93839f195
+ StackToRegisterMappingCogit VMMaker.oscog-eem.250 uuid: e0de5572-7682-4c5e-b5a0-ca2f32cf0c81
  */
-static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.248 uuid: 325b96ad-3c25-438e-af36-04a93839f195 " __DATE__ ;
+static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.250 uuid: e0de5572-7682-4c5e-b5a0-ca2f32cf0c81 " __DATE__ ;
 char *__cogitBuildInfo = __buildInfo;
 
 
@@ -16045,7 +16045,7 @@
  liveRegs = registerMaskForand(FPReg, SPReg);
  for (i = (((simSpillBase < 0) ? 0 : simSpillBase)); i <= stackPtr; i += 1) {
  liveRegs = liveRegs | (registerMask(simStackAt(i)));
- if ((liveRegs & requiredRegsMask) != 0) {
+ if (((registerMask(simStackAt(i))) & requiredRegsMask) != 0) {
  lastRequired = i;
  }
  }

Modified: branches/Cog/src/vm/cogit.h
===================================================================
--- branches/Cog/src/vm/cogit.h 2013-01-05 15:10:09 UTC (rev 2659)
+++ branches/Cog/src/vm/cogit.h 2013-01-07 21:54:37 UTC (rev 2660)
@@ -1,5 +1,5 @@
 /* Automatically generated by
- CCodeGenerator VMMaker.oscog-eem.248 uuid: 325b96ad-3c25-438e-af36-04a93839f195
+ CCodeGenerator VMMaker.oscog-eem.250 uuid: e0de5572-7682-4c5e-b5a0-ca2f32cf0c81
  */
 
 

Modified: branches/Cog/src/vm/cogmethod.h
===================================================================
--- branches/Cog/src/vm/cogmethod.h 2013-01-05 15:10:09 UTC (rev 2659)
+++ branches/Cog/src/vm/cogmethod.h 2013-01-07 21:54:37 UTC (rev 2660)
@@ -1,5 +1,5 @@
 /* Automatically generated by
- CCodeGenerator VMMaker.oscog-eem.248 uuid: 325b96ad-3c25-438e-af36-04a93839f195
+ CCodeGenerator VMMaker.oscog-eem.250 uuid: e0de5572-7682-4c5e-b5a0-ca2f32cf0c81
  */
 
 typedef struct {