[Vm-dev] [commit][3028] CogVM source as per VMMaker.oscog-eem.796
commits at squeakvm.org
commits at squeakvm.org
Thu Jul 3 02:16:20 UTC 2014
Revision: 3028
Author: eliot
Date: 2014-07-02 19:16:19 -0700 (Wed, 02 Jul 2014)
Log Message:
-----------
CogVM source as per VMMaker.oscog-eem.796
Spur:
Implement forwarder following on primitive failure for sideways calls from
machine code.
Fix LargeIntegersPlugin>>isNormalized: for forwarders, no longer assuming that
if its arg isn't a SmallInteger it must be a large integer. Squash an assert
fail in lengthOf:format: on forwarders by using numSlotsOfAny:.
Make sure a forwarder has an accurate slot count, bumping it
to 1 if it was zero.
Modified Paths:
--------------
branches/Cog/nscogsrc/plugins/LargeIntegers/LargeIntegers.c
branches/Cog/nscogsrc/vm/cogit.c
branches/Cog/nscogsrc/vm/cogit.h
branches/Cog/nscogsrc/vm/cogmethod.h
branches/Cog/nscogsrc/vm/cointerp.c
branches/Cog/nscogsrc/vm/cointerp.h
branches/Cog/nscogsrc/vm/gcc3x-cointerp.c
branches/Cog/nscogsrc/vm/interp.h
branches/Cog/nscogsrc/vm/vmCallback.h
branches/Cog/nsspursrc/vm/cogit.c
branches/Cog/nsspursrc/vm/cogit.h
branches/Cog/nsspursrc/vm/cogmethod.h
branches/Cog/nsspursrc/vm/cointerp.c
branches/Cog/nsspursrc/vm/cointerp.h
branches/Cog/nsspursrc/vm/gcc3x-cointerp.c
branches/Cog/nsspursrc/vm/interp.h
branches/Cog/nsspursrc/vm/vmCallback.h
branches/Cog/nsspurstacksrc/vm/gcc3x-interp.c
branches/Cog/nsspurstacksrc/vm/interp.c
branches/Cog/nsspurstacksrc/vm/interp.h
branches/Cog/nsspurstacksrc/vm/vmCallback.h
branches/Cog/sistasrc/vm/cogit.c
branches/Cog/sistasrc/vm/cogit.h
branches/Cog/sistasrc/vm/cogmethod.h
branches/Cog/sistasrc/vm/cointerp.c
branches/Cog/sistasrc/vm/cointerp.h
branches/Cog/sistasrc/vm/gcc3x-cointerp.c
branches/Cog/sistasrc/vm/interp.h
branches/Cog/sistasrc/vm/vmCallback.h
branches/Cog/spursistasrc/vm/cogit.c
branches/Cog/spursistasrc/vm/cogit.h
branches/Cog/spursistasrc/vm/cogmethod.h
branches/Cog/spursistasrc/vm/cointerp.c
branches/Cog/spursistasrc/vm/cointerp.h
branches/Cog/spursistasrc/vm/gcc3x-cointerp.c
branches/Cog/spursistasrc/vm/interp.h
branches/Cog/spursistasrc/vm/vmCallback.h
branches/Cog/spursrc/vm/cogit.c
branches/Cog/spursrc/vm/cogit.h
branches/Cog/spursrc/vm/cogmethod.h
branches/Cog/spursrc/vm/cointerp.c
branches/Cog/spursrc/vm/cointerp.h
branches/Cog/spursrc/vm/gcc3x-cointerp.c
branches/Cog/spursrc/vm/interp.h
branches/Cog/spursrc/vm/vmCallback.h
branches/Cog/spurstacksrc/vm/gcc3x-interp.c
branches/Cog/spurstacksrc/vm/interp.c
branches/Cog/spurstacksrc/vm/interp.h
branches/Cog/spurstacksrc/vm/vmCallback.h
branches/Cog/src/plugins/LargeIntegers/LargeIntegers.c
branches/Cog/src/vm/cogit.c
branches/Cog/src/vm/cogit.h
branches/Cog/src/vm/cogmethod.h
branches/Cog/src/vm/cointerp.c
branches/Cog/src/vm/cointerp.h
branches/Cog/src/vm/cointerpmt.c
branches/Cog/src/vm/cointerpmt.h
branches/Cog/src/vm/gcc3x-cointerp.c
branches/Cog/src/vm/gcc3x-cointerpmt.c
branches/Cog/src/vm/interp.h
branches/Cog/src/vm/vmCallback.h
branches/Cog/stacksrc/vm/gcc3x-interp.c
branches/Cog/stacksrc/vm/interp.c
branches/Cog/stacksrc/vm/interp.h
branches/Cog/stacksrc/vm/vmCallback.h
Property Changed:
----------------
branches/Cog/platforms/Cross/vm/sqSCCSVersion.h
Modified: branches/Cog/nscogsrc/plugins/LargeIntegers/LargeIntegers.c
===================================================================
--- branches/Cog/nscogsrc/plugins/LargeIntegers/LargeIntegers.c 2014-07-03 00:26:26 UTC (rev 3027)
+++ branches/Cog/nscogsrc/plugins/LargeIntegers/LargeIntegers.c 2014-07-03 02:16:19 UTC (rev 3028)
@@ -1,9 +1,9 @@
/* Automatically generated by
- SmartSyntaxPluginCodeGenerator VMMaker.oscog-eem.790 uuid: 1c0587fb-44ad-43f6-8bfd-2a0f91e21a59
+ SmartSyntaxPluginCodeGenerator VMMaker.oscog-eem.796 uuid: 037e61a6-d81c-42e5-bbcb-62adbd938f38
from
- LargeIntegersPlugin VMMaker.oscog-eem.790 uuid: 1c0587fb-44ad-43f6-8bfd-2a0f91e21a59
+ LargeIntegersPlugin VMMaker.oscog-eem.796 uuid: 037e61a6-d81c-42e5-bbcb-62adbd938f38
*/
-static char __buildInfo[] = "LargeIntegersPlugin VMMaker.oscog-eem.790 uuid: 1c0587fb-44ad-43f6-8bfd-2a0f91e21a59 " __DATE__ ;
+static char __buildInfo[] = "LargeIntegersPlugin VMMaker.oscog-eem.796 uuid: 037e61a6-d81c-42e5-bbcb-62adbd938f38 " __DATE__ ;
@@ -37,6 +37,7 @@
/*** Constants ***/
+#define PrimErrBadArgument 3
/*** Function Prototypes ***/
@@ -53,14 +54,14 @@
static int cBytesReplacefromtowithstartingAt(unsigned char * pTo, sqInt start, sqInt stop, unsigned char * pFrom, sqInt repStart);
static sqInt cCopyIntValtoBytes(sqInt val, sqInt bytes);
static sqInt cCoreBytesRshiftCountnfbytesfromlentolen(sqInt count, sqInt n, sqInt f, sqInt b, unsigned char * pFrom, sqInt fromLen, unsigned char * pTo, sqInt toLen);
-static sqInt cCoreDigitDivDivlenremlenquolen(unsigned char * pDiv, sqInt divLen, unsigned char * pRem, sqInt remLen, unsigned char * pQuo, sqInt quoLen);
+static sqInt cCoreDigitDivDivlenremlenquolen(unsigned char *pDiv, sqInt divLen, unsigned char *pRem, sqInt remLen, unsigned char *pQuo, sqInt quoLen);
static unsigned char cDigitAddlenwithleninto(unsigned char * pByteShort, sqInt shortLen, unsigned char * pByteLong, sqInt longLen, unsigned char * pByteRes);
static sqInt cDigitComparewithlen(unsigned char * pFirst, unsigned char * pSecond, sqInt len);
static sqInt cDigitLengthOfCSI(sqInt csi);
static unsigned char cDigitMultiplylenwithleninto(unsigned char * pByteShort, sqInt shortLen, unsigned char * pByteLong, sqInt longLen, unsigned char * pByteRes);
static sqInt cDigitOfCSIat(sqInt csi, sqInt ix);
-static sqInt cDigitSublenwithleninto(unsigned char * pByteSmall, sqInt smallLen, unsigned char * pByteLarge, sqInt largeLen, unsigned char * pByteRes);
-static sqInt cdigitMontgomerylentimeslenmodulolenmInvModBinto(unsigned char * pBytesFirst, sqInt firstLen, unsigned char * pBytesSecond, sqInt secondLen, unsigned char * pBytesThird, sqInt thirdLen, sqInt mInv, unsigned char * pBytesRes);
+static sqInt cDigitSublenwithleninto(unsigned char *pByteSmall, sqInt smallLen, unsigned char *pByteLarge, sqInt largeLen, unsigned char *pByteRes);
+static sqInt cdigitMontgomerylentimeslenmodulolenmInvModBinto(unsigned char *pBytesFirst, sqInt firstLen, unsigned char *pBytesSecond, sqInt secondLen, unsigned char *pBytesThird, sqInt thirdLen, sqInt mInv, unsigned char *pBytesRes);
static sqInt cHighBit(sqInt uint);
static sqInt createLargeFromSmallInteger(sqInt anOop);
static sqInt digitAddLargewith(sqInt firstInteger, sqInt secondInteger);
@@ -135,6 +136,7 @@
static sqInt (*popthenPush)(sqInt nItems, sqInt oop);
static sqInt (*popRemappableOop)(void);
static sqInt (*primitiveFail)(void);
+static sqInt (*primitiveFailFor)(sqInt reasonCode);
static sqInt (*pushRemappableOop)(sqInt oop);
static sqInt (*slotSizeOf)(sqInt oop);
static sqInt (*stObjectatput)(sqInt array, sqInt index, sqInt value);
@@ -160,6 +162,7 @@
extern sqInt popthenPush(sqInt nItems, sqInt oop);
extern sqInt popRemappableOop(void);
extern sqInt primitiveFail(void);
+extern sqInt primitiveFailFor(sqInt reasonCode);
extern sqInt pushRemappableOop(sqInt oop);
extern sqInt slotSizeOf(sqInt oop);
extern sqInt stObjectatput(sqInt array, sqInt index, sqInt value);
@@ -172,9 +175,9 @@
struct VirtualMachine* interpreterProxy;
static const char *moduleName =
#ifdef SQUEAK_BUILTIN_PLUGIN
- "LargeIntegers v1.5 VMMaker.oscog-eem.790 (i)"
+ "LargeIntegers v1.5 VMMaker.oscog-eem.796 (i)"
#else
- "LargeIntegers v1.5 VMMaker.oscog-eem.790 (e)"
+ "LargeIntegers v1.5 VMMaker.oscog-eem.796 (e)"
#endif
;
static const int orOpIndex = 1;
@@ -300,9 +303,16 @@
sqInt newBytes;
sqInt oldLen;
- pushRemappableOop(aBytesObject);
+
+#if SPURVM
newBytes = instantiateClassindexableSize(fetchClassOf(aBytesObject), newLen);
- aBytesObject = popRemappableOop();
+
+#else /* SPURVM */
+pushRemappableOop(aBytesObject);
+ newBytes = instantiateClassindexableSize(fetchClassOf(aBytesObject), newLen);
+ aBytesObject = popRemappableOop()
+#endif /* SPURVM */
+;
oldLen = slotSizeOf(aBytesObject);
if (oldLen < newLen) {
copyLen = oldLen;
@@ -342,9 +352,16 @@
return integerObjectOf(0);
}
newLen = ((highBit + shiftCount) + 7) / 8;
- pushRemappableOop(aBytesOop);
+
+#if SPURVM
newBytes = instantiateClassindexableSize(fetchClassOf(aBytesOop), newLen);
- aBytesOop = popRemappableOop();
+
+#else /* SPURVM */
+pushRemappableOop(aBytesOop);
+ newBytes = instantiateClassindexableSize(fetchClassOf(aBytesOop), newLen);
+ aBytesOop = popRemappableOop()
+#endif /* SPURVM */
+;
/* begin cBytesLshift:from:len:to:len: */
pFrom = firstIndexableField(aBytesOop);
pTo = firstIndexableField(newBytes);
@@ -452,9 +469,16 @@
}
oldLen = slotSizeOf(aBytesOop);
newLen = i - b;
- pushRemappableOop(aBytesOop);
+
+#if SPURVM
newBytes = instantiateClassindexableSize(fetchClassOf(aBytesOop), newLen);
- aBytesOop = popRemappableOop();
+
+#else /* SPURVM */
+pushRemappableOop(aBytesOop);
+ newBytes = instantiateClassindexableSize(fetchClassOf(aBytesOop), newLen);
+ aBytesOop = popRemappableOop()
+#endif /* SPURVM */
+;
/* begin cCoreBytesRshiftCount:n:f:bytes:from:len:to:len: */
pFrom = firstIndexableField(aBytesOop);
pTo = firstIndexableField(newBytes);
@@ -683,7 +707,7 @@
}
static sqInt
-cCoreDigitDivDivlenremlenquolen(unsigned char * pDiv, sqInt divLen, unsigned char * pRem, sqInt remLen, unsigned char * pQuo, sqInt quoLen)
+cCoreDigitDivDivlenremlenquolen(unsigned char *pDiv, sqInt divLen, unsigned char *pRem, sqInt remLen, unsigned char *pQuo, sqInt quoLen)
{
sqInt a;
sqInt cond;
@@ -709,12 +733,9 @@
dl = divLen - 1;
ql = quoLen;
dh = pDiv[dl - 1];
- if (dl == 1) {
- dnh = 0;
- }
- else {
- dnh = pDiv[dl - 2];
- }
+ dnh = (dl == 1
+ ? 0
+ : pDiv[dl - 2]);
for (k = 1; k <= ql; k += 1) {
/* maintain quo*arg+rem=self */
@@ -783,13 +804,9 @@
a = 0;
for (i = 1; i <= divLen; i += 1) {
hi = (pDiv[i - 1]) * (((usqInt) q >> 8));
-
- /* pRem at: l - 1 put: lo - (lo // 256 * 256). */
- /* sign-tolerant form of (lo bitAnd: 255) -> obsolete... */
-
lo = (a + (pRem[l - 1])) - ((pDiv[i - 1]) * (q & 0xFF));
- pRem[l - 1] = (lo & 0xFF);
- a = (lo / 256) - hi;
+ pRem[l - 1] = lo;
+ a = (((signed)lo >> 8)) - hi;
l += 1;
}
if (a < 0) {
@@ -801,7 +818,7 @@
a = 0;
for (i = 1; i <= divLen; i += 1) {
a = ((((usqInt) a >> 8)) + (pRem[l - 1])) + (pDiv[i - 1]);
- pRem[l - 1] = (a & 0xFF);
+ pRem[l - 1] = a;
l += 1;
}
}
@@ -947,7 +964,7 @@
}
static sqInt
-cDigitSublenwithleninto(unsigned char * pByteSmall, sqInt smallLen, unsigned char * pByteLarge, sqInt largeLen, unsigned char * pByteRes)
+cDigitSublenwithleninto(unsigned char *pByteSmall, sqInt smallLen, unsigned char *pByteLarge, sqInt largeLen, unsigned char *pByteRes)
{
sqInt i;
sqInt z;
@@ -958,27 +975,27 @@
z = 0;
for (i = 0; i < smallLen; i += 1) {
z = (z + (pByteLarge[i])) - (pByteSmall[i]);
- pByteRes[i] = (z - ((z / 256) * 256));
+ pByteRes[i] = z;
z = ((signed)z >> 8);
}
for (i = smallLen; i < largeLen; i += 1) {
z += pByteLarge[i];
- pByteRes[i] = (z - ((z / 256) * 256));
+ pByteRes[i] = z;
z = ((signed)z >> 8);
}
}
static sqInt
-cdigitMontgomerylentimeslenmodulolenmInvModBinto(unsigned char * pBytesFirst, sqInt firstLen, unsigned char * pBytesSecond, sqInt secondLen, unsigned char * pBytesThird, sqInt thirdLen, sqInt mInv, unsigned char * pBytesRes)
+cdigitMontgomerylentimeslenmodulolenmInvModBinto(unsigned char *pBytesFirst, sqInt firstLen, unsigned char *pBytesSecond, sqInt secondLen, unsigned char *pBytesThird, sqInt thirdLen, sqInt mInv, unsigned char *pBytesRes)
{
- usqInt accum;
+ usqInt accum;
sqInt i;
sqInt k;
- unsigned char lastByte;
+ unsigned char lastByte;
sqInt limit1;
sqInt limit2;
sqInt limit3;
- unsigned char u;
+ unsigned char u;
limit1 = firstLen - 1;
limit2 = secondLen - 1;
@@ -1020,8 +1037,8 @@
accum = 0;
for (i = 0; i <= limit3; i += 1) {
accum = (accum + (pBytesRes[i])) - (pBytesThird[i]);
- pBytesRes[i] = (accum - ((accum / 256) * 256));
- accum = accum / 256;
+ pBytesRes[i] = accum;
+ accum = ((signed)accum >> 8);
}
}
}
@@ -1146,11 +1163,18 @@
longInt = firstInteger;
longLen = firstLen;
}
- pushRemappableOop(shortInt);
+
+#if SPURVM
+ sum = instantiateClassindexableSize(resClass, longLen);
+
+#else /* SPURVM */
+pushRemappableOop(shortInt);
pushRemappableOop(longInt);
sum = instantiateClassindexableSize(resClass, longLen);
longInt = popRemappableOop();
- shortInt = popRemappableOop();
+ shortInt = popRemappableOop()
+#endif /* SPURVM */
+;
/* begin cDigitAdd:len:with:len:into: */
pByteShort = firstIndexableField(shortInt);
pByteLong = firstIndexableField(longInt);
@@ -1171,9 +1195,16 @@
/* sum := sum growby: 1. */
- pushRemappableOop(sum);
+
+#if SPURVM
newSum = instantiateClassindexableSize(resClass, longLen + 1);
- sum = popRemappableOop();
+
+#else /* SPURVM */
+pushRemappableOop(sum);
+ newSum = instantiateClassindexableSize(resClass, longLen + 1);
+ sum = popRemappableOop()
+#endif /* SPURVM */
+;
cBytesCopyFromtolen(firstIndexableField(sum), firstIndexableField(newSum), longLen);
/* C index! */
@@ -1210,9 +1241,16 @@
if ((integerValueOf(firstInteger)) < 0) {
return primitiveFail();
}
- pushRemappableOop(secondInteger);
+
+#if SPURVM
firstLarge = createLargeFromSmallInteger(firstInteger);
- secondInteger = popRemappableOop();
+
+#else /* SPURVM */
+pushRemappableOop(secondInteger);
+ firstLarge = createLargeFromSmallInteger(firstInteger);
+ secondInteger = popRemappableOop()
+#endif /* SPURVM */
+;
}
else {
if ((fetchClassOf(firstInteger)) == (classLargeNegativeInteger())) {
@@ -1224,9 +1262,16 @@
if ((integerValueOf(secondInteger)) < 0) {
return primitiveFail();
}
- pushRemappableOop(firstLarge);
+
+#if SPURVM
secondLarge = createLargeFromSmallInteger(secondInteger);
- firstLarge = popRemappableOop();
+
+#else /* SPURVM */
+pushRemappableOop(firstLarge);
+ secondLarge = createLargeFromSmallInteger(secondInteger);
+ firstLarge = popRemappableOop()
+#endif /* SPURVM */
+;
}
else {
if ((fetchClassOf(secondInteger)) == (classLargeNegativeInteger())) {
@@ -1248,11 +1293,18 @@
longLen = firstLen;
longLarge = firstLarge;
}
- pushRemappableOop(shortLarge);
+
+#if SPURVM
+ result = instantiateClassindexableSize(classLargePositiveInteger(), longLen);
+
+#else /* SPURVM */
+pushRemappableOop(shortLarge);
pushRemappableOop(longLarge);
result = instantiateClassindexableSize(classLargePositiveInteger(), longLen);
longLarge = popRemappableOop();
- shortLarge = popRemappableOop();
+ shortLarge = popRemappableOop()
+#endif /* SPURVM */
+;
/* begin cByteOp:short:len:long:len:into: */
pByteShort = firstIndexableField(shortLarge);
pByteLong = firstIndexableField(longLarge);
@@ -1346,10 +1398,10 @@
sqInt l1;
sqInt lo;
sqInt mul;
- unsigned char * pDiv;
+ unsigned char *pDiv;
unsigned char *pointer;
- unsigned char * pQuo;
- unsigned char * pRem;
+ unsigned char *pQuo;
+ unsigned char *pRem;
sqInt q;
sqInt ql;
sqInt quo;
@@ -1373,29 +1425,61 @@
}
l = (firstLen - secondLen) + 1;
if (l <= 0) {
- pushRemappableOop(firstInteger);
+
+#if SPURVM
result = instantiateClassindexableSize(classArray(), 2);
- firstInteger = popRemappableOop();
+
+#else /* SPURVM */
+pushRemappableOop(firstInteger);
+ result = instantiateClassindexableSize(classArray(), 2);
+ firstInteger = popRemappableOop()
+#endif /* SPURVM */
+;
stObjectatput(result,1,(integerObjectOf(0)));
stObjectatput(result,2,firstInteger);
return result;
}
d = 8 - (cHighBit(((pointer = firstIndexableField(secondInteger)))[secondLen - 1]));
- pushRemappableOop(firstInteger);
+
+#if SPURVM
div = bytesLshift(secondInteger, d);
div = bytesOrIntgrowTo(div, (digitLength(div)) + 1);
- firstInteger = popRemappableOop();
- pushRemappableOop(div);
+
+#else /* SPURVM */
+pushRemappableOop(firstInteger);
+ div = bytesLshift(secondInteger, d);
+ div = bytesOrIntgrowTo(div, (digitLength(div)) + 1);
+ firstInteger = popRemappableOop()
+#endif /* SPURVM */
+;
+
+#if SPURVM
rem = bytesLshift(firstInteger, d);
if ((digitLength(rem)) == firstLen) {
rem = bytesOrIntgrowTo(rem, firstLen + 1);
}
- div = popRemappableOop();
- pushRemappableOop(div);
+
+#else /* SPURVM */
+pushRemappableOop(div);
+ rem = bytesLshift(firstInteger, d);
+ if ((digitLength(rem)) == firstLen) {
+ rem = bytesOrIntgrowTo(rem, firstLen + 1);
+ }
+ div = popRemappableOop()
+#endif /* SPURVM */
+;
+
+#if SPURVM
+ quo = instantiateClassindexableSize(resultClass, l);
+
+#else /* SPURVM */
+pushRemappableOop(div);
pushRemappableOop(rem);
quo = instantiateClassindexableSize(resultClass, l);
rem = popRemappableOop();
- div = popRemappableOop();
+ div = popRemappableOop()
+#endif /* SPURVM */
+;
/* begin cCoreDigitDivDiv:len:rem:len:quo:len: */
pDiv = firstIndexableField(div);
/* begin digitLength: */
@@ -1484,12 +1568,9 @@
dl = divLen - 1;
ql = quoLen;
dh = pDiv[dl - 1];
- if (dl == 1) {
- dnh = 0;
- }
- else {
- dnh = pDiv[dl - 2];
- }
+ dnh = (dl == 1
+ ? 0
+ : pDiv[dl - 2]);
for (k = 1; k <= ql; k += 1) {
/* maintain quo*arg+rem=self */
@@ -1558,13 +1639,9 @@
a = 0;
for (i = 1; i <= divLen; i += 1) {
hi = (pDiv[i - 1]) * (((usqInt) q >> 8));
-
- /* pRem at: l - 1 put: lo - (lo // 256 * 256). */
- /* sign-tolerant form of (lo bitAnd: 255) -> obsolete... */
-
lo = (a + (pRem[l1 - 1])) - ((pDiv[i - 1]) * (q & 0xFF));
- pRem[l1 - 1] = (lo & 0xFF);
- a = (lo / 256) - hi;
+ pRem[l1 - 1] = lo;
+ a = (((signed)lo >> 8)) - hi;
l1 += 1;
}
if (a < 0) {
@@ -1576,20 +1653,34 @@
a = 0;
for (i = 1; i <= divLen; i += 1) {
a = ((((usqInt) a >> 8)) + (pRem[l1 - 1])) + (pDiv[i - 1]);
- pRem[l1 - 1] = (a & 0xFF);
+ pRem[l1 - 1] = a;
l1 += 1;
}
}
pQuo[quoLen - k] = q;
}
- pushRemappableOop(quo);
+
+#if SPURVM
rem = bytesRshiftbyteslookfirst(rem, d, 0, (digitLength(div)) - 1);
- quo = popRemappableOop();
- pushRemappableOop(quo);
+
+#else /* SPURVM */
+pushRemappableOop(quo);
+ rem = bytesRshiftbyteslookfirst(rem, d, 0, (digitLength(div)) - 1);
+ quo = popRemappableOop()
+#endif /* SPURVM */
+;
+
+#if SPURVM
+ result = instantiateClassindexableSize(classArray(), 2);
+
+#else /* SPURVM */
+pushRemappableOop(quo);
pushRemappableOop(rem);
result = instantiateClassindexableSize(classArray(), 2);
rem = popRemappableOop();
- quo = popRemappableOop();
+ quo = popRemappableOop()
+#endif /* SPURVM */
+;
stObjectatput(result,1,quo);
stObjectatput(result,2,rem);
return result;
@@ -1622,22 +1713,22 @@
static sqInt
digitMontgomerytimesmodulomInvModB(sqInt firstLarge, sqInt secondLarge, sqInt thirdLarge, sqInt mInv)
{
- usqInt accum;
+ usqInt accum;
sqInt firstLen;
sqInt i;
sqInt k;
- unsigned char lastByte;
+ unsigned char lastByte;
sqInt limit1;
sqInt limit2;
sqInt limit3;
- unsigned char * pBytesFirst;
- unsigned char * pBytesRes;
- unsigned char * pBytesSecond;
- unsigned char * pBytesThird;
+ unsigned char *pBytesFirst;
+ unsigned char *pBytesRes;
+ unsigned char *pBytesSecond;
+ unsigned char *pBytesThird;
sqInt prod;
sqInt secondLen;
sqInt thirdLen;
- unsigned char u;
+ unsigned char u;
firstLen = slotSizeOf(firstLarge);
secondLen = slotSizeOf(secondLarge);
@@ -1652,13 +1743,20 @@
&& (mInv <= 0xFF))) {
return primitiveFail();
}
- pushRemappableOop(firstLarge);
+
+#if SPURVM
+ prod = instantiateClassindexableSize(classLargePositiveInteger(), thirdLen);
+
+#else /* SPURVM */
+pushRemappableOop(firstLarge);
pushRemappableOop(secondLarge);
pushRemappableOop(thirdLarge);
prod = instantiateClassindexableSize(classLargePositiveInteger(), thirdLen);
thirdLarge = popRemappableOop();
secondLarge = popRemappableOop();
- firstLarge = popRemappableOop();
+ firstLarge = popRemappableOop()
+#endif /* SPURVM */
+;
/* begin cdigitMontgomery:len:times:len:modulo:len:mInvModB:into: */
pBytesFirst = firstIndexableField(firstLarge);
pBytesSecond = firstIndexableField(secondLarge);
@@ -1704,8 +1802,8 @@
accum = 0;
for (i = 0; i <= limit3; i += 1) {
accum = (accum + (pBytesRes[i])) - (pBytesThird[i]);
- pBytesRes[i] = (accum - ((accum / 256) * 256));
- accum = accum / 256;
+ pBytesRes[i] = accum;
+ accum = ((signed)accum >> 8);
}
}
return normalizePositive(prod);
@@ -1757,11 +1855,18 @@
else {
resultClass = classLargePositiveInteger();
}
- pushRemappableOop(shortInt);
+
+#if SPURVM
+ prod = instantiateClassindexableSize(resultClass, longLen + shortLen);
+
+#else /* SPURVM */
+pushRemappableOop(shortInt);
pushRemappableOop(longInt);
prod = instantiateClassindexableSize(resultClass, longLen + shortLen);
longInt = popRemappableOop();
- shortInt = popRemappableOop();
+ shortInt = popRemappableOop()
+#endif /* SPURVM */
+;
/* begin cDigitMultiply:len:with:len:into: */
pByteShort = firstIndexableField(shortInt);
pByteLong = firstIndexableField(longInt);
@@ -1854,9 +1959,9 @@
sqInt larger;
sqInt largerLen;
sqInt neg;
- unsigned char * pByteLarge;
- unsigned char * pByteRes;
- unsigned char * pByteSmall;
+ unsigned char *pByteLarge;
+ unsigned char *pByteRes;
+ unsigned char *pByteSmall;
sqInt res;
sqInt resLen;
sqInt secondLen;
@@ -1891,13 +1996,22 @@
neg = firstNeg;
}
resLen = largerLen;
- pushRemappableOop(smaller);
+
+#if SPURVM
+ res = instantiateClassindexableSize((neg
+ ? classLargeNegativeInteger()
+ : classLargePositiveInteger()), resLen);
+
+#else /* SPURVM */
+pushRemappableOop(smaller);
pushRemappableOop(larger);
res = instantiateClassindexableSize((neg
? classLargeNegativeInteger()
: classLargePositiveInteger()), resLen);
larger = popRemappableOop();
- smaller = popRemappableOop();
+ smaller = popRemappableOop()
+#endif /* SPURVM */
+;
/* begin cDigitSub:len:with:len:into: */
pByteSmall = firstIndexableField(smaller);
pByteLarge = firstIndexableField(larger);
@@ -1908,12 +2022,12 @@
z = 0;
for (i = 0; i < smallerLen; i += 1) {
z = (z + (pByteLarge[i])) - (pByteSmall[i]);
- pByteRes[i] = (z - ((z / 256) * 256));
+ pByteRes[i] = z;
z = ((signed)z >> 8);
}
for (i = smallerLen; i < largerLen; i += 1) {
z += pByteLarge[i];
- pByteRes[i] = (z - ((z / 256) * 256));
+ pByteRes[i] = z;
z = ((signed)z >> 8);
}
return (neg
@@ -1972,6 +2086,7 @@
static sqInt
isNormalized(sqInt anInteger)
{
+ sqInt class;
sqInt ix;
sqInt len;
sqInt maxVal;
@@ -1980,11 +2095,19 @@
unsigned char *pointer1;
unsigned char *pointer2;
unsigned char *pointer3;
+ sqInt positive;
sqInt sLen;
if (isIntegerObject(anInteger)) {
return 1;
}
+ class = fetchClassOf(anInteger);
+ if (!((positive = class == (classLargePositiveInteger())))) {
+ if (!(class == (classLargeNegativeInteger()))) {
+ primitiveFailFor(PrimErrBadArgument);
+ return 0;
+ }
+ }
/* begin digitLength: */
if (isIntegerObject(anInteger)) {
/* begin cDigitLengthOfCSI: */
@@ -2027,7 +2150,7 @@
if (len < sLen) {
return 0;
}
- if ((fetchClassOf(anInteger)) == (classLargePositiveInteger())) {
+ if (positive) {
/* SmallInteger maxVal */
/* all bytes of maxVal but the highest one are just FF's */
@@ -2044,15 +2167,9 @@
if ((((pointer2 = firstIndexableField(anInteger)))[sLen - 1]) < (cDigitOfCSIat(minVal, sLen))) {
return 0;
}
- else {
-
- /* if just one digit differs, then anInteger < minval (the corresponding digit byte is greater!)
- and therefore a LargeNegativeInteger */
-
- for (ix = 1; ix <= sLen; ix += 1) {
- if (!((((pointer3 = firstIndexableField(anInteger)))[ix - 1]) == (cDigitOfCSIat(minVal, ix)))) {
- return 1;
- }
+ for (ix = 1; ix <= sLen; ix += 1) {
+ if (!((((pointer3 = firstIndexableField(anInteger)))[ix - 1]) == (cDigitOfCSIat(minVal, ix)))) {
+ return 1;
}
}
}
@@ -2322,9 +2439,16 @@
/* convert it to a not normalized LargeInteger */
- pushRemappableOop(secondInteger);
+
+#if SPURVM
firstLarge = createLargeFromSmallInteger(firstInteger);
- secondInteger = popRemappableOop();
+
+#else /* SPURVM */
+pushRemappableOop(secondInteger);
+ firstLarge = createLargeFromSmallInteger(firstInteger);
+ secondInteger = popRemappableOop()
+#endif /* SPURVM */
+;
}
else {
firstLarge = firstInteger;
@@ -2333,9 +2457,16 @@
/* convert it to a not normalized LargeInteger */
- pushRemappableOop(firstLarge);
+
+#if SPURVM
secondLarge = createLargeFromSmallInteger(secondInteger);
- firstLarge = popRemappableOop();
+
+#else /* SPURVM */
+pushRemappableOop(firstLarge);
+ secondLarge = createLargeFromSmallInteger(secondInteger);
+ firstLarge = popRemappableOop()
+#endif /* SPURVM */
+;
}
else {
secondLarge = secondInteger;
@@ -2369,9 +2500,16 @@
/* convert it to a not normalized LargeInteger */
- pushRemappableOop(secondInteger);
+
+#if SPURVM
firstLarge = createLargeFromSmallInteger(firstInteger);
- secondInteger = popRemappableOop();
+
+#else /* SPURVM */
+pushRemappableOop(secondInteger);
+ firstLarge = createLargeFromSmallInteger(firstInteger);
+ secondInteger = popRemappableOop()
+#endif /* SPURVM */
+;
}
else {
firstLarge = firstInteger;
@@ -2380,9 +2518,16 @@
/* convert it to a not normalized LargeInteger */
- pushRemappableOop(firstLarge);
+
+#if SPURVM
secondLarge = createLargeFromSmallInteger(secondInteger);
- firstLarge = popRemappableOop();
+
+#else /* SPURVM */
+pushRemappableOop(firstLarge);
+ secondLarge = createLargeFromSmallInteger(secondInteger);
+ firstLarge = popRemappableOop()
+#endif /* SPURVM */
+;
}
else {
secondLarge = secondInteger;
@@ -2842,9 +2987,16 @@
/* convert to LargeInteger */
- pushRemappableOop(secondInteger);
+
+#if SPURVM
firstAsLargeInteger = createLargeFromSmallInteger(firstInteger);
- secondInteger = popRemappableOop();
+
+#else /* SPURVM */
+pushRemappableOop(secondInteger);
+ firstAsLargeInteger = createLargeFromSmallInteger(firstInteger);
+ secondInteger = popRemappableOop()
+#endif /* SPURVM */
+;
}
else {
firstAsLargeInteger = firstInteger;
@@ -2857,9 +3009,16 @@
primitiveFail();
return null;
}
- pushRemappableOop(firstAsLargeInteger);
+
+#if SPURVM
secondAsLargeInteger = createLargeFromSmallInteger(secondInteger);
- firstAsLargeInteger = popRemappableOop();
+
+#else /* SPURVM */
+pushRemappableOop(firstAsLargeInteger);
+ secondAsLargeInteger = createLargeFromSmallInteger(secondInteger);
+ firstAsLargeInteger = popRemappableOop()
+#endif /* SPURVM */
+;
}
else {
secondAsLargeInteger = secondInteger;
@@ -2899,9 +3058,16 @@
/* convert to LargeInteger */
- pushRemappableOop(secondInteger);
+
+#if SPURVM
firstAsLargeInteger = createLargeFromSmallInteger(firstInteger);
- secondInteger = popRemappableOop();
+
+#else /* SPURVM */
+pushRemappableOop(secondInteger);
+ firstAsLargeInteger = createLargeFromSmallInteger(firstInteger);
+ secondInteger = popRemappableOop()
+#endif /* SPURVM */
+;
}
else {
firstAsLargeInteger = firstInteger;
@@ -2914,9 +3080,16 @@
primitiveFail();
return null;
}
- pushRemappableOop(firstAsLargeInteger);
+
+#if SPURVM
secondAsLargeInteger = createLargeFromSmallInteger(secondInteger);
- firstAsLargeInteger = popRemappableOop();
+
+#else /* SPURVM */
+pushRemappableOop(firstAsLargeInteger);
+ secondAsLargeInteger = createLargeFromSmallInteger(secondInteger);
+ firstAsLargeInteger = popRemappableOop()
+#endif /* SPURVM */
+;
}
else {
secondAsLargeInteger = secondInteger;
@@ -2952,9 +3125,16 @@
/* convert it to a not normalized LargeInteger */
- pushRemappableOop(secondInteger);
+
+#if SPURVM
firstLarge = createLargeFromSmallInteger(firstInteger);
- secondInteger = popRemappableOop();
+
+#else /* SPURVM */
+pushRemappableOop(secondInteger);
+ firstLarge = createLargeFromSmallInteger(firstInteger);
+ secondInteger = popRemappableOop()
+#endif /* SPURVM */
+;
}
else {
firstLarge = firstInteger;
@@ -2963,9 +3143,16 @@
/* convert it to a not normalized LargeInteger */
- pushRemappableOop(firstLarge);
+
+#if SPURVM
secondLarge = createLargeFromSmallInteger(secondInteger);
- firstLarge = popRemappableOop();
+
+#else /* SPURVM */
+pushRemappableOop(firstLarge);
+ secondLarge = createLargeFromSmallInteger(secondInteger);
+ firstLarge = popRemappableOop()
+#endif /* SPURVM */
+;
}
else {
secondLarge = secondInteger;
@@ -3001,9 +3188,16 @@
/* convert it to a not normalized LargeInteger */
- pushRemappableOop(secondInteger);
+
+#if SPURVM
firstLarge = createLargeFromSmallInteger(firstInteger);
- secondInteger = popRemappableOop();
+
+#else /* SPURVM */
+pushRemappableOop(secondInteger);
+ firstLarge = createLargeFromSmallInteger(firstInteger);
+ secondInteger = popRemappableOop()
+#endif /* SPURVM */
+;
}
else {
firstLarge = firstInteger;
@@ -3012,9 +3206,16 @@
/* convert it to a not normalized LargeInteger */
- pushRemappableOop(firstLarge);
+
+#if SPURVM
secondLarge = createLargeFromSmallInteger(secondInteger);
- firstLarge = popRemappableOop();
+
+#else /* SPURVM */
+pushRemappableOop(firstLarge);
+ secondLarge = createLargeFromSmallInteger(secondInteger);
+ firstLarge = popRemappableOop()
+#endif /* SPURVM */
+;
}
else {
secondLarge = secondInteger;
@@ -3048,9 +3249,16 @@
/* convert it to a not normalized LargeInteger */
- pushRemappableOop(secondInteger);
+
+#if SPURVM
firstLarge = createLargeFromSmallInteger(firstInteger);
- secondInteger = popRemappableOop();
+
+#else /* SPURVM */
+pushRemappableOop(secondInteger);
+ firstLarge = createLargeFromSmallInteger(firstInteger);
+ secondInteger = popRemappableOop()
+#endif /* SPURVM */
+;
}
else {
firstLarge = firstInteger;
@@ -3059,9 +3267,16 @@
/* convert it to a not normalized LargeInteger */
- pushRemappableOop(firstLarge);
+
+#if SPURVM
secondLarge = createLargeFromSmallInteger(secondInteger);
- firstLarge = popRemappableOop();
+
+#else /* SPURVM */
+pushRemappableOop(firstLarge);
+ secondLarge = createLargeFromSmallInteger(secondInteger);
+ firstLarge = popRemappableOop()
+#endif /* SPURVM */
+;
}
else {
secondLarge = secondInteger;
@@ -3095,9 +3310,16 @@
/* convert it to a not normalized LargeInteger */
- pushRemappableOop(secondInteger);
+
+#if SPURVM
firstLarge = createLargeFromSmallInteger(firstInteger);
- secondInteger = popRemappableOop();
+
+#else /* SPURVM */
+pushRemappableOop(secondInteger);
+ firstLarge = createLargeFromSmallInteger(firstInteger);
+ secondInteger = popRemappableOop()
+#endif /* SPURVM */
+;
}
else {
firstLarge = firstInteger;
@@ -3106,9 +3328,16 @@
/* convert it to a not normalized LargeInteger */
- pushRemappableOop(firstLarge);
+
+#if SPURVM
secondLarge = createLargeFromSmallInteger(secondInteger);
- firstLarge = popRemappableOop();
+
+#else /* SPURVM */
+pushRemappableOop(firstLarge);
+ secondLarge = createLargeFromSmallInteger(secondInteger);
+ firstLarge = popRemappableOop()
+#endif /* SPURVM */
+;
}
else {
secondLarge = secondInteger;
@@ -3149,20 +3378,20 @@
EXPORT(sqInt)
primMontgomeryTimesModulo(void)
{
- usqInt accum;
+ usqInt accum;
sqInt firstInteger;
sqInt firstLarge;
sqInt firstLen;
sqInt i;
sqInt k;
- unsigned char lastByte;
+ unsigned char lastByte;
sqInt limit1;
sqInt limit2;
sqInt limit3;
- unsigned char * pBytesFirst;
- unsigned char * pBytesRes;
- unsigned char * pBytesSecond;
- unsigned char * pBytesThird;
+ unsigned char *pBytesFirst;
+ unsigned char *pBytesRes;
+ unsigned char *pBytesSecond;
+ unsigned char *pBytesThird;
sqInt prod;
sqInt secondLarge;
sqInt secondLen;
@@ -3171,7 +3400,7 @@
sqInt thirdLarge;
sqInt thirdLen;
sqInt thirdModuloInteger;
- unsigned char u;
+ unsigned char u;
sqInt _return_value;
success(isKindOf(stackValue(2), "Integer"));
@@ -3189,11 +3418,18 @@
/* convert it to a not normalized LargeInteger */
- pushRemappableOop(secondOperandInteger);
+
+#if SPURVM
+ firstLarge = createLargeFromSmallInteger(firstInteger);
+
+#else /* SPURVM */
+pushRemappableOop(secondOperandInteger);
pushRemappableOop(thirdModuloInteger);
firstLarge = createLargeFromSmallInteger(firstInteger);
thirdModuloInteger = popRemappableOop();
- secondOperandInteger = popRemappableOop();
+ secondOperandInteger = popRemappableOop()
+#endif /* SPURVM */
+;
}
else {
firstLarge = firstInteger;
@@ -3202,11 +3438,18 @@
/* convert it to a not normalized LargeInteger */
- pushRemappableOop(firstLarge);
+
+#if SPURVM
+ secondLarge = createLargeFromSmallInteger(secondOperandInteger);
+
+#else /* SPURVM */
+pushRemappableOop(firstLarge);
pushRemappableOop(thirdModuloInteger);
secondLarge = createLargeFromSmallInteger(secondOperandInteger);
thirdModuloInteger = popRemappableOop();
- firstLarge = popRemappableOop();
+ firstLarge = popRemappableOop()
+#endif /* SPURVM */
+;
}
else {
secondLarge = secondOperandInteger;
@@ -3215,11 +3458,18 @@
/* convert it to a not normalized LargeInteger */
- pushRemappableOop(firstLarge);
+
+#if SPURVM
+ thirdLarge = createLargeFromSmallInteger(thirdModuloInteger);
+
+#else /* SPURVM */
+pushRemappableOop(firstLarge);
pushRemappableOop(secondLarge);
thirdLarge = createLargeFromSmallInteger(thirdModuloInteger);
secondLarge = popRemappableOop();
- firstLarge = popRemappableOop();
+ firstLarge = popRemappableOop()
+#endif /* SPURVM */
+;
}
else {
thirdLarge = thirdModuloInteger;
@@ -3241,13 +3491,20 @@
_return_value = primitiveFail();
goto l1;
}
- pushRemappableOop(firstLarge);
+
+#if SPURVM
+ prod = instantiateClassindexableSize(classLargePositiveInteger(), thirdLen);
+
+#else /* SPURVM */
+pushRemappableOop(firstLarge);
pushRemappableOop(secondLarge);
pushRemappableOop(thirdLarge);
prod = instantiateClassindexableSize(classLargePositiveInteger(), thirdLen);
thirdLarge = popRemappableOop();
secondLarge = popRemappableOop();
- firstLarge = popRemappableOop();
+ firstLarge = popRemappableOop()
+#endif /* SPURVM */
+;
/* begin cdigitMontgomery:len:times:len:modulo:len:mInvModB:into: */
pBytesFirst = firstIndexableField(firstLarge);
pBytesSecond = firstIndexableField(secondLarge);
@@ -3293,8 +3550,8 @@
accum = 0;
for (i = 0; i <= limit3; i += 1) {
accum = (accum + (pBytesRes[i])) - (pBytesThird[i]);
- pBytesRes[i] = (accum - ((accum / 256) * 256));
- accum = accum / 256;
+ pBytesRes[i] = accum;
+ accum = ((signed)accum >> 8);
}
}
_return_value = normalizePositive(prod);
@@ -3417,6 +3674,7 @@
popthenPush = interpreterProxy->popthenPush;
popRemappableOop = interpreterProxy->popRemappableOop;
primitiveFail = interpreterProxy->primitiveFail;
+ primitiveFailFor = interpreterProxy->primitiveFailFor;
pushRemappableOop = interpreterProxy->pushRemappableOop;
slotSizeOf = interpreterProxy->slotSizeOf;
stObjectatput = interpreterProxy->stObjectatput;
Modified: branches/Cog/nscogsrc/vm/cogit.c
===================================================================
--- branches/Cog/nscogsrc/vm/cogit.c 2014-07-03 00:26:26 UTC (rev 3027)
+++ branches/Cog/nscogsrc/vm/cogit.c 2014-07-03 02:16:19 UTC (rev 3028)
@@ -1,9 +1,9 @@
/* Automatically generated by
- CCodeGenerator VMMaker.oscog-eem.790 uuid: 1c0587fb-44ad-43f6-8bfd-2a0f91e21a59
+ CCodeGenerator VMMaker.oscog-eem.795 uuid: d77a504d-28ea-407a-9df0-097e6dbaaf06
from
- StackToRegisterMappingCogit VMMaker.oscog-eem.790 uuid: 1c0587fb-44ad-43f6-8bfd-2a0f91e21a59
+ StackToRegisterMappingCogit VMMaker.oscog-eem.795 uuid: d77a504d-28ea-407a-9df0-097e6dbaaf06
*/
-static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.790 uuid: 1c0587fb-44ad-43f6-8bfd-2a0f91e21a59 " __DATE__ ;
+static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.795 uuid: d77a504d-28ea-407a-9df0-097e6dbaaf06 " __DATE__ ;
char *__cogitBuildInfo = __buildInfo;
@@ -956,7 +956,7 @@
static void marshallSendArguments(sqInt numArgs) NoDbgRegParms;
usqInt maxCogMethodAddress(void);
static void maybeCompileAllocFillerCheck(void);
-static void maybeCompileRetryonPrimitiveFail(sqInt retryInst, sqInt primIndex) NoDbgRegParms;
+static void maybeCompileRetryonPrimitiveFail(AbstractInstruction *retryInst, sqInt primIndex) NoDbgRegParms;
static sqInt maybeFreeCogMethodDoesntLookKosher(CogMethod *cogMethod) NoDbgRegParms;
static sqInt maybeGenerateCheckFeatures(void);
static sqInt maybeGenerateICacheFlush(void);
@@ -5028,7 +5028,10 @@
if (flags & PrimCallMayCallBack) {
/* Sideways call the C primitive routine so that we return through cePrimReturnEnterCogCode. */
+ /* On Spur ceActivateFailingPrimitiveMethod: would like to retry if forwarders
+ are found. So insist on PrimCallNeedsPrimitiveFunction being set too. */
+ assert(flags & PrimCallNeedsPrimitiveFunction);
/* begin genSubstituteReturnAddress: */
retpc = (flags & PrimCallCollectsProfileSamples
? cePrimReturnEnterCogCodeProfiling
@@ -14776,9 +14779,11 @@
sqInt address4;
sqInt address5;
sqInt address6;
+ sqInt address7;
AbstractInstruction *continuePostSample;
AbstractInstruction *jmpFail;
AbstractInstruction *jmpSample;
+ sqInt reg;
opcodeIndex = 0;
if (profiling) {
@@ -14825,6 +14830,19 @@
address6 = cStackPointerAddress();
genoperandoperand(MoveAwR, address6, SPReg);
compileCallFornumArgsargargargargresultRegsaveRegs(ceActivateFailingPrimitiveMethod, 1, SendNumArgsReg, null, null, null, null, 0);
+ /* begin MoveAw:R: */
+ address7 = instructionPointerAddress();
+ reg = ClassReg;
+ genoperandoperand(MoveAwR, address7, reg);
+ genLoadStackPointers(backEnd);
+ /* begin MoveMw:r:R: */
+ genoperandoperandoperand(MoveMwrR, BytesPerWord, SPReg, ReceiverResultReg);
+ /* begin PushR: */
+ genoperand(PushR, ClassReg);
+
+ flag("currently caller pushes result");
+ /* begin RetN: */
+ genoperand(RetN, BytesPerWord);
if (profiling) {
/* Call ceCheckProfileTick: to record sample and then continue. newMethod
@@ -18997,7 +19015,7 @@
By default do nothing. */
static void
-maybeCompileRetryonPrimitiveFail(sqInt retryInst, sqInt primIndex)
+maybeCompileRetryonPrimitiveFail(AbstractInstruction *retryInst, sqInt primIndex)
{
}
Modified: branches/Cog/nscogsrc/vm/cogit.h
===================================================================
--- branches/Cog/nscogsrc/vm/cogit.h 2014-07-03 00:26:26 UTC (rev 3027)
+++ branches/Cog/nscogsrc/vm/cogit.h 2014-07-03 02:16:19 UTC (rev 3028)
@@ -1,5 +1,5 @@
/* Automatically generated by
- CCodeGenerator VMMaker.oscog-eem.790 uuid: 1c0587fb-44ad-43f6-8bfd-2a0f91e21a59
+ CCodeGenerator VMMaker.oscog-eem.795 uuid: d77a504d-28ea-407a-9df0-097e6dbaaf06
*/
Modified: branches/Cog/nscogsrc/vm/cogmethod.h
===================================================================
--- branches/Cog/nscogsrc/vm/cogmethod.h 2014-07-03 00:26:26 UTC (rev 3027)
+++ branches/Cog/nscogsrc/vm/cogmethod.h 2014-07-03 02:16:19 UTC (rev 3028)
@@ -1,5 +1,5 @@
/* Automatically generated by
- CCodeGenerator VMMaker.oscog-eem.790 uuid: 1c0587fb-44ad-43f6-8bfd-2a0f91e21a59
+ CCodeGenerator VMMaker.oscog-eem.795 uuid: d77a504d-28ea-407a-9df0-097e6dbaaf06
*/
typedef struct {
Modified: branches/Cog/nscogsrc/vm/cointerp.c
===================================================================
--- branches/Cog/nscogsrc/vm/cointerp.c 2014-07-03 00:26:26 UTC (rev 3027)
+++ branches/Cog/nscogsrc/vm/cointerp.c 2014-07-03 02:16:19 UTC (rev 3028)
@@ -1,9 +1,9 @@
/* Automatically generated by
- CCodeGeneratorGlobalStructure VMMaker.oscog-eem.791 uuid: 7d762755-99b7-46ae-8435-31b17f4f0e0c
+ CCodeGeneratorGlobalStructure VMMaker.oscog-eem.795 uuid: d77a504d-28ea-407a-9df0-097e6dbaaf06
from
- CoInterpreter VMMaker.oscog-eem.791 uuid: 7d762755-99b7-46ae-8435-31b17f4f0e0c
+ CoInterpreter VMMaker.oscog-eem.795 uuid: d77a504d-28ea-407a-9df0-097e6dbaaf06
*/
-static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.791 uuid: 7d762755-99b7-46ae-8435-31b17f4f0e0c " __DATE__ ;
+static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.795 uuid: d77a504d-28ea-407a-9df0-097e6dbaaf06 " __DATE__ ;
char *__interpBuildInfo = __buildInfo;
@@ -1175,7 +1175,7 @@
static void rewriteMethodCacheEntryForExternalPrimitiveToFunction(void (*localPrimAddress)(void)) NoDbgRegParms;
static sqInt roomToPushNArgs(sqInt n) NoDbgRegParms;
static void runLeakCheckerForFullGC(sqInt fullGCFlag) NoDbgRegParms;
-static sqInt safeObjectAfter(sqInt oop) NoDbgRegParms;
+static usqInt safeObjectAfter(sqInt oop) NoDbgRegParms;
static sqInt safePrintStringOf(sqInt oop) NoDbgRegParms;
usqInt scavengeThresholdAddress(void);
EXPORT(sqInt) sendInvokeCallbackContext(VMCallbackContext *vmCallbackContext);
@@ -2064,7 +2064,7 @@
/* 574 */ (void (*)(void))0,
/* 575 */ (void (*)(void))0,
0 };
-const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_VMMaker.oscog-eem.791";
+const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_VMMaker.oscog-eem.795";
sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 10 */;
volatile int sendTrace;
@@ -15033,7 +15033,9 @@
{ DECL_MAYBE_SQ_GLOBAL_STRUCT
sqInt methodHeader;
+ assert(GIV(primFailCode) != 0);
assert(GIV(newMethod) == aPrimitiveMethod);
+
methodHeader = longAt((aPrimitiveMethod + BaseHeaderSize) + (HeaderIndex << ShiftForWord));
if (isCogMethodReference(methodHeader)) {
activateCoggedNewMethod(0);
@@ -23987,17 +23989,15 @@
sqInt header1;
sqInt header2;
sqInt header3;
- sqInt header4;
usqInt lastWord;
sqInt newFreeChunk;
sqInt newOop;
- sqInt next;
+ usqInt next;
sqInt oop;
sqInt realHeader;
sqInt sz;
sqInt sz1;
sqInt sz2;
- sqInt sz3;
sqInt target;
usqInt w;
@@ -24008,21 +24008,7 @@
/* begin objectAfterWhileForwarding: */
header2 = longAt(oop);
if ((header2 & MarkBit) == 0) {
- /* begin objectAfter: */
- if (!(asserta(oopisLessThan(oop, GIV(freeStart))))) {
- error("no objects after the end of memory");
- }
- if (((longAt(oop)) & TypeMask) == HeaderTypeFree) {
- sz2 = (longAt(oop)) & AllButTypeMask;
- }
- else {
- /* begin sizeBitsOf: */
- header3 = longAt(oop);
- sz2 = ((header3 & TypeMask) == HeaderTypeSizeAndClass
- ? (longAt(oop - (BytesPerWord * 2))) & LongSizeMask
- : header3 & SizeMask);
- }
- next = (oop + sz2) + (headerTypeBytes[(longAt(oop + sz2)) & TypeMask]);
+ next = ((sqInt) (objectAfter(oop)));
goto l1;
}
fwdBlock1 = (header2 & AllButMarkBitAndTypeMask) << 1;
@@ -24037,7 +24023,7 @@
else {
sz1 = realHeader & SizeMask;
}
- next = (oop + sz1) + (headerTypeBytes[(longAt(oop + sz1)) & TypeMask]);
+ next = ((sqInt) ((oop + sz1) + (headerTypeBytes[(longAt(oop + sz1)) & TypeMask])));
l1: /* end objectAfterWhileForwarding: */;
if (!(((longAt(oop)) & TypeMask) == HeaderTypeFree)) {
@@ -24091,18 +24077,18 @@
}
/* begin safeObjectAfter: */
if (((longAt(newFreeChunk)) & TypeMask) == HeaderTypeFree) {
- sz3 = (longAt(newFreeChunk)) & AllButTypeMask;
+ sz2 = (longAt(newFreeChunk)) & AllButTypeMask;
}
else {
/* begin sizeBitsOf: */
- header4 = longAt(newFreeChunk);
- sz3 = ((header4 & TypeMask) == HeaderTypeSizeAndClass
+ header3 = longAt(newFreeChunk);
+ sz2 = ((header3 & TypeMask) == HeaderTypeSizeAndClass
? (longAt(newFreeChunk - (BytesPerWord * 2))) & LongSizeMask
- : header4 & SizeMask);
+ : header3 & SizeMask);
}
- next = ((newFreeChunk + sz3) >= GIV(freeStart)
+ next = ((newFreeChunk + sz2) >= GIV(freeStart)
? GIV(freeStart)
- : (newFreeChunk + sz3) + (headerTypeBytes[(longAt(newFreeChunk + sz3)) & TypeMask]));
+ : (newFreeChunk + sz2) + (headerTypeBytes[(longAt(newFreeChunk + sz2)) & TypeMask]));
assert((next == GIV(freeStart))
|| (next == (oopFromChunk(GIV(compEnd)))));
if (next == GIV(freeStart)) {
@@ -50905,7 +50891,7 @@
given object or free chunk in memory. Return freeStart when
enumeration is complete. This is for assertion checking only. */
-static sqInt
+static usqInt
safeObjectAfter(sqInt oop)
{ DECL_MAYBE_SQ_GLOBAL_STRUCT
sqInt header;
Modified: branches/Cog/nscogsrc/vm/cointerp.h
===================================================================
--- branches/Cog/nscogsrc/vm/cointerp.h 2014-07-03 00:26:26 UTC (rev 3027)
+++ branches/Cog/nscogsrc/vm/cointerp.h 2014-07-03 02:16:19 UTC (rev 3028)
@@ -1,5 +1,5 @@
/* Automatically generated by
- CCodeGeneratorGlobalStructure VMMaker.oscog-eem.791 uuid: 7d762755-99b7-46ae-8435-31b17f4f0e0c
+ CCodeGeneratorGlobalStructure VMMaker.oscog-eem.795 uuid: d77a504d-28ea-407a-9df0-097e6dbaaf06
*/
Modified: branches/Cog/nscogsrc/vm/gcc3x-cointerp.c
===================================================================
--- branches/Cog/nscogsrc/vm/gcc3x-cointerp.c 2014-07-03 00:26:26 UTC (rev 3027)
+++ branches/Cog/nscogsrc/vm/gcc3x-cointerp.c 2014-07-03 02:16:19 UTC (rev 3028)
@@ -2,11 +2,11 @@
/* Automatically generated by
- CCodeGeneratorGlobalStructure VMMaker.oscog-eem.791 uuid: 7d762755-99b7-46ae-8435-31b17f4f0e0c
+ CCodeGeneratorGlobalStructure VMMaker.oscog-eem.795 uuid: d77a504d-28ea-407a-9df0-097e6dbaaf06
from
- CoInterpreter VMMaker.oscog-eem.791 uuid: 7d762755-99b7-46ae-8435-31b17f4f0e0c
+ CoInterpreter VMMaker.oscog-eem.795 uuid: d77a504d-28ea-407a-9df0-097e6dbaaf06
*/
-static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.791 uuid: 7d762755-99b7-46ae-8435-31b17f4f0e0c " __DATE__ ;
+static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.795 uuid: d77a504d-28ea-407a-9df0-097e6dbaaf06 " __DATE__ ;
char *__interpBuildInfo = __buildInfo;
@@ -1178,7 +1178,7 @@
static void rewriteMethodCacheEntryForExternalPrimitiveToFunction(void (*localPrimAddress)(void)) NoDbgRegParms;
static sqInt roomToPushNArgs(sqInt n) NoDbgRegParms;
static void runLeakCheckerForFullGC(sqInt fullGCFlag) NoDbgRegParms;
-static sqInt safeObjectAfter(sqInt oop) NoDbgRegParms;
+static usqInt safeObjectAfter(sqInt oop) NoDbgRegParms;
static sqInt safePrintStringOf(sqInt oop) NoDbgRegParms;
usqInt scavengeThresholdAddress(void);
EXPORT(sqInt) sendInvokeCallbackContext(VMCallbackContext *vmCallbackContext);
@@ -2067,7 +2067,7 @@
/* 574 */ (void (*)(void))0,
/* 575 */ (void (*)(void))0,
0 };
-const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_VMMaker.oscog-eem.791";
+const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_VMMaker.oscog-eem.795";
sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 10 */;
volatile int sendTrace;
@@ -15042,7 +15042,9 @@
{ DECL_MAYBE_SQ_GLOBAL_STRUCT
sqInt methodHeader;
+ assert(GIV(primFailCode) != 0);
assert(GIV(newMethod) == aPrimitiveMethod);
+
methodHeader = longAt((aPrimitiveMethod + BaseHeaderSize) + (HeaderIndex << ShiftForWord));
if (isCogMethodReference(methodHeader)) {
activateCoggedNewMethod(0);
@@ -23996,17 +23998,15 @@
sqInt header1;
sqInt header2;
sqInt header3;
- sqInt header4;
usqInt lastWord;
sqInt newFreeChunk;
sqInt newOop;
- sqInt next;
+ usqInt next;
sqInt oop;
sqInt realHeader;
sqInt sz;
sqInt sz1;
sqInt sz2;
- sqInt sz3;
sqInt target;
usqInt w;
@@ -24017,21 +24017,7 @@
/* begin objectAfterWhileForwarding: */
header2 = longAt(oop);
if ((header2 & MarkBit) == 0) {
- /* begin objectAfter: */
- if (!(asserta(oopisLessThan(oop, GIV(freeStart))))) {
- error("no objects after the end of memory");
- }
- if (((longAt(oop)) & TypeMask) == HeaderTypeFree) {
- sz2 = (longAt(oop)) & AllButTypeMask;
- }
- else {
- /* begin sizeBitsOf: */
- header3 = longAt(oop);
- sz2 = ((header3 & TypeMask) == HeaderTypeSizeAndClass
- ? (longAt(oop - (BytesPerWord * 2))) & LongSizeMask
- : header3 & SizeMask);
- }
- next = (oop + sz2) + (headerTypeBytes[(longAt(oop + sz2)) & TypeMask]);
+ next = ((sqInt) (objectAfter(oop)));
goto l1;
}
fwdBlock1 = (header2 & AllButMarkBitAndTypeMask) << 1;
@@ -24046,7 +24032,7 @@
else {
sz1 = realHeader & SizeMask;
}
- next = (oop + sz1) + (headerTypeBytes[(longAt(oop + sz1)) & TypeMask]);
+ next = ((sqInt) ((oop + sz1) + (headerTypeBytes[(longAt(oop + sz1)) & TypeMask])));
l1: /* end objectAfterWhileForwarding: */;
if (!(((longAt(oop)) & TypeMask) == HeaderTypeFree)) {
@@ -24100,18 +24086,18 @@
}
/* begin safeObjectAfter: */
if (((longAt(newFreeChunk)) & TypeMask) == HeaderTypeFree) {
- sz3 = (longAt(newFreeChunk)) & AllButTypeMask;
+ sz2 = (longAt(newFreeChunk)) & AllButTypeMask;
}
else {
/* begin sizeBitsOf: */
- header4 = longAt(newFreeChunk);
- sz3 = ((header4 & TypeMask) == HeaderTypeSizeAndClass
+ header3 = longAt(newFreeChunk);
+ sz2 = ((header3 & TypeMask) == HeaderTypeSizeAndClass
? (longAt(newFreeChunk - (BytesPerWord * 2))) & LongSizeMask
- : header4 & SizeMask);
+ : header3 & SizeMask);
}
- next = ((newFreeChunk + sz3) >= GIV(freeStart)
+ next = ((newFreeChunk + sz2) >= GIV(freeStart)
? GIV(freeStart)
- : (newFreeChunk + sz3) + (headerTypeBytes[(longAt(newFreeChunk + sz3)) & TypeMask]));
+ : (newFreeChunk + sz2) + (headerTypeBytes[(longAt(newFreeChunk + sz2)) & TypeMask]));
assert((next == GIV(freeStart))
|| (next == (oopFromChunk(GIV(compEnd)))));
if (next == GIV(freeStart)) {
@@ -50914,7 +50900,7 @@
given object or free chunk in memory. Return freeStart when
enumeration is complete. This is for assertion checking only. */
-static sqInt
+static usqInt
safeObjectAfter(sqInt oop)
{ DECL_MAYBE_SQ_GLOBAL_STRUCT
sqInt header;
Modified: branches/Cog/nscogsrc/vm/interp.h
===================================================================
--- branches/Cog/nscogsrc/vm/interp.h 2014-07-03 00:26:26 UTC (rev 3027)
+++ branches/Cog/nscogsrc/vm/interp.h 2014-07-03 02:16:19 UTC (rev 3028)
@@ -1,5 +1,5 @@
/* Automatically generated by
- CCodeGeneratorGlobalStructure VMMaker.oscog-eem.791 uuid: 7d762755-99b7-46ae-8435-31b17f4f0e0c
+ CCodeGeneratorGlobalStructure VMMaker.oscog-eem.795 uuid: d77a504d-28ea-407a-9df0-097e6dbaaf06
*/
#define VM_PROXY_MAJOR 1
Modified: branches/Cog/nscogsrc/vm/vmCallback.h
===================================================================
--- branches/Cog/nscogsrc/vm/vmCallback.h 2014-07-03 00:26:26 UTC (rev 3027)
+++ branches/Cog/nscogsrc/vm/vmCallback.h 2014-07-03 02:16:19 UTC (rev 3028)
@@ -1,5 +1,5 @@
/* Automatically generated by
- CCodeGeneratorGlobalStructure VMMaker.oscog-eem.791 uuid: 7d762755-99b7-46ae-8435-31b17f4f0e0c
+ CCodeGeneratorGlobalStructure VMMaker.oscog-eem.795 uuid: d77a504d-28ea-407a-9df0-097e6dbaaf06
*/
#define VM_CALLBACK_INC 1
Modified: branches/Cog/nsspursrc/vm/cogit.c
===================================================================
--- branches/Cog/nsspursrc/vm/cogit.c 2014-07-03 00:26:26 UTC (rev 3027)
+++ branches/Cog/nsspursrc/vm/cogit.c 2014-07-03 02:16:19 UTC (rev 3028)
@@ -1,9 +1,9 @@
/* Automatically generated by
- CCodeGenerator VMMaker.oscog-eem.793 uuid: aa676593-2c7b-4ad7-92a5-9d1e27cb7377
+ CCodeGenerator VMMaker.oscog-eem.795 uuid: d77a504d-28ea-407a-9df0-097e6dbaaf06
from
- StackToRegisterMappingCogit VMMaker.oscog-eem.793 uuid: aa676593-2c7b-4ad7-92a5-9d1e27cb7377
+ StackToRegisterMappingCogit VMMaker.oscog-eem.795 uuid: d77a504d-28ea-407a-9df0-097e6dbaaf06
*/
-static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.793 uuid: aa676593-2c7b-4ad7-92a5-9d1e27cb7377 " __DATE__ ;
+static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.795 uuid: d77a504d-28ea-407a-9df0-097e6dbaaf06 " __DATE__ ;
char *__cogitBuildInfo = __buildInfo;
@@ -962,7 +962,7 @@
static void marshallSendArguments(sqInt numArgs) NoDbgRegParms;
usqInt maxCogMethodAddress(void);
static void maybeCompileAllocFillerCheck(void);
-static sqInt maybeCompileRetryonPrimitiveFail(sqInt retryInst, sqInt primIndex) NoDbgRegParms;
+static sqInt maybeCompileRetryonPrimitiveFail(AbstractInstruction *retryInst, sqInt primIndex) NoDbgRegParms;
static sqInt maybeFreeCogMethodDoesntLookKosher(CogMethod *cogMethod) NoDbgRegParms;
static sqInt maybeGenerateCheckFeatures(void);
static sqInt maybeGenerateICacheFlush(void);
@@ -4968,7 +4968,10 @@
if (flags & PrimCallMayCallBack) {
/* Sideways call the C primitive routine so that we return through cePrimReturnEnterCogCode. */
+ /* On Spur ceActivateFailingPrimitiveMethod: would like to retry if forwarders
+ are found. So insist on PrimCallNeedsPrimitiveFunction being set too. */
+ assert(flags & PrimCallNeedsPrimitiveFunction);
/* begin genSubstituteReturnAddress: */
retpc = (flags & PrimCallCollectsProfileSamples
? cePrimReturnEnterCogCodeProfiling
@@ -16414,9 +16417,11 @@
sqInt address4;
sqInt address5;
sqInt address6;
+ sqInt address7;
AbstractInstruction *continuePostSample;
AbstractInstruction *jmpFail;
AbstractInstruction *jmpSample;
+ sqInt reg;
opcodeIndex = 0;
if (profiling) {
@@ -16463,6 +16468,19 @@
address6 = cStackPointerAddress();
genoperandoperand(MoveAwR, address6, SPReg);
compileCallFornumArgsargargargargresultRegsaveRegs(ceActivateFailingPrimitiveMethod, 1, SendNumArgsReg, null, null, null, null, 0);
+ /* begin MoveAw:R: */
+ address7 = instructionPointerAddress();
+ reg = ClassReg;
+ genoperandoperand(MoveAwR, address7, reg);
+ genLoadStackPointers(backEnd);
+ /* begin MoveMw:r:R: */
+ genoperandoperandoperand(MoveMwrR, BytesPerWord, SPReg, ReceiverResultReg);
+ /* begin PushR: */
+ genoperand(PushR, ClassReg);
+
+ flag("currently caller pushes result");
+ /* begin RetN: */
+ genoperand(RetN, BytesPerWord);
if (profiling) {
/* Call ceCheckProfileTick: to record sample and then continue. newMethod
@@ -20371,7 +20389,7 @@
true, retry the primitive. */
static sqInt
-maybeCompileRetryonPrimitiveFail(sqInt retryInst, sqInt primIndex)
+maybeCompileRetryonPrimitiveFail(AbstractInstruction *retryInst, sqInt primIndex)
{
sqInt accessorDepth;
sqInt address;
Modified: branches/Cog/nsspursrc/vm/cogit.h
===================================================================
--- branches/Cog/nsspursrc/vm/cogit.h 2014-07-03 00:26:26 UTC (rev 3027)
+++ branches/Cog/nsspursrc/vm/cogit.h 2014-07-03 02:16:19 UTC (rev 3028)
@@ -1,5 +1,5 @@
/* Automatically generated by
- CCodeGenerator VMMaker.oscog-eem.793 uuid: aa676593-2c7b-4ad7-92a5-9d1e27cb7377
@@ Diff output truncated at 50000 characters. @@
More information about the Vm-dev
mailing list