Skip to content

Commit b8c7c7e

Browse files
committed
CogVM source as per VMMaker.oscog-eem.3664
Interpreter: Eliminate PrimNumberClosureValueNoContextSwitch & PrimNumberFullClosureValueNoContextSwitch in favour of direct comparison against the two primitives, since there are two indices devoted to primitiveClosureValueNoContextSwitch. Delete obsolete window manipulation primitives that have long since migrated to the HostWindowPlugin. There is no need to use runBlockOnMainThread: in macOS's ioScreenScaleFactor since it uses getMainWindowDelegate which uses runBlockOnMainThread:. Make clear the order of the primitive log in crash dumps. Fix a slip in assertValidExternalFrameWithIP: that shows up in simulation. FilePlugin: Change the width of lastChar in SQFile from char to short to avoid a clang insistence on comparison between a char and -1 being always false (??). -1 being EOF, and lastChar needing to hold EOF, make lastChar a short. Avoid changing the size of SQFile by changing two char flags to 1 bit fields. BitBltPlugin: some simplifications now that Slang is improved. Part of sneaking up on a clipping bug. Forgive the noise.
1 parent 4c9719c commit b8c7c7e

Some content is hidden

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

53 files changed

+851
-7632
lines changed

platforms/Cross/plugins/FilePlugin/FilePlugin.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,18 @@ typedef int mode_t;
3232

3333
/* squeak file record; see sqFilePrims.c for details */
3434
typedef struct {
35-
int sessionID; /* ikp: must be first */
36-
void *file;
35+
int sessionID; /* ikp: must be first */
36+
void *file;
37+
short lastChar; // Must be comparable against EOF, which is -1, but
38+
// e.g. clang refuses to do this with a char variable
3739
#if defined(ACORN)
3840
// ACORN has to have 'lastOp' as at least a 32 bit field in order to work
39-
int lastOp; // actually used to save file position
40-
char writable;
41-
char lastChar;
42-
char isStdioStream;
41+
int lastOp; // actually used to save file position
4342
#else
44-
char writable;
45-
char lastOp; /* 0 = uncommitted, 1 = read, 2 = write */
46-
char lastChar;
47-
char isStdioStream;
43+
char lastOp; /* 0 = uncommitted, 1 = read, 2 = write */
4844
#endif
45+
unsigned writable : 1;
46+
unsigned isStdioStream : 1;
4947
} SQFile;
5048

5149
/* file i/o */

platforms/Cross/plugins/FilePlugin/sqFilePluginBasicPrims.c

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@
7676
positioning operation to be done automatically if needed.
7777
7878
typedef struct {
79-
int sessionID;
80-
File *file;
81-
char writable;
82-
char lastOp; // 0 = uncommitted, 1 = read, 2 = write //
83-
char lastChar; // one character peek for stdin //
84-
char isStdioStream;
79+
int sessionID;
80+
File *file;
81+
short lastChar; // one character peek for stdin; short to bow down to clang
82+
char lastOp; // 0 = uncommitted, 1 = read, 2 = write
83+
unsigned writable : 1;
84+
unsigned isStdioStream : 1;
8585
} SQFile;
8686
8787
***/
@@ -92,9 +92,9 @@
9292
#define WRITE_OP 2
9393

9494
#ifndef SEEK_SET
95-
#define SEEK_SET 0
96-
#define SEEK_CUR 1
97-
#define SEEK_END 2
95+
# define SEEK_SET 0
96+
# define SEEK_CUR 1
97+
# define SEEK_END 2
9898
#endif
9999

100100
/*** Variables ***/
@@ -109,17 +109,13 @@ static FILE *
109109
getFile(SQFile *f)
110110
{
111111
FILE *file;
112-
void *in= (void *)&f->file;
113-
void *out= (void *)&file;
114-
memcpy(out, in, sizeof(FILE *));
112+
memcpy(&file, &f->file, sizeof(FILE *));
115113
return file;
116114
}
117115
static void
118116
setFile(SQFile *f, FILE *file)
119117
{
120-
void *in= (void *)&file;
121-
void *out= (void *)&f->file;
122-
memcpy(out, in, sizeof(FILE *));
118+
memcpy(&f->file, &file, sizeof(FILE *));
123119
}
124120
#else /* OBJECTS_32BIT_ALIGNED */
125121
# define getFile(f) ((FILE *)((f)->file))

platforms/Cross/vm/sq.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,6 @@ sqInt ioHasDisplayDepth(sqInt depth);
244244
sqInt ioSetDisplayMode(sqInt width, sqInt height, sqInt depth, sqInt fullscreenFlag);
245245
char* ioGetLogDirectory(void);
246246
sqInt ioSetLogDirectoryOfSize(void* lblIndex, sqInt sz);
247-
char* ioGetWindowLabel(void);
248-
sqInt ioSetWindowLabelOfSize(void *lblIndex, sqInt sz);
249-
sqInt ioGetWindowWidth(void);
250-
sqInt ioGetWindowHeight(void);
251-
sqInt ioSetWindowWidthHeight(sqInt w, sqInt h);
252247
sqInt ioIsWindowObscured(void);
253248

254249
sqInt ioRelinquishProcessorForMicroseconds(sqInt microSeconds);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ Some of this code was funded via a grant from the European Smalltalk User Group
230230
else
231231
fprintf(file,"\nCan't dump Smalltalk stack(s). Not in VM or GUI thread\n");
232232
# if STACKVM
233-
fprintf(file,"\nMost recent primitives\n");
233+
fprintf(file,"\nMost recent primitives (oldest first)\n");
234234
dumpPrimTraceLogOn(file);
235235
# if COGVM
236236
fprintf(file,"\n");

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

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,9 @@ Some of this code was funded via a grant from the European Smalltalk User Group
6767
}
6868

6969
double ioScreenScaleFactor(void) {
70-
//API Documented
71-
__block double answer;
70+
//API
7271

73-
[gDelegateApp runBlockOnMainThread:^{
74-
answer = [getMainWindowDelegate() ioScreenScaleFactor];
75-
}];
76-
return answer;
72+
return [getMainWindowDelegate() ioScreenScaleFactor];
7773
}
7874

7975
sqInt ioScreenSize(void) {
@@ -137,23 +133,6 @@ sqInt ioShowDisplay(
137133
}
138134

139135

140-
char *ioGetWindowLabel(void)
141-
{
142-
return [getMainWindowDelegate() ioGetTitle];
143-
}
144-
145-
sqInt ioSetWindowLabelOfSize(void *lblIndex, sqInt sz)
146-
{
147-
[getMainWindowDelegate() ioSetTitle: lblIndex length: sz];
148-
return 1;
149-
}
150-
151-
sqInt ioGetWindowWidth(void) { return 0; }
152-
153-
sqInt ioGetWindowHeight(void) { return 0; }
154-
155-
sqInt ioSetWindowWidthHeight(sqInt w, sqInt h) { return 0; }
156-
157136
sqInt ioIsWindowObscured(void) { return 0; }
158137

159138
/* This is invoked when the GC moves the display bitmap. For now do nothing. */

platforms/iOS/vm/OSX/sqSqueakOSXApplication+cursor.m

Lines changed: 27 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,13 @@ - (void) setCursor: (sqInt) cursorBitsIndex withMask: (sqInt) cursorMaskIndex
7373
bytesPerRow: 2
7474
bitsPerPixel: 0]);
7575

76-
unsigned char* planes[5];
76+
unsigned char *planes[5];
7777
[bitmap getBitmapDataPlanes:planes];
7878

79-
unsigned char* data;
80-
unsigned char* mask;
81-
data=planes[0];
82-
mask=planes[1];
79+
unsigned char *data = planes[0];
80+
unsigned char *mask = planes[1];
8381

84-
for (int i= 0; i < 16; ++i) {
82+
for (int i = 0; i < 16; ++i) {
8583
unsigned int word= ((unsigned int *)pointerForOop(cursorBitsIndex))[i];
8684
data[i*2 + 0]= 0xFF ^ ((word >> 24) & 0xFF);
8785
data[i*2 + 1]= 0xFF ^ ((word >> 16) & 0xFF);
@@ -90,24 +88,17 @@ - (void) setCursor: (sqInt) cursorBitsIndex withMask: (sqInt) cursorMaskIndex
9088
word= ((unsigned int *)pointerForOop(cursorMaskIndex))[i];
9189
else
9290
word = 0xFFFFFFFF;
93-
91+
9492
mask[i*2 + 0]= (word >> 24) & 0xFF;
9593
mask[i*2 + 1]= (word >> 16) & 0xFF;
9694
}
9795

9896
NSImage *image = AUTORELEASEOBJ([[NSImage alloc] init]);
9997
[image addRepresentation: bitmap];
100-
101-
98+
10299
NSPoint hotSpot= { -offsetX, -offsetY };
103100
self.squeakCursor = AUTORELEASEOBJ([[NSCursor alloc] initWithImage: image hotSpot: hotSpot]);
104101

105-
/* if (browserActiveAndDrawingContextOkAndNOTInFullScreenMode())
106-
browserSetCursor(&macCursor);
107-
*/
108-
#warning what about browser
109-
110-
111102
if (!gSqueakHeadless || browserActiveAndDrawingContextOkAndInFullScreenMode())
112103
[gDelegateApp runBlockAsyncOnMainThread:^{
113104
@try {
@@ -127,32 +118,31 @@ - (sqInt) ioSetCursorARGB: (sqInt) cursorBitsIndex extentX: (sqInt) extentX exte
127118
return 0;
128119

129120
@autoreleasepool {
130-
131-
NSBitmapImageRep *bitmap= AUTORELEASEOBJ([[NSBitmapImageRep alloc]
132-
initWithBitmapDataPlanes: NULL pixelsWide: extentX pixelsHigh: extentY
133-
bitsPerSample: 8 samplesPerPixel: 4
134-
hasAlpha: YES isPlanar: NO
135-
colorSpaceName: NSCalibratedRGBColorSpace
136-
bytesPerRow: extentX * 4
137-
bitsPerPixel: 0]);
138-
unsigned int *planes[5];
139-
[bitmap getBitmapDataPlanes: (unsigned char **) planes];
140-
unsigned int *src= (unsigned int*) pointerForOop(cursorBitsIndex);
141-
unsigned int *dst= planes[0];
142-
sqInt i;
143-
for (i= 0; i < extentX * extentY; ++i, ++dst, ++src) {
121+
122+
NSBitmapImageRep *bitmap= AUTORELEASEOBJ([[NSBitmapImageRep alloc]
123+
initWithBitmapDataPlanes: NULL pixelsWide: extentX pixelsHigh: extentY
124+
bitsPerSample: 8 samplesPerPixel: 4
125+
hasAlpha: YES isPlanar: NO
126+
colorSpaceName: NSCalibratedRGBColorSpace
127+
bytesPerRow: extentX * 4
128+
bitsPerPixel: 0]);
129+
unsigned int *planes[5];
130+
[bitmap getBitmapDataPlanes: (unsigned char **) planes];
131+
unsigned int *src= (unsigned int*) pointerForOop(cursorBitsIndex);
132+
unsigned int *dst= planes[0];
133+
for (sqInt i = 0; i < extentX * extentY; ++i, ++dst, ++src) {
144134
#if VMENDIANNESS
145-
*dst= ((*src & 0xFF000000) >> 24) | ((*src & 0x00FFFFFF) << 8) ; // ARGB to RGBA
135+
*dst= ((*src & 0xFF000000) >> 24) | ((*src & 0x00FFFFFF) << 8) ; // ARGB to RGBA
146136
#else
147-
*dst= (*src & 0xFF00FF00) | ((*src & 0x000000FF) << 16) | ((*src & 0x00FF0000) >> 16); // BGRA to RGBA
137+
*dst= (*src & 0xFF00FF00) | ((*src & 0x000000FF) << 16) | ((*src & 0x00FF0000) >> 16); // BGRA to RGBA
148138
#endif
139+
}
140+
NSImage *image= AUTORELEASEOBJ([[NSImage alloc] init]);
141+
[image addRepresentation: bitmap];
142+
NSPoint hotSpot= { -offsetX, -offsetY };
143+
self.squeakCursor = AUTORELEASEOBJ([[NSCursor alloc] initWithImage: image hotSpot: hotSpot]);
144+
[gDelegateApp runBlockAsyncOnMainThread:^{ [self.squeakCursor set]; }];
149145
}
150-
NSImage *image= AUTORELEASEOBJ([[NSImage alloc] init]);
151-
[image addRepresentation: bitmap];
152-
NSPoint hotSpot= { -offsetX, -offsetY };
153-
self.squeakCursor = AUTORELEASEOBJ([[NSCursor alloc] initWithImage: image hotSpot: hotSpot]);
154-
[gDelegateApp runBlockAsyncOnMainThread:^{ [self.squeakCursor set]; }];
155-
}
156146
return 1;
157147
}
158148
@end

platforms/minheadless/common/sqWindow-Dispatch.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -138,30 +138,6 @@ ioSetDisplayMode(sqInt width, sqInt height, sqInt depth, sqInt fullscreenFlag)
138138
return currentWindowSystem->setDisplayMode(width, height, depth, fullscreenFlag);
139139
}
140140

141-
char*
142-
ioGetWindowLabel(void)
143-
{
144-
return currentWindowSystem->getWindowLabel();
145-
}
146-
147-
sqInt
148-
ioSetWindowLabelOfSize(void *lblIndex, sqInt sz)
149-
{
150-
return currentWindowSystem->setWindowLabelOfSize(lblIndex, sz);
151-
}
152-
153-
sqInt
154-
ioGetWindowWidth(void)
155-
{
156-
return currentWindowSystem->getWindowWidth();
157-
}
158-
159-
sqInt
160-
ioGetWindowHeight(void)
161-
{
162-
return currentWindowSystem->getWindowHeight();
163-
}
164-
165141
sqInt
166142
ioSetWindowWidthHeight(sqInt w, sqInt h)
167143
{

platforms/minheadless/common/sqWindow-Null.c

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -91,30 +91,6 @@ sqNull_setDisplayMode(sqInt width, sqInt height, sqInt depth, sqInt fullscreenFl
9191
return 0;
9292
}
9393

94-
static char*
95-
sqNull_getWindowLabel(void)
96-
{
97-
return "";
98-
}
99-
100-
static sqInt
101-
sqNull_setWindowLabelOfSize(void *lblIndex, sqInt sz)
102-
{
103-
return 0;
104-
}
105-
106-
static sqInt
107-
sqNull_getWindowWidth(void)
108-
{
109-
return currentDisplayWidth;
110-
}
111-
112-
static sqInt
113-
sqNull_getWindowHeight(void)
114-
{
115-
return currentDisplayHeight;
116-
}
117-
11894
static sqInt
11995
sqNull_setWindowWidthHeight(sqInt w, sqInt h)
12096
{
@@ -226,10 +202,6 @@ sqWindowSystem sqNullWindowSystem = {
226202
.showDisplay = sqNull_showDisplay,
227203
.hasDisplayDepth = sqNull_hasDisplayDepth,
228204
.setDisplayMode = sqNull_setDisplayMode,
229-
.getWindowLabel = sqNull_getWindowLabel,
230-
.setWindowLabelOfSize = sqNull_setWindowLabelOfSize,
231-
.getWindowWidth = sqNull_getWindowWidth,
232-
.getWindowHeight = sqNull_getWindowHeight,
233205
.setWindowWidthHeight = sqNull_setWindowWidthHeight,
234206
.isWindowObscured = sqNull_isWindowObscured,
235207
.getNextEvent = sqNull_getNextEvent,

platforms/minheadless/common/sqWindow.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,6 @@ typedef struct
3535

3636
sqInt (*setDisplayMode)(sqInt width, sqInt height, sqInt depth, sqInt fullscreenFlag);
3737

38-
char* (*getWindowLabel)(void);
39-
40-
sqInt (*setWindowLabelOfSize)(void *lblIndex, sqInt sz);
41-
42-
sqInt (*getWindowWidth)(void);
43-
44-
sqInt (*getWindowHeight)(void);
45-
4638
sqInt (*setWindowWidthHeight)(sqInt w, sqInt h);
4739

4840
sqInt (*isWindowObscured)(void);

platforms/minheadless/sdl2-window/sqWindow-SDL2.c

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -846,47 +846,6 @@ sqSDL2_setDisplayMode(sqInt width, sqInt height, sqInt depth, sqInt fullscreenFl
846846
return 0;
847847
}
848848

849-
static char*
850-
sqSDL2_getWindowLabel(void)
851-
{
852-
return (char*)SDL_GetWindowTitle(window);
853-
}
854-
855-
static sqInt
856-
sqSDL2_setWindowLabelOfSize(void *lblIndex, sqInt size)
857-
{
858-
char *buffer;
859-
860-
buffer = (char*)malloc(size + 1);
861-
memcpy(buffer, lblIndex, size);
862-
buffer[size] = 0;
863-
864-
SDL_SetWindowTitle(window, buffer);
865-
866-
free(buffer);
867-
return 0;
868-
}
869-
870-
static sqInt
871-
sqSDL2_getWindowWidth(void)
872-
{
873-
int width = 0;
874-
int height = 0;
875-
if(windowRenderer)
876-
SDL_GetRendererOutputSize(windowRenderer, &width, &height);
877-
return width;
878-
}
879-
880-
static sqInt
881-
sqSDL2_getWindowHeight(void)
882-
{
883-
int width = 0;
884-
int height = 0;
885-
if(windowRenderer)
886-
SDL_GetRendererOutputSize(windowRenderer, &width, &height);
887-
return height;
888-
}
889-
890849
static sqInt
891850
sqSDL2_setWindowWidthHeight(sqInt w, sqInt h)
892851
{
@@ -1135,10 +1094,6 @@ sqWindowSystem sqSDL2WindowSystem = {
11351094
.showDisplay = sqSDL2_showDisplay,
11361095
.hasDisplayDepth = sqSDL2_hasDisplayDepth,
11371096
.setDisplayMode = sqSDL2_setDisplayMode,
1138-
.getWindowLabel = sqSDL2_getWindowLabel,
1139-
.setWindowLabelOfSize = sqSDL2_setWindowLabelOfSize,
1140-
.getWindowWidth = sqSDL2_getWindowWidth,
1141-
.getWindowHeight = sqSDL2_getWindowHeight,
11421097
.setWindowWidthHeight = sqSDL2_setWindowWidthHeight,
11431098
.isWindowObscured = sqSDL2_isWindowObscured,
11441099
.getNextEvent = sqSDL2_getNextEvent,

0 commit comments

Comments
 (0)