Skip to content

Commit 1283ba4

Browse files
committed
CogVM source as per VMMaker.oscog-eem.3183
BitBltPlugin: implement primitivePixelValueAtX:y:put: to complement primitivePixelValueAtX:y:. Reuse the obsolete & unused sendInvokeCallback:Stack:Registers:Jmpbuf: function in the VirtualMachione struct to access storeLong32:ofObject:withValue:.
1 parent 06dca1d commit 1283ba4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+649
-6134
lines changed

platforms/Cross/vm/sqVirtualMachine.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,11 @@ struct VirtualMachine* sqGetInterpreterProxy(void)
258258
VM->setInterruptCheckChain = setInterruptCheckChain;
259259
VM->classAlien = classAlien;
260260
VM->classUnsafeAlien = classUnsafeAlien;
261+
# if OLD_FOR_REFERENCE /* slot repurposed for storeLong32ofObjectwithValue */
261262
VM->sendInvokeCallbackStackRegistersJmpbuf = sendInvokeCallbackStackRegistersJmpbuf;
263+
# else
264+
VM->storeLong32ofObjectwithValue = storeLong32ofObjectwithValue;
265+
# endif
262266
VM->reestablishContextPriorToCallback = reestablishContextPriorToCallback;
263267
VM->getStackPointer = (sqInt *(*)(void))getStackPointer;
264268
VM->isOopImmutable = isOopImmutable;

platforms/Cross/vm/sqVirtualMachine.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,11 @@ typedef struct VirtualMachine {
288288
void *(*setInterruptCheckChain)(void (*aFunction)(void));
289289
sqInt (*classAlien)(void);
290290
sqInt (*classUnsafeAlien)(void);
291+
# if OLD_FOR_REFERENCE /* slot repurposed for storeLong32ofObjectwithValue */
291292
sqInt (*sendInvokeCallbackStackRegistersJmpbuf)(sqInt thunkPtrAsInt, sqInt stackPtrAsInt, sqInt regsPtrAsInt, sqInt jmpBufPtrAsInt);
293+
# else
294+
usqInt (*storeLong32ofObjectwithValue)(sqInt index, sqInt oop, usqInt);
295+
# endif
292296
sqInt (*reestablishContextPriorToCallback)(sqInt callbackContext);
293297
sqInt *(*getStackPointer)(void);
294298
sqInt (*isOopImmutable)(sqInt oop);
@@ -548,7 +552,11 @@ usqInt sizeOfAlienData(sqInt);
548552
sqInt signalNoResume(sqInt);
549553
#if VM_PROXY_MINOR > 8
550554
sqInt *getStackPointer(void); /* Alien FFI */
555+
# if OLD_FOR_REFERENCE /* slot repurposed for storeLong32ofObjectwithValue */
551556
sqInt sendInvokeCallbackStackRegistersJmpbuf(sqInt thunkPtrAsInt, sqInt stackPtrAsInt, sqInt regsPtrAsInt, sqInt jmpBufPtrAsInt); /* Alien FFI */
557+
# else
558+
usqInt storeLong32ofObjectwithValue(sqInt index, sqInt oop, usqInt);
559+
# endif
552560
sqInt reestablishContextPriorToCallback(sqInt callbackContext); /* Alien FFI */
553561
sqInt sendInvokeCallbackContext(vmccp);
554562
sqInt returnAsThroughCallbackContext(sqInt, vmccp, sqInt);

platforms/iOS/vm/Common/Classes/sqSqueakAppDelegate.m

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ Some of this code was funded via a grant from the European Smalltalk User Group
1717
copies of the Software, and to permit persons to whom the
1818
Software is furnished to do so, subject to the following
1919
conditions:
20-
20+
2121
The above copyright notice and this permission notice shall be
2222
included in all copies or substantial portions of the Software.
23-
23+
2424
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2525
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
2626
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -50,37 +50,35 @@ - (void)dealloc {
5050
}
5151

5252
- (void) makeMainWindow {
53-
53+
5454
/*Beware creating a main window must be done on main thread it will not work from this interpreter squeak thread */
55-
55+
5656
sqInt width,height;
5757
windowDescriptorBlock *windowBlock;
58-
58+
5959
NSObject * createdWindow = [self createPossibleWindow];
60-
60+
6161
extern sqInt getSavedWindowSize(void); //This is VM Callback
6262
extern sqInt setSavedWindowSize(sqInt value); //This is VM Callback
63-
63+
6464
/* get old window size */
6565
width = ((unsigned) getSavedWindowSize()) >> 16;
6666
height = getSavedWindowSize() & 0xFFFF;
67-
67+
6868
extern sqInt getFullScreenFlag(void);
69-
if (!getFullScreenFlag()) {
69+
if (!getFullScreenFlag())
7070
[self placeMainWindowOnLargerScreenGivenWidth: width height: height];
71-
}
72-
71+
7372
windowBlock = AddWindowBlock();
7473
windowBlock->handle = (__bridge void*) createdWindow;
7574
windowBlock->context = nil;
7675
windowBlock->updateArea = CGRectZero;
77-
78-
setSavedWindowSize( (width << 16) |(height & 0xFFFF));
76+
77+
setSavedWindowSize((width << 16) | (height & 0xFFFF));
7978
windowBlock->width = width;
8079
windowBlock->height = height;
8180

8281
ioSetFullScreen(getFullScreenFlag());
83-
8482
}
8583

8684
- (sqSqueakMainApplication *) makeApplicationInstance {
@@ -105,14 +103,14 @@ - (void) workerThreadStart {
105103
#if COGVM
106104
[squeakThread setStackSize: [squeakThread stackSize]*4];
107105
#endif
108-
106+
109107
[squeakThread start];
110108
}
111109

112110
- (void) singleThreadStart {
113111
/* This the carbon logic model
114112
described by http://developer.apple.com/qa/qa2001/qa1061.html */
115-
113+
116114
[[NSRunLoop mainRunLoop] performSelector: @selector(runSqueak)
117115
target: self.squeakApplication
118116
argument: nil

src/plugins/BitBltPlugin/BitBltPlugin.c

Lines changed: 113 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/* Automatically generated by
2-
SmartSyntaxPluginCodeGenerator VMMaker.oscog-eem.3171 uuid: b926bcd4-a4a9-4d38-8267-4eac3fec60d9
2+
SmartSyntaxPluginCodeGenerator VMMaker.oscog-eem.3183 uuid: c5c103b4-2c5c-44e7-8e32-030e79600ca6
33
from
4-
BitBltSimulation VMMaker.oscog-eem.3171 uuid: b926bcd4-a4a9-4d38-8267-4eac3fec60d9
4+
BitBltSimulation VMMaker.oscog-eem.3183 uuid: c5c103b4-2c5c-44e7-8e32-030e79600ca6
55
*/
6-
static char __buildInfo[] = "BitBltSimulation VMMaker.oscog-eem.3171 uuid: b926bcd4-a4a9-4d38-8267-4eac3fec60d9 " __DATE__ ;
6+
static char __buildInfo[] = "BitBltSimulation VMMaker.oscog-eem.3183 uuid: c5c103b4-2c5c-44e7-8e32-030e79600ca6 " __DATE__ ;
77

88

99
#include "config.h"
@@ -167,6 +167,7 @@ EXPORT(sqInt) primitiveCopyBits(void);
167167
EXPORT(sqInt) primitiveDisplayString(void);
168168
EXPORT(sqInt) primitiveDrawLoop(void);
169169
EXPORT(sqInt) primitivePixelValueAt(void);
170+
EXPORT(sqInt) primitivePixelValueAtPut(void);
170171
EXPORT(sqInt) primitiveWarpBits(void);
171172
static sqInt reloadDestAndSourceForms(void);
172173
static unsigned int rgbAddwith(unsigned int sourceWord, unsigned int destinationWord);
@@ -298,6 +299,7 @@ static sqInt (*stackObjectValue)(sqInt offset);
298299
static sqInt (*stackValue)(sqInt offset);
299300
static sqInt (*statNumGCs)(void);
300301
static sqInt (*storeIntegerofObjectwithValue)(sqInt index, sqInt oop, sqInt integer);
302+
static usqInt (*storeLong32ofObjectwithValue)(sqInt fieldIndex, sqInt oop, usqInt anInteger);
301303
#else /* !defined(SQUEAK_BUILTIN_PLUGIN) */
302304
extern sqInt byteSizeOf(sqInt oop);
303305
extern sqInt failed(void);
@@ -348,6 +350,11 @@ extern sqInt statNumGCs(void);
348350
# define statNumGCs() 0
349351
#endif
350352
extern sqInt storeIntegerofObjectwithValue(sqInt index, sqInt oop, sqInt integer);
353+
#if VM_PROXY_MAJOR > 1 || (VM_PROXY_MAJOR == 1 && VM_PROXY_MINOR >= 16)
354+
extern usqInt storeLong32ofObjectwithValue(sqInt fieldIndex, sqInt oop, usqInt anInteger);
355+
#else
356+
# define storeLong32ofObjectwithValue(fieldIndex, oop, anInteger) 0
357+
#endif
351358
extern
352359
#endif
353360
struct VirtualMachine* interpreterProxy;
@@ -358,7 +365,7 @@ static int maskTable[33] = {
358365
0, 1, 3, 0, 15, 31, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 65535,
359366
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1
360367
};
361-
static const char *moduleName = "BitBltPlugin VMMaker.oscog-eem.3171 " INT_EXT;
368+
static const char *moduleName = "BitBltPlugin VMMaker.oscog-eem.3183 " INT_EXT;
362369
static sqInt noHalftone;
363370
static sqInt noSource;
364371
static sqInt numGCsOnInvocation;
@@ -5696,6 +5703,99 @@ primitivePixelValueAt(void)
56965703
}
56975704

56985705

5706+
/* Sets the single pixel at x@y. Answers the previous value of the pixel.
5707+
It does not handle LSB bitmaps right now.
5708+
If x or y are < 0, return 0 to indicate transparent (cf
5709+
BitBlt>bitPeekerFromForm: usage).
5710+
Likewise if x>width or y>depth.
5711+
Fail if the rcvr doesn't seem to be a Form, or x|y seem wrong
5712+
*/
5713+
5714+
/* BitBltSimulation>>#primitivePixelValueAtX:y:put: */
5715+
EXPORT(sqInt)
5716+
primitivePixelValueAtPut(void)
5717+
{
5718+
sqInt bitmap;
5719+
sqInt bitsSize;
5720+
sqInt depth;
5721+
unsigned int mask;
5722+
sqInt oldPixel;
5723+
sqInt pixel;
5724+
sqInt ppW;
5725+
sqInt rcvr;
5726+
sqInt shift;
5727+
sqInt stride;
5728+
sqInt word;
5729+
sqInt xVal;
5730+
sqInt yVal;
5731+
5732+
if (!((isIntegerObject((xVal = stackValue(2))))
5733+
&& ((isIntegerObject((yVal = stackValue(1))))
5734+
&& (isIntegerObject((pixel = stackValue(0))))))) {
5735+
return primitiveFailFor(PrimErrBadArgument);
5736+
}
5737+
xVal = integerValueOf(xVal);
5738+
yVal = integerValueOf(yVal);
5739+
pixel = integerValueOf(pixel);
5740+
rcvr = stackValue(3);
5741+
rcvr = stackValue(methodArgumentCount());
5742+
if (!((isPointers(rcvr))
5743+
&& ((slotSizeOf(rcvr)) >= 4))) {
5744+
return primitiveFailFor(PrimErrBadReceiver);
5745+
}
5746+
bitmap = fetchPointerofObject(FormBitsIndex, rcvr);
5747+
if (!(isWordsOrBytes(bitmap))) {
5748+
return primitiveFailFor(PrimErrBadReceiver);
5749+
}
5750+
width = fetchIntegerofObject(FormWidthIndex, rcvr);
5751+
height = fetchIntegerofObject(FormHeightIndex, rcvr);
5752+
5753+
/* if width/height/depth are not integer, fail */
5754+
depth = fetchIntegerofObject(FormDepthIndex, rcvr);
5755+
if ((failed())
5756+
|| (depth < 0)) {
5757+
return primitiveFailFor(PrimErrBadReceiver);
5758+
}
5759+
if ((xVal < 0)
5760+
|| ((xVal >= width)
5761+
|| ((yVal < 0)
5762+
|| ((yVal >= height)
5763+
|| (pixel < 0))))) {
5764+
return primitiveFailFor(PrimErrBadArgument);
5765+
}
5766+
5767+
/* pixels in each word */
5768+
ppW = 32 / depth;
5769+
5770+
/* how many words per row of pixels */
5771+
stride = (width + (ppW - 1)) / ppW;
5772+
bitsSize = byteSizeOf(bitmap);
5773+
if (!(bitsSize >= ((stride * height) * 4))) {
5774+
5775+
/* bytes per word */
5776+
return primitiveFailFor(PrimErrBadReceiver);
5777+
}
5778+
5779+
/* load the word that contains our target */
5780+
word = fetchLong32ofObject((yVal * stride) + (xVal / ppW), bitmap);
5781+
5782+
/* make a mask to isolate the pixel within that word */
5783+
mask = ((usqInt)(0xFFFFFFFFU)) >> (32 - depth);
5784+
5785+
/* this is the tricky MSB part - we mask the xVal to find how far into the word we need, then add 1 for the pixel we're looking for, then * depth to get the bit shift */
5786+
shift = 32 - (((xVal & (ppW - 1)) + 1) * depth);
5787+
5788+
/* shift, mask and dim the lights */
5789+
oldPixel = (((usqInt)(word)) >> shift) & mask;
5790+
word = ((word | (((usqInt)(mask) << shift))) - (((usqInt)(mask) << shift))) + (((sqInt)((usqInt)(pixel) << shift)));
5791+
storeLong32ofObjectwithValue((yVal * stride) + (xVal / ppW), bitmap, word);
5792+
if (!(failed())) {
5793+
methodReturnValue(positive32BitIntegerFor(oldPixel));
5794+
}
5795+
return null;
5796+
}
5797+
5798+
56995799
/* Invoke the warpBits primitive. If the destination is the display, then
57005800
copy it to the screen.
57015801
*/
@@ -6811,6 +6911,13 @@ setInterpreter(struct VirtualMachine *anInterpreter)
68116911
#endif
68126912
#endif
68136913
storeIntegerofObjectwithValue = interpreterProxy->storeIntegerofObjectwithValue;
6914+
#if VM_PROXY_MAJOR > 1 || (VM_PROXY_MAJOR == 1 && VM_PROXY_MINOR >= 16)
6915+
storeLong32ofObjectwithValue = interpreterProxy->storeLong32ofObjectwithValue;
6916+
#else
6917+
#if !defined(storeLong32ofObjectwithValue)
6918+
storeLong32ofObjectwithValue = 0;
6919+
#endif
6920+
#endif
68146921
#endif /* !defined(SQUEAK_BUILTIN_PLUGIN) */
68156922
}
68166923
return ok;
@@ -8276,6 +8383,7 @@ void* BitBltPlugin_exports[][3] = {
82768383
{(void*)_m, "primitiveDisplayString\000\001\000", (void*)primitiveDisplayString},
82778384
{(void*)_m, "primitiveDrawLoop\000\002\000", (void*)primitiveDrawLoop},
82788385
{(void*)_m, "primitivePixelValueAt\000\002\001", (void*)primitivePixelValueAt},
8386+
{(void*)_m, "primitivePixelValueAtPut\000\002\001", (void*)primitivePixelValueAtPut},
82798387
{(void*)_m, "primitiveWarpBits\000\001\000", (void*)primitiveWarpBits},
82808388
{(void*)_m, "setInterpreter", (void*)setInterpreter},
82818389
{NULL, NULL, NULL}
@@ -8289,6 +8397,7 @@ EXPORT(signed short) primitiveCopyBitsMetadata = 0x100;
82898397
EXPORT(signed short) primitiveDisplayStringMetadata = 0x100;
82908398
EXPORT(signed short) primitiveDrawLoopMetadata = 0x200;
82918399
EXPORT(signed short) primitivePixelValueAtMetadata = 513;
8400+
EXPORT(signed short) primitivePixelValueAtPutMetadata = 513;
82928401
EXPORT(signed short) primitiveWarpBitsMetadata = 0x100;
82938402
#endif // SPURVM
82948403

src/spur32.cog.lowcode/cogit.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* Automatically generated by
2-
CCodeGenerator VMMaker.oscog-eem.3174 uuid: 2edcc3c8-ba87-4012-b4f4-ea60094be91f
2+
CCodeGenerator VMMaker.oscog-eem.3183 uuid: c5c103b4-2c5c-44e7-8e32-030e79600ca6
33
*/
44

55

0 commit comments

Comments
 (0)