Skip to content

Commit 84e3711

Browse files
committed
CogVM source as per VMMaker.oscog-eem.2469
Plugins: Clean up BalloonEngine>>primitiveInitializeBuffer. Fix a bug in FloatArrayPlugin>>primitiveDivFloatArray; the old code didn't check for -0.0. Eliminate several unnecessary stackObjectValue:'s in Matrix2x3Plugin; isWords: checks for immediates anyway. Fix several comments in FloatArrayPlugin.
1 parent 15341b5 commit 84e3711

File tree

5 files changed

+231
-335
lines changed

5 files changed

+231
-335
lines changed

src/plugins/B2DPlugin/B2DPlugin.c

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/* Automatically generated by
2-
VMPluginCodeGenerator VMMaker.oscog-eem.2420 uuid: f303796f-283f-4d4c-a910-bf205a0b4600
2+
VMPluginCodeGenerator VMMaker.oscog-eem.2469 uuid: ec87b9e1-5a90-4000-9720-392114a61187
33
from
4-
BalloonEnginePlugin VMMaker.oscog-eem.2420 uuid: f303796f-283f-4d4c-a910-bf205a0b4600
4+
BalloonEnginePlugin VMMaker.oscog-eem.2469 uuid: ec87b9e1-5a90-4000-9720-392114a61187
55
*/
6-
static char __buildInfo[] = "BalloonEnginePlugin VMMaker.oscog-eem.2420 uuid: f303796f-283f-4d4c-a910-bf205a0b4600 " __DATE__ ;
6+
static char __buildInfo[] = "BalloonEnginePlugin VMMaker.oscog-eem.2469 uuid: ec87b9e1-5a90-4000-9720-392114a61187 " __DATE__ ;
77

88

99

@@ -770,7 +770,6 @@ static sqInt (*positive32BitIntegerFor)(unsigned int integerValue);
770770
static usqInt (*positive32BitValueOf)(sqInt oop);
771771
static sqInt (*primitiveFail)(void);
772772
static sqInt (*primitiveFailFor)(sqInt reasonCode);
773-
static sqInt (*push)(sqInt object);
774773
static sqInt (*pushBool)(sqInt trueOrFalse);
775774
static sqInt (*pushInteger)(sqInt integerValue);
776775
static sqInt (*pushRemappableOop)(sqInt oop);
@@ -820,7 +819,6 @@ extern sqInt positive32BitIntegerFor(unsigned int integerValue);
820819
extern usqInt positive32BitValueOf(sqInt oop);
821820
extern sqInt primitiveFail(void);
822821
extern sqInt primitiveFailFor(sqInt reasonCode);
823-
extern sqInt push(sqInt object);
824822
extern sqInt pushBool(sqInt trueOrFalse);
825823
extern sqInt pushInteger(sqInt integerValue);
826824
extern sqInt pushRemappableOop(sqInt oop);
@@ -837,9 +835,9 @@ struct VirtualMachine* interpreterProxy;
837835
static void * loadBBFn;
838836
static const char *moduleName =
839837
#ifdef SQUEAK_BUILTIN_PLUGIN
840-
"B2DPlugin VMMaker.oscog-eem.2420 (i)"
838+
"B2DPlugin VMMaker.oscog-eem.2469 (i)"
841839
#else
842-
"B2DPlugin VMMaker.oscog-eem.2420 (e)"
840+
"B2DPlugin VMMaker.oscog-eem.2469 (e)"
843841
#endif
844842
;
845843
static int* objBuffer;
@@ -11144,17 +11142,9 @@ primitiveInitializeBuffer(void)
1114411142
sqInt size;
1114511143
sqInt wbOop;
1114611144

11147-
if (!((methodArgumentCount()) == 1)) {
11148-
return primitiveFail();
11149-
}
11150-
wbOop = stackObjectValue(0);
11151-
if (failed()) {
11152-
return null;
11153-
}
11154-
if (!(isWords(wbOop))) {
11155-
return primitiveFail();
11156-
}
11157-
if (((size = slotSizeOf(wbOop))) < GWMinimalSize) {
11145+
if (!(((methodArgumentCount()) == 1)
11146+
&& ((isWords((wbOop = stackValue(0))))
11147+
&& (((size = slotSizeOf(wbOop))) >= GWMinimalSize)))) {
1115811148
return primitiveFail();
1115911149
}
1116011150
/* begin workBufferPut: */
@@ -11199,8 +11189,7 @@ primitiveInitializeBuffer(void)
1119911189
resetGraphicsEngineStats();
1120011190
initEdgeTransform();
1120111191
initColorTransform();
11202-
pop(2);
11203-
push(wbOop);
11192+
popthenPush(2, wbOop);
1120411193
return 0;
1120511194
}
1120611195

@@ -12656,7 +12645,6 @@ setInterpreter(struct VirtualMachine*anInterpreter)
1265612645
positive32BitValueOf = interpreterProxy->positive32BitValueOf;
1265712646
primitiveFail = interpreterProxy->primitiveFail;
1265812647
primitiveFailFor = interpreterProxy->primitiveFailFor;
12659-
push = interpreterProxy->push;
1266012648
pushBool = interpreterProxy->pushBool;
1266112649
pushInteger = interpreterProxy->pushInteger;
1266212650
pushRemappableOop = interpreterProxy->pushRemappableOop;

src/plugins/DESPlugin/DESPlugin.c

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* Automatically generated by
2-
VMPluginCodeGenerator VMMaker.oscog-eem.2347 uuid: 062614a7-e3da-4b30-997a-9568911b9ff5
2+
VMPluginCodeGenerator VMMaker.oscog-eem.2468 uuid: cd788ac3-2314-48ce-a656-f4cd6c2935ae
33
from
44
DESPlugin CryptographyPlugins-eem.12 uuid: 2945c878-6a44-4c6a-8374-b56aa6175d0f
55
*/
@@ -280,13 +280,13 @@ cookKeyto(unsigned long *rawPtr, unsigned long *cookPtr)
280280
for (i = 0; i <= 15; i += 1) {
281281
raw0 = rawPtr[i * 2];
282282
raw1 = rawPtr[(i * 2) + 1];
283-
cook = (raw0 & 0xFC0000) << 6;
284-
cook = cook | ((raw0 & 0xFC0) << 10);
283+
cook = ((usqInt)((raw0 & 0xFC0000)) << 6);
284+
cook = cook | (((usqInt)((raw0 & 0xFC0)) << 10));
285285
cook = cook | (((usqInt) (raw1 & 0xFC0000)) >> 10);
286286
cook = cook | (((usqInt) (raw1 & 0xFC0)) >> 6);
287287
cookPtr[i * 2] = cook;
288-
cook = (raw0 & 0x3F000) << 12;
289-
cook = cook | ((raw0 & 0x3F) << 16);
288+
cook = ((usqInt)((raw0 & 0x3F000)) << 12);
289+
cook = cook | (((usqInt)((raw0 & 0x3F)) << 16));
290290
cook = cook | (((usqInt) (raw1 & 0x3F000)) >> 4);
291291
cook = cook | (raw1 & 0x3F);
292292
cookPtr[(i * 2) + 1] = cook;
@@ -310,25 +310,25 @@ encryptwith(unsigned long *dataPtr, unsigned long *key)
310310
right = dataPtr[1];
311311
work = ((((usqInt) left) >> 4) ^ right) & 252645135;
312312
right = right ^ work;
313-
left = left ^ (work << 4);
313+
left = left ^ (((usqInt)(work) << 4));
314314
work = ((((usqInt) left) >> 16) ^ right) & 0xFFFF;
315315
right = right ^ work;
316-
left = left ^ (work << 16);
316+
left = left ^ (((usqInt)(work) << 16));
317317
work = ((((usqInt) right) >> 2) ^ left) & 858993459;
318318
left = left ^ work;
319-
right = right ^ (work << 2);
319+
right = right ^ (((usqInt)(work) << 2));
320320
work = ((((usqInt) right) >> 8) ^ left) & 16711935;
321321
left = left ^ work;
322-
right = right ^ (work << 8);
323-
right = ((right << 1) | ((((usqInt) right) >> 0x1F) & 1)) & 0xFFFFFFFFU;
322+
right = right ^ (((usqInt)(work) << 8));
323+
right = ((((usqInt)(right) << 1)) | ((((usqInt) right) >> 0x1F) & 1)) & 0xFFFFFFFFU;
324324
work = (left ^ right) & 2863311530U;
325325
left = left ^ work;
326326
right = right ^ work;
327327

328328
/* perform the 8 rounds of real encryption */
329-
left = ((left << 1) | ((((usqInt) left) >> 0x1F) & 1)) & 0xFFFFFFFFU;
329+
left = ((((usqInt)(left) << 1)) | ((((usqInt) left) >> 0x1F) & 1)) & 0xFFFFFFFFU;
330330
for (round = 0; round <= 28; round += 4) {
331-
work = (right << 28) | (((usqInt) right) >> 4);
331+
work = (((usqInt)(right) << 28)) | (((usqInt) right) >> 4);
332332
work = work ^ (key[round]);
333333
fVal = sp7[work & 0x3F];
334334
fVal = fVal | (sp5[(((usqInt) work) >> 8) & 0x3F]);
@@ -340,7 +340,7 @@ encryptwith(unsigned long *dataPtr, unsigned long *key)
340340
fVal = fVal | (sp4[(((usqInt) work) >> 16) & 0x3F]);
341341
fVal = fVal | (sp2[(((usqInt) work) >> 24) & 0x3F]);
342342
left = left ^ fVal;
343-
work = (left << 28) | (((usqInt) left) >> 4);
343+
work = (((usqInt)(left) << 28)) | (((usqInt) left) >> 4);
344344
work = work ^ (key[round + 2]);
345345
fVal = sp7[work & 0x3F];
346346
fVal = fVal | (sp5[(((usqInt) work) >> 8) & 0x3F]);
@@ -353,23 +353,23 @@ encryptwith(unsigned long *dataPtr, unsigned long *key)
353353
fVal = fVal | (sp2[(((usqInt) work) >> 24) & 0x3F]);
354354
right = right ^ fVal;
355355
}
356-
right = (right << 0x1F) | (((usqInt) right) >> 1);
356+
right = (((usqInt)(right) << 0x1F)) | (((usqInt) right) >> 1);
357357
work = (left ^ right) & 2863311530U;
358358
left = left ^ work;
359359
right = right ^ work;
360-
left = (left << 0x1F) | (((usqInt) left) >> 1);
360+
left = (((usqInt)(left) << 0x1F)) | (((usqInt) left) >> 1);
361361
work = ((((usqInt) left) >> 8) ^ right) & 16711935;
362362
right = right ^ work;
363-
left = left ^ (work << 8);
363+
left = left ^ (((usqInt)(work) << 8));
364364
work = ((((usqInt) left) >> 2) ^ right) & 858993459;
365365
right = right ^ work;
366-
left = left ^ (work << 2);
366+
left = left ^ (((usqInt)(work) << 2));
367367
work = ((((usqInt) right) >> 16) ^ left) & 0xFFFF;
368368
left = left ^ work;
369-
right = right ^ (work << 16);
369+
right = right ^ (((usqInt)(work) << 16));
370370
work = ((((usqInt) right) >> 4) ^ left) & 252645135;
371371
left = left ^ work;
372-
right = right ^ (work << 4);
372+
right = right ^ (((usqInt)(work) << 4));
373373
dataPtr[0] = right;
374374
dataPtr[1] = left;
375375
return 0;
@@ -480,25 +480,25 @@ primitiveDESTransform(void)
480480
right = work[1];
481481
work1 = ((((usqInt) left) >> 4) ^ right) & 252645135;
482482
right = right ^ work1;
483-
left = left ^ (work1 << 4);
483+
left = left ^ (((usqInt)(work1) << 4));
484484
work1 = ((((usqInt) left) >> 16) ^ right) & 0xFFFF;
485485
right = right ^ work1;
486-
left = left ^ (work1 << 16);
486+
left = left ^ (((usqInt)(work1) << 16));
487487
work1 = ((((usqInt) right) >> 2) ^ left) & 858993459;
488488
left = left ^ work1;
489-
right = right ^ (work1 << 2);
489+
right = right ^ (((usqInt)(work1) << 2));
490490
work1 = ((((usqInt) right) >> 8) ^ left) & 16711935;
491491
left = left ^ work1;
492-
right = right ^ (work1 << 8);
493-
right = ((right << 1) | ((((usqInt) right) >> 0x1F) & 1)) & 0xFFFFFFFFU;
492+
right = right ^ (((usqInt)(work1) << 8));
493+
right = ((((usqInt)(right) << 1)) | ((((usqInt) right) >> 0x1F) & 1)) & 0xFFFFFFFFU;
494494
work1 = (left ^ right) & 2863311530U;
495495
left = left ^ work1;
496496
right = right ^ work1;
497497

498498
/* perform the 8 rounds of real encryption */
499-
left = ((left << 1) | ((((usqInt) left) >> 0x1F) & 1)) & 0xFFFFFFFFU;
499+
left = ((((usqInt)(left) << 1)) | ((((usqInt) left) >> 0x1F) & 1)) & 0xFFFFFFFFU;
500500
for (round = 0; round <= 28; round += 4) {
501-
work1 = (right << 28) | (((usqInt) right) >> 4);
501+
work1 = (((usqInt)(right) << 28)) | (((usqInt) right) >> 4);
502502
work1 = work1 ^ (cooked[round]);
503503
fVal = sp7[work1 & 0x3F];
504504
fVal = fVal | (sp5[(((usqInt) work1) >> 8) & 0x3F]);
@@ -510,7 +510,7 @@ primitiveDESTransform(void)
510510
fVal = fVal | (sp4[(((usqInt) work1) >> 16) & 0x3F]);
511511
fVal = fVal | (sp2[(((usqInt) work1) >> 24) & 0x3F]);
512512
left = left ^ fVal;
513-
work1 = (left << 28) | (((usqInt) left) >> 4);
513+
work1 = (((usqInt)(left) << 28)) | (((usqInt) left) >> 4);
514514
work1 = work1 ^ (cooked[round + 2]);
515515
fVal = sp7[work1 & 0x3F];
516516
fVal = fVal | (sp5[(((usqInt) work1) >> 8) & 0x3F]);
@@ -523,23 +523,23 @@ primitiveDESTransform(void)
523523
fVal = fVal | (sp2[(((usqInt) work1) >> 24) & 0x3F]);
524524
right = right ^ fVal;
525525
}
526-
right = (right << 0x1F) | (((usqInt) right) >> 1);
526+
right = (((usqInt)(right) << 0x1F)) | (((usqInt) right) >> 1);
527527
work1 = (left ^ right) & 2863311530U;
528528
left = left ^ work1;
529529
right = right ^ work1;
530-
left = (left << 0x1F) | (((usqInt) left) >> 1);
530+
left = (((usqInt)(left) << 0x1F)) | (((usqInt) left) >> 1);
531531
work1 = ((((usqInt) left) >> 8) ^ right) & 16711935;
532532
right = right ^ work1;
533-
left = left ^ (work1 << 8);
533+
left = left ^ (((usqInt)(work1) << 8));
534534
work1 = ((((usqInt) left) >> 2) ^ right) & 858993459;
535535
right = right ^ work1;
536-
left = left ^ (work1 << 2);
536+
left = left ^ (((usqInt)(work1) << 2));
537537
work1 = ((((usqInt) right) >> 16) ^ left) & 0xFFFF;
538538
left = left ^ work1;
539-
right = right ^ (work1 << 16);
539+
right = right ^ (((usqInt)(work1) << 16));
540540
work1 = ((((usqInt) right) >> 4) ^ left) & 252645135;
541541
left = left ^ work1;
542-
right = right ^ (work1 << 4);
542+
right = right ^ (((usqInt)(work1) << 4));
543543
work[0] = right;
544544
work[1] = left;
545545
/* begin unscrunch:to: */
@@ -623,13 +623,13 @@ processKeymodeto(unsigned char *keyPtr, sqInt encode, unsigned long *cookedPtr)
623623
for (i1 = 0; i1 <= 15; i1 += 1) {
624624
raw0 = rawKey[i1 * 2];
625625
raw1 = rawKey[(i1 * 2) + 1];
626-
cook = (raw0 & 0xFC0000) << 6;
627-
cook = cook | ((raw0 & 0xFC0) << 10);
626+
cook = ((usqInt)((raw0 & 0xFC0000)) << 6);
627+
cook = cook | (((usqInt)((raw0 & 0xFC0)) << 10));
628628
cook = cook | (((usqInt) (raw1 & 0xFC0000)) >> 10);
629629
cook = cook | (((usqInt) (raw1 & 0xFC0)) >> 6);
630630
cookedPtr[i1 * 2] = cook;
631-
cook = (raw0 & 0x3F000) << 12;
632-
cook = cook | ((raw0 & 0x3F) << 16);
631+
cook = ((usqInt)((raw0 & 0x3F000)) << 12);
632+
cook = cook | (((usqInt)((raw0 & 0x3F)) << 16));
633633
cook = cook | (((usqInt) (raw1 & 0x3F000)) >> 4);
634634
cook = cook | (raw1 & 0x3F);
635635
cookedPtr[(i1 * 2) + 1] = cook;

0 commit comments

Comments
 (0)