[Vm-dev] [commit] r2539 - Fix bad conceptual bug with become on
methods. Unlike full and incremental GC,
commits at squeakvm.org
commits at squeakvm.org
Tue Apr 3 21:03:20 UTC 2012
Author: eliot
Date: 2012-04-03 14:03:16 -0700 (Tue, 03 Apr 2012)
New Revision: 2539
Modified:
branches/Cog/nscogsrc/plugins/UnixOSProcessPlugin/UnixOSProcessPlugin.c
branches/Cog/nscogsrc/plugins/ZipPlugin/ZipPlugin.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/platforms/Cross/vm/sqSCCSVersion.h
branches/Cog/platforms/Mac OS/vm/sqMacMain.c
branches/Cog/platforms/unix/config/bin.squeak.sh.in
branches/Cog/platforms/unix/config/squeak.sh.in
branches/Cog/src/plugins/UnixOSProcessPlugin/UnixOSProcessPlugin.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
Log:
Fix bad conceptual bug with become on methods. Unlike full and incremental GC,
the reference from a Cog method to its method object must not be remapped since
they're two halves of the same object.
Merge Merge VMConstruction-Plugins-OSProcessPlugin-dtl.33's changes.
Regenerate the apparently truncated nscogsrc ZipPlugin.c.
Handle more libc variations for LD_LIBRARY_PATH in the unix launch scripts.
Modified: branches/Cog/nscogsrc/plugins/UnixOSProcessPlugin/UnixOSProcessPlugin.c
===================================================================
--- branches/Cog/nscogsrc/plugins/UnixOSProcessPlugin/UnixOSProcessPlugin.c 2012-03-03 21:13:51 UTC (rev 2538)
+++ branches/Cog/nscogsrc/plugins/UnixOSProcessPlugin/UnixOSProcessPlugin.c 2012-04-03 21:03:16 UTC (rev 2539)
@@ -1,9 +1,9 @@
/* Automatically generated by
- VMPluginCodeGenerator VMMaker.oscog-eem.144 uuid: bafb8042-095a-42f3-9058-ee7bd133da50
+ VMPluginCodeGenerator VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa
from
- UnixOSProcessPlugin VMConstruction-Plugins-OSProcessPlugin.oscog-eem.33 uuid: 3c8b9706-e5ad-4eb4-85a3-a82fd91005a0
+ UnixOSProcessPlugin VMConstruction-Plugins-OSProcessPlugin.oscog-eem.34 uuid: 90d36152-4f89-4764-b476-2cc44c195139
*/
-static char __buildInfo[] = "UnixOSProcessPlugin VMConstruction-Plugins-OSProcessPlugin.oscog-eem.33 uuid: 3c8b9706-e5ad-4eb4-85a3-a82fd91005a0 " __DATE__ ;
+static char __buildInfo[] = "UnixOSProcessPlugin VMConstruction-Plugins-OSProcessPlugin.oscog-eem.34 uuid: 90d36152-4f89-4764-b476-2cc44c195139 " __DATE__ ;
@@ -57,6 +57,7 @@
/*** Constants ***/
#define BytesPerWord 4
+#define MULTIPLEBYTECODESETS 0
#define PrimErrNoMemory 9
#define PrimErrUnsupported 7
@@ -98,7 +99,7 @@
static sqInt maskSignalForThisThread(int sigNum);
EXPORT(sqInt) moduleUnloaded(char *aModuleName);
static sqInt msg(char *s);
-static sqInt newPthreadTypeByteArray(sqInt aPthreadType);
+static sqInt newPthreadTypeByteArray(pthread_t aPthreadType);
static sqInt newSQFileByteArray(void);
static sqInt newSQSocketByteArray(void);
static void ** originalSignalHandlers(void);
@@ -248,9 +249,9 @@
struct VirtualMachine* interpreterProxy;
static const char *moduleName =
#ifdef SQUEAK_BUILTIN_PLUGIN
- "UnixOSProcessPlugin VMConstruction-Plugins-OSProcessPlugin.oscog-eem.33 (i)"
+ "UnixOSProcessPlugin VMConstruction-Plugins-OSProcessPlugin.oscog-eem.34 (i)"
#else
- "UnixOSProcessPlugin VMConstruction-Plugins-OSProcessPlugin.oscog-eem.33 (e)"
+ "UnixOSProcessPlugin VMConstruction-Plugins-OSProcessPlugin.oscog-eem.34 (e)"
#endif
;
static void *originalSigHandlers[NSIG];
@@ -1142,7 +1143,7 @@
passed to the image. */
static sqInt
-newPthreadTypeByteArray(sqInt aPthreadType)
+newPthreadTypeByteArray(pthread_t aPthreadType)
{
sqInt byteArray;
sqInt len;
@@ -1151,7 +1152,7 @@
len = sizeof(pthread_t);
byteArray = interpreterProxy->instantiateClassindexableSize(interpreterProxy->classByteArray(), len);
ptr = interpreterProxy->arrayValueOf(byteArray);
- *ptr = aPthreadType;
+ ptr[0] = aPthreadType;
return byteArray;
}
Modified: branches/Cog/nscogsrc/plugins/ZipPlugin/ZipPlugin.c
===================================================================
--- branches/Cog/nscogsrc/plugins/ZipPlugin/ZipPlugin.c 2012-03-03 21:13:51 UTC (rev 2538)
+++ branches/Cog/nscogsrc/plugins/ZipPlugin/ZipPlugin.c 2012-04-03 21:03:16 UTC (rev 2539)
@@ -1,9 +1,9 @@
/* Automatically generated by
- VMPluginCodeGenerator VMMaker.oscog-eem.105 uuid: 79234f80-ee6a-404c-9e5c-2134e3b76463
+ VMPluginCodeGenerator VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa
from
- InflatePlugin VMMaker.oscog-eem.105 uuid: 79234f80-ee6a-404c-9e5c-2134e3b76463
+ DeflatePlugin VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa
*/
-static char __buildInfo[] = "InflatePlugin VMMaker.oscog-eem.105 uuid: 79234f80-ee6a-404c-9e5c-2134e3b76463 " __DATE__ ;
+static char __buildInfo[] = "DeflatePlugin VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa " __DATE__ ;
@@ -37,17 +37,47 @@
/*** Constants ***/
+#define BytesPerWord 4
+#define DeflateHashMask 0x7FFF
+#define DeflateHashShift 5
+#define DeflateHashTableSize 32768
+#define DeflateMaxDistance 0x8000
+#define DeflateMaxDistanceCodes 30
+#define DeflateMaxLiteralCodes 0x11E
+#define DeflateMaxMatch 258
+#define DeflateMinMatch 3
+#define DeflateWindowMask 0x7FFF
+#define DeflateWindowSize 32768
#define MaxBits 16
+#define MULTIPLEBYTECODESETS 0
#define StateNoMoreData 1
/*** Function Prototypes ***/
+static sqInt comparewithmin(sqInt here, sqInt matchPos, sqInt minLength);
+static sqInt deflateBlockchainLengthgoodMatch(sqInt lastIndex, sqInt chainLength, sqInt goodMatch);
+static sqInt encodeLiteral(sqInt lit);
+static sqInt encodeMatchdistance(sqInt length, sqInt dist);
+static sqInt findMatchlastLengthlastMatchchainLengthgoodMatch(sqInt here, sqInt lastLength, sqInt lastMatch, sqInt maxChainLength, sqInt goodMatch);
static VirtualMachine * getInterpreter(void);
EXPORT(const char*) getModuleName(void);
static sqInt halt(void);
+static sqInt insertStringAt(sqInt here);
+static sqInt loadDeflateStreamFrom(sqInt rcvr);
+static sqInt loadZipEncoderFrom(sqInt rcvr);
static sqInt msg(char *s);
+static sqInt nextZipBitsput(sqInt nBits, sqInt value);
+EXPORT(sqInt) primitiveDeflateBlock(void);
+EXPORT(sqInt) primitiveDeflateUpdateHashTable(void);
EXPORT(sqInt) primitiveInflateDecompressBlock(void);
+EXPORT(sqInt) primitiveUpdateAdler32(void);
+EXPORT(sqInt) primitiveUpdateGZipCrc32(void);
+EXPORT(sqInt) primitiveZipSendBlock(void);
+static sqInt sendBlockwithwithwith(sqInt literalStream, sqInt distanceStream, sqInt litTree, sqInt distTree);
EXPORT(sqInt) setInterpreter(struct VirtualMachine*anInterpreter);
+static sqInt shouldFlush(void);
+static sqInt updateHashAt(sqInt here);
+static sqInt updateHash(sqInt nextValue);
static sqInt zipDecodeValueFromsize(unsigned int *table, sqInt tableSize);
static sqInt zipDecompressBlock(void);
static sqInt zipNextBits(sqInt n);
@@ -61,19 +91,110 @@
struct VirtualMachine* interpreterProxy;
static const char *moduleName =
#ifdef SQUEAK_BUILTIN_PLUGIN
- "ZipPlugin VMMaker.oscog-eem.105 (i)"
+ "ZipPlugin VMMaker.oscog-eem.154 (i)"
#else
- "ZipPlugin VMMaker.oscog-eem.105 (e)"
+ "ZipPlugin VMMaker.oscog-eem.154 (e)"
#endif
;
+static unsigned int zipBaseDistance[] = {
+0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192,
+256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576};
+static unsigned int zipBaseLength[] = {
+0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28,
+32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 0};
static sqInt zipBitBuf;
static sqInt zipBitPos;
+static sqInt zipBlockPos;
+static sqInt zipBlockStart;
static unsigned char* zipCollection;
static sqInt zipCollectionSize;
+static unsigned int zipCrcTable[] = {
+0, 1996959894, 3993919788U, 2567524794U, 124634137, 1886057615, 3915621685U, 2657392035U, 249268274, 2044508324, 3772115230U, 2547177864U, 162941995, 2125561021, 3887607047U, 2428444049U,
+498536548, 1789927666, 4089016648U, 2227061214U, 450548861, 1843258603, 4107580753U, 2211677639U, 325883990, 1684777152, 4251122042U, 2321926636U, 335633487, 1661365465, 4195302755U, 2366115317U,
+997073096, 1281953886, 3579855332U, 2724688242U, 1006888145, 1258607687, 3524101629U, 2768942443U, 901097722, 1119000684, 3686517206U, 2898065728U, 853044451, 1172266101, 3705015759U, 2882616665U,
+651767980, 1373503546, 3369554304U, 3218104598U, 565507253, 1454621731, 3485111705U, 3099436303U, 671266974, 1594198024, 3322730930U, 2970347812U, 795835527, 1483230225, 3244367275U, 3060149565U,
+1994146192, 31158534, 2563907772U, 4023717930U, 1907459465, 112637215, 2680153253U, 3904427059U, 2013776290, 251722036, 2517215374U, 3775830040U, 2137656763, 141376813, 2439277719U, 3865271297U,
+1802195444, 476864866, 2238001368U, 4066508878U, 1812370925, 453092731, 2181625025U, 4111451223U, 1706088902, 314042704, 2344532202U, 4240017532U, 1658658271, 366619977, 2362670323U, 4224994405U,
+1303535960, 984961486, 2747007092U, 3569037538U, 1256170817, 1037604311, 2765210733U, 3554079995U, 1131014506, 879679996, 2909243462U, 3663771856U, 1141124467, 855842277, 2852801631U, 3708648649U,
+1342533948, 654459306, 3188396048U, 3373015174U, 1466479909, 544179635, 3110523913U, 3462522015U, 1591671054, 702138776, 2966460450U, 3352799412U, 1504918807, 783551873, 3082640443U, 3233442989U,
+3988292384U, 2596254646U, 62317068, 1957810842, 3939845945U, 2647816111U, 81470997, 1943803523, 3814918930U, 2489596804U, 225274430, 2053790376, 3826175755U, 2466906013U, 167816743, 2097651377,
+4027552580U, 2265490386U, 503444072, 1762050814, 4150417245U, 2154129355U, 426522225, 1852507879, 4275313526U, 2312317920U, 282753626, 1742555852, 4189708143U, 2394877945U, 397917763, 1622183637,
+3604390888U, 2714866558U, 953729732, 1340076626, 3518719985U, 2797360999U, 1068828381, 1219638859, 3624741850U, 2936675148U, 906185462, 1090812512, 3747672003U, 2825379669U, 829329135, 1181335161,
+3412177804U, 3160834842U, 628085408, 1382605366, 3423369109U, 3138078467U, 570562233, 1426400815, 3317316542U, 2998733608U, 733239954, 1555261956, 3268935591U, 3050360625U, 752459403, 1541320221,
+2607071920U, 3965973030U, 1969922972, 40735498, 2617837225U, 3943577151U, 1913087877, 83908371, 2512341634U, 3803740692U, 2075208622, 213261112, 2463272603U, 3855990285U, 2094854071, 198958881,
+2262029012U, 4057260610U, 1759359992, 534414190, 2176718541U, 4139329115U, 1873836001, 414664567, 2282248934U, 4279200368U, 1711684554, 285281116, 2405801727U, 4167216745U, 1634467795, 376229701,
+2685067896U, 3608007406U, 1308918612, 956543938, 2808555105U, 3495958263U, 1231636301, 1047427035, 2932959818U, 3654703836U, 1088359270, 936918000, 2847714899U, 3736837829U, 1202900863, 817233897,
+3183342108U, 3401237130U, 1404277552, 615818150, 3134207493U, 3453421203U, 1423857449, 601450431, 3009837614U, 3294710456U, 1567103746, 711928724, 3020668471U, 3272380065U, 1510334235, 755167117};
+static unsigned int zipDistanceCodes[] = {
+0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7,
+8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9,
+10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
+11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
+12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
+12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
+13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+0, 0, 16, 17, 18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21,
+22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23,
+24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
+25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
+26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
+27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
+27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
+28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
+28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
+28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
+28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
+29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
+29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
+29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
+29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29};
+static unsigned int* zipDistanceFreq;
+static unsigned int* zipDistances;
static unsigned int* zipDistTable;
static sqInt zipDistTableSize;
+static unsigned int zipExtraDistanceBits[] = {
+0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
+7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13};
+static unsigned int zipExtraLengthBits[] = {
+0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
+3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0};
+static unsigned int* zipHashHead;
+static unsigned int* zipHashTail;
+static sqInt zipHashValue;
+static sqInt zipLiteralCount;
+static unsigned int* zipLiteralFreq;
+static sqInt zipLiteralSize;
+static unsigned char* zipLiterals;
static unsigned int* zipLitTable;
static sqInt zipLitTableSize;
+static sqInt zipMatchCount;
+static unsigned int zipMatchLengthCodes[] = {
+257, 258, 259, 260, 261, 262, 263, 264, 265, 265, 266, 266, 267, 267, 268, 268,
+269, 269, 269, 269, 270, 270, 270, 270, 271, 271, 271, 271, 272, 272, 272, 272,
+273, 273, 273, 273, 273, 273, 273, 273, 274, 274, 274, 274, 274, 274, 274, 274,
+275, 275, 275, 275, 275, 275, 275, 275, 276, 276, 276, 276, 276, 276, 276, 276,
+277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, 277,
+278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278,
+279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279,
+280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280,
+281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281,
+281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, 281,
+282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282,
+282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282,
+283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283,
+283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, 283,
+284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284,
+284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284};
static sqInt zipPosition;
static sqInt zipReadLimit;
static unsigned char* zipSource;
@@ -83,6 +204,305 @@
+/* Compare the two strings and return the length of matching characters.
+ minLength is a lower bound for match lengths that will be accepted.
+ Note: here and matchPos are zero based. */
+
+static sqInt
+comparewithmin(sqInt here, sqInt matchPos, sqInt minLength)
+{
+ sqInt length;
+
+ if (!((zipCollection[here + minLength]) == (zipCollection[matchPos + minLength]))) {
+ return 0;
+ }
+ if (!((zipCollection[(here + minLength) - 1]) == (zipCollection[(matchPos + minLength) - 1]))) {
+ return 0;
+ }
+ if (!((zipCollection[here]) == (zipCollection[matchPos]))) {
+ return 0;
+ }
+ if (!((zipCollection[here + 1]) == (zipCollection[matchPos + 1]))) {
+ return 1;
+ }
+ length = 2;
+ while ((length < DeflateMaxMatch)
+ && ((zipCollection[here + length]) == (zipCollection[matchPos + length]))) {
+ length += 1;
+ }
+ return length;
+}
+
+
+/* Continue deflating the receiver's collection from blockPosition to
+ lastIndex. Note that lastIndex must be at least MaxMatch away from the end
+ of collection
+ */
+
+static sqInt
+deflateBlockchainLengthgoodMatch(sqInt lastIndex, sqInt chainLength, sqInt goodMatch)
+{
+ sqInt distance;
+ sqInt flushNeeded;
+ sqInt hasMatch;
+ sqInt here;
+ sqInt here1;
+ sqInt hereLength;
+ sqInt hereMatch;
+ sqInt i;
+ sqInt literal;
+ sqInt matchResult;
+ sqInt newLength;
+ sqInt newMatch;
+ sqInt prevEntry;
+ sqInt prevEntry1;
+ sqInt prevEntry2;
+
+ if (zipBlockPos > lastIndex) {
+ return 0;
+ }
+ if (zipLiteralCount >= zipLiteralSize) {
+ return 1;
+ }
+ hasMatch = 0;
+ here = zipBlockPos;
+ while (here <= lastIndex) {
+ if (!hasMatch) {
+
+ /* Find the first match */
+
+ matchResult = findMatchlastLengthlastMatchchainLengthgoodMatch(here, DeflateMinMatch - 1, here, chainLength, goodMatch);
+ /* begin insertStringAt: */
+ zipHashValue = ((((usqInt) zipHashValue << 5)) ^ (zipCollection[(here + DeflateMinMatch) - 1])) & DeflateHashMask;
+ prevEntry = zipHashHead[zipHashValue];
+ zipHashHead[zipHashValue] = here;
+ zipHashTail[here & DeflateWindowMask] = prevEntry;
+ hereMatch = matchResult & 65535;
+ hereLength = ((usqInt) matchResult >> 16);
+ }
+ matchResult = findMatchlastLengthlastMatchchainLengthgoodMatch(here + 1, hereLength, hereMatch, chainLength, goodMatch);
+ newMatch = matchResult & 65535;
+
+ /* Now check if the next match is better than the current one.
+ If not, output the current match (provided that the current match
+ is at least MinMatch long) */
+
+ newLength = ((usqInt) matchResult >> 16);
+ if ((hereLength >= newLength)
+ && (hereLength >= DeflateMinMatch)) {
+ /* begin encodeMatch:distance: */
+ zipLiterals[zipLiteralCount] = (hereLength - DeflateMinMatch);
+ zipDistances[zipLiteralCount] = (here - hereMatch);
+ literal = zipMatchLengthCodes[hereLength - DeflateMinMatch];
+ zipLiteralFreq[literal] = ((zipLiteralFreq[literal]) + 1);
+ if ((here - hereMatch) < 257) {
+ distance = zipDistanceCodes[(here - hereMatch) - 1];
+ }
+ else {
+ distance = zipDistanceCodes[256 + (((usqInt) ((here - hereMatch) - 1) >> 7))];
+ }
+ zipDistanceFreq[distance] = ((zipDistanceFreq[distance]) + 1);
+ zipLiteralCount += 1;
+ zipMatchCount += 1;
+ flushNeeded = (zipLiteralCount == zipLiteralSize)
+ || (((zipLiteralCount & 4095) == 0)
+ && (shouldFlush()));
+ for (i = 1; i <= (hereLength - 1); i += 1) {
+ /* begin insertStringAt: */
+ here1 = (here += 1);
+ zipHashValue = ((((usqInt) zipHashValue << 5)) ^ (zipCollection[(here1 + DeflateMinMatch) - 1])) & DeflateHashMask;
+ prevEntry1 = zipHashHead[zipHashValue];
+ zipHashHead[zipHashValue] = here1;
+ zipHashTail[here1 & DeflateWindowMask] = prevEntry1;
+ }
+ hasMatch = 0;
+ here += 1;
+ }
+ else {
+ /* begin encodeLiteral: */
+ zipLiterals[zipLiteralCount] = (zipCollection[here]);
+ zipDistances[zipLiteralCount] = 0;
+ zipLiteralFreq[zipCollection[here]] = ((zipLiteralFreq[zipCollection[here]]) + 1);
+ zipLiteralCount += 1;
+ flushNeeded = (zipLiteralCount == zipLiteralSize)
+ || (((zipLiteralCount & 4095) == 0)
+ && (shouldFlush()));
+ here += 1;
+ if ((here <= lastIndex)
+ && (!flushNeeded)) {
+ /* begin insertStringAt: */
+ zipHashValue = ((((usqInt) zipHashValue << 5)) ^ (zipCollection[(here + DeflateMinMatch) - 1])) & DeflateHashMask;
+ prevEntry2 = zipHashHead[zipHashValue];
+ zipHashHead[zipHashValue] = here;
+ zipHashTail[here & DeflateWindowMask] = prevEntry2;
+ hasMatch = 1;
+ hereMatch = newMatch;
+ hereLength = newLength;
+ }
+ }
+ if (flushNeeded) {
+ zipBlockPos = here;
+ return 1;
+ }
+ }
+ zipBlockPos = here;
+ return 0;
+}
+
+
+/* Encode the given literal */
+
+static sqInt
+encodeLiteral(sqInt lit)
+{
+ zipLiterals[zipLiteralCount] = lit;
+ zipDistances[zipLiteralCount] = 0;
+ zipLiteralFreq[lit] = ((zipLiteralFreq[lit]) + 1);
+ zipLiteralCount += 1;
+ return (zipLiteralCount == zipLiteralSize)
+ || (((zipLiteralCount & 4095) == 0)
+ && (shouldFlush()));
+}
+
+
+/* Encode the given match of length length starting at dist bytes ahead */
+
+static sqInt
+encodeMatchdistance(sqInt length, sqInt dist)
+{
+ sqInt distance;
+ sqInt literal;
+
+ zipLiterals[zipLiteralCount] = (length - DeflateMinMatch);
+ zipDistances[zipLiteralCount] = dist;
+ literal = zipMatchLengthCodes[length - DeflateMinMatch];
+ zipLiteralFreq[literal] = ((zipLiteralFreq[literal]) + 1);
+ if (dist < 257) {
+ distance = zipDistanceCodes[dist - 1];
+ }
+ else {
+ distance = zipDistanceCodes[256 + (((usqInt) (dist - 1) >> 7))];
+ }
+ zipDistanceFreq[distance] = ((zipDistanceFreq[distance]) + 1);
+ zipLiteralCount += 1;
+ zipMatchCount += 1;
+ return (zipLiteralCount == zipLiteralSize)
+ || (((zipLiteralCount & 4095) == 0)
+ && (shouldFlush()));
+}
+
+
+/* Find the longest match for the string starting at here.
+ If there is no match longer than lastLength return lastMatch/lastLength.
+ Traverse at most maxChainLength entries in the hash table.
+ Stop if a match of at least goodMatch size has been found. */
+
+static sqInt
+findMatchlastLengthlastMatchchainLengthgoodMatch(sqInt here, sqInt lastLength, sqInt lastMatch, sqInt maxChainLength, sqInt goodMatch)
+{
+ sqInt bestLength;
+ sqInt chainLength;
+ sqInt distance;
+ sqInt length;
+ sqInt length1;
+ sqInt limit;
+ sqInt matchPos;
+ sqInt matchResult;
+
+
+ /* Compute the default match result */
+ /* There is no way to find a better match than MaxMatch */
+
+ matchResult = (((usqInt) lastLength << 16)) | lastMatch;
+ if (lastLength >= DeflateMaxMatch) {
+ return matchResult;
+ }
+
+ /* Compute the distance to the (possible) match */
+
+ matchPos = zipHashHead[((((usqInt) zipHashValue << 5)) ^ (zipCollection[(here + DeflateMinMatch) - 1])) & DeflateHashMask];
+
+ /* Note: It is required that 0 < distance < MaxDistance */
+
+ distance = here - matchPos;
+ if (!((distance > 0)
+ && (distance < DeflateMaxDistance))) {
+ return matchResult;
+ }
+
+ /* Max. nr of match chain to search */
+
+ chainLength = maxChainLength;
+ if (here > DeflateMaxDistance) {
+
+ /* Limit for matches that are too old */
+
+ limit = here - DeflateMaxDistance;
+ }
+ else {
+ limit = 0;
+ }
+ bestLength = lastLength;
+ while (1) {
+ /* begin compare:with:min: */
+ if (!((zipCollection[here + bestLength]) == (zipCollection[matchPos + bestLength]))) {
+ length = 0;
+ goto l1;
+ }
+ if (!((zipCollection[(here + bestLength) - 1]) == (zipCollection[(matchPos + bestLength) - 1]))) {
+ length = 0;
+ goto l1;
+ }
+ if (!((zipCollection[here]) == (zipCollection[matchPos]))) {
+ length = 0;
+ goto l1;
+ }
+ if (!((zipCollection[here + 1]) == (zipCollection[matchPos + 1]))) {
+ length = 1;
+ goto l1;
+ }
+ length1 = 2;
+ while ((length1 < DeflateMaxMatch)
+ && ((zipCollection[here + length1]) == (zipCollection[matchPos + length1]))) {
+ length1 += 1;
+ }
+ length = length1;
+ l1: /* end compare:with:min: */;
+ if ((here + length) > zipPosition) {
+ length = zipPosition - here;
+ }
+ if ((length == DeflateMinMatch)
+ && ((here - matchPos) > (((sqInt) DeflateMaxDistance >> 2)))) {
+ length = DeflateMinMatch - 1;
+ }
+ if (length > bestLength) {
+
+ /* We have a new (better) match than before */
+ /* Compute the new match result */
+
+ matchResult = (((usqInt) length << 16)) | matchPos;
+
+ /* There is no way to find a better match than MaxMatch */
+
+ bestLength = length;
+ if (bestLength >= DeflateMaxMatch) {
+ return matchResult;
+ }
+ if (bestLength > goodMatch) {
+ return matchResult;
+ }
+ }
+ if (!(((chainLength -= 1)) > 0)) {
+ return matchResult;
+ }
+ matchPos = zipHashTail[matchPos & DeflateWindowMask];
+ if (matchPos <= limit) {
+ return matchResult;
+ }
+ }
+}
+
+
/* Note: This is coded so that plugins can be run from Squeak. */
static VirtualMachine *
@@ -110,7 +530,137 @@
return 0;
}
+
+/* Insert the string at the given start position into the hash table.
+ Note: The hash value is updated starting at MinMatch-1 since
+ all strings before have already been inserted into the hash table
+ (and the hash value is updated as well). */
+
static sqInt
+insertStringAt(sqInt here)
+{
+ sqInt prevEntry;
+
+ zipHashValue = ((((usqInt) zipHashValue << 5)) ^ (zipCollection[(here + DeflateMinMatch) - 1])) & DeflateHashMask;
+ prevEntry = zipHashHead[zipHashValue];
+ zipHashHead[zipHashValue] = here;
+ zipHashTail[here & DeflateWindowMask] = prevEntry;
+}
+
+static sqInt
+loadDeflateStreamFrom(sqInt rcvr)
+{
+ sqInt oop;
+
+ if (!((interpreterProxy->isPointers(rcvr))
+ && ((interpreterProxy->slotSizeOf(rcvr)) >= 15))) {
+ return 0;
+ }
+ oop = interpreterProxy->fetchPointerofObject(0, rcvr);
+ if (interpreterProxy->isIntegerObject(oop)) {
+ return 0;
+ }
+ if (!(interpreterProxy->isBytes(oop))) {
+ return 0;
+ }
+ zipCollection = interpreterProxy->firstIndexableField(oop);
+ zipCollectionSize = interpreterProxy->byteSizeOf(oop);
+ zipPosition = interpreterProxy->fetchIntegerofObject(1, rcvr);
+
+ /* zipWriteLimit := interpreterProxy fetchInteger: 3 ofObject: rcvr. */
+
+ zipReadLimit = interpreterProxy->fetchIntegerofObject(2, rcvr);
+ oop = interpreterProxy->fetchPointerofObject(4, rcvr);
+ if ((interpreterProxy->isIntegerObject(oop))
+ || (!(interpreterProxy->isWords(oop)))) {
+ return 0;
+ }
+ if (!((interpreterProxy->slotSizeOf(oop)) == DeflateHashTableSize)) {
+ return 0;
+ }
+ zipHashHead = interpreterProxy->firstIndexableField(oop);
+ oop = interpreterProxy->fetchPointerofObject(5, rcvr);
+ if ((interpreterProxy->isIntegerObject(oop))
+ || (!(interpreterProxy->isWords(oop)))) {
+ return 0;
+ }
+ if (!((interpreterProxy->slotSizeOf(oop)) == DeflateWindowSize)) {
+ return 0;
+ }
+ zipHashTail = interpreterProxy->firstIndexableField(oop);
+ zipHashValue = interpreterProxy->fetchIntegerofObject(6, rcvr);
+
+ /* zipBlockStart := interpreterProxy fetchInteger: 8 ofObject: rcvr. */
+
+ zipBlockPos = interpreterProxy->fetchIntegerofObject(7, rcvr);
+ oop = interpreterProxy->fetchPointerofObject(9, rcvr);
+ if ((interpreterProxy->isIntegerObject(oop))
+ || (!(interpreterProxy->isBytes(oop)))) {
+ return 0;
+ }
+ zipLiteralSize = interpreterProxy->slotSizeOf(oop);
+ zipLiterals = interpreterProxy->firstIndexableField(oop);
+ oop = interpreterProxy->fetchPointerofObject(10, rcvr);
+ if ((interpreterProxy->isIntegerObject(oop))
+ || (!(interpreterProxy->isWords(oop)))) {
+ return 0;
+ }
+ if ((interpreterProxy->slotSizeOf(oop)) < zipLiteralSize) {
+ return 0;
+ }
+ zipDistances = interpreterProxy->firstIndexableField(oop);
+ oop = interpreterProxy->fetchPointerofObject(11, rcvr);
+ if ((interpreterProxy->isIntegerObject(oop))
+ || (!(interpreterProxy->isWords(oop)))) {
+ return 0;
+ }
+ if (!((interpreterProxy->slotSizeOf(oop)) == DeflateMaxLiteralCodes)) {
+ return 0;
+ }
+ zipLiteralFreq = interpreterProxy->firstIndexableField(oop);
+ oop = interpreterProxy->fetchPointerofObject(12, rcvr);
+ if ((interpreterProxy->isIntegerObject(oop))
+ || (!(interpreterProxy->isWords(oop)))) {
+ return 0;
+ }
+ if (!((interpreterProxy->slotSizeOf(oop)) == DeflateMaxDistanceCodes)) {
+ return 0;
+ }
+ zipDistanceFreq = interpreterProxy->firstIndexableField(oop);
+ zipLiteralCount = interpreterProxy->fetchIntegerofObject(13, rcvr);
+ zipMatchCount = interpreterProxy->fetchIntegerofObject(14, rcvr);
+ return !(interpreterProxy->failed());
+}
+
+static sqInt
+loadZipEncoderFrom(sqInt rcvr)
+{
+ sqInt oop;
+
+ if (!((interpreterProxy->isPointers(rcvr))
+ && ((interpreterProxy->slotSizeOf(rcvr)) >= 6))) {
+ return 0;
+ }
+ oop = interpreterProxy->fetchPointerofObject(0, rcvr);
+ if (interpreterProxy->isIntegerObject(oop)) {
+ return interpreterProxy->primitiveFail();
+ }
+ if (!(interpreterProxy->isBytes(oop))) {
+ return interpreterProxy->primitiveFail();
+ }
+ zipCollection = interpreterProxy->firstIndexableField(oop);
+ zipCollectionSize = interpreterProxy->byteSizeOf(oop);
+ zipPosition = interpreterProxy->fetchIntegerofObject(1, rcvr);
+
+ /* zipWriteLimit := interpreterProxy fetchInteger: 3 ofObject: rcvr. */
+
+ zipReadLimit = interpreterProxy->fetchIntegerofObject(2, rcvr);
+ zipBitBuf = interpreterProxy->fetchIntegerofObject(4, rcvr);
+ zipBitPos = interpreterProxy->fetchIntegerofObject(5, rcvr);
+ return !(interpreterProxy->failed());
+}
+
+static sqInt
msg(char *s)
{
fprintf(stderr, "\n%s: %s", moduleName, s);
@@ -118,6 +668,107 @@
}
+/* Require:
+ zipCollection, zipCollectionSize, zipPosition,
+ zipBitBuf, zipBitPos.
+ */
+
+static sqInt
+nextZipBitsput(sqInt nBits, sqInt value)
+{
+ if (!((value >= 0)
+ && ((1 << nBits) > value))) {
+ return interpreterProxy->primitiveFail();
+ }
+ zipBitBuf = zipBitBuf | (((zipBitPos < 0) ? ((usqInt) value >> -zipBitPos) : ((usqInt) value << zipBitPos)));
+ zipBitPos += nBits;
+ while ((zipBitPos >= 8)
+ && (zipPosition < zipCollectionSize)) {
+ zipCollection[zipPosition] = (zipBitBuf & 255);
+ zipPosition += 1;
+ zipBitBuf = ((usqInt) zipBitBuf) >> 8;
+ zipBitPos -= 8;
+ }
+}
+
+
+/* Primitive. Deflate the current contents of the receiver. */
+
+EXPORT(sqInt)
+primitiveDeflateBlock(void)
+{
+ sqInt chainLength;
+ sqInt goodMatch;
+ sqInt lastIndex;
+ sqInt rcvr;
+ sqInt result;
+
+ if (!((interpreterProxy->methodArgumentCount()) == 3)) {
+ return interpreterProxy->primitiveFail();
+ }
+ goodMatch = interpreterProxy->stackIntegerValue(0);
+ chainLength = interpreterProxy->stackIntegerValue(1);
+ lastIndex = interpreterProxy->stackIntegerValue(2);
+ rcvr = interpreterProxy->stackObjectValue(3);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ ;
+ if (!(loadDeflateStreamFrom(rcvr))) {
+ return interpreterProxy->primitiveFail();
+ }
+ result = deflateBlockchainLengthgoodMatch(lastIndex, chainLength, goodMatch);
+ if (!(interpreterProxy->failed())) {
+ interpreterProxy->storeIntegerofObjectwithValue(6, rcvr, zipHashValue);
+ interpreterProxy->storeIntegerofObjectwithValue(7, rcvr, zipBlockPos);
+ interpreterProxy->storeIntegerofObjectwithValue(13, rcvr, zipLiteralCount);
+ interpreterProxy->storeIntegerofObjectwithValue(14, rcvr, zipMatchCount);
+ }
+ if (!(interpreterProxy->failed())) {
+ interpreterProxy->pop(4);
+ interpreterProxy->pushBool(result);
+ }
+}
+
+
+/* Primitive. Update the hash tables after data has been moved by delta. */
+
+EXPORT(sqInt)
+primitiveDeflateUpdateHashTable(void)
+{
+ sqInt delta;
+ sqInt entry;
+ sqInt i;
+ sqInt table;
+ int *tablePtr;
+ sqInt tableSize;
+
+ if (!((interpreterProxy->methodArgumentCount()) == 2)) {
+ return interpreterProxy->primitiveFail();
+ }
+ delta = interpreterProxy->stackIntegerValue(0);
+ table = interpreterProxy->stackObjectValue(1);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ if (!(interpreterProxy->isWords(table))) {
+ return interpreterProxy->primitiveFail();
+ }
+ tableSize = interpreterProxy->slotSizeOf(table);
+ tablePtr = interpreterProxy->firstIndexableField(table);
+ for (i = 0; i <= (tableSize - 1); i += 1) {
+ entry = tablePtr[i];
+ if (entry >= delta) {
+ tablePtr[i] = (entry - delta);
+ }
+ else {
+ tablePtr[i] = 0;
+ }
+ }
+ interpreterProxy->pop(2);
+}
+
+
/* Primitive. Inflate a single block. */
EXPORT(sqInt)
@@ -179,7 +830,7 @@
zipSourceLimit -= 1;
oop = interpreterProxy->fetchPointerofObject(0, rcvr);
- if ((oop & 1)) {
+ if (interpreterProxy->isIntegerObject(oop)) {
return interpreterProxy->primitiveFail();
}
if (!(interpreterProxy->isBytes(oop))) {
@@ -191,7 +842,7 @@
zipCollectionSize = interpreterProxy->byteSizeOf(oop);
oop = interpreterProxy->fetchPointerofObject(6, rcvr);
- if ((oop & 1)) {
+ if (interpreterProxy->isIntegerObject(oop)) {
return interpreterProxy->primitiveFail();
}
if (!(interpreterProxy->isBytes(oop))) {
@@ -213,6 +864,631 @@
}
+/* Primitive. Update a 32bit CRC value. */
+
+EXPORT(sqInt)
+primitiveUpdateAdler32(void)
+{
+ unsigned int adler32;
+ sqInt b;
+ unsigned char *bytePtr;
+ sqInt collection;
+ sqInt i;
+ sqInt length;
+ sqInt s1;
+ sqInt s2;
+ sqInt startIndex;
+ sqInt stopIndex;
+
+ if (!((interpreterProxy->methodArgumentCount()) == 4)) {
+ return interpreterProxy->primitiveFail();
+ }
+ collection = interpreterProxy->stackObjectValue(0);
+ stopIndex = interpreterProxy->stackIntegerValue(1);
+ startIndex = interpreterProxy->stackIntegerValue(2);
+ adler32 = interpreterProxy->positive32BitValueOf(interpreterProxy->stackValue(3));
+ if (interpreterProxy->failed()) {
+ return 0;
+ }
+ if (!((interpreterProxy->isBytes(collection))
+ && ((stopIndex >= startIndex)
+ && (startIndex > 0)))) {
+ return interpreterProxy->primitiveFail();
+ }
+ length = interpreterProxy->byteSizeOf(collection);
+ if (!(stopIndex <= length)) {
+ return interpreterProxy->primitiveFail();
+ }
+ bytePtr = interpreterProxy->firstIndexableField(collection);
+ startIndex -= 1;
+ stopIndex -= 1;
+ s1 = adler32 & 65535;
+ s2 = (((usqInt) adler32) >> 16) & 65535;
+ for (i = startIndex; i <= stopIndex; i += 1) {
+ b = bytePtr[i];
+ s1 = (s1 + b) % 65521;
+ s2 = (s2 + s1) % 65521;
+ }
+ adler32 = (((usqInt) s2 << 16)) + s1;
+ interpreterProxy->pop(5);
+ interpreterProxy->push(interpreterProxy->positive32BitIntegerFor(adler32));
+}
+
+
+/* Primitive. Update a 32bit CRC value. */
+
+EXPORT(sqInt)
+primitiveUpdateGZipCrc32(void)
+{
+ unsigned char *bytePtr;
+ sqInt collection;
+ unsigned int crc;
+ sqInt i;
+ sqInt length;
+ sqInt startIndex;
+ sqInt stopIndex;
+
+ if (!((interpreterProxy->methodArgumentCount()) == 4)) {
+ return interpreterProxy->primitiveFail();
+ }
+ collection = interpreterProxy->stackObjectValue(0);
+ stopIndex = interpreterProxy->stackIntegerValue(1);
+ startIndex = interpreterProxy->stackIntegerValue(2);
+ crc = interpreterProxy->positive32BitValueOf(interpreterProxy->stackValue(3));
+ if (interpreterProxy->failed()) {
+ return 0;
+ }
+ if (!((interpreterProxy->isBytes(collection))
+ && ((stopIndex >= startIndex)
+ && (startIndex > 0)))) {
+ return interpreterProxy->primitiveFail();
+ }
+ length = interpreterProxy->byteSizeOf(collection);
+ if (!(stopIndex <= length)) {
+ return interpreterProxy->primitiveFail();
+ }
+ bytePtr = interpreterProxy->firstIndexableField(collection);
+ ;
+ startIndex -= 1;
+ stopIndex -= 1;
+ for (i = startIndex; i <= stopIndex; i += 1) {
+ crc = (zipCrcTable[(crc ^ (bytePtr[i])) & 255]) ^ (((usqInt) crc) >> 8);
+ }
+ interpreterProxy->pop(5);
+ interpreterProxy->push(interpreterProxy->positive32BitIntegerFor(crc));
+}
+
+EXPORT(sqInt)
+primitiveZipSendBlock(void)
+{
+ sqInt code;
+ sqInt dist;
+ unsigned int *distArray;
+ unsigned int *distBitLengths;
+ sqInt distBlCount;
+ unsigned int *distCodes;
+ sqInt distStream;
+ sqInt distTree;
+ sqInt extra;
+ sqInt lit;
+ unsigned char *litArray;
+ sqInt litBlCount;
+ sqInt litLimit;
+ sqInt litPos;
+ sqInt litStream;
+ sqInt litTree;
+ unsigned int *llBitLengths;
+ unsigned int *llCodes;
+ sqInt oop;
+ sqInt rcvr;
+ sqInt result;
+ sqInt sum;
+
+ if (!((interpreterProxy->methodArgumentCount()) == 4)) {
+ return interpreterProxy->primitiveFail();
+ }
+ distTree = interpreterProxy->stackObjectValue(0);
+ litTree = interpreterProxy->stackObjectValue(1);
+ distStream = interpreterProxy->stackObjectValue(2);
+ litStream = interpreterProxy->stackObjectValue(3);
+ rcvr = interpreterProxy->stackObjectValue(4);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ if (!(loadZipEncoderFrom(rcvr))) {
+ return interpreterProxy->primitiveFail();
+ }
+ if (!((interpreterProxy->isPointers(distTree))
+ && ((interpreterProxy->slotSizeOf(distTree)) >= 2))) {
+ return interpreterProxy->primitiveFail();
+ }
+ if (!((interpreterProxy->isPointers(litTree))
+ && ((interpreterProxy->slotSizeOf(litTree)) >= 2))) {
+ return interpreterProxy->primitiveFail();
+ }
+ if (!((interpreterProxy->isPointers(litStream))
+ && ((interpreterProxy->slotSizeOf(litStream)) >= 3))) {
+ return interpreterProxy->primitiveFail();
+ }
+ if (!((interpreterProxy->isPointers(distStream))
+ && ((interpreterProxy->slotSizeOf(distStream)) >= 3))) {
+ return interpreterProxy->primitiveFail();
+ }
+ ;
+ /* begin sendBlock:with:with:with: */
+ oop = interpreterProxy->fetchPointerofObject(0, litStream);
+ litPos = interpreterProxy->fetchIntegerofObject(1, litStream);
+ litLimit = interpreterProxy->fetchIntegerofObject(2, litStream);
+ if (!((!(interpreterProxy->isIntegerObject(oop)))
+ && ((litPos <= litLimit)
+ && ((litLimit <= (interpreterProxy->byteSizeOf(oop)))
+ && (interpreterProxy->isBytes(oop)))))) {
+ result = interpreterProxy->primitiveFail();
+ goto l7;
+ }
+ litArray = interpreterProxy->firstIndexableField(oop);
+ oop = interpreterProxy->fetchPointerofObject(0, distStream);
+ if (!((!(interpreterProxy->isIntegerObject(oop)))
+ && (((interpreterProxy->fetchIntegerofObject(1, distStream)) == litPos)
+ && ((interpreterProxy->fetchIntegerofObject(2, distStream)) == litLimit)))) {
+ result = interpreterProxy->primitiveFail();
+ goto l7;
+ }
+ if (!((interpreterProxy->isWords(oop))
+ && (litLimit <= (interpreterProxy->slotSizeOf(oop))))) {
+ result = interpreterProxy->primitiveFail();
+ goto l7;
+ }
+ distArray = interpreterProxy->firstIndexableField(oop);
+ oop = interpreterProxy->fetchPointerofObject(0, litTree);
+ if (!((!(interpreterProxy->isIntegerObject(oop)))
+ && (interpreterProxy->isWords(oop)))) {
+ result = interpreterProxy->primitiveFail();
+ goto l7;
+ }
+ litBlCount = interpreterProxy->slotSizeOf(oop);
+ llBitLengths = interpreterProxy->firstIndexableField(oop);
+ oop = interpreterProxy->fetchPointerofObject(1, litTree);
+ if (!((!(interpreterProxy->isIntegerObject(oop)))
+ && (interpreterProxy->isWords(oop)))) {
+ result = interpreterProxy->primitiveFail();
+ goto l7;
+ }
+ if (!(litBlCount == (interpreterProxy->slotSizeOf(oop)))) {
+ result = interpreterProxy->primitiveFail();
+ goto l7;
+ }
+ llCodes = interpreterProxy->firstIndexableField(oop);
+ oop = interpreterProxy->fetchPointerofObject(0, distTree);
+ if (!((!(interpreterProxy->isIntegerObject(oop)))
+ && (interpreterProxy->isWords(oop)))) {
+ result = interpreterProxy->primitiveFail();
+ goto l7;
+ }
+ distBlCount = interpreterProxy->slotSizeOf(oop);
+ distBitLengths = interpreterProxy->firstIndexableField(oop);
+ oop = interpreterProxy->fetchPointerofObject(1, distTree);
+ if (!((!(interpreterProxy->isIntegerObject(oop)))
+ && (interpreterProxy->isWords(oop)))) {
+ result = interpreterProxy->primitiveFail();
+ goto l7;
+ }
+ if (!(distBlCount == (interpreterProxy->slotSizeOf(oop)))) {
+ result = interpreterProxy->primitiveFail();
+ goto l7;
+ }
+ distCodes = interpreterProxy->firstIndexableField(oop);
+ if (interpreterProxy->failed()) {
+ result = null;
+ goto l7;
+ }
+ /* begin nextZipBits:put: */
+ if (!((0 >= 0)
+ && ((1 << 0) > 0))) {
+ interpreterProxy->primitiveFail();
+ goto l6;
+ }
+ zipBitBuf = zipBitBuf | (((zipBitPos < 0) ? ((usqInt) 0 >> -zipBitPos) : ((usqInt) 0 << zipBitPos)));
+ zipBitPos += 0;
+ while ((zipBitPos >= 8)
+ && (zipPosition < zipCollectionSize)) {
+ zipCollection[zipPosition] = (zipBitBuf & 255);
+ zipPosition += 1;
+ zipBitBuf = ((usqInt) zipBitBuf) >> 8;
+ zipBitPos -= 8;
+ }
+l6: /* end nextZipBits:put: */;
+ sum = 0;
+ while ((litPos < litLimit)
+ && ((zipPosition + 4) < zipCollectionSize)) {
+ lit = litArray[litPos];
+ dist = distArray[litPos];
+ litPos += 1;
+ if (dist == 0) {
+
+ /* literal */
+
+ sum += 1;
+ if (!(lit < litBlCount)) {
+ result = interpreterProxy->primitiveFail();
+ goto l7;
+ }
+ /* begin nextZipBits:put: */
+ if (!(((llCodes[lit]) >= 0)
+ && ((1 << (llBitLengths[lit])) > (llCodes[lit])))) {
+ interpreterProxy->primitiveFail();
+ goto l1;
+ }
+ zipBitBuf = zipBitBuf | (((zipBitPos < 0) ? ((usqInt) (llCodes[lit]) >> -zipBitPos) : ((usqInt) (llCodes[lit]) << zipBitPos)));
+ zipBitPos += llBitLengths[lit];
+ while ((zipBitPos >= 8)
+ && (zipPosition < zipCollectionSize)) {
+ zipCollection[zipPosition] = (zipBitBuf & 255);
+ zipPosition += 1;
+ zipBitBuf = ((usqInt) zipBitBuf) >> 8;
+ zipBitPos -= 8;
+ }
+ l1: /* end nextZipBits:put: */;
+ }
+ else {
+
+ /* match */
+
+ sum = (sum + lit) + DeflateMinMatch;
+ if (!(lit < 256)) {
+ result = interpreterProxy->primitiveFail();
+ goto l7;
+ }
+ code = zipMatchLengthCodes[lit];
+ if (!(code < litBlCount)) {
+ result = interpreterProxy->primitiveFail();
+ goto l7;
+ }
+ /* begin nextZipBits:put: */
+ if (!(((llCodes[code]) >= 0)
+ && ((1 << (llBitLengths[code])) > (llCodes[code])))) {
+ interpreterProxy->primitiveFail();
+ goto l4;
+ }
+ zipBitBuf = zipBitBuf | (((zipBitPos < 0) ? ((usqInt) (llCodes[code]) >> -zipBitPos) : ((usqInt) (llCodes[code]) << zipBitPos)));
+ zipBitPos += llBitLengths[code];
+ while ((zipBitPos >= 8)
+ && (zipPosition < zipCollectionSize)) {
+ zipCollection[zipPosition] = (zipBitBuf & 255);
+ zipPosition += 1;
+ zipBitBuf = ((usqInt) zipBitBuf) >> 8;
+ zipBitPos -= 8;
+ }
+ l4: /* end nextZipBits:put: */;
+ extra = zipExtraLengthBits[code - 257];
+ if (!(extra == 0)) {
+ lit -= zipBaseLength[code - 257];
+ /* begin nextZipBits:put: */
+ if (!((lit >= 0)
+ && ((1 << extra) > lit))) {
+ interpreterProxy->primitiveFail();
+ goto l2;
+ }
+ zipBitBuf = zipBitBuf | (((zipBitPos < 0) ? ((usqInt) lit >> -zipBitPos) : ((usqInt) lit << zipBitPos)));
+ zipBitPos += extra;
+ while ((zipBitPos >= 8)
+ && (zipPosition < zipCollectionSize)) {
+ zipCollection[zipPosition] = (zipBitBuf & 255);
+ zipPosition += 1;
+ zipBitBuf = ((usqInt) zipBitBuf) >> 8;
+ zipBitPos -= 8;
+ }
+ l2: /* end nextZipBits:put: */;
+ }
+ dist -= 1;
+ if (!(dist < 32768)) {
+ result = interpreterProxy->primitiveFail();
+ goto l7;
+ }
+ if (dist < 256) {
+ code = zipDistanceCodes[dist];
+ }
+ else {
+ code = zipDistanceCodes[256 + (((usqInt) dist) >> 7)];
+ }
+ if (!(code < distBlCount)) {
+ result = interpreterProxy->primitiveFail();
+ goto l7;
+ }
+ /* begin nextZipBits:put: */
+ if (!(((distCodes[code]) >= 0)
+ && ((1 << (distBitLengths[code])) > (distCodes[code])))) {
+ interpreterProxy->primitiveFail();
+ goto l5;
+ }
+ zipBitBuf = zipBitBuf | (((zipBitPos < 0) ? ((usqInt) (distCodes[code]) >> -zipBitPos) : ((usqInt) (distCodes[code]) << zipBitPos)));
+ zipBitPos += distBitLengths[code];
+ while ((zipBitPos >= 8)
+ && (zipPosition < zipCollectionSize)) {
+ zipCollection[zipPosition] = (zipBitBuf & 255);
+ zipPosition += 1;
+ zipBitBuf = ((usqInt) zipBitBuf) >> 8;
+ zipBitPos -= 8;
+ }
+ l5: /* end nextZipBits:put: */;
+ extra = zipExtraDistanceBits[code];
+ if (!(extra == 0)) {
+ dist -= zipBaseDistance[code];
+ /* begin nextZipBits:put: */
+ if (!((dist >= 0)
+ && ((1 << extra) > dist))) {
+ interpreterProxy->primitiveFail();
+ goto l3;
+ }
+ zipBitBuf = zipBitBuf | (((zipBitPos < 0) ? ((usqInt) dist >> -zipBitPos) : ((usqInt) dist << zipBitPos)));
+ zipBitPos += extra;
+ while ((zipBitPos >= 8)
+ && (zipPosition < zipCollectionSize)) {
+ zipCollection[zipPosition] = (zipBitBuf & 255);
+ zipPosition += 1;
+ zipBitBuf = ((usqInt) zipBitBuf) >> 8;
+ zipBitPos -= 8;
+ }
+ l3: /* end nextZipBits:put: */;
+ }
+ }
+ }
+ if (interpreterProxy->failed()) {
+ result = null;
+ goto l7;
+ }
+ interpreterProxy->storeIntegerofObjectwithValue(1, litStream, litPos);
+ interpreterProxy->storeIntegerofObjectwithValue(1, distStream, litPos);
+ result = sum;
+l7: /* end sendBlock:with:with:with: */;
+ if (!(interpreterProxy->failed())) {
+ interpreterProxy->storeIntegerofObjectwithValue(1, rcvr, zipPosition);
+ interpreterProxy->storeIntegerofObjectwithValue(4, rcvr, zipBitBuf);
+ interpreterProxy->storeIntegerofObjectwithValue(5, rcvr, zipBitPos);
+ }
+ if (!(interpreterProxy->failed())) {
+ interpreterProxy->pop(5);
+ interpreterProxy->pushInteger(result);
+ }
+}
+
+
+/* Require:
+ zipCollection, zipCollectionSize, zipPosition,
+ zipBitBuf, zipBitPos.
+ */
+
+static sqInt
+sendBlockwithwithwith(sqInt literalStream, sqInt distanceStream, sqInt litTree, sqInt distTree)
+{
+ sqInt code;
+ sqInt dist;
+ unsigned int *distArray;
+ unsigned int *distBitLengths;
+ sqInt distBlCount;
+ unsigned int *distCodes;
+ sqInt extra;
+ sqInt lit;
+ unsigned char *litArray;
+ sqInt litBlCount;
+ sqInt litLimit;
+ sqInt litPos;
+ unsigned int *llBitLengths;
+ unsigned int *llCodes;
+ sqInt oop;
+ sqInt sum;
+
+ oop = interpreterProxy->fetchPointerofObject(0, literalStream);
+ litPos = interpreterProxy->fetchIntegerofObject(1, literalStream);
+ litLimit = interpreterProxy->fetchIntegerofObject(2, literalStream);
+ if (!((!(interpreterProxy->isIntegerObject(oop)))
+ && ((litPos <= litLimit)
+ && ((litLimit <= (interpreterProxy->byteSizeOf(oop)))
+ && (interpreterProxy->isBytes(oop)))))) {
+ return interpreterProxy->primitiveFail();
+ }
+ litArray = interpreterProxy->firstIndexableField(oop);
+ oop = interpreterProxy->fetchPointerofObject(0, distanceStream);
+ if (!((!(interpreterProxy->isIntegerObject(oop)))
+ && (((interpreterProxy->fetchIntegerofObject(1, distanceStream)) == litPos)
+ && ((interpreterProxy->fetchIntegerofObject(2, distanceStream)) == litLimit)))) {
+ return interpreterProxy->primitiveFail();
+ }
+ if (!((interpreterProxy->isWords(oop))
+ && (litLimit <= (interpreterProxy->slotSizeOf(oop))))) {
+ return interpreterProxy->primitiveFail();
+ }
+ distArray = interpreterProxy->firstIndexableField(oop);
+ oop = interpreterProxy->fetchPointerofObject(0, litTree);
+ if (!((!(interpreterProxy->isIntegerObject(oop)))
+ && (interpreterProxy->isWords(oop)))) {
+ return interpreterProxy->primitiveFail();
+ }
+ litBlCount = interpreterProxy->slotSizeOf(oop);
+ llBitLengths = interpreterProxy->firstIndexableField(oop);
+ oop = interpreterProxy->fetchPointerofObject(1, litTree);
+ if (!((!(interpreterProxy->isIntegerObject(oop)))
+ && (interpreterProxy->isWords(oop)))) {
+ return interpreterProxy->primitiveFail();
+ }
+ if (!(litBlCount == (interpreterProxy->slotSizeOf(oop)))) {
+ return interpreterProxy->primitiveFail();
+ }
+ llCodes = interpreterProxy->firstIndexableField(oop);
+ oop = interpreterProxy->fetchPointerofObject(0, distTree);
+ if (!((!(interpreterProxy->isIntegerObject(oop)))
+ && (interpreterProxy->isWords(oop)))) {
+ return interpreterProxy->primitiveFail();
+ }
+ distBlCount = interpreterProxy->slotSizeOf(oop);
+ distBitLengths = interpreterProxy->firstIndexableField(oop);
+ oop = interpreterProxy->fetchPointerofObject(1, distTree);
+ if (!((!(interpreterProxy->isIntegerObject(oop)))
+ && (interpreterProxy->isWords(oop)))) {
+ return interpreterProxy->primitiveFail();
+ }
+ if (!(distBlCount == (interpreterProxy->slotSizeOf(oop)))) {
+ return interpreterProxy->primitiveFail();
+ }
+ distCodes = interpreterProxy->firstIndexableField(oop);
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ /* begin nextZipBits:put: */
+ if (!((0 >= 0)
+ && ((1 << 0) > 0))) {
+ interpreterProxy->primitiveFail();
+ goto l6;
+ }
+ zipBitBuf = zipBitBuf | (((zipBitPos < 0) ? ((usqInt) 0 >> -zipBitPos) : ((usqInt) 0 << zipBitPos)));
+ zipBitPos += 0;
+ while ((zipBitPos >= 8)
+ && (zipPosition < zipCollectionSize)) {
+ zipCollection[zipPosition] = (zipBitBuf & 255);
+ zipPosition += 1;
+ zipBitBuf = ((usqInt) zipBitBuf) >> 8;
+ zipBitPos -= 8;
+ }
+l6: /* end nextZipBits:put: */;
+ sum = 0;
+ while ((litPos < litLimit)
+ && ((zipPosition + 4) < zipCollectionSize)) {
+ lit = litArray[litPos];
+ dist = distArray[litPos];
+ litPos += 1;
+ if (dist == 0) {
+
+ /* literal */
+
+ sum += 1;
+ if (!(lit < litBlCount)) {
+ return interpreterProxy->primitiveFail();
+ }
+ /* begin nextZipBits:put: */
+ if (!(((llCodes[lit]) >= 0)
+ && ((1 << (llBitLengths[lit])) > (llCodes[lit])))) {
+ interpreterProxy->primitiveFail();
+ goto l1;
+ }
+ zipBitBuf = zipBitBuf | (((zipBitPos < 0) ? ((usqInt) (llCodes[lit]) >> -zipBitPos) : ((usqInt) (llCodes[lit]) << zipBitPos)));
+ zipBitPos += llBitLengths[lit];
+ while ((zipBitPos >= 8)
+ && (zipPosition < zipCollectionSize)) {
+ zipCollection[zipPosition] = (zipBitBuf & 255);
+ zipPosition += 1;
+ zipBitBuf = ((usqInt) zipBitBuf) >> 8;
+ zipBitPos -= 8;
+ }
+ l1: /* end nextZipBits:put: */;
+ }
+ else {
+
+ /* match */
+
+ sum = (sum + lit) + DeflateMinMatch;
+ if (!(lit < 256)) {
+ return interpreterProxy->primitiveFail();
+ }
+ code = zipMatchLengthCodes[lit];
+ if (!(code < litBlCount)) {
+ return interpreterProxy->primitiveFail();
+ }
+ /* begin nextZipBits:put: */
+ if (!(((llCodes[code]) >= 0)
+ && ((1 << (llBitLengths[code])) > (llCodes[code])))) {
+ interpreterProxy->primitiveFail();
+ goto l4;
+ }
+ zipBitBuf = zipBitBuf | (((zipBitPos < 0) ? ((usqInt) (llCodes[code]) >> -zipBitPos) : ((usqInt) (llCodes[code]) << zipBitPos)));
+ zipBitPos += llBitLengths[code];
+ while ((zipBitPos >= 8)
+ && (zipPosition < zipCollectionSize)) {
+ zipCollection[zipPosition] = (zipBitBuf & 255);
+ zipPosition += 1;
+ zipBitBuf = ((usqInt) zipBitBuf) >> 8;
+ zipBitPos -= 8;
+ }
+ l4: /* end nextZipBits:put: */;
+ extra = zipExtraLengthBits[code - 257];
+ if (!(extra == 0)) {
+ lit -= zipBaseLength[code - 257];
+ /* begin nextZipBits:put: */
+ if (!((lit >= 0)
+ && ((1 << extra) > lit))) {
+ interpreterProxy->primitiveFail();
+ goto l2;
+ }
+ zipBitBuf = zipBitBuf | (((zipBitPos < 0) ? ((usqInt) lit >> -zipBitPos) : ((usqInt) lit << zipBitPos)));
+ zipBitPos += extra;
+ while ((zipBitPos >= 8)
+ && (zipPosition < zipCollectionSize)) {
+ zipCollection[zipPosition] = (zipBitBuf & 255);
+ zipPosition += 1;
+ zipBitBuf = ((usqInt) zipBitBuf) >> 8;
+ zipBitPos -= 8;
+ }
+ l2: /* end nextZipBits:put: */;
+ }
+ dist -= 1;
+ if (!(dist < 32768)) {
+ return interpreterProxy->primitiveFail();
+ }
+ if (dist < 256) {
+ code = zipDistanceCodes[dist];
+ }
+ else {
+ code = zipDistanceCodes[256 + (((usqInt) dist) >> 7)];
+ }
+ if (!(code < distBlCount)) {
+ return interpreterProxy->primitiveFail();
+ }
+ /* begin nextZipBits:put: */
+ if (!(((distCodes[code]) >= 0)
+ && ((1 << (distBitLengths[code])) > (distCodes[code])))) {
+ interpreterProxy->primitiveFail();
+ goto l5;
+ }
+ zipBitBuf = zipBitBuf | (((zipBitPos < 0) ? ((usqInt) (distCodes[code]) >> -zipBitPos) : ((usqInt) (distCodes[code]) << zipBitPos)));
+ zipBitPos += distBitLengths[code];
+ while ((zipBitPos >= 8)
+ && (zipPosition < zipCollectionSize)) {
+ zipCollection[zipPosition] = (zipBitBuf & 255);
+ zipPosition += 1;
+ zipBitBuf = ((usqInt) zipBitBuf) >> 8;
+ zipBitPos -= 8;
+ }
+ l5: /* end nextZipBits:put: */;
+ extra = zipExtraDistanceBits[code];
+ if (!(extra == 0)) {
+ dist -= zipBaseDistance[code];
+ /* begin nextZipBits:put: */
+ if (!((dist >= 0)
+ && ((1 << extra) > dist))) {
+ interpreterProxy->primitiveFail();
+ goto l3;
+ }
+ zipBitBuf = zipBitBuf | (((zipBitPos < 0) ? ((usqInt) dist >> -zipBitPos) : ((usqInt) dist << zipBitPos)));
+ zipBitPos += extra;
+ while ((zipBitPos >= 8)
+ && (zipPosition < zipCollectionSize)) {
+ zipCollection[zipPosition] = (zipBitBuf & 255);
+ zipPosition += 1;
+ zipBitBuf = ((usqInt) zipBitBuf) >> 8;
+ zipBitPos -= 8;
+ }
+ l3: /* end nextZipBits:put: */;
+ }
+ }
+ }
+ if (interpreterProxy->failed()) {
+ return null;
+ }
+ interpreterProxy->storeIntegerofObjectwithValue(1, literalStream, litPos);
+ interpreterProxy->storeIntegerofObjectwithValue(1, distanceStream, litPos);
+ return sum;
+}
+
+
/* Note: This is coded so that is can be run from Squeak. */
EXPORT(sqInt)
@@ -230,6 +1506,50 @@
}
+/* Check if we should flush the current block.
+ Flushing can be useful if the input characteristics change. */
+
+static sqInt
+shouldFlush(void)
+{
+ sqInt nLits;
+
+ if (zipLiteralCount == zipLiteralSize) {
+ return 1;
+ }
+ if (!((zipLiteralCount & 4095) == 0)) {
+ return 0;
+ }
+ if ((zipMatchCount * 10) <= zipLiteralCount) {
+ return 0;
+ }
+ nLits = zipLiteralCount - zipMatchCount;
+ if (nLits <= zipMatchCount) {
+ return 0;
+ }
+ return (nLits * 4) <= zipMatchCount;
+}
+
+
+/* Update the hash value at position here (one based) */
+
+static sqInt
+updateHashAt(sqInt here)
+{
+ return ((((usqInt) zipHashValue << 5)) ^ (zipCollection[here])) & DeflateHashMask;
+}
+
+
+/* Update the running hash value based on the next input byte.
+ Return the new updated hash value. */
+
+static sqInt
+updateHash(sqInt nextValue)
+{
+ return ((((usqInt) zipHashValue << 5)) ^ nextValue) & DeflateHashMask;
+}
+
+
/* Decode the next value in the receiver using the given huffman table. */
static sqInt
@@ -380,7 +1700,12 @@
void* ZipPlugin_exports[][3] = {
{"ZipPlugin", "getModuleName", (void*)getModuleName},
+ {"ZipPlugin", "primitiveDeflateBlock", (void*)primitiveDeflateBlock},
+ {"ZipPlugin", "primitiveDeflateUpdateHashTable", (void*)primitiveDeflateUpdateHashTable},
{"ZipPlugin", "primitiveInflateDecompressBlock", (void*)primitiveInflateDecompressBlock},
+ {"ZipPlugin", "primitiveUpdateAdler32", (void*)primitiveUpdateAdler32},
+ {"ZipPlugin", "primitiveUpdateGZipCrc32", (void*)primitiveUpdateGZipCrc32},
+ {"ZipPlugin", "primitiveZipSendBlock", (void*)primitiveZipSendBlock},
{"ZipPlugin", "setInterpreter", (void*)setInterpreter},
{NULL, NULL, NULL}
};
Modified: branches/Cog/nscogsrc/vm/cogit.c
===================================================================
--- branches/Cog/nscogsrc/vm/cogit.c 2012-03-03 21:13:51 UTC (rev 2538)
+++ branches/Cog/nscogsrc/vm/cogit.c 2012-04-03 21:03:16 UTC (rev 2539)
@@ -1,9 +1,9 @@
/* Automatically generated by
- CCodeGenerator VMMaker.oscog-eem.148 uuid: bb53aa60-4173-48ed-874b-dc0ff5a48992
+ CCodeGenerator VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa
from
- StackToRegisterMappingCogit VMMaker.oscog-eem.148 uuid: bb53aa60-4173-48ed-874b-dc0ff5a48992
+ StackToRegisterMappingCogit VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa
*/
-static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.148 uuid: bb53aa60-4173-48ed-874b-dc0ff5a48992 " __DATE__ ;
+static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa " __DATE__ ;
char *__cogitBuildInfo = __buildInfo;
@@ -13906,8 +13906,10 @@
/* Update all references to objects in machine code for a become.
- Unlike incrementalGC or fullGC a method that does not refer to young
- may refer to young as a result of the become operation. */
+ Unlike incrementalGC or fullGC a method that does not refer to young may
+ refer to young as a result of the become operation. Unlike incrementalGC
+ or fullGC the reference from a Cog method to its methodObject *must not*
+ change since the two are two halves of the same object. */
static void
mapObjectReferencesInMachineCodeForBecome(void)
@@ -13940,7 +13942,6 @@
}
if (((cogMethod->cmType)) == CMMethod) {
assert(((cogMethod->objectHeader)) == (nullHeaderForMachineCodeMethod()));
- (cogMethod->methodObject = remapOop((cogMethod->methodObject)));
assert(((rawHeaderOf((cogMethod->methodObject))) == (((sqInt)cogMethod)))
|| ((noAssertMethodClassAssociationOf((cogMethod->methodObject))) == (nilObject())));
if (isYoung((cogMethod->methodObject))) {
Modified: branches/Cog/nscogsrc/vm/cogit.h
===================================================================
--- branches/Cog/nscogsrc/vm/cogit.h 2012-03-03 21:13:51 UTC (rev 2538)
+++ branches/Cog/nscogsrc/vm/cogit.h 2012-04-03 21:03:16 UTC (rev 2539)
@@ -1,5 +1,5 @@
/* Automatically generated by
- CCodeGenerator VMMaker.oscog-eem.148 uuid: bb53aa60-4173-48ed-874b-dc0ff5a48992
+ CCodeGenerator VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa
*/
Modified: branches/Cog/nscogsrc/vm/cogmethod.h
===================================================================
--- branches/Cog/nscogsrc/vm/cogmethod.h 2012-03-03 21:13:51 UTC (rev 2538)
+++ branches/Cog/nscogsrc/vm/cogmethod.h 2012-04-03 21:03:16 UTC (rev 2539)
@@ -1,5 +1,5 @@
/* Automatically generated by
- CCodeGenerator VMMaker.oscog-eem.148 uuid: bb53aa60-4173-48ed-874b-dc0ff5a48992
+ CCodeGenerator VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa
*/
typedef struct {
Modified: branches/Cog/nscogsrc/vm/cointerp.c
===================================================================
--- branches/Cog/nscogsrc/vm/cointerp.c 2012-03-03 21:13:51 UTC (rev 2538)
+++ branches/Cog/nscogsrc/vm/cointerp.c 2012-04-03 21:03:16 UTC (rev 2539)
@@ -1,9 +1,9 @@
/* Automatically generated by
- CCodeGeneratorGlobalStructure VMMaker.oscog-eem.152 uuid: d39d62b0-45ca-4621-8f67-e3981bbe1875
+ CCodeGeneratorGlobalStructure VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa
from
- CoInterpreter VMMaker.oscog-eem.152 uuid: d39d62b0-45ca-4621-8f67-e3981bbe1875
+ CoInterpreter VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa
*/
-static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.152 uuid: d39d62b0-45ca-4621-8f67-e3981bbe1875 " __DATE__ ;
+static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa " __DATE__ ;
char *__interpBuildInfo = __buildInfo;
@@ -649,6 +649,7 @@
static sqInt loadImageSegmentFromoutPointers(sqInt segmentWordArray, sqInt outPointerArray);
void loadInitialContext(void);
void longPrintOop(sqInt oop);
+void longPrintReferencesTo(sqInt anOop);
static sqInt lookupInMethodCacheSelclass(sqInt selector, sqInt class);
static sqInt lookupMethodInClass(sqInt class);
static sqInt lookupMethodInDictionary(sqInt dictionary);
@@ -1163,8 +1164,8 @@
_iss sqInt nilObj;
_iss usqInt method;
_iss usqInt instructionPointer;
+_iss usqInt freeStart;
_iss sqInt argumentCount;
-_iss usqInt freeStart;
_iss usqInt newMethod;
_iss sqInt messageSelector;
_iss usqInt youngStart;
@@ -1909,7 +1910,7 @@
/* 575 */ (void (*)(void))0,
0 };
static void (*externalPrimitiveTable[MaxExternalPrimitiveTableSize + 1 /* 4097 */])(void);
-const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_VMMaker.oscog-eem.152";
+const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_VMMaker.oscog-eem.154";
sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 10 */;
volatile int sendTrace;
@@ -20766,6 +20767,134 @@
}
+/* Scan the heap long printing the oops of any and all objects that refer to
+ anOop
+ */
+
+void
+longPrintReferencesTo(sqInt anOop)
+{ DECL_MAYBE_SQ_GLOBAL_STRUCT
+ sqInt header;
+ sqInt header1;
+ sqInt header2;
+ sqInt i;
+ sqInt obj;
+ sqInt obj1;
+ sqInt oop;
+ sqInt prntObj;
+ sqInt sz;
+ sqInt sz1;
+ sqInt sz2;
+
+ prntObj = 0;
+ /* begin firstAccessibleObject */
+ obj1 = heapBase + (headerTypeBytes[(longAt(heapBase)) & TypeMask]);
+ while ((((usqInt) obj1)) < (((usqInt) GIV(freeStart)))) {
+ if (!(((longAt(obj1)) & TypeMask) == HeaderTypeFree)) {
+ oop = obj1;
+ goto l2;
+ }
+ /* begin objectAfter: */
+ if (DoAssertionChecks) {
+ if ((((usqInt) obj1)) >= (((usqInt) GIV(endOfMemory)))) {
+ error("no objects after the end of memory");
+ }
+ }
+ if (((longAt(obj1)) & TypeMask) == HeaderTypeFree) {
+ sz = (longAt(obj1)) & AllButTypeMask;
+ }
+ else {
+ /* begin sizeBitsOf: */
+ header = longAt(obj1);
+ sz = ((header & TypeMask) == HeaderTypeSizeAndClass
+ ? (longAt(obj1 - (BytesPerWord * 2))) & LongSizeMask
+ : header & SizeMask);
+ }
+ obj1 = (obj1 + sz) + (headerTypeBytes[(longAt(obj1 + sz)) & TypeMask]);
+ }
+ error("heap is empty");
+ oop = null;
+l2: /* end firstAccessibleObject */;
+ while (!(oop == null)) {
+ if ((((oop & 1) == 0)
+ && (((((usqInt) (longAt(oop))) >> 8) & 15) <= 4))
+ || (((((usqInt) (longAt(oop))) >> 8) & 15) >= 12)) {
+ if (((((usqInt) (longAt(oop))) >> 8) & 15) >= 12) {
+ i = (literalCountOf(oop)) - 1;
+ }
+ else {
+ if (((oop & 1) == 0)
+ && (((((usqInt) (longAt(oop))) >> 12) & 31) == ClassMethodContextCompactIndex)) {
+ i = (CtxtTempFrameStart + (fetchStackPointerOf(oop))) - 1;
+ }
+ else {
+ i = (lengthOf(oop)) - 1;
+ }
+ }
+ while (i >= 0) {
+ if (anOop == (longAt((oop + BaseHeaderSize) + (i << ShiftForWord)))) {
+ printHex(oop);
+ print(" @ ");
+ printNum(i);
+ /* begin cr */
+ printf("\n");
+ prntObj = 1;
+ i = 0;
+ }
+ i -= 1;
+ }
+ if (prntObj) {
+ prntObj = 0;
+ longPrintOop(oop);
+ }
+ }
+ /* begin accessibleObjectAfter: */
+ /* begin objectAfter: */
+ if (DoAssertionChecks) {
+ if ((((usqInt) oop)) >= (((usqInt) GIV(endOfMemory)))) {
+ error("no objects after the end of memory");
+ }
+ }
+ if (((longAt(oop)) & TypeMask) == HeaderTypeFree) {
+ sz2 = (longAt(oop)) & AllButTypeMask;
+ }
+ else {
+ /* begin sizeBitsOf: */
+ header2 = longAt(oop);
+ sz2 = ((header2 & TypeMask) == HeaderTypeSizeAndClass
+ ? (longAt(oop - (BytesPerWord * 2))) & LongSizeMask
+ : header2 & SizeMask);
+ }
+ obj = (oop + sz2) + (headerTypeBytes[(longAt(oop + sz2)) & TypeMask]);
+ while ((((usqInt) obj)) < (((usqInt) GIV(freeStart)))) {
+ if (!(((longAt(obj)) & TypeMask) == HeaderTypeFree)) {
+ oop = obj;
+ goto l1;
+ }
+ /* begin objectAfter: */
+ if (DoAssertionChecks) {
+ if ((((usqInt) obj)) >= (((usqInt) GIV(endOfMemory)))) {
+ error("no objects after the end of memory");
+ }
+ }
+ if (((longAt(obj)) & TypeMask) == HeaderTypeFree) {
+ sz1 = (longAt(obj)) & AllButTypeMask;
+ }
+ else {
+ /* begin sizeBitsOf: */
+ header1 = longAt(obj);
+ sz1 = ((header1 & TypeMask) == HeaderTypeSizeAndClass
+ ? (longAt(obj - (BytesPerWord * 2))) & LongSizeMask
+ : header1 & SizeMask);
+ }
+ obj = (obj + sz1) + (headerTypeBytes[(longAt(obj + sz1)) & TypeMask]);
+ }
+ oop = null;
+ l1: /* end accessibleObjectAfter: */;
+ }
+}
+
+
/* This method implements a simple method lookup cache. If an entry for the
given selector and class is found in the cache, set the values of
'newMethod' and 'primitiveFunctionPointer' and return true. Otherwise,
Modified: branches/Cog/nscogsrc/vm/cointerp.h
===================================================================
--- branches/Cog/nscogsrc/vm/cointerp.h 2012-03-03 21:13:51 UTC (rev 2538)
+++ branches/Cog/nscogsrc/vm/cointerp.h 2012-04-03 21:03:16 UTC (rev 2539)
@@ -1,5 +1,5 @@
/* Automatically generated by
- CCodeGeneratorGlobalStructure VMMaker.oscog-eem.152 uuid: d39d62b0-45ca-4621-8f67-e3981bbe1875
+ CCodeGeneratorGlobalStructure VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa
*/
@@ -106,6 +106,7 @@
sqInt literalCountOfHeader(sqInt headerPointer);
sqInt literalofMethod(sqInt offset, sqInt methodPointer);
void longPrintOop(sqInt oop);
+void longPrintReferencesTo(sqInt anOop);
sqInt lookupreceiver(sqInt selector, sqInt rcvr);
void markActiveMethodsAndReferents(void);
void markAndTrace(sqInt oop);
@@ -201,7 +202,7 @@
/*** Global Variables ***/
char * breakSelector;
sqInt breakSelectorLength ;
-#define bytecodeSetSelector 0;
+#define bytecodeSetSelector 0
sqInt checkForLeaks;
sqInt deferDisplayUpdates;
sqInt desiredCogCodeSize;
Modified: branches/Cog/nscogsrc/vm/gcc3x-cointerp.c
===================================================================
--- branches/Cog/nscogsrc/vm/gcc3x-cointerp.c 2012-03-03 21:13:51 UTC (rev 2538)
+++ branches/Cog/nscogsrc/vm/gcc3x-cointerp.c 2012-04-03 21:03:16 UTC (rev 2539)
@@ -2,11 +2,11 @@
/* Automatically generated by
- CCodeGeneratorGlobalStructure VMMaker.oscog-eem.152 uuid: d39d62b0-45ca-4621-8f67-e3981bbe1875
+ CCodeGeneratorGlobalStructure VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa
from
- CoInterpreter VMMaker.oscog-eem.152 uuid: d39d62b0-45ca-4621-8f67-e3981bbe1875
+ CoInterpreter VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa
*/
-static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.152 uuid: d39d62b0-45ca-4621-8f67-e3981bbe1875 " __DATE__ ;
+static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa " __DATE__ ;
char *__interpBuildInfo = __buildInfo;
@@ -652,6 +652,7 @@
static sqInt loadImageSegmentFromoutPointers(sqInt segmentWordArray, sqInt outPointerArray);
void loadInitialContext(void);
void longPrintOop(sqInt oop);
+void longPrintReferencesTo(sqInt anOop);
static sqInt lookupInMethodCacheSelclass(sqInt selector, sqInt class);
static sqInt lookupMethodInClass(sqInt class);
static sqInt lookupMethodInDictionary(sqInt dictionary);
@@ -1166,8 +1167,8 @@
_iss sqInt nilObj;
_iss usqInt method;
_iss usqInt instructionPointer;
+_iss usqInt freeStart;
_iss sqInt argumentCount;
-_iss usqInt freeStart;
_iss usqInt newMethod;
_iss sqInt messageSelector;
_iss usqInt youngStart;
@@ -1912,7 +1913,7 @@
/* 575 */ (void (*)(void))0,
0 };
static void (*externalPrimitiveTable[MaxExternalPrimitiveTableSize + 1 /* 4097 */])(void);
-const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_VMMaker.oscog-eem.152";
+const char *interpreterVersion = "Newspeak Virtual Machine CoInterpreter_VMMaker.oscog-eem.154";
sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 10 */;
volatile int sendTrace;
@@ -20770,6 +20771,134 @@
}
+/* Scan the heap long printing the oops of any and all objects that refer to
+ anOop
+ */
+
+void
+longPrintReferencesTo(sqInt anOop)
+{ DECL_MAYBE_SQ_GLOBAL_STRUCT
+ sqInt header;
+ sqInt header1;
+ sqInt header2;
+ sqInt i;
+ sqInt obj;
+ sqInt obj1;
+ sqInt oop;
+ sqInt prntObj;
+ sqInt sz;
+ sqInt sz1;
+ sqInt sz2;
+
+ prntObj = 0;
+ /* begin firstAccessibleObject */
+ obj1 = heapBase + (headerTypeBytes[(longAt(heapBase)) & TypeMask]);
+ while ((((usqInt) obj1)) < (((usqInt) GIV(freeStart)))) {
+ if (!(((longAt(obj1)) & TypeMask) == HeaderTypeFree)) {
+ oop = obj1;
+ goto l2;
+ }
+ /* begin objectAfter: */
+ if (DoAssertionChecks) {
+ if ((((usqInt) obj1)) >= (((usqInt) GIV(endOfMemory)))) {
+ error("no objects after the end of memory");
+ }
+ }
+ if (((longAt(obj1)) & TypeMask) == HeaderTypeFree) {
+ sz = (longAt(obj1)) & AllButTypeMask;
+ }
+ else {
+ /* begin sizeBitsOf: */
+ header = longAt(obj1);
+ sz = ((header & TypeMask) == HeaderTypeSizeAndClass
+ ? (longAt(obj1 - (BytesPerWord * 2))) & LongSizeMask
+ : header & SizeMask);
+ }
+ obj1 = (obj1 + sz) + (headerTypeBytes[(longAt(obj1 + sz)) & TypeMask]);
+ }
+ error("heap is empty");
+ oop = null;
+l2: /* end firstAccessibleObject */;
+ while (!(oop == null)) {
+ if ((((oop & 1) == 0)
+ && (((((usqInt) (longAt(oop))) >> 8) & 15) <= 4))
+ || (((((usqInt) (longAt(oop))) >> 8) & 15) >= 12)) {
+ if (((((usqInt) (longAt(oop))) >> 8) & 15) >= 12) {
+ i = (literalCountOf(oop)) - 1;
+ }
+ else {
+ if (((oop & 1) == 0)
+ && (((((usqInt) (longAt(oop))) >> 12) & 31) == ClassMethodContextCompactIndex)) {
+ i = (CtxtTempFrameStart + (fetchStackPointerOf(oop))) - 1;
+ }
+ else {
+ i = (lengthOf(oop)) - 1;
+ }
+ }
+ while (i >= 0) {
+ if (anOop == (longAt((oop + BaseHeaderSize) + (i << ShiftForWord)))) {
+ printHex(oop);
+ print(" @ ");
+ printNum(i);
+ /* begin cr */
+ printf("\n");
+ prntObj = 1;
+ i = 0;
+ }
+ i -= 1;
+ }
+ if (prntObj) {
+ prntObj = 0;
+ longPrintOop(oop);
+ }
+ }
+ /* begin accessibleObjectAfter: */
+ /* begin objectAfter: */
+ if (DoAssertionChecks) {
+ if ((((usqInt) oop)) >= (((usqInt) GIV(endOfMemory)))) {
+ error("no objects after the end of memory");
+ }
+ }
+ if (((longAt(oop)) & TypeMask) == HeaderTypeFree) {
+ sz2 = (longAt(oop)) & AllButTypeMask;
+ }
+ else {
+ /* begin sizeBitsOf: */
+ header2 = longAt(oop);
+ sz2 = ((header2 & TypeMask) == HeaderTypeSizeAndClass
+ ? (longAt(oop - (BytesPerWord * 2))) & LongSizeMask
+ : header2 & SizeMask);
+ }
+ obj = (oop + sz2) + (headerTypeBytes[(longAt(oop + sz2)) & TypeMask]);
+ while ((((usqInt) obj)) < (((usqInt) GIV(freeStart)))) {
+ if (!(((longAt(obj)) & TypeMask) == HeaderTypeFree)) {
+ oop = obj;
+ goto l1;
+ }
+ /* begin objectAfter: */
+ if (DoAssertionChecks) {
+ if ((((usqInt) obj)) >= (((usqInt) GIV(endOfMemory)))) {
+ error("no objects after the end of memory");
+ }
+ }
+ if (((longAt(obj)) & TypeMask) == HeaderTypeFree) {
+ sz1 = (longAt(obj)) & AllButTypeMask;
+ }
+ else {
+ /* begin sizeBitsOf: */
+ header1 = longAt(obj);
+ sz1 = ((header1 & TypeMask) == HeaderTypeSizeAndClass
+ ? (longAt(obj - (BytesPerWord * 2))) & LongSizeMask
+ : header1 & SizeMask);
+ }
+ obj = (obj + sz1) + (headerTypeBytes[(longAt(obj + sz1)) & TypeMask]);
+ }
+ oop = null;
+ l1: /* end accessibleObjectAfter: */;
+ }
+}
+
+
/* This method implements a simple method lookup cache. If an entry for the
given selector and class is found in the cache, set the values of
'newMethod' and 'primitiveFunctionPointer' and return true. Otherwise,
Modified: branches/Cog/nscogsrc/vm/interp.h
===================================================================
--- branches/Cog/nscogsrc/vm/interp.h 2012-03-03 21:13:51 UTC (rev 2538)
+++ branches/Cog/nscogsrc/vm/interp.h 2012-04-03 21:03:16 UTC (rev 2539)
@@ -1,5 +1,5 @@
/* Automatically generated by
- CCodeGeneratorGlobalStructure VMMaker.oscog-eem.152 uuid: d39d62b0-45ca-4621-8f67-e3981bbe1875
+ CCodeGeneratorGlobalStructure VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa
*/
#define VM_PROXY_MAJOR 1
Modified: branches/Cog/nscogsrc/vm/vmCallback.h
===================================================================
--- branches/Cog/nscogsrc/vm/vmCallback.h 2012-03-03 21:13:51 UTC (rev 2538)
+++ branches/Cog/nscogsrc/vm/vmCallback.h 2012-04-03 21:03:16 UTC (rev 2539)
@@ -1,5 +1,5 @@
/* Automatically generated by
- CCodeGeneratorGlobalStructure VMMaker.oscog-eem.152 uuid: d39d62b0-45ca-4621-8f67-e3981bbe1875
+ CCodeGeneratorGlobalStructure VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa
*/
#define VM_CALLBACK_INC 1
Property changes on: branches/Cog/platforms/Cross/vm/sqSCCSVersion.h
___________________________________________________________________
Modified: checkindate
- Sat Mar 3 13:12:18 PST 2012
+ Tue Apr 3 14:00:16 PDT 2012
Modified: branches/Cog/platforms/Mac OS/vm/sqMacMain.c
===================================================================
--- branches/Cog/platforms/Mac OS/vm/sqMacMain.c 2012-03-03 21:13:51 UTC (rev 2538)
+++ branches/Cog/platforms/Mac OS/vm/sqMacMain.c 2012-04-03 21:03:16 UTC (rev 2539)
@@ -581,8 +581,10 @@
versionString = CFBundleGetValueForInfoDictionaryKey(mainBundle, CFSTR("CFBundleShortVersionString"));
bzero(data,255);
strcat(data,interpreterVersion);
- strcat(data," ");
- CFStringGetCString (versionString, data+strlen(data), 255-strlen(data), gCurrentVMEncoding);
+ if (versionString) {
+ strcat(data," ");
+ CFStringGetCString (versionString, data+strlen(data), 255-strlen(data), gCurrentVMEncoding);
+ }
return data;
}
Modified: branches/Cog/platforms/unix/config/bin.squeak.sh.in
===================================================================
--- branches/Cog/platforms/unix/config/bin.squeak.sh.in 2012-03-03 21:13:51 UTC (rev 2538)
+++ branches/Cog/platforms/unix/config/bin.squeak.sh.in 2012-04-03 21:03:16 UTC (rev 2539)
@@ -10,14 +10,21 @@
/*) PLUGINS="$BIN";;
*) PLUGINS="`pwd`/$BIN"
esac
-# On some old linuxes there is a /lib/tls thread-local-storage version of the C
-# library which the VM may use and if so should take precedence over /lib libc.
+# On some linuxes there multiple versions of the C library. If the image uses
+# libc (e.g. through the FFI) then it must use the same version that the VM uses
+# and so it should take precedence over /lib libc. This is done by setting
+# LD_LIBRARY_PATH appropriately, based on ldd's idea of the libc use by the VM.
case `/usr/bin/ldd "$BIN/squeak" | /bin/fgrep /libc. | sed 's/^.*=> //'` in
/lib/libc*) SVMLLP="/lib:/usr/lib";;
/lib32/libc*) SVMLLP="/lib32:/usr/lib32";;
/lib64/libc*) SVMLLP="/lib64:/usr/lib64";;
/lib/tls/libc*) SVMLLP="/lib/tls:/lib:/usr/lib/tls:/usr/lib";;
-/lib/i386-linux-gnu/libc*) SVMLLP="/lib/i386-linux-gnu:/usr/lib/i386-linux-gnu";;
+/lib/i386-linux-gnu/libc*) \
+ SVMLLP="/lib/i386-linux-gnu:/usr/lib/i386-linux-gnu";;
+/lib/tls/i686/cmov/libc*) \
+ SVMLLP="/lib/tls/i686/cmov:/lib:/usr/lib/tls/i686/cmov:/usr/lib";;
+/lib/tls/i686/nosegneg/libc*) \
+ SVMLLP="/lib/i686/nosegneg/tls:/lib:/usr/lib/i686/nosegneg/tls:/usr/lib";;
*) echo "can't infer base LD_LIBRARY_PATH. Aborting." 1>&2;
exit 1
esac
Modified: branches/Cog/platforms/unix/config/squeak.sh.in
===================================================================
--- branches/Cog/platforms/unix/config/squeak.sh.in 2012-03-03 21:13:51 UTC (rev 2538)
+++ branches/Cog/platforms/unix/config/squeak.sh.in 2012-04-03 21:03:16 UTC (rev 2539)
@@ -10,14 +10,21 @@
/*) PLUGINS="$BIN";;
*) PLUGINS="`pwd`/$BIN"
esac
-# On some old linuxes there is a /lib/tls thread-local-storage version of the C
-# library which the VM may use and if so should take precedence over /lib libc.
+# On some linuxes there multiple versions of the C library. If the image uses
+# libc (e.g. through the FFI) then it must use the same version that the VM uses
+# and so it should take precedence over /lib libc. This is done by setting
+# LD_LIBRARY_PATH appropriately, based on ldd's idea of the libc use by the VM.
case `/usr/bin/ldd "$BIN/squeak" | /bin/fgrep /libc. | sed 's/^.*=> //'` in
/lib/libc*) SVMLLP="/lib:/usr/lib";;
/lib32/libc*) SVMLLP="/lib32:/usr/lib32";;
/lib64/libc*) SVMLLP="/lib64:/usr/lib64";;
/lib/tls/libc*) SVMLLP="/lib/tls:/lib:/usr/lib/tls:/usr/lib";;
-/lib/i386-linux-gnu/libc*) SVMLLP="/lib/i386-linux-gnu:/usr/lib/i386-linux-gnu";;
+/lib/i386-linux-gnu/libc*) \
+ SVMLLP="/lib/i386-linux-gnu:/usr/lib/i386-linux-gnu";;
+/lib/tls/i686/cmov/libc*) \
+ SVMLLP="/lib/tls/i686/cmov:/lib:/usr/lib/tls/i686/cmov:/usr/lib";;
+/lib/tls/i686/nosegneg/libc*) \
+ SVMLLP="/lib/i686/nosegneg/tls:/lib:/usr/lib/i686/nosegneg/tls:/usr/lib";;
*) echo "can't infer base LD_LIBRARY_PATH. Aborting." 1>&2;
exit 1
esac
Modified: branches/Cog/src/plugins/UnixOSProcessPlugin/UnixOSProcessPlugin.c
===================================================================
--- branches/Cog/src/plugins/UnixOSProcessPlugin/UnixOSProcessPlugin.c 2012-03-03 21:13:51 UTC (rev 2538)
+++ branches/Cog/src/plugins/UnixOSProcessPlugin/UnixOSProcessPlugin.c 2012-04-03 21:03:16 UTC (rev 2539)
@@ -1,9 +1,9 @@
/* Automatically generated by
- VMPluginCodeGenerator VMMaker.oscog-eem.144 uuid: bafb8042-095a-42f3-9058-ee7bd133da50
+ VMPluginCodeGenerator VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa
from
- UnixOSProcessPlugin VMConstruction-Plugins-OSProcessPlugin.oscog-eem.33 uuid: 3c8b9706-e5ad-4eb4-85a3-a82fd91005a0
+ UnixOSProcessPlugin VMConstruction-Plugins-OSProcessPlugin.oscog-eem.34 uuid: 90d36152-4f89-4764-b476-2cc44c195139
*/
-static char __buildInfo[] = "UnixOSProcessPlugin VMConstruction-Plugins-OSProcessPlugin.oscog-eem.33 uuid: 3c8b9706-e5ad-4eb4-85a3-a82fd91005a0 " __DATE__ ;
+static char __buildInfo[] = "UnixOSProcessPlugin VMConstruction-Plugins-OSProcessPlugin.oscog-eem.34 uuid: 90d36152-4f89-4764-b476-2cc44c195139 " __DATE__ ;
@@ -57,6 +57,7 @@
/*** Constants ***/
#define BytesPerWord 4
+#define MULTIPLEBYTECODESETS 0
#define PrimErrNoMemory 9
#define PrimErrUnsupported 7
@@ -98,7 +99,7 @@
static sqInt maskSignalForThisThread(int sigNum);
EXPORT(sqInt) moduleUnloaded(char *aModuleName);
static sqInt msg(char *s);
-static sqInt newPthreadTypeByteArray(sqInt aPthreadType);
+static sqInt newPthreadTypeByteArray(pthread_t aPthreadType);
static sqInt newSQFileByteArray(void);
static sqInt newSQSocketByteArray(void);
static void ** originalSignalHandlers(void);
@@ -248,9 +249,9 @@
struct VirtualMachine* interpreterProxy;
static const char *moduleName =
#ifdef SQUEAK_BUILTIN_PLUGIN
- "UnixOSProcessPlugin VMConstruction-Plugins-OSProcessPlugin.oscog-eem.33 (i)"
+ "UnixOSProcessPlugin VMConstruction-Plugins-OSProcessPlugin.oscog-eem.34 (i)"
#else
- "UnixOSProcessPlugin VMConstruction-Plugins-OSProcessPlugin.oscog-eem.33 (e)"
+ "UnixOSProcessPlugin VMConstruction-Plugins-OSProcessPlugin.oscog-eem.34 (e)"
#endif
;
static void *originalSigHandlers[NSIG];
@@ -1142,7 +1143,7 @@
passed to the image. */
static sqInt
-newPthreadTypeByteArray(sqInt aPthreadType)
+newPthreadTypeByteArray(pthread_t aPthreadType)
{
sqInt byteArray;
sqInt len;
@@ -1151,7 +1152,7 @@
len = sizeof(pthread_t);
byteArray = interpreterProxy->instantiateClassindexableSize(interpreterProxy->classByteArray(), len);
ptr = interpreterProxy->arrayValueOf(byteArray);
- *ptr = aPthreadType;
+ ptr[0] = aPthreadType;
return byteArray;
}
Modified: branches/Cog/src/vm/cogit.c
===================================================================
--- branches/Cog/src/vm/cogit.c 2012-03-03 21:13:51 UTC (rev 2538)
+++ branches/Cog/src/vm/cogit.c 2012-04-03 21:03:16 UTC (rev 2539)
@@ -1,9 +1,9 @@
/* Automatically generated by
- CCodeGenerator VMMaker.oscog-eem.148 uuid: bb53aa60-4173-48ed-874b-dc0ff5a48992
+ CCodeGenerator VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa
from
- StackToRegisterMappingCogit VMMaker.oscog-eem.148 uuid: bb53aa60-4173-48ed-874b-dc0ff5a48992
+ StackToRegisterMappingCogit VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa
*/
-static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.148 uuid: bb53aa60-4173-48ed-874b-dc0ff5a48992 " __DATE__ ;
+static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa " __DATE__ ;
char *__cogitBuildInfo = __buildInfo;
@@ -13694,8 +13694,10 @@
/* Update all references to objects in machine code for a become.
- Unlike incrementalGC or fullGC a method that does not refer to young
- may refer to young as a result of the become operation. */
+ Unlike incrementalGC or fullGC a method that does not refer to young may
+ refer to young as a result of the become operation. Unlike incrementalGC
+ or fullGC the reference from a Cog method to its methodObject *must not*
+ change since the two are two halves of the same object. */
static void
mapObjectReferencesInMachineCodeForBecome(void)
@@ -13728,7 +13730,6 @@
}
if (((cogMethod->cmType)) == CMMethod) {
assert(((cogMethod->objectHeader)) == (nullHeaderForMachineCodeMethod()));
- (cogMethod->methodObject = remapOop((cogMethod->methodObject)));
assert(((rawHeaderOf((cogMethod->methodObject))) == (((sqInt)cogMethod)))
|| ((noAssertMethodClassAssociationOf((cogMethod->methodObject))) == (nilObject())));
if (isYoung((cogMethod->methodObject))) {
Modified: branches/Cog/src/vm/cogit.h
===================================================================
--- branches/Cog/src/vm/cogit.h 2012-03-03 21:13:51 UTC (rev 2538)
+++ branches/Cog/src/vm/cogit.h 2012-04-03 21:03:16 UTC (rev 2539)
@@ -1,5 +1,5 @@
/* Automatically generated by
- CCodeGenerator VMMaker.oscog-eem.148 uuid: bb53aa60-4173-48ed-874b-dc0ff5a48992
+ CCodeGenerator VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa
*/
Modified: branches/Cog/src/vm/cogmethod.h
===================================================================
--- branches/Cog/src/vm/cogmethod.h 2012-03-03 21:13:51 UTC (rev 2538)
+++ branches/Cog/src/vm/cogmethod.h 2012-04-03 21:03:16 UTC (rev 2539)
@@ -1,5 +1,5 @@
/* Automatically generated by
- CCodeGenerator VMMaker.oscog-eem.152 uuid: d39d62b0-45ca-4621-8f67-e3981bbe1875
+ CCodeGenerator VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa
*/
typedef struct {
Modified: branches/Cog/src/vm/cointerp.c
===================================================================
--- branches/Cog/src/vm/cointerp.c 2012-03-03 21:13:51 UTC (rev 2538)
+++ branches/Cog/src/vm/cointerp.c 2012-04-03 21:03:16 UTC (rev 2539)
@@ -1,9 +1,9 @@
/* Automatically generated by
- CCodeGeneratorGlobalStructure VMMaker.oscog-eem.152 uuid: d39d62b0-45ca-4621-8f67-e3981bbe1875
+ CCodeGeneratorGlobalStructure VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa
from
- CoInterpreter VMMaker.oscog-eem.152 uuid: d39d62b0-45ca-4621-8f67-e3981bbe1875
+ CoInterpreter VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa
*/
-static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.152 uuid: d39d62b0-45ca-4621-8f67-e3981bbe1875 " __DATE__ ;
+static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa " __DATE__ ;
char *__interpBuildInfo = __buildInfo;
@@ -640,6 +640,7 @@
static sqInt loadImageSegmentFromoutPointers(sqInt segmentWordArray, sqInt outPointerArray);
void loadInitialContext(void);
void longPrintOop(sqInt oop);
+void longPrintReferencesTo(sqInt anOop);
static sqInt lookupInMethodCacheSelclass(sqInt selector, sqInt class);
static sqInt lookupMethodInClass(sqInt class);
static sqInt lookupMethodInDictionary(sqInt dictionary);
@@ -1899,7 +1900,7 @@
/* 575 */ (void (*)(void))0,
0 };
static void (*externalPrimitiveTable[MaxExternalPrimitiveTableSize + 1 /* 4097 */])(void);
-const char *interpreterVersion = "Croquet Closure Cog VM [CoInterpreter VMMaker.oscog-eem.152]";
+const char *interpreterVersion = "Croquet Closure Cog VM [CoInterpreter VMMaker.oscog-eem.154]";
sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 10 */;
volatile int sendTrace;
@@ -20090,6 +20091,134 @@
}
+/* Scan the heap long printing the oops of any and all objects that refer to
+ anOop
+ */
+
+void
+longPrintReferencesTo(sqInt anOop)
+{ DECL_MAYBE_SQ_GLOBAL_STRUCT
+ sqInt header;
+ sqInt header1;
+ sqInt header2;
+ sqInt i;
+ sqInt obj;
+ sqInt obj1;
+ sqInt oop;
+ sqInt prntObj;
+ sqInt sz;
+ sqInt sz1;
+ sqInt sz2;
+
+ prntObj = 0;
+ /* begin firstAccessibleObject */
+ obj1 = heapBase + (headerTypeBytes[(longAt(heapBase)) & TypeMask]);
+ while ((((usqInt) obj1)) < (((usqInt) GIV(freeStart)))) {
+ if (!(((longAt(obj1)) & TypeMask) == HeaderTypeFree)) {
+ oop = obj1;
+ goto l2;
+ }
+ /* begin objectAfter: */
+ if (DoAssertionChecks) {
+ if ((((usqInt) obj1)) >= (((usqInt) GIV(endOfMemory)))) {
+ error("no objects after the end of memory");
+ }
+ }
+ if (((longAt(obj1)) & TypeMask) == HeaderTypeFree) {
+ sz = (longAt(obj1)) & AllButTypeMask;
+ }
+ else {
+ /* begin sizeBitsOf: */
+ header = longAt(obj1);
+ sz = ((header & TypeMask) == HeaderTypeSizeAndClass
+ ? (longAt(obj1 - (BytesPerWord * 2))) & LongSizeMask
+ : header & SizeMask);
+ }
+ obj1 = (obj1 + sz) + (headerTypeBytes[(longAt(obj1 + sz)) & TypeMask]);
+ }
+ error("heap is empty");
+ oop = null;
+l2: /* end firstAccessibleObject */;
+ while (!(oop == null)) {
+ if ((((oop & 1) == 0)
+ && (((((usqInt) (longAt(oop))) >> 8) & 15) <= 4))
+ || (((((usqInt) (longAt(oop))) >> 8) & 15) >= 12)) {
+ if (((((usqInt) (longAt(oop))) >> 8) & 15) >= 12) {
+ i = (literalCountOf(oop)) - 1;
+ }
+ else {
+ if (((oop & 1) == 0)
+ && (((((usqInt) (longAt(oop))) >> 12) & 31) == ClassMethodContextCompactIndex)) {
+ i = (CtxtTempFrameStart + (fetchStackPointerOf(oop))) - 1;
+ }
+ else {
+ i = (lengthOf(oop)) - 1;
+ }
+ }
+ while (i >= 0) {
+ if (anOop == (longAt((oop + BaseHeaderSize) + (i << ShiftForWord)))) {
+ printHex(oop);
+ print(" @ ");
+ printNum(i);
+ /* begin cr */
+ printf("\n");
+ prntObj = 1;
+ i = 0;
+ }
+ i -= 1;
+ }
+ if (prntObj) {
+ prntObj = 0;
+ longPrintOop(oop);
+ }
+ }
+ /* begin accessibleObjectAfter: */
+ /* begin objectAfter: */
+ if (DoAssertionChecks) {
+ if ((((usqInt) oop)) >= (((usqInt) GIV(endOfMemory)))) {
+ error("no objects after the end of memory");
+ }
+ }
+ if (((longAt(oop)) & TypeMask) == HeaderTypeFree) {
+ sz2 = (longAt(oop)) & AllButTypeMask;
+ }
+ else {
+ /* begin sizeBitsOf: */
+ header2 = longAt(oop);
+ sz2 = ((header2 & TypeMask) == HeaderTypeSizeAndClass
+ ? (longAt(oop - (BytesPerWord * 2))) & LongSizeMask
+ : header2 & SizeMask);
+ }
+ obj = (oop + sz2) + (headerTypeBytes[(longAt(oop + sz2)) & TypeMask]);
+ while ((((usqInt) obj)) < (((usqInt) GIV(freeStart)))) {
+ if (!(((longAt(obj)) & TypeMask) == HeaderTypeFree)) {
+ oop = obj;
+ goto l1;
+ }
+ /* begin objectAfter: */
+ if (DoAssertionChecks) {
+ if ((((usqInt) obj)) >= (((usqInt) GIV(endOfMemory)))) {
+ error("no objects after the end of memory");
+ }
+ }
+ if (((longAt(obj)) & TypeMask) == HeaderTypeFree) {
+ sz1 = (longAt(obj)) & AllButTypeMask;
+ }
+ else {
+ /* begin sizeBitsOf: */
+ header1 = longAt(obj);
+ sz1 = ((header1 & TypeMask) == HeaderTypeSizeAndClass
+ ? (longAt(obj - (BytesPerWord * 2))) & LongSizeMask
+ : header1 & SizeMask);
+ }
+ obj = (obj + sz1) + (headerTypeBytes[(longAt(obj + sz1)) & TypeMask]);
+ }
+ oop = null;
+ l1: /* end accessibleObjectAfter: */;
+ }
+}
+
+
/* This method implements a simple method lookup cache. If an entry for the
given selector and class is found in the cache, set the values of
'newMethod' and 'primitiveFunctionPointer' and return true. Otherwise,
Modified: branches/Cog/src/vm/cointerp.h
===================================================================
--- branches/Cog/src/vm/cointerp.h 2012-03-03 21:13:51 UTC (rev 2538)
+++ branches/Cog/src/vm/cointerp.h 2012-04-03 21:03:16 UTC (rev 2539)
@@ -1,5 +1,5 @@
/* Automatically generated by
- CCodeGeneratorGlobalStructure VMMaker.oscog-eem.152 uuid: d39d62b0-45ca-4621-8f67-e3981bbe1875
+ CCodeGeneratorGlobalStructure VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa
*/
@@ -106,6 +106,7 @@
sqInt literalCountOfHeader(sqInt headerPointer);
sqInt literalofMethod(sqInt offset, sqInt methodPointer);
void longPrintOop(sqInt oop);
+void longPrintReferencesTo(sqInt anOop);
sqInt lookupreceiver(sqInt selector, sqInt rcvr);
void markActiveMethodsAndReferents(void);
void markAndTrace(sqInt oop);
@@ -201,7 +202,7 @@
/*** Global Variables ***/
char * breakSelector;
sqInt breakSelectorLength ;
-#define bytecodeSetSelector 0;
+#define bytecodeSetSelector 0
sqInt checkForLeaks;
sqInt deferDisplayUpdates;
sqInt desiredCogCodeSize;
Modified: branches/Cog/src/vm/cointerpmt.c
===================================================================
--- branches/Cog/src/vm/cointerpmt.c 2012-03-03 21:13:51 UTC (rev 2538)
+++ branches/Cog/src/vm/cointerpmt.c 2012-04-03 21:03:16 UTC (rev 2539)
@@ -1,9 +1,9 @@
/* Automatically generated by
- CCodeGeneratorGlobalStructure VMMaker.oscog-eem.152 uuid: d39d62b0-45ca-4621-8f67-e3981bbe1875
+ CCodeGeneratorGlobalStructure VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa
from
- CoInterpreterMT VMMaker.oscog-eem.152 uuid: d39d62b0-45ca-4621-8f67-e3981bbe1875
+ CoInterpreterMT VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa
*/
-static char __buildInfo[] = "CoInterpreterMT VMMaker.oscog-eem.152 uuid: d39d62b0-45ca-4621-8f67-e3981bbe1875 " __DATE__ ;
+static char __buildInfo[] = "CoInterpreterMT VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa " __DATE__ ;
char *__interpBuildInfo = __buildInfo;
@@ -696,6 +696,7 @@
static sqInt loadImageSegmentFromoutPointers(sqInt segmentWordArray, sqInt outPointerArray);
void loadInitialContext(void);
void longPrintOop(sqInt oop);
+void longPrintReferencesTo(sqInt anOop);
static sqInt lookupInMethodCacheSelclass(sqInt selector, sqInt class);
static sqInt lookupMethodInClass(sqInt class);
static sqInt lookupMethodInDictionary(sqInt dictionary);
@@ -1998,7 +1999,7 @@
/* 575 */ (void (*)(void))0,
0 };
static void (*externalPrimitiveTable[MaxExternalPrimitiveTableSize + 1 /* 4097 */])(void);
-const char *interpreterVersion = "Croquet Closure Cog MT VM [CoInterpreterMT VMMaker.oscog-eem.152]";
+const char *interpreterVersion = "Croquet Closure Cog MT VM [CoInterpreterMT VMMaker.oscog-eem.154]";
sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 10 */;
volatile int sendTrace;
sqInt willNotThreadWarnCount;
@@ -20822,6 +20823,134 @@
}
+/* Scan the heap long printing the oops of any and all objects that refer to
+ anOop
+ */
+
+void
+longPrintReferencesTo(sqInt anOop)
+{ DECL_MAYBE_SQ_GLOBAL_STRUCT
+ sqInt header;
+ sqInt header1;
+ sqInt header2;
+ sqInt i;
+ sqInt obj;
+ sqInt obj1;
+ sqInt oop;
+ sqInt prntObj;
+ sqInt sz;
+ sqInt sz1;
+ sqInt sz2;
+
+ prntObj = 0;
+ /* begin firstAccessibleObject */
+ obj1 = heapBase + (headerTypeBytes[(longAt(heapBase)) & TypeMask]);
+ while ((((usqInt) obj1)) < (((usqInt) GIV(freeStart)))) {
+ if (!(((longAt(obj1)) & TypeMask) == HeaderTypeFree)) {
+ oop = obj1;
+ goto l2;
+ }
+ /* begin objectAfter: */
+ if (DoAssertionChecks) {
+ if ((((usqInt) obj1)) >= (((usqInt) GIV(endOfMemory)))) {
+ error("no objects after the end of memory");
+ }
+ }
+ if (((longAt(obj1)) & TypeMask) == HeaderTypeFree) {
+ sz = (longAt(obj1)) & AllButTypeMask;
+ }
+ else {
+ /* begin sizeBitsOf: */
+ header = longAt(obj1);
+ sz = ((header & TypeMask) == HeaderTypeSizeAndClass
+ ? (longAt(obj1 - (BytesPerWord * 2))) & LongSizeMask
+ : header & SizeMask);
+ }
+ obj1 = (obj1 + sz) + (headerTypeBytes[(longAt(obj1 + sz)) & TypeMask]);
+ }
+ error("heap is empty");
+ oop = null;
+l2: /* end firstAccessibleObject */;
+ while (!(oop == null)) {
+ if ((((oop & 1) == 0)
+ && (((((usqInt) (longAt(oop))) >> 8) & 15) <= 4))
+ || (((((usqInt) (longAt(oop))) >> 8) & 15) >= 12)) {
+ if (((((usqInt) (longAt(oop))) >> 8) & 15) >= 12) {
+ i = (literalCountOf(oop)) - 1;
+ }
+ else {
+ if (((oop & 1) == 0)
+ && (((((usqInt) (longAt(oop))) >> 12) & 31) == ClassMethodContextCompactIndex)) {
+ i = (CtxtTempFrameStart + (fetchStackPointerOf(oop))) - 1;
+ }
+ else {
+ i = (lengthOf(oop)) - 1;
+ }
+ }
+ while (i >= 0) {
+ if (anOop == (longAt((oop + BaseHeaderSize) + (i << ShiftForWord)))) {
+ printHex(oop);
+ print(" @ ");
+ printNum(i);
+ /* begin cr */
+ printf("\n");
+ prntObj = 1;
+ i = 0;
+ }
+ i -= 1;
+ }
+ if (prntObj) {
+ prntObj = 0;
+ longPrintOop(oop);
+ }
+ }
+ /* begin accessibleObjectAfter: */
+ /* begin objectAfter: */
+ if (DoAssertionChecks) {
+ if ((((usqInt) oop)) >= (((usqInt) GIV(endOfMemory)))) {
+ error("no objects after the end of memory");
+ }
+ }
+ if (((longAt(oop)) & TypeMask) == HeaderTypeFree) {
+ sz2 = (longAt(oop)) & AllButTypeMask;
+ }
+ else {
+ /* begin sizeBitsOf: */
+ header2 = longAt(oop);
+ sz2 = ((header2 & TypeMask) == HeaderTypeSizeAndClass
+ ? (longAt(oop - (BytesPerWord * 2))) & LongSizeMask
+ : header2 & SizeMask);
+ }
+ obj = (oop + sz2) + (headerTypeBytes[(longAt(oop + sz2)) & TypeMask]);
+ while ((((usqInt) obj)) < (((usqInt) GIV(freeStart)))) {
+ if (!(((longAt(obj)) & TypeMask) == HeaderTypeFree)) {
+ oop = obj;
+ goto l1;
+ }
+ /* begin objectAfter: */
+ if (DoAssertionChecks) {
+ if ((((usqInt) obj)) >= (((usqInt) GIV(endOfMemory)))) {
+ error("no objects after the end of memory");
+ }
+ }
+ if (((longAt(obj)) & TypeMask) == HeaderTypeFree) {
+ sz1 = (longAt(obj)) & AllButTypeMask;
+ }
+ else {
+ /* begin sizeBitsOf: */
+ header1 = longAt(obj);
+ sz1 = ((header1 & TypeMask) == HeaderTypeSizeAndClass
+ ? (longAt(obj - (BytesPerWord * 2))) & LongSizeMask
+ : header1 & SizeMask);
+ }
+ obj = (obj + sz1) + (headerTypeBytes[(longAt(obj + sz1)) & TypeMask]);
+ }
+ oop = null;
+ l1: /* end accessibleObjectAfter: */;
+ }
+}
+
+
/* This method implements a simple method lookup cache. If an entry for the
given selector and class is found in the cache, set the values of
'newMethod' and 'primitiveFunctionPointer' and return true. Otherwise,
Modified: branches/Cog/src/vm/cointerpmt.h
===================================================================
--- branches/Cog/src/vm/cointerpmt.h 2012-03-03 21:13:51 UTC (rev 2538)
+++ branches/Cog/src/vm/cointerpmt.h 2012-04-03 21:03:16 UTC (rev 2539)
@@ -1,5 +1,5 @@
/* Automatically generated by
- CCodeGeneratorGlobalStructure VMMaker.oscog-eem.152 uuid: d39d62b0-45ca-4621-8f67-e3981bbe1875
+ CCodeGeneratorGlobalStructure VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa
*/
@@ -108,6 +108,7 @@
sqInt literalCountOfHeader(sqInt headerPointer);
sqInt literalofMethod(sqInt offset, sqInt methodPointer);
void longPrintOop(sqInt oop);
+void longPrintReferencesTo(sqInt anOop);
sqInt lookupreceiver(sqInt selector, sqInt rcvr);
void markActiveMethodsAndReferents(void);
void markAndTrace(sqInt oop);
@@ -205,7 +206,7 @@
/*** Global Variables ***/
char * breakSelector;
sqInt breakSelectorLength ;
-#define bytecodeSetSelector 0;
+#define bytecodeSetSelector 0
sqInt checkForLeaks;
sqInt deferDisplayUpdates;
sqInt desiredCogCodeSize;
Modified: branches/Cog/src/vm/gcc3x-cointerp.c
===================================================================
--- branches/Cog/src/vm/gcc3x-cointerp.c 2012-03-03 21:13:51 UTC (rev 2538)
+++ branches/Cog/src/vm/gcc3x-cointerp.c 2012-04-03 21:03:16 UTC (rev 2539)
@@ -2,11 +2,11 @@
/* Automatically generated by
- CCodeGeneratorGlobalStructure VMMaker.oscog-eem.152 uuid: d39d62b0-45ca-4621-8f67-e3981bbe1875
+ CCodeGeneratorGlobalStructure VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa
from
- CoInterpreter VMMaker.oscog-eem.152 uuid: d39d62b0-45ca-4621-8f67-e3981bbe1875
+ CoInterpreter VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa
*/
-static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.152 uuid: d39d62b0-45ca-4621-8f67-e3981bbe1875 " __DATE__ ;
+static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa " __DATE__ ;
char *__interpBuildInfo = __buildInfo;
@@ -643,6 +643,7 @@
static sqInt loadImageSegmentFromoutPointers(sqInt segmentWordArray, sqInt outPointerArray);
void loadInitialContext(void);
void longPrintOop(sqInt oop);
+void longPrintReferencesTo(sqInt anOop);
static sqInt lookupInMethodCacheSelclass(sqInt selector, sqInt class);
static sqInt lookupMethodInClass(sqInt class);
static sqInt lookupMethodInDictionary(sqInt dictionary);
@@ -1902,7 +1903,7 @@
/* 575 */ (void (*)(void))0,
0 };
static void (*externalPrimitiveTable[MaxExternalPrimitiveTableSize + 1 /* 4097 */])(void);
-const char *interpreterVersion = "Croquet Closure Cog VM [CoInterpreter VMMaker.oscog-eem.152]";
+const char *interpreterVersion = "Croquet Closure Cog VM [CoInterpreter VMMaker.oscog-eem.154]";
sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 10 */;
volatile int sendTrace;
@@ -20094,6 +20095,134 @@
}
+/* Scan the heap long printing the oops of any and all objects that refer to
+ anOop
+ */
+
+void
+longPrintReferencesTo(sqInt anOop)
+{ DECL_MAYBE_SQ_GLOBAL_STRUCT
+ sqInt header;
+ sqInt header1;
+ sqInt header2;
+ sqInt i;
+ sqInt obj;
+ sqInt obj1;
+ sqInt oop;
+ sqInt prntObj;
+ sqInt sz;
+ sqInt sz1;
+ sqInt sz2;
+
+ prntObj = 0;
+ /* begin firstAccessibleObject */
+ obj1 = heapBase + (headerTypeBytes[(longAt(heapBase)) & TypeMask]);
+ while ((((usqInt) obj1)) < (((usqInt) GIV(freeStart)))) {
+ if (!(((longAt(obj1)) & TypeMask) == HeaderTypeFree)) {
+ oop = obj1;
+ goto l2;
+ }
+ /* begin objectAfter: */
+ if (DoAssertionChecks) {
+ if ((((usqInt) obj1)) >= (((usqInt) GIV(endOfMemory)))) {
+ error("no objects after the end of memory");
+ }
+ }
+ if (((longAt(obj1)) & TypeMask) == HeaderTypeFree) {
+ sz = (longAt(obj1)) & AllButTypeMask;
+ }
+ else {
+ /* begin sizeBitsOf: */
+ header = longAt(obj1);
+ sz = ((header & TypeMask) == HeaderTypeSizeAndClass
+ ? (longAt(obj1 - (BytesPerWord * 2))) & LongSizeMask
+ : header & SizeMask);
+ }
+ obj1 = (obj1 + sz) + (headerTypeBytes[(longAt(obj1 + sz)) & TypeMask]);
+ }
+ error("heap is empty");
+ oop = null;
+l2: /* end firstAccessibleObject */;
+ while (!(oop == null)) {
+ if ((((oop & 1) == 0)
+ && (((((usqInt) (longAt(oop))) >> 8) & 15) <= 4))
+ || (((((usqInt) (longAt(oop))) >> 8) & 15) >= 12)) {
+ if (((((usqInt) (longAt(oop))) >> 8) & 15) >= 12) {
+ i = (literalCountOf(oop)) - 1;
+ }
+ else {
+ if (((oop & 1) == 0)
+ && (((((usqInt) (longAt(oop))) >> 12) & 31) == ClassMethodContextCompactIndex)) {
+ i = (CtxtTempFrameStart + (fetchStackPointerOf(oop))) - 1;
+ }
+ else {
+ i = (lengthOf(oop)) - 1;
+ }
+ }
+ while (i >= 0) {
+ if (anOop == (longAt((oop + BaseHeaderSize) + (i << ShiftForWord)))) {
+ printHex(oop);
+ print(" @ ");
+ printNum(i);
+ /* begin cr */
+ printf("\n");
+ prntObj = 1;
+ i = 0;
+ }
+ i -= 1;
+ }
+ if (prntObj) {
+ prntObj = 0;
+ longPrintOop(oop);
+ }
+ }
+ /* begin accessibleObjectAfter: */
+ /* begin objectAfter: */
+ if (DoAssertionChecks) {
+ if ((((usqInt) oop)) >= (((usqInt) GIV(endOfMemory)))) {
+ error("no objects after the end of memory");
+ }
+ }
+ if (((longAt(oop)) & TypeMask) == HeaderTypeFree) {
+ sz2 = (longAt(oop)) & AllButTypeMask;
+ }
+ else {
+ /* begin sizeBitsOf: */
+ header2 = longAt(oop);
+ sz2 = ((header2 & TypeMask) == HeaderTypeSizeAndClass
+ ? (longAt(oop - (BytesPerWord * 2))) & LongSizeMask
+ : header2 & SizeMask);
+ }
+ obj = (oop + sz2) + (headerTypeBytes[(longAt(oop + sz2)) & TypeMask]);
+ while ((((usqInt) obj)) < (((usqInt) GIV(freeStart)))) {
+ if (!(((longAt(obj)) & TypeMask) == HeaderTypeFree)) {
+ oop = obj;
+ goto l1;
+ }
+ /* begin objectAfter: */
+ if (DoAssertionChecks) {
+ if ((((usqInt) obj)) >= (((usqInt) GIV(endOfMemory)))) {
+ error("no objects after the end of memory");
+ }
+ }
+ if (((longAt(obj)) & TypeMask) == HeaderTypeFree) {
+ sz1 = (longAt(obj)) & AllButTypeMask;
+ }
+ else {
+ /* begin sizeBitsOf: */
+ header1 = longAt(obj);
+ sz1 = ((header1 & TypeMask) == HeaderTypeSizeAndClass
+ ? (longAt(obj - (BytesPerWord * 2))) & LongSizeMask
+ : header1 & SizeMask);
+ }
+ obj = (obj + sz1) + (headerTypeBytes[(longAt(obj + sz1)) & TypeMask]);
+ }
+ oop = null;
+ l1: /* end accessibleObjectAfter: */;
+ }
+}
+
+
/* This method implements a simple method lookup cache. If an entry for the
given selector and class is found in the cache, set the values of
'newMethod' and 'primitiveFunctionPointer' and return true. Otherwise,
Modified: branches/Cog/src/vm/gcc3x-cointerpmt.c
===================================================================
--- branches/Cog/src/vm/gcc3x-cointerpmt.c 2012-03-03 21:13:51 UTC (rev 2538)
+++ branches/Cog/src/vm/gcc3x-cointerpmt.c 2012-04-03 21:03:16 UTC (rev 2539)
@@ -2,11 +2,11 @@
/* Automatically generated by
- CCodeGeneratorGlobalStructure VMMaker.oscog-eem.152 uuid: d39d62b0-45ca-4621-8f67-e3981bbe1875
+ CCodeGeneratorGlobalStructure VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa
from
- CoInterpreterMT VMMaker.oscog-eem.152 uuid: d39d62b0-45ca-4621-8f67-e3981bbe1875
+ CoInterpreterMT VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa
*/
-static char __buildInfo[] = "CoInterpreterMT VMMaker.oscog-eem.152 uuid: d39d62b0-45ca-4621-8f67-e3981bbe1875 " __DATE__ ;
+static char __buildInfo[] = "CoInterpreterMT VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa " __DATE__ ;
char *__interpBuildInfo = __buildInfo;
@@ -699,6 +699,7 @@
static sqInt loadImageSegmentFromoutPointers(sqInt segmentWordArray, sqInt outPointerArray);
void loadInitialContext(void);
void longPrintOop(sqInt oop);
+void longPrintReferencesTo(sqInt anOop);
static sqInt lookupInMethodCacheSelclass(sqInt selector, sqInt class);
static sqInt lookupMethodInClass(sqInt class);
static sqInt lookupMethodInDictionary(sqInt dictionary);
@@ -2001,7 +2002,7 @@
/* 575 */ (void (*)(void))0,
0 };
static void (*externalPrimitiveTable[MaxExternalPrimitiveTableSize + 1 /* 4097 */])(void);
-const char *interpreterVersion = "Croquet Closure Cog MT VM [CoInterpreterMT VMMaker.oscog-eem.152]";
+const char *interpreterVersion = "Croquet Closure Cog MT VM [CoInterpreterMT VMMaker.oscog-eem.154]";
sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 10 */;
volatile int sendTrace;
sqInt willNotThreadWarnCount;
@@ -20826,6 +20827,134 @@
}
+/* Scan the heap long printing the oops of any and all objects that refer to
+ anOop
+ */
+
+void
+longPrintReferencesTo(sqInt anOop)
+{ DECL_MAYBE_SQ_GLOBAL_STRUCT
+ sqInt header;
+ sqInt header1;
+ sqInt header2;
+ sqInt i;
+ sqInt obj;
+ sqInt obj1;
+ sqInt oop;
+ sqInt prntObj;
+ sqInt sz;
+ sqInt sz1;
+ sqInt sz2;
+
+ prntObj = 0;
+ /* begin firstAccessibleObject */
+ obj1 = heapBase + (headerTypeBytes[(longAt(heapBase)) & TypeMask]);
+ while ((((usqInt) obj1)) < (((usqInt) GIV(freeStart)))) {
+ if (!(((longAt(obj1)) & TypeMask) == HeaderTypeFree)) {
+ oop = obj1;
+ goto l2;
+ }
+ /* begin objectAfter: */
+ if (DoAssertionChecks) {
+ if ((((usqInt) obj1)) >= (((usqInt) GIV(endOfMemory)))) {
+ error("no objects after the end of memory");
+ }
+ }
+ if (((longAt(obj1)) & TypeMask) == HeaderTypeFree) {
+ sz = (longAt(obj1)) & AllButTypeMask;
+ }
+ else {
+ /* begin sizeBitsOf: */
+ header = longAt(obj1);
+ sz = ((header & TypeMask) == HeaderTypeSizeAndClass
+ ? (longAt(obj1 - (BytesPerWord * 2))) & LongSizeMask
+ : header & SizeMask);
+ }
+ obj1 = (obj1 + sz) + (headerTypeBytes[(longAt(obj1 + sz)) & TypeMask]);
+ }
+ error("heap is empty");
+ oop = null;
+l2: /* end firstAccessibleObject */;
+ while (!(oop == null)) {
+ if ((((oop & 1) == 0)
+ && (((((usqInt) (longAt(oop))) >> 8) & 15) <= 4))
+ || (((((usqInt) (longAt(oop))) >> 8) & 15) >= 12)) {
+ if (((((usqInt) (longAt(oop))) >> 8) & 15) >= 12) {
+ i = (literalCountOf(oop)) - 1;
+ }
+ else {
+ if (((oop & 1) == 0)
+ && (((((usqInt) (longAt(oop))) >> 12) & 31) == ClassMethodContextCompactIndex)) {
+ i = (CtxtTempFrameStart + (fetchStackPointerOf(oop))) - 1;
+ }
+ else {
+ i = (lengthOf(oop)) - 1;
+ }
+ }
+ while (i >= 0) {
+ if (anOop == (longAt((oop + BaseHeaderSize) + (i << ShiftForWord)))) {
+ printHex(oop);
+ print(" @ ");
+ printNum(i);
+ /* begin cr */
+ printf("\n");
+ prntObj = 1;
+ i = 0;
+ }
+ i -= 1;
+ }
+ if (prntObj) {
+ prntObj = 0;
+ longPrintOop(oop);
+ }
+ }
+ /* begin accessibleObjectAfter: */
+ /* begin objectAfter: */
+ if (DoAssertionChecks) {
+ if ((((usqInt) oop)) >= (((usqInt) GIV(endOfMemory)))) {
+ error("no objects after the end of memory");
+ }
+ }
+ if (((longAt(oop)) & TypeMask) == HeaderTypeFree) {
+ sz2 = (longAt(oop)) & AllButTypeMask;
+ }
+ else {
+ /* begin sizeBitsOf: */
+ header2 = longAt(oop);
+ sz2 = ((header2 & TypeMask) == HeaderTypeSizeAndClass
+ ? (longAt(oop - (BytesPerWord * 2))) & LongSizeMask
+ : header2 & SizeMask);
+ }
+ obj = (oop + sz2) + (headerTypeBytes[(longAt(oop + sz2)) & TypeMask]);
+ while ((((usqInt) obj)) < (((usqInt) GIV(freeStart)))) {
+ if (!(((longAt(obj)) & TypeMask) == HeaderTypeFree)) {
+ oop = obj;
+ goto l1;
+ }
+ /* begin objectAfter: */
+ if (DoAssertionChecks) {
+ if ((((usqInt) obj)) >= (((usqInt) GIV(endOfMemory)))) {
+ error("no objects after the end of memory");
+ }
+ }
+ if (((longAt(obj)) & TypeMask) == HeaderTypeFree) {
+ sz1 = (longAt(obj)) & AllButTypeMask;
+ }
+ else {
+ /* begin sizeBitsOf: */
+ header1 = longAt(obj);
+ sz1 = ((header1 & TypeMask) == HeaderTypeSizeAndClass
+ ? (longAt(obj - (BytesPerWord * 2))) & LongSizeMask
+ : header1 & SizeMask);
+ }
+ obj = (obj + sz1) + (headerTypeBytes[(longAt(obj + sz1)) & TypeMask]);
+ }
+ oop = null;
+ l1: /* end accessibleObjectAfter: */;
+ }
+}
+
+
/* This method implements a simple method lookup cache. If an entry for the
given selector and class is found in the cache, set the values of
'newMethod' and 'primitiveFunctionPointer' and return true. Otherwise,
Modified: branches/Cog/src/vm/interp.h
===================================================================
--- branches/Cog/src/vm/interp.h 2012-03-03 21:13:51 UTC (rev 2538)
+++ branches/Cog/src/vm/interp.h 2012-04-03 21:03:16 UTC (rev 2539)
@@ -1,5 +1,5 @@
/* Automatically generated by
- CCodeGeneratorGlobalStructure VMMaker.oscog-eem.152 uuid: d39d62b0-45ca-4621-8f67-e3981bbe1875
+ CCodeGeneratorGlobalStructure VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa
*/
#define VM_PROXY_MAJOR 1
Modified: branches/Cog/src/vm/vmCallback.h
===================================================================
--- branches/Cog/src/vm/vmCallback.h 2012-03-03 21:13:51 UTC (rev 2538)
+++ branches/Cog/src/vm/vmCallback.h 2012-04-03 21:03:16 UTC (rev 2539)
@@ -1,5 +1,5 @@
/* Automatically generated by
- CCodeGeneratorGlobalStructure VMMaker.oscog-eem.152 uuid: d39d62b0-45ca-4621-8f67-e3981bbe1875
+ CCodeGeneratorGlobalStructure VMMaker.oscog-eem.154 uuid: 5cbb57c7-0a54-4b7e-848c-1f292759f1fa
*/
#define VM_CALLBACK_INC 1
More information about the Vm-dev
mailing list