|
6 | 6 | #include <setjmp.h> |
7 | 7 |
|
8 | 8 | #include "sqAssert.h" |
| 9 | +#define FOR_SVM_C |
9 | 10 | #include "sqVirtualMachine.h" |
10 | 11 |
|
11 | 12 |
|
12 | | -/*** Function prototypes ***/ |
13 | | - |
14 | | -/* InterpreterProxy methodsFor: 'stack access' */ |
15 | | -sqInt pop(sqInt nItems); |
16 | | -sqInt popthenPush(sqInt nItems, sqInt oop); |
17 | | -sqInt push(sqInt object); |
18 | | -sqInt pushBool(sqInt trueOrFalse); |
19 | | -sqInt pushFloat(double f); |
20 | | -sqInt pushInteger(sqInt integerValue); |
21 | | -double stackFloatValue(sqInt offset); |
22 | | -sqInt stackIntegerValue(sqInt offset); |
23 | | -sqInt stackObjectValue(sqInt offset); |
24 | | -sqInt stackValue(sqInt offset); |
25 | | - |
26 | | -/*** variables ***/ |
27 | | - |
28 | | -/* InterpreterProxy methodsFor: 'object access' */ |
29 | | -sqInt argumentCountOf(sqInt methodPointer); |
30 | | -void *arrayValueOf(sqInt oop); |
31 | | -sqInt byteSizeOf(sqInt oop); |
32 | | -void *fetchArrayofObject(sqInt fieldIndex, sqInt objectPointer); |
33 | | -sqInt fetchClassOf(sqInt oop); |
34 | | -double fetchFloatofObject(sqInt fieldIndex, sqInt objectPointer); |
35 | | -sqInt fetchIntegerofObject(sqInt fieldIndex, sqInt objectPointer); |
36 | | -sqInt fetchPointerofObject(sqInt index, sqInt oop); |
37 | | -#if OLD_FOR_REFERENCE /* slot repurposed for error */ |
38 | | -/* sqInt fetchWordofObject(sqInt fieldIndex, sqInt oop); * |
39 | | - * has been rescinded as of VMMaker 3.8 and the 64bitclean VM * |
40 | | - * work. To support old plugins we keep a valid function in * |
41 | | - * the same location in the VM struct but rename it to * |
42 | | - * something utterly horrible to scare off the natives. A new * |
43 | | - * equivalent but 64 bit valid function is added as * |
44 | | - * 'fetchLong32OfObject' */ |
45 | | -sqInt obsoleteDontUseThisFetchWordofObject(sqInt index, sqInt oop); |
46 | | -#endif |
47 | | -sqInt fetchLong32ofObject(sqInt index, sqInt oop); |
48 | | -void *firstFixedField(sqInt oop); |
49 | | -void *firstIndexableField(sqInt oop); |
50 | | -sqInt literalofMethod(sqInt offset, sqInt methodPointer); |
51 | | -sqInt literalCountOf(sqInt methodPointer); |
52 | | -sqInt methodArgumentCount(void); |
53 | | -sqInt methodPrimitiveIndex(void); |
54 | | -sqInt primitiveMethod(void); |
55 | | -sqInt primitiveIndexOf(sqInt methodPointer); |
56 | | -sqInt sizeOfSTArrayFromCPrimitive(void *cPtr); |
57 | | -sqInt slotSizeOf(sqInt oop); |
58 | | -sqInt stObjectat(sqInt array, sqInt index); |
59 | | -sqInt stObjectatput(sqInt array, sqInt index, sqInt value); |
60 | | -sqInt stSizeOf(sqInt oop); |
61 | | -sqInt storeIntegerofObjectwithValue(sqInt index, sqInt oop, sqInt integer); |
62 | | -sqInt storePointerofObjectwithValue(sqInt index, sqInt oop, sqInt valuePointer); |
63 | | - |
64 | | - |
65 | | -/* InterpreterProxy methodsFor: 'testing' */ |
66 | | -sqInt isKindOf(sqInt oop, char *aString); |
67 | | -sqInt isMemberOf(sqInt oop, char *aString); |
68 | | -sqInt isBytes(sqInt oop); |
69 | | -sqInt isFloatObject(sqInt oop); |
70 | | -sqInt isIndexable(sqInt oop); |
71 | | -sqInt isIntegerObject(sqInt oop); |
72 | | -sqInt isIntegerValue(sqInt intValue); |
73 | | -sqInt isPointers(sqInt oop); |
74 | | -sqInt isWeak(sqInt oop); |
75 | | -sqInt isWords(sqInt oop); |
76 | | -sqInt isWordsOrBytes(sqInt oop); |
77 | | -sqInt includesBehaviorThatOf(sqInt aClass, sqInt aSuperClass); |
78 | | -#if VM_PROXY_MINOR > 10 |
79 | | -sqInt isKindOfClass(sqInt oop, sqInt aClass); |
80 | | -sqInt primitiveErrorTable(void); |
81 | | -sqInt primitiveFailureCode(void); |
82 | | -sqInt instanceSizeOf(sqInt aClass); |
83 | | -void tenuringIncrementalGC(void); |
84 | | -#endif |
85 | | -sqInt isArray(sqInt oop); |
86 | | -sqInt isOopMutable(sqInt oop); |
87 | | -sqInt isOopImmutable(sqInt oop); |
88 | | - |
89 | | -/* InterpreterProxy methodsFor: 'converting' */ |
90 | | -sqInt booleanValueOf(sqInt obj); |
91 | | -sqInt checkedIntegerValueOf(sqInt intOop); |
92 | | -sqInt floatObjectOf(double aFloat); |
93 | | -double floatValueOf(sqInt oop); |
94 | | -sqInt integerObjectOf(sqInt value); |
95 | | -sqInt integerValueOf(sqInt oop); |
96 | | -sqInt positive32BitIntegerFor(unsigned int integerValue); |
97 | | -usqInt positive32BitValueOf(sqInt oop); |
98 | | -sqInt signed32BitIntegerFor(sqInt integerValue); |
99 | | -int signed32BitValueOf(sqInt oop); |
100 | | -sqInt positive64BitIntegerFor(usqLong integerValue); |
101 | | -usqLong positive64BitValueOf(sqInt oop); |
102 | | -sqInt signed64BitIntegerFor(sqLong integerValue); |
103 | | -sqLong signed64BitValueOf(sqInt oop); |
104 | | -sqIntptr_t signedMachineIntegerValueOf(sqInt); |
105 | | -sqIntptr_t stackSignedMachineIntegerValue(sqInt); |
106 | | -usqIntptr_t positiveMachineIntegerValueOf(sqInt); |
107 | | -usqIntptr_t stackPositiveMachineIntegerValue(sqInt); |
108 | | - |
109 | | -/* InterpreterProxy methodsFor: 'special objects' */ |
110 | | -sqInt characterTable(void); |
111 | | -sqInt displayObject(void); |
112 | | -sqInt falseObject(void); |
113 | | -sqInt nilObject(void); |
114 | | -sqInt trueObject(void); |
115 | | - |
116 | | - |
117 | | -/* InterpreterProxy methodsFor: 'special classes' */ |
118 | | -sqInt classArray(void); |
119 | | -sqInt classBitmap(void); |
120 | | -sqInt classByteArray(void); |
121 | | -sqInt classCharacter(void); |
122 | | -sqInt classFloat(void); |
123 | | -sqInt classLargePositiveInteger(void); |
124 | | -sqInt classLargeNegativeInteger(void); |
125 | | -sqInt classPoint(void); |
126 | | -sqInt classSemaphore(void); |
127 | | -sqInt classSmallInteger(void); |
128 | | -sqInt classString(void); |
129 | | - |
130 | | - |
131 | | -/* InterpreterProxy methodsFor: 'instance creation' */ |
132 | | -sqInt clone(sqInt oop); |
133 | | -sqInt instantiateClassindexableSize(sqInt classPointer, sqInt size); |
134 | | -sqInt makePointwithxValueyValue(sqInt xValue, sqInt yValue); |
135 | | -sqInt popRemappableOop(void); |
136 | | -sqInt pushRemappableOop(sqInt oop); |
137 | | - |
138 | | - |
139 | | -/* InterpreterProxy methodsFor: 'other' */ |
140 | | -sqInt becomewith(sqInt array1, sqInt array2); |
141 | | -sqInt byteSwapped(sqInt w); |
142 | | -sqInt failed(void); |
143 | | -sqInt fullDisplayUpdate(void); |
144 | | -void fullGC(void); |
145 | | -void incrementalGC(void); |
146 | | -sqInt primitiveFail(void); |
147 | | -sqInt primitiveFailFor(sqInt reasonCode); |
148 | | -sqInt showDisplayBitsLeftTopRightBottom(sqInt aForm, sqInt l, sqInt t, sqInt r, sqInt b); |
149 | | -sqInt signalSemaphoreWithIndex(sqInt semaIndex); |
150 | | -sqInt success(sqInt aBoolean); |
151 | | -sqInt superclassOf(sqInt classPointer); |
152 | | -sqInt ioMicroMSecs(void); |
153 | | -unsigned long long ioUTCMicroseconds(void); |
154 | | -unsigned long long ioUTCMicrosecondsNow(void); |
155 | | -void forceInterruptCheck(void); |
156 | | -sqInt getThisSessionID(void); |
157 | | -sqInt ioFilenamefromStringofLengthresolveAliases(char* aCharBuffer, char* filenameIndex, sqInt filenameLength, sqInt resolveFlag); |
158 | | -sqInt vmEndianness(void); |
159 | | -sqInt getInterruptPending(void); |
160 | | -void error(const char *); |
161 | | - |
162 | | -/* InterpreterProxy methodsFor: 'BitBlt support' */ |
163 | | -sqInt loadBitBltFrom(sqInt bbOop); |
164 | | -sqInt copyBits(void); |
165 | | -sqInt copyBitsFromtoat(sqInt leftX, sqInt rightX, sqInt yValue); |
166 | | - |
167 | | -/* InterpreterProxy methodsFor: 'FFI support' */ |
168 | | -sqInt classExternalAddress(void); |
169 | | -sqInt classExternalData(void); |
170 | | -sqInt classExternalFunction(void); |
171 | | -sqInt classExternalLibrary(void); |
172 | | -sqInt classExternalStructure(void); |
173 | | -void *ioLoadModuleOfLength(sqInt moduleNameIndex, sqInt moduleNameLength); |
174 | | -void *ioLoadSymbolOfLengthFromModule(sqInt functionNameIndex, sqInt functionNameLength, sqInt moduleHandle); |
175 | | -sqInt isInMemory(sqInt address); |
176 | | -sqInt classAlien(void); /* Alien FFI */ |
177 | | -sqInt classUnsafeAlien(void); /* Alien FFI */ |
178 | | -sqInt *getStackPointer(void); /* Newsqueak FFI */ |
179 | | -void *startOfAlienData(sqInt); |
180 | | -usqInt sizeOfAlienData(sqInt); |
181 | | -sqInt signalNoResume(sqInt); |
182 | | -#if VM_PROXY_MINOR > 8 |
183 | | -sqInt *getStackPointer(void); /* Alien FFI */ |
184 | | -sqInt sendInvokeCallbackStackRegistersJmpbuf(sqInt thunkPtrAsInt, sqInt stackPtrAsInt, sqInt regsPtrAsInt, sqInt jmpBufPtrAsInt); /* Alien FFI */ |
185 | | -sqInt reestablishContextPriorToCallback(sqInt callbackContext); /* Alien FFI */ |
186 | | -sqInt sendInvokeCallbackContext(vmccp); |
187 | | -sqInt returnAsThroughCallbackContext(int, vmccp, sqInt); |
188 | | -#endif /* VM_PROXY_MINOR > 8 */ |
189 | | -#if VM_PROXY_MINOR > 12 /* Spur */ |
190 | | -sqInt isImmediate(sqInt oop); |
191 | | -sqInt isCharacterObject(sqInt oop); |
192 | | -sqInt isCharacterValue(int charCode); |
193 | | -sqInt characterObjectOf(int charCode); |
194 | | -sqInt characterValueOf(sqInt oop); |
195 | | -sqInt isPinned(sqInt objOop); |
196 | | -sqInt pinObject(sqInt objOop); |
197 | | -sqInt unpinObject(sqInt objOop); |
198 | | -char *cStringOrNullFor(sqInt); |
199 | | -#endif |
200 | | -#if VM_PROXY_MINOR > 13 /* More Spur + OS Errors available via prim error code */ |
201 | | -sqInt statNumGCs(void); |
202 | | -sqInt stringForCString(char *); |
203 | | -sqInt primitiveFailForOSError(sqLong); |
204 | | -sqInt primitiveFailForFFIExceptionat(usqLong exceptionCode, usqInt pc); |
205 | | -#endif |
206 | | -#if VM_PROXY_MINOR > 14 /* SmartSyntaxPlugin validation rewrite support */ |
207 | | -sqInt isBooleanObject(sqInt oop); |
208 | | -sqInt isPositiveMachineIntegerObject(sqInt oop); |
209 | | -#endif |
210 | | -#if VM_PROXY_MINOR > 15 /* Spur integer and float array classes */ |
211 | | -sqInt classDoubleByteArray(void); |
212 | | -sqInt classWordArray(void); |
213 | | -sqInt classDoubleWordArray(void); |
214 | | -sqInt classFloat32Array(void); |
215 | | -sqInt classFloat64Array(void); |
216 | | -#endif |
217 | | -#if VM_PROXY_MINOR > 16 /* Spur isShorts and isLong64s testing support, hash */ |
218 | | -sqInt isShorts(sqInt); |
219 | | -sqInt isLong64s(sqInt); |
220 | | -sqInt identityHashOf(sqInt); |
221 | | -sqInt isWordsOrShorts(sqInt); |
222 | | -sqInt bytesPerElement(sqInt); |
223 | | -sqInt fileTimesInUTC(void); |
224 | | -#endif |
225 | | - |
226 | | -void *ioLoadFunctionFrom(char *fnName, char *modName); |
227 | | - |
228 | | - |
229 | | -/* Proxy declarations for v1.8 */ |
230 | | -#if NewspeakVM |
231 | | -static sqInt |
232 | | -callbackEnter(sqInt *callbackID) { return 0; } |
233 | | -static sqInt |
234 | | -callbackLeave(sqInt callbackID) { return 0; } |
235 | | -#else |
236 | | -sqInt callbackEnter(sqInt *callbackID); |
237 | | -sqInt callbackLeave(sqInt callbackID); |
238 | | -#endif |
239 | | -sqInt addGCRoot(sqInt *varLoc); |
240 | | -sqInt removeGCRoot(sqInt *varLoc); |
241 | | - |
242 | | -/* Proxy declarations for v1.10 */ |
243 | | -# if VM_PROXY_MINOR > 13 /* OS Errors available in primitives; easy return forms */ |
244 | | -sqInt methodReturnBool(sqInt); |
245 | | -sqInt methodReturnFloat(double); |
246 | | -sqInt methodReturnInteger(sqInt); |
247 | | -sqInt methodReturnReceiver(void); |
248 | | -sqInt methodReturnString(char *); |
249 | | -# else |
250 | | -sqInt methodArg(sqInt index); |
251 | | -sqInt objectArg(sqInt index); |
252 | | -sqInt integerArg(sqInt index); |
253 | | -double floatArg(sqInt index); |
254 | | -#endif |
255 | | -sqInt methodReturnValue(sqInt oop); |
256 | | -sqInt topRemappableOop(void); |
257 | | - |
258 | 13 | struct VirtualMachine *VM = NULL; |
259 | 14 |
|
260 | | -static sqInt majorVersion(void) { |
261 | | - return VM_PROXY_MAJOR; |
262 | | -} |
| 15 | +static sqInt majorVersion(void) { return VM_PROXY_MAJOR; } |
263 | 16 |
|
264 | | -static sqInt minorVersion(void) { |
265 | | - return VM_PROXY_MINOR; |
266 | | -} |
| 17 | +static sqInt minorVersion(void) { return VM_PROXY_MINOR; } |
267 | 18 |
|
268 | 19 | #if !IMMUTABILITY |
269 | 20 | static sqInt isNonIntegerObject(sqInt objectPointer) |
|
0 commit comments