/src/moddable/xs/sources/xsRun.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2016-2025 Moddable Tech, Inc. |
3 | | * |
4 | | * This file is part of the Moddable SDK Runtime. |
5 | | * |
6 | | * The Moddable SDK Runtime is free software: you can redistribute it and/or modify |
7 | | * it under the terms of the GNU Lesser General Public License as published by |
8 | | * the Free Software Foundation, either version 3 of the License, or |
9 | | * (at your option) any later version. |
10 | | * |
11 | | * The Moddable SDK Runtime is distributed in the hope that it will be useful, |
12 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | | * GNU Lesser General Public License for more details. |
15 | | * |
16 | | * You should have received a copy of the GNU Lesser General Public License |
17 | | * along with the Moddable SDK Runtime. If not, see <http://www.gnu.org/licenses/>. |
18 | | * |
19 | | * This file incorporates work covered by the following copyright and |
20 | | * permission notice: |
21 | | * |
22 | | * Copyright (C) 2010-2016 Marvell International Ltd. |
23 | | * Copyright (C) 2002-2010 Kinoma, Inc. |
24 | | * |
25 | | * Licensed under the Apache License, Version 2.0 (the "License"); |
26 | | * you may not use this file except in compliance with the License. |
27 | | * You may obtain a copy of the License at |
28 | | * |
29 | | * http://www.apache.org/licenses/LICENSE-2.0 |
30 | | * |
31 | | * Unless required by applicable law or agreed to in writing, software |
32 | | * distributed under the License is distributed on an "AS IS" BASIS, |
33 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
34 | | * See the License for the specific language governing permissions and |
35 | | * limitations under the License. |
36 | | */ |
37 | | |
38 | | #include "xsAll.h" |
39 | | |
40 | | //#define mxTrace 1 |
41 | | //#define mxTraceCall 1 |
42 | | |
43 | | #define c_iszero(NUMBER) (C_FP_ZERO == c_fpclassify(NUMBER)) |
44 | | |
45 | | static void fxRunArguments(txMachine* the, txIndex offset); |
46 | | static void fxRunBase(txMachine* the); |
47 | | static void fxRunConstructor(txMachine* the); |
48 | | static txBoolean fxRunDefine(txMachine* the, txSlot* instance, txSlot* check, txID id, txIndex index, txSlot* slot, txFlag mask); |
49 | | static txBoolean fxRunDelete(txMachine* the, txSlot* instance, txID id, txIndex index); |
50 | | static void fxRunDerived(txMachine* the); |
51 | | static void fxRunExtends(txMachine* the); |
52 | | static void fxRunForOf(txMachine* the); |
53 | | static txBoolean fxRunHas(txMachine* the, txSlot* instance, txID id, txIndex index); |
54 | | static void fxRunIn(txMachine* the); |
55 | | static void fxRunInstantiate(txMachine* the); |
56 | | static void fxRunProxy(txMachine* the, txSlot* instance); |
57 | | static void fxRunInstanceOf(txMachine* the); |
58 | | static void fxRunUsed(txMachine* the, txSlot* selector); |
59 | | static void fxRunUsing(txMachine* the); |
60 | | static void fxRunUsingAsync(txMachine* the); |
61 | | static txBoolean fxIsScopableSlot(txMachine* the, txSlot* instance, txID id); |
62 | | static txBoolean fxToNumericInteger(txMachine* the, txSlot* theSlot); |
63 | | static txBoolean fxToNumericIntegerUnary(txMachine* the, txSlot* theSlot, txBigIntUnary op); |
64 | | static txBoolean fxToNumericIntegerBinary(txMachine* the, txSlot* a, txSlot* b, txBigIntBinary op); |
65 | | static txBoolean fxToNumericNumber(txMachine* the, txSlot* theSlot); |
66 | | static txBoolean fxToNumericNumberUnary(txMachine* the, txSlot* theSlot, txBigIntUnary op); |
67 | | static txBoolean fxToNumericNumberBinary(txMachine* the, txSlot* a, txSlot* b, txBigIntBinary op); |
68 | | |
69 | | #if defined(__GNUC__) && defined(__OPTIMIZE__) |
70 | | #if defined(mxFrequency) |
71 | | #define mxBreak \ |
72 | | the->frequencies[byte]++; \ |
73 | | goto *bytes[byte] |
74 | | #elif defined(mxTrace) |
75 | | #define mxBreak \ |
76 | | if (gxDoTrace) fxTraceCode(the, stack, byte); \ |
77 | | goto *bytes[byte] |
78 | | #elif defined(mxMetering) |
79 | | #define mxBreak \ |
80 | 1.52G | the->meterIndex += XS_CODE_METERING; \ |
81 | 1.52G | goto *bytes[byte] |
82 | | #else |
83 | | #define mxBreak \ |
84 | | goto *bytes[byte] |
85 | | #endif |
86 | 1.60G | #define mxCase(OPCODE) OPCODE: |
87 | 1.21M | #define mxSwitch(OPCODE) mxBreak; |
88 | | #else |
89 | | #define mxBreak \ |
90 | | break |
91 | | #define mxCase(OPCODE) \ |
92 | | case OPCODE: |
93 | | #if defined(mxFrequency) |
94 | | #define mxSwitch(OPCODE) \ |
95 | | the->frequencies[OPCODE]++; \ |
96 | | switch(OPCODE) |
97 | | #else |
98 | | #define mxSwitch(OPCODE) \ |
99 | | switch(OPCODE) |
100 | | #endif |
101 | | #endif |
102 | | |
103 | 5.91G | #define mxCode code |
104 | 4.17G | #define mxFrame frame |
105 | 844M | #define mxEnvironment environment |
106 | 1.67G | #define mxScope scope |
107 | 7.26G | #define mxStack stack |
108 | | |
109 | 182M | #define mxFrameEnd (mxFrame + 5) |
110 | 15.0M | #define mxFrameThis (mxFrame + 4) |
111 | 2.65M | #define mxFrameFunction (mxFrame + 3) |
112 | 15.5M | #define mxFrameTarget (mxFrame + 2) |
113 | 226M | #define mxFrameResult (mxFrame + 1) |
114 | 5.64M | #define mxFrameArgc ((mxFrame - 1)->value.integer) |
115 | 4.79M | #define mxFrameArgv(THE_INDEX) (mxFrame - 2 - (THE_INDEX)) |
116 | | |
117 | 396M | #define mxRestoreState { \ |
118 | 396M | mxStack = the->stack; \ |
119 | 396M | mxScope = the->scope; \ |
120 | 396M | mxFrame = the->frame; \ |
121 | 396M | mxEnvironment = mxFrameToEnvironment(mxFrame); \ |
122 | 396M | mxCode = the->code; \ |
123 | 396M | } |
124 | 30.1M | #define mxRestoreStateKeepStack { \ |
125 | 30.1M | mxScope = the->scope; \ |
126 | 30.1M | mxFrame = the->frame; \ |
127 | 30.1M | mxEnvironment = mxFrameToEnvironment(mxFrame); \ |
128 | 30.1M | mxCode = the->code; \ |
129 | 30.1M | } |
130 | | #if defined(mxFrequency) |
131 | | #define mxSaveState { \ |
132 | | the->exits[byte]++; \ |
133 | | the->stack = mxStack; \ |
134 | | the->scope = mxScope; \ |
135 | | the->frame = mxFrame; \ |
136 | | the->code = mxCode; \ |
137 | | } |
138 | | #define mxSaveStateKeepStack { \ |
139 | | the->exits[byte]++; \ |
140 | | the->scope = mxScope; \ |
141 | | the->frame = mxFrame; \ |
142 | | the->code = mxCode; \ |
143 | | } |
144 | | #else |
145 | 534M | #define mxSaveState { \ |
146 | 534M | the->stack = mxStack; \ |
147 | 534M | the->scope = mxScope; \ |
148 | 534M | the->frame = mxFrame; \ |
149 | 534M | the->code = mxCode; \ |
150 | 534M | } |
151 | 30.1M | #define mxSaveStateKeepStack { \ |
152 | 30.1M | the->scope = mxScope; \ |
153 | 30.1M | the->frame = mxFrame; \ |
154 | 30.1M | the->code = mxCode; \ |
155 | 30.1M | } |
156 | | #endif |
157 | | |
158 | | #if mxBoundsCheck |
159 | | #define mxAllocStack(_COUNT) \ |
160 | 913M | if ((mxStack - _COUNT) < the->stackBottom) \ |
161 | 913M | goto STACK_OVERFLOW; \ |
162 | 913M | mxStack -= _COUNT |
163 | | #else |
164 | | #define mxAllocStack(_COUNT) \ |
165 | | mxStack -= _COUNT |
166 | | #endif |
167 | | |
168 | 603M | #define mxPushKind(_KIND) { \ |
169 | 603M | mxAllocStack(1); \ |
170 | 603M | mxStack->next = C_NULL; \ |
171 | 603M | mxInitSlotKind(mxStack, _KIND); \ |
172 | 603M | } |
173 | | |
174 | 8.92M | #define mxRunDebug(_ERROR, ...) { \ |
175 | 8.92M | mxSaveState; \ |
176 | 8.92M | fxThrowMessage(the, NULL, 0, _ERROR, __VA_ARGS__); \ |
177 | 8.92M | } |
178 | | |
179 | 0 | #define mxRunDebugID(_ERROR, _MESSAGE, _ID) { \ |
180 | 701k | mxSaveState; \ |
181 | 0 | fxIDToString(the, _ID, the->nameBuffer, sizeof(the->nameBuffer)); \ |
182 | 0 | fxThrowMessage(the, NULL, 0, _ERROR, _MESSAGE, the->nameBuffer); \ |
183 | 701k | } |
184 | | |
185 | | #define mxToBoolean(SLOT) \ |
186 | 8.23M | if (XS_BOOLEAN_KIND != (SLOT)->kind) { \ |
187 | 5.50M | if (XS_SYMBOL_KIND <= (SLOT)->kind) { \ |
188 | 1.42M | mxSaveState; \ |
189 | 1.42M | fxToBoolean(the, SLOT); \ |
190 | 1.42M | mxRestoreState; \ |
191 | 1.42M | } \ |
192 | 5.50M | else \ |
193 | 5.50M | fxToBoolean(the, SLOT); \ |
194 | 5.50M | } |
195 | | |
196 | | #define mxToInteger(SLOT) \ |
197 | | if (XS_INTEGER_KIND != (SLOT)->kind) { \ |
198 | | if (XS_STRING_KIND <= (SLOT)->kind) { \ |
199 | | mxSaveState; \ |
200 | | fxToInteger(the, SLOT); \ |
201 | | mxRestoreState; \ |
202 | | } \ |
203 | | else \ |
204 | | fxToInteger(the, SLOT); \ |
205 | | } |
206 | | |
207 | | #define mxToNumber(SLOT) \ |
208 | 4.67M | if (XS_NUMBER_KIND != (SLOT)->kind) { \ |
209 | 4.40M | if (XS_STRING_KIND <= (SLOT)->kind) { \ |
210 | 3.01M | mxSaveState; \ |
211 | 3.01M | fxToNumber(the, SLOT); \ |
212 | 3.01M | mxRestoreState; \ |
213 | 3.01M | } \ |
214 | 4.40M | else \ |
215 | 4.40M | fxToNumber(the, SLOT); \ |
216 | 4.40M | } |
217 | | |
218 | | #define mxToString(SLOT) \ |
219 | 3.18M | if ((XS_STRING_KIND != (SLOT)->kind) && (XS_STRING_X_KIND != (SLOT)->kind)) { \ |
220 | 2.98M | mxSaveState; \ |
221 | 2.98M | fxToString(the, SLOT); \ |
222 | 2.98M | mxRestoreState; \ |
223 | 2.98M | } |
224 | | |
225 | | #define mxToInstance(SLOT) \ |
226 | 255M | if (XS_REFERENCE_KIND != (SLOT)->kind) { \ |
227 | 22.5M | mxSaveState; \ |
228 | 22.5M | variable = fxToInstance(the, SLOT); \ |
229 | 22.5M | mxRestoreState; \ |
230 | 22.5M | primitive = 1; \ |
231 | 22.5M | } \ |
232 | 255M | else { \ |
233 | 233M | variable = (SLOT)->value.reference; \ |
234 | 233M | primitive = 0; \ |
235 | 233M | } |
236 | | |
237 | | #ifndef mxUnalignedAccess |
238 | | #define mxUnalignedAccess 1 |
239 | | #endif |
240 | | |
241 | 203M | #define mxRunS1(OFFSET) ((txS1*)mxCode)[OFFSET] |
242 | 213M | #define mxRunU1(OFFSET) ((txU1*)mxCode)[OFFSET] |
243 | | #if mxBigEndian |
244 | | #define mxRunS2(OFFSET) (((txS1*)mxCode)[OFFSET+0] << 8) | ((txU1*)mxCode)[OFFSET+1] |
245 | | #define mxRunS4(OFFSET) (((txS1*)mxCode)[OFFSET+0] << 24) | (((txU1*)mxCode)[OFFSET+1] << 16) | (((txU1*)mxCode)[OFFSET+2] << 8) | ((txU1*)mxCode)[OFFSET+3] |
246 | | #define mxRunU2(OFFSET) (((txU1*)mxCode)[OFFSET+0] << 8) | ((txU1*)mxCode)[OFFSET+1] |
247 | | #else |
248 | | #if mxUnalignedAccess |
249 | 149M | #define mxRunS2(OFFSET) *((txS2*)(mxCode + OFFSET)) |
250 | 395M | #define mxRunS4(OFFSET) *((txS4*)(mxCode + OFFSET)) |
251 | 3.46M | #define mxRunU2(OFFSET) *((txU2*)(mxCode + OFFSET)) |
252 | | #else |
253 | | #define mxRunS2(OFFSET) (((txS1*)mxCode)[OFFSET+1] << 8) | ((txU1*)mxCode)[OFFSET+0] |
254 | | #define mxRunS4(OFFSET) (((txS1*)mxCode)[OFFSET+3] << 24) | (((txU1*)mxCode)[OFFSET+2] << 16) | (((txU1*)mxCode)[OFFSET+1] << 8) | ((txU1*)mxCode)[OFFSET+0] |
255 | | #define mxRunU2(OFFSET) (((txU1*)mxCode)[OFFSET+1] << 8) | ((txU1*)mxCode)[OFFSET+0] |
256 | | #endif |
257 | | #endif |
258 | | #ifdef mx32bitID |
259 | 385M | #define mxRunID(OFFSET) mxRunS4(OFFSET) |
260 | | #else |
261 | | #define mxRunID(OFFSET) mxRunS2(OFFSET) |
262 | | #endif |
263 | | |
264 | 1.47G | #define mxNextCode(OFFSET) { \ |
265 | 1.47G | mxCode += OFFSET; \ |
266 | 1.47G | byte = *((txU1*)mxCode); \ |
267 | 1.47G | } |
268 | 81.5M | #define mxSkipCode(OFFSET) { \ |
269 | 81.5M | mxCode += OFFSET; \ |
270 | 81.5M | } |
271 | | |
272 | | #ifdef mxMetering |
273 | | #define mxCheckMeter() \ |
274 | 101M | if (the->meterInterval && (the->meterIndex > the->meterCount)) { \ |
275 | 27.0k | mxSaveState; \ |
276 | 27.0k | fxCheckMetering(the); \ |
277 | 27.0k | mxRestoreState; \ |
278 | 27.0k | } |
279 | | #define mxBranch(INDEX, OFFSET) \ |
280 | 50.4M | if ((OFFSET) < 0) { \ |
281 | 39.8M | mxCheckMeter(); \ |
282 | 39.8M | } \ |
283 | 50.4M | mxNextCode((txS4)INDEX + OFFSET) |
284 | | #define mxBranchElse(TEST, INDEX, OFFSET) \ |
285 | 32.6M | if (TEST) { \ |
286 | 26.3M | mxNextCode((txS4)INDEX); \ |
287 | 26.3M | } \ |
288 | 30.3M | else { \ |
289 | 4.07M | mxBranch(INDEX, OFFSET); \ |
290 | 4.07M | } |
291 | | #define mxBranchIf(TEST, INDEX, OFFSET) \ |
292 | 24.1M | if (TEST) { \ |
293 | 4.54M | mxBranch(INDEX, OFFSET); \ |
294 | 4.54M | } \ |
295 | 16.5M | else { \ |
296 | 11.9M | mxNextCode((txS4)index); \ |
297 | 11.9M | } |
298 | | #define mxFirstCode() \ |
299 | 61.5M | mxCheckMeter(); \ |
300 | 61.5M | byte = *((txU1*)mxCode) |
301 | | #else |
302 | | #define mxBranch(INDEX, OFFSET) \ |
303 | | mxNextCode((txS4)INDEX + OFFSET) |
304 | | #define mxBranchElse(TEST, INDEX, OFFSET) \ |
305 | | mxNextCode((TEST) ? (txS4)INDEX : (txS4)INDEX + OFFSET) |
306 | | #define mxBranchIf(TEST, INDEX, OFFSET) \ |
307 | | mxNextCode((TEST) ? (txS4)INDEX + OFFSET : (txS4)INDEX) |
308 | | #define mxFirstCode() \ |
309 | | byte = *((txU1*)mxCode) |
310 | | #endif |
311 | | |
312 | | #ifdef mxTrace |
313 | | short gxDoTrace = 1; |
314 | | |
315 | | #ifdef mxMetering |
316 | | static void fxTraceCode(txMachine* the, txSlot* stack, txU1 theCode) |
317 | | { |
318 | | if (((XS_NO_CODE < theCode) && (theCode < XS_CODE_COUNT))) |
319 | | fprintf(stderr, "\n%u %ld: %s", the->meterIndex, the->stackTop - stack, gxCodeNames[theCode]); |
320 | | else |
321 | | fprintf(stderr, "\n%u %ld: ?", the->meterIndex, the->stackTop - stack); |
322 | | } |
323 | | #else |
324 | | static void fxTraceCode(txMachine* the, txSlot* stack, txU1 theCode) |
325 | | { |
326 | | if (((XS_NO_CODE < theCode) && (theCode < XS_CODE_COUNT))) |
327 | | fprintf(stderr, "\n%ld: %s", the->stackTop - stack, gxCodeNames[theCode]); |
328 | | else |
329 | | fprintf(stderr, "\n%ld: ?", the->stackTop - stack); |
330 | | } |
331 | | #endif |
332 | | |
333 | | static void fxTraceID(txMachine* the, txID id, txIndex index) |
334 | | { |
335 | | if (id) { |
336 | | char* key = fxGetKeyName(the, id); |
337 | | if (key) |
338 | | fprintf(stderr, " [%s]", key); |
339 | | else |
340 | | fprintf(stderr, " [?]"); |
341 | | } |
342 | | else |
343 | | fprintf(stderr, " [%d]", index); |
344 | | } |
345 | | |
346 | | static void fxTraceIndex(txMachine* the, txU2 theIndex) |
347 | | { |
348 | | fprintf(stderr, " %d", theIndex); |
349 | | } |
350 | | |
351 | | static void fxTraceInteger(txMachine* the, txInteger theInteger) |
352 | | { |
353 | | fprintf(stderr, " %ld", (long)theInteger); |
354 | | } |
355 | | |
356 | | static void fxTraceNumber(txMachine* the, txNumber theNumber) |
357 | | { |
358 | | fprintf(stderr, " %lf", theNumber); |
359 | | } |
360 | | |
361 | | static void fxTraceReturn(txMachine* the) |
362 | | { |
363 | | fprintf(stderr, "\n"); |
364 | | } |
365 | | |
366 | | static void fxTraceString(txMachine* the, txString theString) |
367 | | { |
368 | | fprintf(stderr, " \"%s\"", theString); |
369 | | } |
370 | | #endif |
371 | | |
372 | | #ifdef mxTraceCall |
373 | | int gxTraceCall = 0; |
374 | | static int depth = 0; |
375 | | static void fxTraceCallBegin(txMachine* the, txSlot* function) |
376 | | { |
377 | | if (gxTraceCall) { |
378 | | txSlot* slot = mxBehaviorGetProperty(the, function->value.reference, mxID(_name), 0, XS_ANY); |
379 | | int i; |
380 | | for (i = 0; i < depth; i++) |
381 | | fprintf(stderr, "\t"); |
382 | | if (slot && ((slot->kind == XS_STRING_KIND) || (slot->kind == XS_STRING_X_KIND))) |
383 | | fprintf(stderr, " [%s]\n", slot->value.string); |
384 | | else |
385 | | fprintf(stderr, " [?]\n"); |
386 | | depth++; |
387 | | } |
388 | | } |
389 | | static void fxTraceCallEnd(txMachine* the, txSlot* function) |
390 | | { |
391 | | if (gxTraceCall) { |
392 | | depth--; |
393 | | if (depth < 0) |
394 | | depth = 0; |
395 | | } |
396 | | } |
397 | | #endif |
398 | | |
399 | | #if defined(mxInstrument) && !defined(mxDebug) |
400 | | static void fxTraceException(txMachine *the) |
401 | | { |
402 | | #ifndef mxNoConsole |
403 | | if (XS_REFERENCE_KIND == mxException.kind) { |
404 | | txSlot* internal = mxException.value.reference->next; |
405 | | if (internal && (internal->kind == XS_ERROR_KIND)) { |
406 | | txSlot* msg = internal->next; |
407 | | if (msg && ((msg->kind == XS_STRING_KIND) || (msg->kind == XS_STRING_X_KIND))) |
408 | | c_printf("Exception %s: %s\n", gxErrorNames[internal->value.error.which], msg->value.string); |
409 | | else |
410 | | c_printf("Exception %s\n", gxErrorNames[internal->value.error.which]); |
411 | | } |
412 | | } |
413 | | else |
414 | | c_printf("Exception\n"); |
415 | | #endif |
416 | | } |
417 | | #endif |
418 | | |
419 | | void fxRunID(txMachine* the, txSlot* generator, txInteger count) |
420 | 130M | { |
421 | 130M | register txSlot* stack = the->stack; |
422 | 130M | register txSlot* scope = the->scope; |
423 | 130M | register txSlot* frame = the->frame; |
424 | 130M | register txSlot* environment; |
425 | 130M | register txByte* code = the->code; |
426 | 130M | register txSlot* variable; |
427 | 130M | register txSlot* slot; |
428 | 130M | register txU1 byte = 0; |
429 | 130M | register txU4 index; |
430 | 130M | register txS4 offset; |
431 | 130M | txU1 primitive = 0; |
432 | 130M | txU1 ignore = 0; |
433 | 130M | #if defined(__GNUC__) && defined(__OPTIMIZE__) |
434 | 130M | static void *const |
435 | 130M | #if !defined(__ets__) || ESP32 |
436 | 130M | ICACHE_RAM_ATTR |
437 | 130M | #endif |
438 | 130M | gxBytes[] = { |
439 | 130M | &&XS_NO_CODE, |
440 | 130M | &&XS_CODE_ADD, |
441 | 130M | &&XS_CODE_ARGUMENT, |
442 | 130M | &&XS_CODE_ARGUMENTS, |
443 | 130M | &&XS_CODE_ARGUMENTS_SLOPPY, |
444 | 130M | &&XS_CODE_ARGUMENTS_STRICT, |
445 | 130M | &&XS_CODE_ARRAY, |
446 | 130M | &&XS_CODE_ASYNC_FUNCTION, |
447 | 130M | &&XS_CODE_ASYNC_GENERATOR_FUNCTION, |
448 | 130M | &&XS_CODE_AT, |
449 | 130M | &&XS_CODE_AWAIT, |
450 | 130M | &&XS_CODE_BEGIN_SLOPPY, |
451 | 130M | &&XS_CODE_BEGIN_STRICT, |
452 | 130M | &&XS_CODE_BEGIN_STRICT_BASE, |
453 | 130M | &&XS_CODE_BEGIN_STRICT_DERIVED, |
454 | 130M | &&XS_CODE_BEGIN_STRICT_FIELD, |
455 | 130M | &&XS_CODE_BIGINT_1, |
456 | 130M | &&XS_CODE_BIGINT_2, |
457 | 130M | &&XS_CODE_BIT_AND, |
458 | 130M | &&XS_CODE_BIT_NOT, |
459 | 130M | &&XS_CODE_BIT_OR, |
460 | 130M | &&XS_CODE_BIT_XOR, |
461 | 130M | &&XS_CODE_BRANCH_1, |
462 | 130M | &&XS_CODE_BRANCH_2, |
463 | 130M | &&XS_CODE_BRANCH_4, |
464 | 130M | &&XS_CODE_BRANCH_CHAIN_1, |
465 | 130M | &&XS_CODE_BRANCH_CHAIN_2, |
466 | 130M | &&XS_CODE_BRANCH_CHAIN_4, |
467 | 130M | &&XS_CODE_BRANCH_COALESCE_1, |
468 | 130M | &&XS_CODE_BRANCH_COALESCE_2, |
469 | 130M | &&XS_CODE_BRANCH_COALESCE_4, |
470 | 130M | &&XS_CODE_BRANCH_ELSE_1, |
471 | 130M | &&XS_CODE_BRANCH_ELSE_2, |
472 | 130M | &&XS_CODE_BRANCH_ELSE_4, |
473 | 130M | &&XS_CODE_BRANCH_IF_1, |
474 | 130M | &&XS_CODE_BRANCH_IF_2, |
475 | 130M | &&XS_CODE_BRANCH_IF_4, |
476 | 130M | &&XS_CODE_BRANCH_STATUS_1, |
477 | 130M | &&XS_CODE_BRANCH_STATUS_2, |
478 | 130M | &&XS_CODE_BRANCH_STATUS_4, |
479 | 130M | &&XS_CODE_CALL, |
480 | 130M | &&XS_CODE_CATCH_1, |
481 | 130M | &&XS_CODE_CATCH_2, |
482 | 130M | &&XS_CODE_CATCH_4, |
483 | 130M | &&XS_CODE_CHECK_INSTANCE, |
484 | 130M | &&XS_CODE_CLASS, |
485 | 130M | &&XS_CODE_CODE_1, |
486 | 130M | &&XS_CODE_CODE_2, |
487 | 130M | &&XS_CODE_CODE_4, |
488 | 130M | &&XS_CODE_CODE_ARCHIVE_1, |
489 | 130M | &&XS_CODE_CODE_ARCHIVE_2, |
490 | 130M | &&XS_CODE_CODE_ARCHIVE_4, |
491 | 130M | &&XS_CODE_CONST_CLOSURE_1, |
492 | 130M | &&XS_CODE_CONST_CLOSURE_2, |
493 | 130M | &&XS_CODE_CONST_LOCAL_1, |
494 | 130M | &&XS_CODE_CONST_LOCAL_2, |
495 | 130M | &&XS_CODE_CONSTRUCTOR_FUNCTION, |
496 | 130M | &&XS_CODE_COPY_OBJECT, |
497 | 130M | &&XS_CODE_CURRENT, |
498 | 130M | &&XS_CODE_DEBUGGER, |
499 | 130M | &&XS_CODE_DECREMENT, |
500 | 130M | &&XS_CODE_DELETE_PROPERTY, |
501 | 130M | &&XS_CODE_DELETE_PROPERTY_AT, |
502 | 130M | &&XS_CODE_DELETE_SUPER, |
503 | 130M | &&XS_CODE_DELETE_SUPER_AT, |
504 | 130M | &&XS_CODE_DIVIDE, |
505 | 130M | &&XS_CODE_DUB, |
506 | 130M | &&XS_CODE_DUB_AT, |
507 | 130M | &&XS_CODE_END, |
508 | 130M | &&XS_CODE_END_ARROW, |
509 | 130M | &&XS_CODE_END_BASE, |
510 | 130M | &&XS_CODE_END_DERIVED, |
511 | 130M | &&XS_CODE_ENVIRONMENT, |
512 | 130M | &&XS_CODE_EQUAL, |
513 | 130M | &&XS_CODE_EVAL, |
514 | 130M | &&XS_CODE_EVAL_ENVIRONMENT, |
515 | 130M | &&XS_CODE_EVAL_PRIVATE, |
516 | 130M | &&XS_CODE_EVAL_REFERENCE, |
517 | 130M | &&XS_CODE_EVAL_TAIL, |
518 | 130M | &&XS_CODE_EXCEPTION, |
519 | 130M | &&XS_CODE_EXPONENTIATION, |
520 | 130M | &&XS_CODE_EXTEND, |
521 | 130M | &&XS_CODE_FALSE, |
522 | 130M | &&XS_CODE_FILE, |
523 | 130M | &&XS_CODE_FOR_AWAIT_OF, |
524 | 130M | &&XS_CODE_FOR_IN, |
525 | 130M | &&XS_CODE_FOR_OF, |
526 | 130M | &&XS_CODE_FUNCTION, |
527 | 130M | &&XS_CODE_FUNCTION_ENVIRONMENT, |
528 | 130M | &&XS_CODE_GENERATOR_FUNCTION, |
529 | 130M | &&XS_CODE_GET_CLOSURE_1, |
530 | 130M | &&XS_CODE_GET_CLOSURE_2, |
531 | 130M | &&XS_CODE_GET_LOCAL_1, |
532 | 130M | &&XS_CODE_GET_LOCAL_2, |
533 | 130M | &&XS_CODE_GET_PRIVATE_1, |
534 | 130M | &&XS_CODE_GET_PRIVATE_2, |
535 | 130M | &&XS_CODE_GET_PROPERTY, |
536 | 130M | &&XS_CODE_GET_PROPERTY_AT, |
537 | 130M | &&XS_CODE_GET_RESULT, |
538 | 130M | &&XS_CODE_GET_SUPER, |
539 | 130M | &&XS_CODE_GET_SUPER_AT, |
540 | 130M | &&XS_CODE_GET_THIS, |
541 | 130M | &&XS_CODE_GET_VARIABLE, |
542 | 130M | &&XS_CODE_GET_THIS_VARIABLE, |
543 | 130M | &&XS_CODE_GLOBAL, |
544 | 130M | &&XS_CODE_HAS_PRIVATE_1, |
545 | 130M | &&XS_CODE_HAS_PRIVATE_2, |
546 | 130M | &&XS_CODE_HOST, |
547 | 130M | &&XS_CODE_IMPORT, |
548 | 130M | &&XS_CODE_IMPORT_META, |
549 | 130M | &&XS_CODE_IN, |
550 | 130M | &&XS_CODE_INCREMENT, |
551 | 130M | &&XS_CODE_INSTANCEOF, |
552 | 130M | &&XS_CODE_INSTANTIATE, |
553 | 130M | &&XS_CODE_INTEGER_1, |
554 | 130M | &&XS_CODE_INTEGER_2, |
555 | 130M | &&XS_CODE_INTEGER_4, |
556 | 130M | &&XS_CODE_LEFT_SHIFT, |
557 | 130M | &&XS_CODE_LESS, |
558 | 130M | &&XS_CODE_LESS_EQUAL, |
559 | 130M | &&XS_CODE_LET_CLOSURE_1, |
560 | 130M | &&XS_CODE_LET_CLOSURE_2, |
561 | 130M | &&XS_CODE_LET_LOCAL_1, |
562 | 130M | &&XS_CODE_LET_LOCAL_2, |
563 | 130M | &&XS_CODE_LINE, |
564 | 130M | &&XS_CODE_MINUS, |
565 | 130M | &&XS_CODE_MODULE, |
566 | 130M | &&XS_CODE_MODULO, |
567 | 130M | &&XS_CODE_MORE, |
568 | 130M | &&XS_CODE_MORE_EQUAL, |
569 | 130M | &&XS_CODE_MULTIPLY, |
570 | 130M | &&XS_CODE_NAME, |
571 | 130M | &&XS_CODE_NEW, |
572 | 130M | &&XS_CODE_NEW_CLOSURE, |
573 | 130M | &&XS_CODE_NEW_LOCAL, |
574 | 130M | &&XS_CODE_NEW_PRIVATE_1, |
575 | 130M | &&XS_CODE_NEW_PRIVATE_2, |
576 | 130M | &&XS_CODE_NEW_PROPERTY, |
577 | 130M | &&XS_CODE_NEW_PROPERTY_AT, |
578 | 130M | &&XS_CODE_NEW_TEMPORARY, |
579 | 130M | &&XS_CODE_NOT, |
580 | 130M | &&XS_CODE_NOT_EQUAL, |
581 | 130M | &&XS_CODE_NULL, |
582 | 130M | &&XS_CODE_NUMBER, |
583 | 130M | &&XS_CODE_OBJECT, |
584 | 130M | &&XS_CODE_PLUS, |
585 | 130M | &&XS_CODE_POP, |
586 | 130M | &&XS_CODE_PROGRAM_ENVIRONMENT, |
587 | 130M | &&XS_CODE_PROGRAM_REFERENCE, |
588 | 130M | &&XS_CODE_PULL_CLOSURE_1, |
589 | 130M | &&XS_CODE_PULL_CLOSURE_2, |
590 | 130M | &&XS_CODE_PULL_LOCAL_1, |
591 | 130M | &&XS_CODE_PULL_LOCAL_2, |
592 | 130M | &&XS_CODE_REFRESH_CLOSURE_1, |
593 | 130M | &&XS_CODE_REFRESH_CLOSURE_2, |
594 | 130M | &&XS_CODE_REFRESH_LOCAL_1, |
595 | 130M | &&XS_CODE_REFRESH_LOCAL_2, |
596 | 130M | &&XS_CODE_REGEXP, |
597 | 130M | &&XS_CODE_RESERVE_1, |
598 | 130M | &&XS_CODE_RESERVE_2, |
599 | 130M | &&XS_CODE_RESET_CLOSURE_1, |
600 | 130M | &&XS_CODE_RESET_CLOSURE_2, |
601 | 130M | &&XS_CODE_RESET_LOCAL_1, |
602 | 130M | &&XS_CODE_RESET_LOCAL_2, |
603 | 130M | &&XS_CODE_RETHROW, |
604 | 130M | &&XS_CODE_RETRIEVE_1, |
605 | 130M | &&XS_CODE_RETRIEVE_2, |
606 | 130M | &&XS_CODE_RETRIEVE_TARGET, |
607 | 130M | &&XS_CODE_RETRIEVE_THIS, |
608 | 130M | &&XS_CODE_RETURN, |
609 | 130M | &&XS_CODE_RUN, |
610 | 130M | &&XS_CODE_RUN_1, |
611 | 130M | &&XS_CODE_RUN_2, |
612 | 130M | &&XS_CODE_RUN_4, |
613 | 130M | &&XS_CODE_RUN_TAIL, |
614 | 130M | &&XS_CODE_RUN_TAIL_1, |
615 | 130M | &&XS_CODE_RUN_TAIL_2, |
616 | 130M | &&XS_CODE_RUN_TAIL_4, |
617 | 130M | &&XS_CODE_SET_CLOSURE_1, |
618 | 130M | &&XS_CODE_SET_CLOSURE_2, |
619 | 130M | &&XS_CODE_SET_HOME, |
620 | 130M | &&XS_CODE_SET_LOCAL_1, |
621 | 130M | &&XS_CODE_SET_LOCAL_2, |
622 | 130M | &&XS_CODE_SET_PRIVATE_1, |
623 | 130M | &&XS_CODE_SET_PRIVATE_2, |
624 | 130M | &&XS_CODE_SET_PROPERTY, |
625 | 130M | &&XS_CODE_SET_PROPERTY_AT, |
626 | 130M | &&XS_CODE_SET_RESULT, |
627 | 130M | &&XS_CODE_SET_SUPER, |
628 | 130M | &&XS_CODE_SET_SUPER_AT, |
629 | 130M | &&XS_CODE_SET_THIS, |
630 | 130M | &&XS_CODE_SET_VARIABLE, |
631 | 130M | &&XS_CODE_SIGNED_RIGHT_SHIFT, |
632 | 130M | &&XS_CODE_START_ASYNC, |
633 | 130M | &&XS_CODE_START_ASYNC_GENERATOR, |
634 | 130M | &&XS_CODE_START_GENERATOR, |
635 | 130M | &&XS_CODE_STORE_1, |
636 | 130M | &&XS_CODE_STORE_2, |
637 | 130M | &&XS_CODE_STORE_ARROW, |
638 | 130M | &&XS_CODE_STRICT_EQUAL, |
639 | 130M | &&XS_CODE_STRICT_NOT_EQUAL, |
640 | 130M | &&XS_CODE_STRING_1, |
641 | 130M | &&XS_CODE_STRING_2, |
642 | 130M | &&XS_CODE_STRING_4, |
643 | 130M | &&XS_CODE_STRING_ARCHIVE_1, |
644 | 130M | &&XS_CODE_STRING_ARCHIVE_2, |
645 | 130M | &&XS_CODE_STRING_ARCHIVE_4, |
646 | 130M | &&XS_CODE_SUBTRACT, |
647 | 130M | &&XS_CODE_SUPER, |
648 | 130M | &&XS_CODE_SWAP, |
649 | 130M | &&XS_CODE_SYMBOL, |
650 | 130M | &&XS_CODE_TARGET, |
651 | 130M | &&XS_CODE_TEMPLATE, |
652 | 130M | &&XS_CODE_TEMPLATE_CACHE, |
653 | 130M | &&XS_CODE_THIS, |
654 | 130M | &&XS_CODE_THROW, |
655 | 130M | &&XS_CODE_THROW_STATUS, |
656 | 130M | &&XS_CODE_TO_INSTANCE, |
657 | 130M | &&XS_CODE_TO_NUMERIC, |
658 | 130M | &&XS_CODE_TO_STRING, |
659 | 130M | &&XS_CODE_TRANSFER, |
660 | 130M | &&XS_CODE_TRUE, |
661 | 130M | &&XS_CODE_TYPEOF, |
662 | 130M | &&XS_CODE_UNCATCH, |
663 | 130M | &&XS_CODE_UNDEFINED, |
664 | 130M | &&XS_CODE_UNSIGNED_RIGHT_SHIFT, |
665 | 130M | &&XS_CODE_UNWIND_1, |
666 | 130M | &&XS_CODE_UNWIND_2, |
667 | 130M | &&XS_CODE_VAR_CLOSURE_1, |
668 | 130M | &&XS_CODE_VAR_CLOSURE_2, |
669 | 130M | &&XS_CODE_VAR_LOCAL_1, |
670 | 130M | &&XS_CODE_VAR_LOCAL_2, |
671 | 130M | &&XS_CODE_VOID, |
672 | 130M | &&XS_CODE_WITH, |
673 | 130M | &&XS_CODE_WITHOUT, |
674 | 130M | &&XS_CODE_YIELD, |
675 | 130M | &&XS_CODE_PROFILE, |
676 | 130M | &&XS_CODE_YIELD_STAR, |
677 | 130M | &&XS_CODE_USED_1, |
678 | 130M | &&XS_CODE_USED_2, |
679 | 130M | &&XS_CODE_USING, |
680 | 130M | &&XS_CODE_USING_ASYNC, |
681 | 130M | &&XS_CODE_AT_2, |
682 | 130M | &&XS_CODE_SUPER_AT, |
683 | 130M | &&XS_CODE_SUPER_AT_2, |
684 | 130M | &&XS_CODE_TRANSFER_JSON, |
685 | 130M | }; |
686 | 130M | register void * const *bytes = gxBytes; |
687 | 130M | #endif |
688 | 130M | txJump* jump = C_NULL; |
689 | 130M | txSlot scratch; |
690 | 130M | txSlot** address; |
691 | 130M | txJump* yieldJump = the->firstJump; |
692 | | |
693 | 130M | mxCheckCStack(); |
694 | 130M | if (generator) { |
695 | 1.21M | slot = mxStack; |
696 | 1.21M | variable = generator->next; |
697 | 1.21M | offset = variable->value.stack.length; |
698 | 1.21M | mxAllocStack(offset); |
699 | 1.21M | c_memcpy(mxStack, variable->value.stack.address, offset * sizeof(txSlot)); |
700 | 1.21M | mxCode = (mxStack++)->value.reference->next->value.code.address; |
701 | 1.21M | offset = (mxStack++)->value.integer; |
702 | 1.21M | while (offset) { |
703 | 27 | jump = c_malloc(sizeof(txJump)); |
704 | 27 | if (jump) { |
705 | 27 | jump->nextJump = the->firstJump; |
706 | 27 | jump->stack = slot - (mxStack++)->value.integer; |
707 | 27 | jump->frame = slot - (mxStack++)->value.integer; |
708 | 27 | jump->scope = slot - (mxStack++)->value.integer; |
709 | 27 | jump->code = mxCode + (mxStack++)->value.integer; |
710 | 27 | jump->flag = 1; |
711 | 27 | the->firstJump = jump; |
712 | 27 | if (c_setjmp(jump->buffer) == 1) { |
713 | 13 | jump = the->firstJump; |
714 | 13 | the->firstJump = jump->nextJump; |
715 | 13 | mxStack = jump->stack; |
716 | 13 | mxScope = jump->scope; |
717 | 13 | mxFrame = jump->frame; |
718 | 13 | mxEnvironment = mxFrameToEnvironment(mxFrame); |
719 | 13 | mxCode = jump->code; |
720 | 13 | c_free(jump); |
721 | 13 | goto XS_CODE_JUMP; |
722 | 13 | } |
723 | 27 | } |
724 | 0 | else { |
725 | 0 | mxSaveState; |
726 | 0 | fxAbort(the, XS_NOT_ENOUGH_MEMORY_EXIT); |
727 | 0 | } |
728 | 14 | offset--; |
729 | 14 | } |
730 | 1.21M | variable = slot - (mxStack++)->value.integer; |
731 | 1.21M | variable->next = mxFrame; |
732 | 1.21M | variable->value.frame.code = the->code; |
733 | 1.21M | variable->value.frame.scope = mxScope; |
734 | 1.21M | mxFrame = variable; |
735 | 1.21M | mxEnvironment = mxFrameToEnvironment(mxFrame); |
736 | 1.21M | mxScope = slot - (mxStack++)->value.integer; |
737 | 1.21M | mxCode = mxCode + (mxStack++)->value.integer; |
738 | 1.21M | mxStack->kind = the->scratch.kind; |
739 | 1.21M | mxStack->value = the->scratch.value; |
740 | | #ifdef mxTraceCall |
741 | | fxTraceCallBegin(the, mxFrameFunction); |
742 | | #endif |
743 | 1.21M | XS_CODE_JUMP: |
744 | 1.21M | mxFirstCode(); |
745 | 1.21M | } |
746 | 129M | else { |
747 | 129M | offset = count; |
748 | 129M | goto XS_CODE_RUN_ALL; |
749 | 129M | } |
750 | 1.21M | for (;;) { |
751 | | |
752 | | #ifdef mxTrace |
753 | | if (gxDoTrace) fxTraceCode(the, stack, byte); |
754 | | #endif |
755 | 1.21M | #ifdef mxMetering |
756 | 1.21M | the->meterIndex += XS_CODE_METERING; |
757 | 1.21M | #endif |
758 | | |
759 | 1.21M | mxSwitch(byte) { |
760 | 1.21M | mxCase(XS_NO_CODE) |
761 | 0 | mxBreak; |
762 | |
|
763 | 1.11M | mxCase(XS_CODE_RUN_TAIL) |
764 | 1.11M | mxSkipCode(1); |
765 | 1.11M | offset = mxStack->value.integer; |
766 | 1.11M | mxStack++; |
767 | 1.11M | goto XS_CODE_RUN_TAIL_ALL; |
768 | 0 | mxCase(XS_CODE_RUN_TAIL_4) |
769 | 0 | offset = mxRunS4(1); |
770 | 0 | mxSkipCode(5); |
771 | 0 | goto XS_CODE_RUN_TAIL_ALL; |
772 | 0 | mxCase(XS_CODE_RUN_TAIL_2) |
773 | 0 | offset = mxRunS2(1); |
774 | 0 | mxSkipCode(3); |
775 | 0 | goto XS_CODE_RUN_TAIL_ALL; |
776 | 1.58k | mxCase(XS_CODE_RUN_TAIL_1) |
777 | 1.58k | offset = mxRunS1(1); |
778 | 1.58k | mxSkipCode(2); |
779 | 1.11M | XS_CODE_RUN_TAIL_ALL: |
780 | 1.11M | if (mxFrameTarget->kind) |
781 | 3 | goto XS_CODE_RUN_ALL; |
782 | 1.11M | #ifdef mxDebug |
783 | 1.11M | slot = mxStack + offset + 4; |
784 | 1.11M | if (!fxIsCallable(the, slot)) |
785 | 1.51k | goto XS_CODE_RUN_ALL; |
786 | 1.11M | #endif |
787 | 1.11M | variable = mxFrameEnd - 6 - offset; |
788 | 1.11M | mxScope = mxFrame->value.frame.scope; |
789 | 1.11M | mxCode = mxFrame->value.frame.code; |
790 | 1.11M | mxFrame = mxFrame->next; |
791 | 1.11M | c_memmove(variable, mxStack, (6 + offset) * sizeof(txSlot)); |
792 | 1.11M | mxStack = variable; |
793 | 1.11M | goto XS_CODE_RUN_ALL; |
794 | | |
795 | 3.80k | mxCase(XS_CODE_RUN) |
796 | 3.80k | mxSkipCode(1); |
797 | 3.80k | offset = mxStack->value.integer; |
798 | 3.80k | mxStack++; |
799 | 3.80k | goto XS_CODE_RUN_ALL; |
800 | 0 | mxCase(XS_CODE_RUN_4) |
801 | 0 | offset = mxRunS4(1); |
802 | 0 | mxSkipCode(5); |
803 | 0 | goto XS_CODE_RUN_ALL; |
804 | 27.1k | mxCase(XS_CODE_RUN_2) |
805 | 27.1k | offset = mxRunS2(1); |
806 | 27.1k | mxSkipCode(3); |
807 | 27.1k | goto XS_CODE_RUN_ALL; |
808 | 43.2M | mxCase(XS_CODE_RUN_1) |
809 | 43.2M | offset = mxRunS1(1); |
810 | 43.2M | mxSkipCode(2); |
811 | 183M | XS_CODE_RUN_ALL: |
812 | | #ifdef mxTrace |
813 | | if (gxDoTrace) fxTraceInteger(the, offset); |
814 | | #endif |
815 | | // COUNT |
816 | 183M | slot = mxStack + offset; |
817 | 183M | slot->kind = XS_INTEGER_KIND; |
818 | 183M | slot->value.integer = offset; |
819 | 183M | slot++; |
820 | | // FRAME |
821 | 183M | slot->kind = XS_FRAME_KIND; |
822 | 183M | slot->next = mxFrame; |
823 | 183M | slot->flag = XS_NO_FLAG; |
824 | 183M | #ifdef mxDebug |
825 | 183M | if (mxFrame && (mxFrame->flag & XS_STEP_INTO_FLAG)) |
826 | 0 | slot->flag |= XS_STEP_INTO_FLAG | XS_STEP_OVER_FLAG; |
827 | 183M | #endif |
828 | 183M | slot->value.frame.code = mxCode; |
829 | 183M | slot->value.frame.scope = mxScope; |
830 | 183M | slot++; |
831 | | // RESULT |
832 | 183M | slot++; |
833 | | // TARGET |
834 | 183M | slot++; |
835 | | // FUNCTION |
836 | 183M | byte = ((slot + 1)->kind == XS_UNINITIALIZED_KIND) ? 1 : 0; |
837 | 183M | if (slot->kind == XS_REFERENCE_KIND) { |
838 | 183M | variable = slot->value.reference; |
839 | 183M | slot = variable->next; |
840 | 183M | if (slot && (slot->flag & XS_INTERNAL_FLAG)) { |
841 | 183M | if ((slot->kind == XS_CODE_KIND) || (slot->kind == XS_CODE_X_KIND)) { |
842 | 8.76M | if (byte && !mxIsConstructor(variable)) |
843 | 8.76M | mxRunDebug(XS_TYPE_ERROR, "new: not a constructor"); |
844 | 8.76M | variable = slot->value.code.closures; |
845 | 8.76M | if (variable) { |
846 | 3.33M | mxPushKind(XS_REFERENCE_KIND); |
847 | 3.33M | mxStack->value.environment.variable.reference = variable; |
848 | 3.33M | } |
849 | 5.43M | else { |
850 | 5.43M | mxPushKind(XS_NULL_KIND); |
851 | 5.43M | mxStack->value.environment.variable.reference = C_NULL; |
852 | 5.43M | } |
853 | 8.76M | #ifdef mxDebug |
854 | 8.76M | mxStack->ID = XS_NO_ID; |
855 | 8.76M | mxStack->value.environment.line = 0; |
856 | 8.76M | #endif |
857 | 8.76M | mxFrame = mxStack + 1 + offset + 1; |
858 | 8.76M | mxEnvironment = mxStack; |
859 | 8.76M | mxScope = mxStack; |
860 | 8.76M | mxCode = slot->value.code.address; |
861 | | #ifdef mxTraceCall |
862 | | fxTraceCallBegin(the, mxFrameFunction); |
863 | | #endif |
864 | 8.76M | mxFirstCode(); |
865 | 8.76M | mxBreak; |
866 | 8.76M | } |
867 | 183M | if ((slot->kind == XS_CALLBACK_KIND) || (slot->kind == XS_CALLBACK_X_KIND)) { |
868 | 174M | if (byte && !mxIsConstructor(variable)) |
869 | 174M | mxRunDebug(XS_TYPE_ERROR, "new: not a constructor"); |
870 | 174M | mxPushKind(XS_VAR_KIND); |
871 | 174M | mxStack->value.environment.variable.count = 0; |
872 | 174M | #ifdef mxDebug |
873 | 174M | mxStack->ID = XS_NO_ID; |
874 | 174M | mxStack->value.environment.line = 0; |
875 | 174M | #endif |
876 | 174M | mxFrame = mxStack + 1 + offset + 1; |
877 | 174M | mxFrame->flag |= XS_C_FLAG; |
878 | 174M | mxScope = mxStack; |
879 | 174M | mxCode = C_NULL; |
880 | 174M | byte = XS_CODE_CALL; |
881 | | #ifdef mxTraceCall |
882 | | fxTraceCallBegin(the, mxFrameFunction); |
883 | | #endif |
884 | 174M | mxSaveState; |
885 | | #ifdef mxLink |
886 | | if ((txU1*)slot->value.callback.address - (txU1*)the->fakeCallback < 0) |
887 | | mxRunDebug(XS_TYPE_ERROR, "link: unavailable function"); |
888 | | #endif |
889 | 174M | if (slot->flag & XS_BASE_FLAG) |
890 | 0 | fxRunBase(the); |
891 | 174M | else if (slot->flag & XS_DERIVED_FLAG) |
892 | 0 | fxRunDerived(the); |
893 | 174M | (*(slot->value.callback.address))(the); |
894 | 174M | mxRestoreState; |
895 | 174M | if (mxCode) { |
896 | 1.11M | byte = *mxCode; |
897 | 1.11M | mxBreak; |
898 | 1.11M | } |
899 | 174M | #if defined(mxInstrument) || defined(mxProfile) |
900 | 174M | fxCheckProfiler(the, mxFrame); |
901 | 174M | #endif |
902 | 174M | if (slot->flag & XS_BASE_FLAG) |
903 | 0 | goto XS_CODE_END_BASE_ALL; |
904 | 174M | if (slot->flag & XS_DERIVED_FLAG) |
905 | 0 | goto XS_CODE_END_DERIVED_ALL; |
906 | 174M | slot = mxFrameResult; |
907 | 174M | goto XS_CODE_END_ALL; |
908 | 174M | } |
909 | 8.80M | if (slot->kind == XS_PROXY_KIND) { |
910 | 28 | mxPushKind(XS_VAR_KIND); |
911 | 28 | mxStack->value.environment.variable.count = 0; |
912 | 28 | #ifdef mxDebug |
913 | 28 | mxStack->ID = XS_NO_ID; |
914 | 28 | mxStack->value.environment.line = 0; |
915 | 28 | #endif |
916 | 28 | mxFrame = mxStack + 1 + offset + 1; |
917 | 28 | mxFrame->flag |= XS_C_FLAG; |
918 | 28 | mxScope = mxStack; |
919 | 28 | mxCode = C_NULL; |
920 | 28 | byte = XS_CODE_CALL; |
921 | | #ifdef mxTraceCall |
922 | | fxTraceCallBegin(the, mxFrameFunction); |
923 | | #endif |
924 | 28 | mxSaveState; |
925 | 28 | fxRunProxy(the, variable); |
926 | 28 | mxRestoreState; |
927 | 28 | slot = mxFrameResult; |
928 | 28 | goto XS_CODE_END_ALL; |
929 | 28 | } |
930 | 8.80M | } |
931 | 183M | } |
932 | | #if mxHostFunctionPrimitive |
933 | | else if (slot->kind == XS_HOST_FUNCTION_KIND) { |
934 | | if (byte) |
935 | | mxRunDebug(XS_TYPE_ERROR, "new: not a constructor"); |
936 | | mxPushKind(XS_VAR_KIND); |
937 | | mxStack->value.environment.variable.count = 0; |
938 | | #ifdef mxDebug |
939 | | mxStack->ID = XS_NO_ID; |
940 | | mxStack->value.environment.line = 0; |
941 | | #endif |
942 | | mxFrame = mxStack + 1 + offset + 1; |
943 | | mxFrame->flag |= XS_C_FLAG; |
944 | | mxScope = mxStack; |
945 | | mxCode = C_NULL; |
946 | | byte = XS_CODE_CALL; |
947 | | #ifdef mxTraceCall |
948 | | fxTraceCallBegin(the, mxFrameFunction); |
949 | | #endif |
950 | | mxSaveState; |
951 | | #ifdef mxLink |
952 | | if ((txU1*)slot->value.hostFunction.builder->callback - (txU1*)the->fakeCallback < 0) |
953 | | mxRunDebug(XS_TYPE_ERROR, "link: unavailable function"); |
954 | | #endif |
955 | | (*(slot->value.hostFunction.builder->callback))(the); |
956 | | mxRestoreState; |
957 | | if (mxCode) { |
958 | | byte = *mxCode; |
959 | | mxBreak; |
960 | | } |
961 | | slot = mxFrameResult; |
962 | | goto XS_CODE_END_ALL; |
963 | | } |
964 | | #endif |
965 | 8.91M | if (byte) { |
966 | 4.01k | mxRunDebug(XS_TYPE_ERROR, "new: not a constructor"); |
967 | 0 | } |
968 | 8.91M | else { |
969 | 8.91M | mxRunDebug(XS_TYPE_ERROR, "call: not a function"); |
970 | 0 | } |
971 | 0 | mxBreak; |
972 | | |
973 | 7.11M | mxCase(XS_CODE_BEGIN_SLOPPY) |
974 | 7.11M | if ((mxFrameTarget->kind != XS_UNDEFINED_KIND) && (mxFrameFunction->value.reference->flag & XS_CAN_CONSTRUCT_FLAG)) { |
975 | 53.8k | mxSaveState; |
976 | 53.8k | fxRunConstructor(the); |
977 | 53.8k | mxRestoreState; |
978 | 53.8k | } |
979 | 7.05M | else { |
980 | 7.05M | index = mxFrameThis->kind; |
981 | 7.05M | if (index < XS_REFERENCE_KIND) { |
982 | 2.68M | if ((index == XS_UNDEFINED_KIND) || (index == XS_NULL_KIND)) { |
983 | 2.60M | mxFrameThis->kind = XS_REFERENCE_KIND; |
984 | 2.60M | variable = mxFunctionInstanceHome(mxFrameFunction->value.reference)->value.home.module; |
985 | 2.60M | variable = mxModuleInstanceInternal(variable)->value.module.realm; |
986 | 2.60M | if (!variable) variable = mxModuleInstanceInternal(mxProgram.value.reference)->value.module.realm; |
987 | 2.60M | mxFrameThis->value.reference = mxRealmGlobal(variable)->value.reference; |
988 | 2.60M | } |
989 | 79.8k | else { |
990 | 79.8k | mxSaveState; |
991 | 79.8k | fxToInstance(the, mxFrameThis); |
992 | 79.8k | mxRestoreState; |
993 | 79.8k | } |
994 | 2.68M | } |
995 | 7.05M | } |
996 | 7.11M | mxNextCode(2); |
997 | 7.11M | mxBreak; |
998 | 7.11M | mxCase(XS_CODE_BEGIN_STRICT) |
999 | 1.18M | mxFrame->flag |= XS_STRICT_FLAG; |
1000 | 1.18M | if ((mxFrameTarget->kind != XS_UNDEFINED_KIND) && (mxFrameFunction->value.reference->flag & XS_CAN_CONSTRUCT_FLAG)) { |
1001 | 1 | mxSaveState; |
1002 | 1 | fxRunConstructor(the); |
1003 | 1 | mxRestoreState; |
1004 | 1 | } |
1005 | 1.18M | mxNextCode(2); |
1006 | 1.18M | mxBreak; |
1007 | 1.18M | mxCase(XS_CODE_BEGIN_STRICT_BASE) |
1008 | 35.1k | mxFrame->flag |= XS_STRICT_FLAG; |
1009 | 35.1k | mxSaveState; |
1010 | 35.1k | fxRunBase(the); |
1011 | 35.1k | mxRestoreState; |
1012 | 35.1k | mxNextCode(2); |
1013 | 35.1k | mxBreak; |
1014 | 35.1k | mxCase(XS_CODE_BEGIN_STRICT_DERIVED) |
1015 | 3.52k | mxFrame->flag |= XS_STRICT_FLAG; |
1016 | 3.52k | mxSaveState; |
1017 | 3.52k | fxRunDerived(the); |
1018 | 3.52k | mxRestoreState; |
1019 | 3.52k | mxNextCode(2); |
1020 | 3.52k | mxBreak; |
1021 | 29.1k | mxCase(XS_CODE_BEGIN_STRICT_FIELD) |
1022 | 29.1k | mxFrame->flag |= XS_STRICT_FLAG | XS_FIELD_FLAG; |
1023 | 29.1k | if (mxFrameTarget->kind != XS_UNDEFINED_KIND) { |
1024 | 0 | mxSaveState; |
1025 | 0 | fxRunConstructor(the); |
1026 | 0 | mxRestoreState; |
1027 | 0 | } |
1028 | 29.1k | mxNextCode(2); |
1029 | 29.1k | mxBreak; |
1030 | | |
1031 | 476k | mxCase(XS_CODE_END_ARROW) |
1032 | 476k | slot = mxFrameResult; |
1033 | 476k | goto XS_CODE_END_ALL; |
1034 | 215 | mxCase(XS_CODE_END_BASE) |
1035 | 215 | XS_CODE_END_BASE_ALL: |
1036 | 215 | slot = mxFrameResult; |
1037 | 215 | if (slot->kind != XS_REFERENCE_KIND) |
1038 | 212 | slot = mxFrameThis; |
1039 | 215 | goto XS_CODE_END_ALL; |
1040 | 401 | mxCase(XS_CODE_END_DERIVED) |
1041 | 401 | XS_CODE_END_DERIVED_ALL: |
1042 | 401 | slot = mxFrameResult; |
1043 | 401 | if (slot->kind != XS_REFERENCE_KIND) { |
1044 | 368 | if ((slot->kind != XS_UNDEFINED_KIND) && (slot->kind != XS_CLOSURE_KIND)) |
1045 | 367 | mxRunDebug(XS_TYPE_ERROR, "result: invalid constructor"); |
1046 | 367 | slot = mxFrameThis->value.closure; |
1047 | 367 | if (slot->kind < 0) |
1048 | 366 | mxRunDebug(XS_REFERENCE_ERROR, "this: not initialized"); |
1049 | 366 | } |
1050 | 399 | goto XS_CODE_END_ALL; |
1051 | 4.08M | mxCase(XS_CODE_END) |
1052 | 4.08M | slot = mxFrameResult; |
1053 | 4.08M | if (mxFrameTarget->kind) { |
1054 | 266 | if (slot->kind != XS_REFERENCE_KIND) |
1055 | 224 | slot = mxFrameThis; |
1056 | 266 | } |
1057 | 179M | XS_CODE_END_ALL: |
1058 | | #ifdef mxTraceCall |
1059 | | fxTraceCallEnd(the, mxFrameFunction); |
1060 | | #endif |
1061 | | #ifdef mxInstrument |
1062 | | if (the->stackPeak > mxStack) |
1063 | | the->stackPeak = mxStack; |
1064 | | #endif |
1065 | 179M | mxStack = mxFrameEnd; |
1066 | 179M | mxScope = mxFrame->value.frame.scope; |
1067 | 179M | mxCode = mxFrame->value.frame.code; |
1068 | 179M | mxAllocStack(1); |
1069 | 179M | *mxStack = *slot; |
1070 | 179M | mxFrame = mxFrame->next; |
1071 | 179M | if (!mxFrame || (mxFrame->flag & XS_C_FLAG)) { |
1072 | | #ifdef mxTrace |
1073 | | if (gxDoTrace) fxTraceReturn(the); |
1074 | | #endif |
1075 | 128M | byte = XS_CODE_END; |
1076 | 128M | mxSaveState; |
1077 | 128M | return; |
1078 | 128M | } |
1079 | 50.7M | mxEnvironment = mxFrameToEnvironment(mxFrame); |
1080 | 50.7M | mxFirstCode(); |
1081 | 50.7M | mxBreak; |
1082 | 50.7M | mxCase(XS_CODE_RETURN) |
1083 | 99.0k | mxStack = mxFrameEnd; |
1084 | 99.0k | mxScope = mxFrame->value.frame.scope; |
1085 | 99.0k | mxCode = mxFrame->value.frame.code; |
1086 | 99.0k | mxAllocStack(1); |
1087 | 99.0k | *mxStack = *mxFrameResult; |
1088 | 99.0k | mxFrame = mxFrame->next; |
1089 | | #ifdef mxTrace |
1090 | | if (gxDoTrace) |
1091 | | if (gxDoTrace) fxTraceReturn(the); |
1092 | | #endif |
1093 | 99.0k | mxSaveState; |
1094 | 99.0k | return; |
1095 | | |
1096 | 547k | mxCase(XS_CODE_START_ASYNC) |
1097 | 547k | mxSkipCode(1); |
1098 | 547k | mxSaveState; |
1099 | 547k | variable = gxDefaults.newAsyncInstance(the); |
1100 | 547k | mxRestoreState; |
1101 | 547k | slot = mxFrameEnd; |
1102 | 547k | mxPushKind(XS_INTEGER_KIND); |
1103 | 547k | mxStack->value.integer = mxPtrDiff(mxCode - mxFrameFunction->value.reference->next->value.code.address); |
1104 | 547k | mxPushKind(XS_INTEGER_KIND); |
1105 | 547k | mxStack->value.integer = mxPtrDiff(slot - mxScope); |
1106 | 547k | mxPushKind(XS_INTEGER_KIND); |
1107 | 547k | mxStack->value.integer = mxPtrDiff(slot - mxFrame); |
1108 | 547k | mxPushKind(XS_INTEGER_KIND); |
1109 | 547k | mxStack->value.integer = 0; |
1110 | 547k | mxPushKind(mxFrameFunction->kind); |
1111 | 547k | mxStack->value = mxFrameFunction->value; |
1112 | 547k | index = mxPtrDiff(slot - mxStack); |
1113 | 547k | slot = variable->next; |
1114 | 547k | variable = slot->value.stack.address; |
1115 | 547k | if (slot->value.stack.length < index) { |
1116 | 547k | mxSaveState; |
1117 | 547k | if (variable) |
1118 | 0 | variable = (txSlot *)fxRenewChunk(the, variable, index * sizeof(txSlot)); |
1119 | 547k | if (!variable) |
1120 | 547k | variable = (txSlot *)fxNewChunk(the, index * sizeof(txSlot)); |
1121 | 547k | mxRestoreState; |
1122 | 547k | slot->value.stack.address = variable; |
1123 | 547k | } |
1124 | 547k | slot->value.stack.length = index; |
1125 | 547k | c_memcpy(variable, mxStack, index * sizeof(txSlot)); |
1126 | 547k | mxStack += 5; |
1127 | 547k | mxSaveState; |
1128 | 547k | gxDefaults.runAsync(the, mxStack->value.reference); |
1129 | 547k | mxRestoreState; |
1130 | 547k | slot = mxFrameResult; |
1131 | 547k | goto XS_CODE_END_ALL; |
1132 | | |
1133 | 17.3k | mxCase(XS_CODE_START_ASYNC_GENERATOR) |
1134 | 17.3k | mxSkipCode(1); |
1135 | 17.3k | if (mxFrameTarget->kind != XS_UNDEFINED_KIND) |
1136 | 17.3k | mxRunDebug(XS_TYPE_ERROR, "new: async generator"); |
1137 | 17.3k | slot = mxBehaviorGetProperty(the, mxFrameFunction->value.reference, mxID(_prototype), 0, XS_ANY); |
1138 | 17.3k | mxPushKind(slot->kind); |
1139 | 17.3k | mxStack->value = slot->value; |
1140 | 17.3k | mxSaveState; |
1141 | 17.3k | variable = gxDefaults.newAsyncGeneratorInstance(the); |
1142 | 17.3k | mxRestoreState; |
1143 | 17.3k | mxFrameResult->kind = XS_UNINITIALIZED_KIND; |
1144 | 17.3k | slot = mxFrameEnd; |
1145 | 17.3k | mxPushKind(XS_INTEGER_KIND); |
1146 | 17.3k | mxStack->value.integer = mxPtrDiff(mxCode - mxFrameFunction->value.reference->next->value.code.address); |
1147 | 17.3k | mxPushKind(XS_INTEGER_KIND); |
1148 | 17.3k | mxStack->value.integer = mxPtrDiff(slot - mxScope); |
1149 | 17.3k | mxPushKind(XS_INTEGER_KIND); |
1150 | 17.3k | mxStack->value.integer = mxPtrDiff(slot - mxFrame); |
1151 | 17.3k | mxPushKind(XS_INTEGER_KIND); |
1152 | 17.3k | mxStack->value.integer = 0; |
1153 | 17.3k | mxPushKind(mxFrameFunction->kind); |
1154 | 17.3k | mxStack->value = mxFrameFunction->value; |
1155 | 17.3k | index = mxPtrDiff(slot - mxStack); |
1156 | 17.3k | slot = variable->next; |
1157 | 17.3k | variable = slot->value.stack.address; |
1158 | 17.3k | if (slot->value.stack.length < index) { |
1159 | 17.3k | mxSaveState; |
1160 | 17.3k | if (variable) |
1161 | 0 | variable = (txSlot *)fxRenewChunk(the, variable, index * sizeof(txSlot)); |
1162 | 17.3k | if (!variable) |
1163 | 17.3k | variable = (txSlot *)fxNewChunk(the, index * sizeof(txSlot)); |
1164 | 17.3k | mxRestoreState; |
1165 | 17.3k | slot->value.stack.address = variable; |
1166 | 17.3k | } |
1167 | 17.3k | slot->value.stack.length = index; |
1168 | 17.3k | c_memcpy(variable, mxStack, index * sizeof(txSlot)); |
1169 | 17.3k | mxStack += 5; |
1170 | 17.3k | *mxFrameResult = *(mxStack++); |
1171 | 17.3k | slot = mxFrameResult; |
1172 | 17.3k | goto XS_CODE_END_ALL; |
1173 | | |
1174 | 1.29M | mxCase(XS_CODE_START_GENERATOR) |
1175 | 1.29M | mxSkipCode(1); |
1176 | 1.29M | if (mxFrameTarget->kind != XS_UNDEFINED_KIND) |
1177 | 1.29M | mxRunDebug(XS_TYPE_ERROR, "new: generator"); |
1178 | 1.29M | slot = mxBehaviorGetProperty(the, mxFrameFunction->value.reference, mxID(_prototype), 0, XS_ANY); |
1179 | 1.29M | mxPushKind(slot->kind); |
1180 | 1.29M | mxStack->value = slot->value; |
1181 | 1.29M | mxSaveState; |
1182 | 1.29M | variable = gxDefaults.newGeneratorInstance(the); |
1183 | 1.29M | mxRestoreState; |
1184 | 1.29M | slot = mxFrameEnd; |
1185 | 1.29M | mxPushKind(XS_INTEGER_KIND); |
1186 | 1.29M | mxStack->value.integer = mxPtrDiff(mxCode - mxFrameFunction->value.reference->next->value.code.address); |
1187 | 1.29M | mxPushKind(XS_INTEGER_KIND); |
1188 | 1.29M | mxStack->value.integer = mxPtrDiff(slot - mxScope); |
1189 | 1.29M | mxPushKind(XS_INTEGER_KIND); |
1190 | 1.29M | mxStack->value.integer = mxPtrDiff(slot - mxFrame); |
1191 | 1.29M | mxPushKind(XS_INTEGER_KIND); |
1192 | 1.29M | mxStack->value.integer = 0; |
1193 | 1.29M | mxPushKind(mxFrameFunction->kind); |
1194 | 1.29M | mxStack->value = mxFrameFunction->value; |
1195 | 1.29M | index = mxPtrDiff(slot - mxStack); |
1196 | 1.29M | slot = variable->next; |
1197 | 1.29M | variable = slot->value.stack.address; |
1198 | 1.29M | if (slot->value.stack.length < index) { |
1199 | 1.29M | mxSaveState; |
1200 | 1.29M | if (variable) |
1201 | 0 | variable = (txSlot *)fxRenewChunk(the, variable, index * sizeof(txSlot)); |
1202 | 1.29M | if (!variable) |
1203 | 1.29M | variable = (txSlot *)fxNewChunk(the, index * sizeof(txSlot)); |
1204 | 1.29M | mxRestoreState; |
1205 | 1.29M | slot->value.stack.address = variable; |
1206 | 1.29M | } |
1207 | 1.29M | slot->value.stack.length = index; |
1208 | 1.29M | c_memcpy(variable, mxStack, index * sizeof(txSlot)); |
1209 | 1.29M | mxStack += 5; |
1210 | 1.29M | *mxFrameResult = *(mxStack++); |
1211 | 1.29M | slot = mxFrameResult; |
1212 | 1.29M | goto XS_CODE_END_ALL; |
1213 | | |
1214 | 491k | mxCase(XS_CODE_AWAIT) |
1215 | 660k | mxCase(XS_CODE_YIELD) |
1216 | 660k | mxCase(XS_CODE_YIELD_STAR) |
1217 | 660k | generator->next->next->value.integer = byte; |
1218 | 660k | mxSkipCode(1); |
1219 | 660k | slot = mxFrameEnd; |
1220 | 660k | mxPushKind(XS_INTEGER_KIND); |
1221 | 660k | mxStack->value.integer = mxPtrDiff(mxCode - mxFrameFunction->value.reference->next->value.code.address); |
1222 | 660k | mxPushKind(XS_INTEGER_KIND); |
1223 | 660k | mxStack->value.integer = mxPtrDiff(slot - mxScope); |
1224 | 660k | mxPushKind(XS_INTEGER_KIND); |
1225 | 660k | mxStack->value.integer = mxPtrDiff(slot - mxFrame); |
1226 | 660k | jump = the->firstJump; |
1227 | 660k | offset = 0; |
1228 | 660k | while (jump != yieldJump) { |
1229 | 28 | txJump* nextJump = jump->nextJump; |
1230 | 28 | mxPushKind(XS_INTEGER_KIND); |
1231 | 28 | mxStack->value.integer = mxPtrDiff(jump->code - mxFrameFunction->value.reference->next->value.code.address); |
1232 | 28 | mxPushKind(XS_INTEGER_KIND); |
1233 | 28 | mxStack->value.integer = mxPtrDiff(slot - jump->scope); |
1234 | 28 | mxPushKind(XS_INTEGER_KIND); |
1235 | 28 | mxStack->value.integer = mxPtrDiff(slot - jump->frame); |
1236 | 28 | mxPushKind(XS_INTEGER_KIND); |
1237 | 28 | mxStack->value.integer = mxPtrDiff(slot - jump->stack); |
1238 | 28 | c_free(jump); |
1239 | 28 | jump = nextJump; |
1240 | 28 | offset++; |
1241 | 28 | } |
1242 | 660k | the->firstJump = yieldJump; |
1243 | 660k | mxPushKind(XS_INTEGER_KIND); |
1244 | 660k | mxStack->value.integer = offset; |
1245 | 660k | mxPushKind(mxFrameFunction->kind); |
1246 | 660k | mxStack->value = mxFrameFunction->value; |
1247 | 660k | index = mxPtrDiff(slot - mxStack); |
1248 | 660k | slot = generator->next; |
1249 | 660k | variable = slot->value.stack.address; |
1250 | 660k | if (slot->value.stack.length < index) { |
1251 | 344k | mxSaveState; |
1252 | 344k | if (variable) |
1253 | 344k | variable = (txSlot *)fxRenewChunk(the, variable, index * sizeof(txSlot)); |
1254 | 344k | if (!variable) |
1255 | 63.0k | variable = (txSlot *)fxNewChunk(the, index * sizeof(txSlot)); |
1256 | 344k | mxRestoreState; |
1257 | 344k | slot->value.stack.address = variable; |
1258 | 344k | } |
1259 | 660k | slot->value.stack.length = index; |
1260 | 660k | c_memcpy(variable, mxStack, index * sizeof(txSlot)); |
1261 | 660k | mxStack += 5 + (offset * 4); |
1262 | 660k | *mxFrameResult = *(mxStack++); |
1263 | 660k | slot = mxFrameResult; |
1264 | 660k | goto XS_CODE_END_ALL; |
1265 | | |
1266 | | /* FRAMES */ |
1267 | 5.64M | mxCase(XS_CODE_ARGUMENT) |
1268 | 5.64M | offset = mxRunU1(1); |
1269 | | #ifdef mxTrace |
1270 | | if (gxDoTrace) fxTraceInteger(the, offset); |
1271 | | #endif |
1272 | 5.64M | if (offset < mxFrameArgc) { |
1273 | 4.79M | slot = mxFrameArgv(offset); |
1274 | 4.79M | mxPushKind(slot->kind); |
1275 | 4.79M | mxStack->value = slot->value; |
1276 | 4.79M | } |
1277 | 849k | else { |
1278 | 849k | mxPushKind(XS_UNDEFINED_KIND); |
1279 | 849k | } |
1280 | 5.64M | mxNextCode(2); |
1281 | 5.64M | mxBreak; |
1282 | 5.64M | mxCase(XS_CODE_ARGUMENTS) |
1283 | 150k | offset = mxRunU1(1); |
1284 | | #ifdef mxTrace |
1285 | | if (gxDoTrace) fxTraceInteger(the, offset); |
1286 | | #endif |
1287 | 150k | mxSaveState; |
1288 | 150k | fxRunArguments(the, offset); |
1289 | 150k | mxRestoreState; |
1290 | 150k | mxNextCode(2); |
1291 | 150k | mxBreak; |
1292 | 150k | mxCase(XS_CODE_ARGUMENTS_SLOPPY) |
1293 | 138k | offset = mxRunU1(1); |
1294 | 138k | mxAllocStack(1); |
1295 | 138k | *mxStack = mxArgumentsSloppyPrototype; |
1296 | 138k | mxSaveState; |
1297 | 138k | gxDefaults.newArgumentsSloppyInstance(the, offset); |
1298 | 138k | mxRestoreState; |
1299 | 138k | mxNextCode(2); |
1300 | 138k | mxBreak; |
1301 | 138k | mxCase(XS_CODE_ARGUMENTS_STRICT) |
1302 | 76.9k | offset = mxRunU1(1); |
1303 | 76.9k | mxAllocStack(1); |
1304 | 76.9k | *mxStack = mxArgumentsStrictPrototype; |
1305 | 76.9k | mxSaveState; |
1306 | 76.9k | gxDefaults.newArgumentsStrictInstance(the, offset); |
1307 | 76.9k | mxRestoreState; |
1308 | 76.9k | mxNextCode(2); |
1309 | 76.9k | mxBreak; |
1310 | 76.9k | mxCase(XS_CODE_CURRENT) |
1311 | 73.4k | mxAllocStack(1); |
1312 | 73.4k | *mxStack = *mxFrameFunction; |
1313 | 73.4k | if (!(mxFrame->flag & XS_STRICT_FLAG)) |
1314 | 73.4k | ignore = 1; |
1315 | 73.4k | mxNextCode(1); |
1316 | 73.4k | mxBreak; |
1317 | 73.4k | mxCase(XS_CODE_GET_RESULT) |
1318 | 822 | mxAllocStack(1); |
1319 | 822 | *mxStack = *mxFrameResult; |
1320 | 822 | mxNextCode(1); |
1321 | 822 | mxBreak; |
1322 | 42.4M | mxCase(XS_CODE_SET_RESULT) |
1323 | 42.4M | *mxFrameResult = *(mxStack++); |
1324 | 42.4M | mxNextCode(1); |
1325 | 42.4M | mxBreak; |
1326 | 42.4M | mxCase(XS_CODE_TARGET) |
1327 | 2 | mxAllocStack(1); |
1328 | 2 | *mxStack = *mxFrameTarget; |
1329 | 2 | mxNextCode(1); |
1330 | 2 | mxBreak; |
1331 | 1.91M | mxCase(XS_CODE_THIS) |
1332 | 1.91M | mxAllocStack(1); |
1333 | 1.91M | *mxStack = *mxFrameThis; |
1334 | 1.91M | mxNextCode(1); |
1335 | 1.91M | mxBreak; |
1336 | 1.91M | mxCase(XS_CODE_GET_THIS) |
1337 | 3.21k | slot = mxFrameThis; |
1338 | 3.21k | variable = slot->value.closure; |
1339 | 3.21k | if (variable->kind < 0) |
1340 | 3.21k | mxRunDebug(XS_REFERENCE_ERROR, "this: not initialized yet"); |
1341 | 3.21k | mxPushKind(variable->kind); |
1342 | 3.21k | mxStack->value = variable->value; |
1343 | 3.21k | mxNextCode(1); |
1344 | 3.21k | mxBreak; |
1345 | 3.49k | mxCase(XS_CODE_SET_THIS) |
1346 | 3.49k | slot = mxFrameThis; |
1347 | 3.49k | variable = slot->value.closure; |
1348 | 3.49k | if (variable->kind >= 0) |
1349 | 3.49k | mxRunDebug(XS_REFERENCE_ERROR, "this: already initialized"); |
1350 | 3.49k | variable->kind = mxStack->kind; |
1351 | 3.49k | variable->value = mxStack->value; |
1352 | 3.49k | mxNextCode(1); |
1353 | 3.49k | mxBreak; |
1354 | | |
1355 | | /* EXCEPTIONS */ |
1356 | 1.65M | mxCase(XS_CODE_EXCEPTION) |
1357 | 1.65M | mxAllocStack(1); |
1358 | 1.65M | *mxStack = mxException; |
1359 | 1.65M | mxException = mxUndefined; |
1360 | 1.65M | mxNextCode(1); |
1361 | 1.65M | mxBreak; |
1362 | 1.65M | mxCase(XS_CODE_CATCH_4) |
1363 | 2.97k | offset = mxRunS4(1); |
1364 | 2.97k | mxNextCode(5); |
1365 | 2.97k | goto XS_CODE_CATCH; |
1366 | 809k | mxCase(XS_CODE_CATCH_2) |
1367 | 809k | offset = mxRunS2(1); |
1368 | 809k | mxNextCode(3); |
1369 | 809k | goto XS_CODE_CATCH; |
1370 | 1.29M | mxCase(XS_CODE_CATCH_1) |
1371 | 1.29M | offset = mxRunS1(1); |
1372 | 1.29M | mxNextCode(2); |
1373 | 2.10M | XS_CODE_CATCH: |
1374 | 2.10M | jump = c_malloc(sizeof(txJump)); |
1375 | 2.10M | if (jump) { |
1376 | 2.10M | jump->nextJump = the->firstJump; |
1377 | 2.10M | jump->stack = mxStack; |
1378 | 2.10M | jump->scope = mxScope; |
1379 | 2.10M | jump->frame = mxFrame; |
1380 | 2.10M | jump->environment = mxEnvironment->value.reference; |
1381 | 2.10M | jump->code = mxCode + offset; |
1382 | 2.10M | jump->flag = 1; |
1383 | 2.10M | the->firstJump = jump; |
1384 | 2.10M | if (c_setjmp(jump->buffer) != 0) { |
1385 | 765k | jump = the->firstJump; |
1386 | 765k | the->firstJump = jump->nextJump; |
1387 | 765k | mxStack = jump->stack; |
1388 | 765k | mxScope = jump->scope; |
1389 | 765k | mxFrame = jump->frame; |
1390 | 765k | mxEnvironment = mxFrameToEnvironment(mxFrame); |
1391 | 765k | mxEnvironment->value.reference = jump->environment; |
1392 | 765k | mxCode = jump->code; |
1393 | 765k | c_free(jump); |
1394 | 765k | mxFirstCode(); |
1395 | 765k | } |
1396 | 2.10M | } |
1397 | 0 | else { |
1398 | 0 | mxSaveState; |
1399 | 0 | fxAbort(the, XS_NOT_ENOUGH_MEMORY_EXIT); |
1400 | 0 | } |
1401 | 2.10M | mxBreak; |
1402 | 2.10M | mxCase(XS_CODE_RETHROW) |
1403 | 0 | mxSaveState; |
1404 | 0 | fxJump(the); |
1405 | 0 | mxBreak; |
1406 | 397k | mxCase(XS_CODE_THROW) |
1407 | 397k | mxException = *mxStack; |
1408 | 397k | #ifdef mxDebug |
1409 | 397k | mxSaveState; |
1410 | 397k | fxDebugThrow(the, C_NULL, 0, "throw"); |
1411 | 397k | mxRestoreState; |
1412 | | #elif mxInstrument |
1413 | | mxSaveState; |
1414 | | fxTraceException(the); |
1415 | | mxRestoreState; |
1416 | | #endif |
1417 | 397k | mxSaveState; |
1418 | 397k | fxJump(the); |
1419 | 0 | mxBreak; |
1420 | 14 | mxCase(XS_CODE_THROW_STATUS) |
1421 | 14 | if (the->status & XS_THROW_STATUS) { |
1422 | 5 | mxException = *mxStack; |
1423 | 5 | #ifdef mxDebug |
1424 | 5 | mxSaveState; |
1425 | 5 | fxDebugThrow(the, C_NULL, 0, "throw"); |
1426 | 5 | mxRestoreState; |
1427 | | #elif mxInstrument |
1428 | | mxSaveState; |
1429 | | fxTraceException(the); |
1430 | | mxRestoreState; |
1431 | | #endif |
1432 | 5 | mxSaveState; |
1433 | 5 | fxJump(the); |
1434 | 5 | } |
1435 | 9 | mxNextCode(1); |
1436 | 9 | mxBreak; |
1437 | 1.32M | mxCase(XS_CODE_UNCATCH) |
1438 | 1.32M | jump = the->firstJump; |
1439 | 1.32M | the->firstJump = jump->nextJump; |
1440 | 1.32M | c_free(jump); |
1441 | 1.32M | mxNextCode(1); |
1442 | 1.32M | mxBreak; |
1443 | | |
1444 | | /* BRANCHES */ |
1445 | 21.3M | mxCase(XS_CODE_BRANCH_1) |
1446 | 21.3M | offset = mxRunS1(1); |
1447 | 21.3M | mxBranch(2, offset); |
1448 | 21.3M | mxBreak; |
1449 | 21.3M | mxCase(XS_CODE_BRANCH_2) |
1450 | 15.8M | offset = mxRunS2(1); |
1451 | 15.8M | mxBranch(3, offset); |
1452 | 15.8M | mxBreak; |
1453 | 15.8M | mxCase(XS_CODE_BRANCH_4) |
1454 | 490k | offset = mxRunS4(1); |
1455 | 490k | mxBranch(5, offset); |
1456 | 490k | mxBreak; |
1457 | 490k | mxCase(XS_CODE_BRANCH_CHAIN_4) |
1458 | 3 | offset = mxRunS4(1); |
1459 | 3 | index = 5; |
1460 | 3 | goto XS_CODE_BRANCH_CHAIN; |
1461 | 112k | mxCase(XS_CODE_BRANCH_CHAIN_2) |
1462 | 112k | offset = mxRunS2(1); |
1463 | 112k | index = 3; |
1464 | 112k | goto XS_CODE_BRANCH_CHAIN; |
1465 | 154k | mxCase(XS_CODE_BRANCH_CHAIN_1) |
1466 | 154k | offset = mxRunS1(1); |
1467 | 154k | index = 2; |
1468 | 267k | XS_CODE_BRANCH_CHAIN: |
1469 | 267k | byte = mxStack->kind; |
1470 | 267k | if ((XS_UNDEFINED_KIND == byte) || (XS_NULL_KIND == byte)) { |
1471 | 19.2k | mxStack->kind = XS_UNDEFINED_KIND; |
1472 | 19.2k | mxBranch(index, offset); |
1473 | 19.2k | } |
1474 | 248k | else |
1475 | 248k | mxNextCode((txS4)index); |
1476 | 267k | mxBreak; |
1477 | 267k | mxCase(XS_CODE_BRANCH_COALESCE_4) |
1478 | 148k | offset = mxRunS4(1); |
1479 | 148k | index = 5; |
1480 | 148k | goto XS_CODE_BRANCH_COALESCE; |
1481 | 3.08M | mxCase(XS_CODE_BRANCH_COALESCE_2) |
1482 | 3.08M | offset = mxRunS2(1); |
1483 | 3.08M | index = 3; |
1484 | 3.08M | goto XS_CODE_BRANCH_COALESCE; |
1485 | 907k | mxCase(XS_CODE_BRANCH_COALESCE_1) |
1486 | 907k | offset = mxRunS1(1); |
1487 | 907k | index = 2; |
1488 | 4.14M | XS_CODE_BRANCH_COALESCE: |
1489 | 4.14M | byte = mxStack->kind; |
1490 | 4.14M | if ((XS_UNDEFINED_KIND == byte) || (XS_NULL_KIND == byte)) { |
1491 | 4.23k | mxStack++; |
1492 | 4.23k | mxNextCode((txS4)index); |
1493 | 4.23k | } |
1494 | 4.14M | else { |
1495 | 4.14M | mxBranch(index, offset); |
1496 | 4.14M | } |
1497 | 4.14M | mxBreak; |
1498 | 4.14M | mxCase(XS_CODE_BRANCH_ELSE_4) |
1499 | 397k | offset = mxRunS4(1); |
1500 | 397k | index = 5; |
1501 | 397k | goto XS_CODE_BRANCH_ELSE; |
1502 | 8.82M | mxCase(XS_CODE_BRANCH_ELSE_2) |
1503 | 8.82M | offset = mxRunS2(1); |
1504 | 8.82M | index = 3; |
1505 | 8.82M | goto XS_CODE_BRANCH_ELSE; |
1506 | 24.4M | mxCase(XS_CODE_BRANCH_ELSE_1) |
1507 | 24.4M | offset = mxRunS1(1); |
1508 | 24.4M | index = 2; |
1509 | 33.6M | XS_CODE_BRANCH_ELSE: |
1510 | 33.6M | byte = mxStack->kind; |
1511 | 33.6M | if (XS_BOOLEAN_KIND == byte) { |
1512 | 17.1M | mxBranchElse(mxStack->value.boolean, index, offset); |
1513 | 17.1M | } |
1514 | 16.4M | else if (XS_INTEGER_KIND == byte) { |
1515 | 11.5M | mxBranchElse(mxStack->value.integer, index, offset); |
1516 | 11.5M | } |
1517 | 4.96M | else if (XS_NUMBER_KIND == byte) { |
1518 | 1.65M | mxBranchIf((c_isnan(mxStack->value.number) || c_iszero(mxStack->value.number)), index, offset); |
1519 | 1.65M | mxFloatingPointOp("else"); |
1520 | 1.65M | } |
1521 | 3.31M | else if ((XS_BIGINT_KIND == byte) || (XS_BIGINT_X_KIND == byte)) { |
1522 | 850k | mxBranchIf(((mxStack->value.bigint.size == 1) && (mxStack->value.bigint.data[0] == 0)), index, offset); |
1523 | 850k | } |
1524 | 2.46M | else if ((XS_STRING_KIND == byte) || (XS_STRING_X_KIND == byte)) { |
1525 | 1.13M | mxBranchIf(c_isEmpty(mxStack->value.string), index, offset); |
1526 | 1.13M | } |
1527 | 1.32M | else { |
1528 | 1.32M | mxBranchIf((XS_UNDEFINED_KIND == byte) || (XS_NULL_KIND == byte), index, offset); |
1529 | 1.32M | } |
1530 | 33.6M | mxStack++; |
1531 | 33.6M | mxBreak; |
1532 | 33.6M | mxCase(XS_CODE_BRANCH_IF_4) |
1533 | 26.0k | offset = mxRunS4(1); |
1534 | 26.0k | index = 5; |
1535 | 26.0k | goto XS_CODE_BRANCH_IF; |
1536 | 6.53M | mxCase(XS_CODE_BRANCH_IF_2) |
1537 | 6.53M | offset = mxRunS2(1); |
1538 | 6.53M | index = 3; |
1539 | 6.53M | goto XS_CODE_BRANCH_IF; |
1540 | 6.69M | mxCase(XS_CODE_BRANCH_IF_1) |
1541 | 6.69M | offset = mxRunS1(1); |
1542 | 6.69M | index = 2; |
1543 | 13.2M | XS_CODE_BRANCH_IF: |
1544 | 13.2M | byte = mxStack->kind; |
1545 | 13.2M | if (XS_BOOLEAN_KIND == byte) { |
1546 | 8.45M | mxBranchIf(mxStack->value.boolean, index, offset); |
1547 | 8.45M | } |
1548 | 4.80M | else if (XS_INTEGER_KIND == byte) { |
1549 | 3.09M | mxBranchIf(mxStack->value.integer, index, offset); |
1550 | 3.09M | } |
1551 | 1.70M | else if (XS_NUMBER_KIND == byte) { |
1552 | 410k | mxBranchElse(c_isnan(mxStack->value.number) || c_iszero(mxStack->value.number), index, offset); |
1553 | 410k | mxFloatingPointOp("if"); |
1554 | 410k | } |
1555 | 1.29M | else if ((XS_BIGINT_KIND == byte) || (XS_BIGINT_X_KIND == byte)) { |
1556 | 200k | mxBranchElse((mxStack->value.bigint.size == 1) && (mxStack->value.bigint.data[0] == 0), index, offset); |
1557 | 200k | } |
1558 | 1.09M | else if ((XS_STRING_KIND == byte) || (XS_STRING_X_KIND == byte)) { |
1559 | 593k | mxBranchElse(c_isEmpty(mxStack->value.string), index, offset); |
1560 | 593k | } |
1561 | 501k | else { |
1562 | 501k | mxBranchElse((XS_UNDEFINED_KIND == byte) || (XS_NULL_KIND == byte), index, offset); |
1563 | 501k | } |
1564 | 13.2M | mxStack++; |
1565 | 13.2M | mxBreak; |
1566 | 13.2M | mxCase(XS_CODE_BRANCH_STATUS_4) |
1567 | 0 | offset = mxRunS4(1); |
1568 | 0 | index = 5; |
1569 | 0 | goto XS_CODE_BRANCH_STATUS; |
1570 | 57.8k | mxCase(XS_CODE_BRANCH_STATUS_2) |
1571 | 57.8k | offset = mxRunS2(1); |
1572 | 57.8k | index = 3; |
1573 | 57.8k | goto XS_CODE_BRANCH_STATUS; |
1574 | 563k | mxCase(XS_CODE_BRANCH_STATUS_1) |
1575 | 563k | offset = mxRunS1(1); |
1576 | 563k | index = 2; |
1577 | 621k | XS_CODE_BRANCH_STATUS: |
1578 | 621k | if (the->status & XS_THROW_STATUS) { |
1579 | 2 | mxException = *mxStack; |
1580 | 2 | #ifdef mxDebug |
1581 | 2 | mxSaveState; |
1582 | 2 | fxDebugThrow(the, C_NULL, 0, "throw"); |
1583 | 2 | mxRestoreState; |
1584 | | #elif mxInstrument |
1585 | | mxSaveState; |
1586 | | fxTraceException(the); |
1587 | | mxRestoreState; |
1588 | | #endif |
1589 | 2 | mxSaveState; |
1590 | 2 | fxJump(the); |
1591 | 2 | } |
1592 | 621k | mxNextCode((the->status & XS_RETURN_STATUS) ? index : index + offset); |
1593 | 621k | mxBreak; |
1594 | | |
1595 | | /* STACK */ |
1596 | 57.6M | mxCase(XS_CODE_DUB) |
1597 | 57.6M | mxAllocStack(1); |
1598 | 57.6M | *mxStack = *(mxStack + 1); |
1599 | 57.6M | mxNextCode(1); |
1600 | 57.6M | mxBreak; |
1601 | 57.6M | mxCase(XS_CODE_DUB_AT) |
1602 | 2.54M | mxAllocStack(2); |
1603 | 2.54M | *(mxStack + 1) = *(mxStack + 3); |
1604 | 2.54M | *mxStack = *(mxStack + 2); |
1605 | 2.54M | mxNextCode(1); |
1606 | 2.54M | mxBreak; |
1607 | 82.1M | mxCase(XS_CODE_POP) |
1608 | 82.1M | mxStack++; |
1609 | 82.1M | mxNextCode(1); |
1610 | 82.1M | mxBreak; |
1611 | 82.1M | mxCase(XS_CODE_SWAP) |
1612 | 7.27k | scratch = *(mxStack); |
1613 | 7.27k | *(mxStack) = *(mxStack + 1); |
1614 | 7.27k | *(mxStack + 1) = scratch; |
1615 | 7.27k | mxNextCode(1); |
1616 | 7.27k | mxBreak; |
1617 | | |
1618 | | /* SCOPE */ |
1619 | 7.27k | mxCase(XS_CODE_CONST_CLOSURE_2) |
1620 | 0 | index = mxRunU2(1); |
1621 | 0 | mxNextCode(3); |
1622 | 0 | goto XS_CODE_CONST_CLOSURE; |
1623 | 487k | mxCase(XS_CODE_CONST_CLOSURE_1) |
1624 | 487k | index = mxRunU1(1); |
1625 | 487k | mxNextCode(2); |
1626 | 487k | XS_CODE_CONST_CLOSURE: |
1627 | | #ifdef mxTrace |
1628 | | if (gxDoTrace) fxTraceIndex(the, index - 1); |
1629 | | #endif |
1630 | 487k | slot = mxEnvironment - index; |
1631 | 487k | variable = slot->value.closure; |
1632 | 487k | if (variable->kind >= 0) |
1633 | 477k | mxRunDebugID(XS_REFERENCE_ERROR, "set %s: already initialized", slot->ID); |
1634 | | // slot->flag |= XS_DONT_SET_FLAG; //@@ |
1635 | 477k | variable->flag |= XS_DONT_SET_FLAG; |
1636 | 477k | variable->kind = mxStack->kind; |
1637 | 477k | variable->value = mxStack->value; |
1638 | 477k | if (!(mxFrame->flag & XS_STRICT_FLAG) && ignore) { |
1639 | 2.10k | ignore = 0; |
1640 | 2.10k | variable->flag |= XS_DONT_ENUM_FLAG; |
1641 | 2.10k | } |
1642 | 477k | mxBreak; |
1643 | 477k | mxCase(XS_CODE_CONST_LOCAL_2) |
1644 | 131k | index = mxRunU2(1); |
1645 | 131k | mxNextCode(3); |
1646 | 131k | goto XS_CODE_CONST_LOCAL; |
1647 | 4.15M | mxCase(XS_CODE_CONST_LOCAL_1) |
1648 | 4.15M | index = mxRunU1(1); |
1649 | 4.15M | mxNextCode(2); |
1650 | 4.28M | XS_CODE_CONST_LOCAL: |
1651 | | #ifdef mxTrace |
1652 | | if (gxDoTrace) fxTraceIndex(the, index - 1); |
1653 | | #endif |
1654 | 4.28M | variable = mxEnvironment - index; |
1655 | 4.28M | if (variable->kind >= 0) |
1656 | 4.28M | mxRunDebugID(XS_REFERENCE_ERROR, "set %s: already initialized", variable->ID); |
1657 | 4.28M | variable->flag |= XS_DONT_SET_FLAG; |
1658 | 4.28M | variable->kind = mxStack->kind; |
1659 | 4.28M | variable->value = mxStack->value; |
1660 | 4.28M | if (!(mxFrame->flag & XS_STRICT_FLAG) && ignore) { |
1661 | 58.5k | ignore = 0; |
1662 | 58.5k | variable->flag |= XS_DONT_ENUM_FLAG; |
1663 | 58.5k | } |
1664 | 4.28M | mxBreak; |
1665 | | |
1666 | 4.28M | mxCase(XS_CODE_GET_CLOSURE_2) |
1667 | 0 | index = mxRunU2(1); |
1668 | 0 | mxNextCode(3); |
1669 | 0 | goto XS_CODE_GET_CLOSURE; |
1670 | 6.12M | mxCase(XS_CODE_GET_CLOSURE_1) |
1671 | 6.12M | index = mxRunU1(1); |
1672 | 6.12M | mxNextCode(2); |
1673 | 6.12M | XS_CODE_GET_CLOSURE: |
1674 | | #ifdef mxTrace |
1675 | | if (gxDoTrace) fxTraceIndex(the, index - 1); |
1676 | | #endif |
1677 | 6.12M | slot = mxEnvironment - index; |
1678 | 6.12M | #ifdef mxDebug |
1679 | 6.12M | offset = slot->ID; |
1680 | 6.12M | #endif |
1681 | 6.12M | variable = slot->value.closure; |
1682 | 6.12M | if (variable->kind < 0) |
1683 | 6.08M | mxRunDebugID(XS_REFERENCE_ERROR, "get %s: not initialized yet", slot->ID); |
1684 | | #if mxAliasInstance |
1685 | | offset = variable->ID; |
1686 | | if (offset) { |
1687 | | slot = the->aliasArray[offset]; |
1688 | | if (slot) |
1689 | | variable = slot; |
1690 | | } |
1691 | | #endif |
1692 | 6.08M | mxPushKind(variable->kind); |
1693 | 6.08M | mxStack->value = variable->value; |
1694 | 6.08M | mxBreak; |
1695 | 6.08M | mxCase(XS_CODE_GET_LOCAL_2) |
1696 | 400k | index = mxRunU2(1); |
1697 | 400k | mxNextCode(3); |
1698 | 400k | goto XS_CODE_GET_LOCAL; |
1699 | 56.7M | mxCase(XS_CODE_GET_LOCAL_1) |
1700 | 56.7M | index = mxRunU1(1); |
1701 | 56.7M | mxNextCode(2); |
1702 | 57.1M | XS_CODE_GET_LOCAL: |
1703 | | #ifdef mxTrace |
1704 | | if (gxDoTrace) fxTraceIndex(the, index - 1); |
1705 | | #endif |
1706 | 57.1M | variable = mxEnvironment - index; |
1707 | 57.1M | #ifdef mxDebug |
1708 | 57.1M | offset = variable->ID; |
1709 | 57.1M | #endif |
1710 | 57.1M | if (variable->kind < 0) |
1711 | 57.1M | mxRunDebugID(XS_REFERENCE_ERROR, "get %s: not initialized yet", variable->ID); |
1712 | 57.1M | mxPushKind(variable->kind); |
1713 | 57.1M | mxStack->value = variable->value; |
1714 | 57.1M | mxBreak; |
1715 | | |
1716 | 57.1M | mxCase(XS_CODE_LET_CLOSURE_2) |
1717 | 0 | index = mxRunU2(1); |
1718 | 0 | mxNextCode(3); |
1719 | 0 | goto XS_CODE_LET_CLOSURE; |
1720 | 161k | mxCase(XS_CODE_LET_CLOSURE_1) |
1721 | 161k | index = mxRunU1(1); |
1722 | 161k | mxNextCode(2); |
1723 | 161k | XS_CODE_LET_CLOSURE: |
1724 | | #ifdef mxTrace |
1725 | | if (gxDoTrace) fxTraceIndex(the, index - 1); |
1726 | | #endif |
1727 | 161k | slot = mxEnvironment - index; |
1728 | 161k | variable = slot->value.closure; |
1729 | 161k | variable->kind = mxStack->kind; |
1730 | 161k | variable->value = mxStack->value; |
1731 | 161k | mxBreak; |
1732 | 161k | mxCase(XS_CODE_LET_LOCAL_2) |
1733 | 0 | index = mxRunU2(1); |
1734 | 0 | mxNextCode(3); |
1735 | 0 | goto XS_CODE_LET_LOCAL; |
1736 | 1.32M | mxCase(XS_CODE_LET_LOCAL_1) |
1737 | 1.32M | index = mxRunU1(1); |
1738 | 1.32M | mxNextCode(2); |
1739 | 1.32M | XS_CODE_LET_LOCAL: |
1740 | | #ifdef mxTrace |
1741 | | if (gxDoTrace) fxTraceIndex(the, index - 1); |
1742 | | #endif |
1743 | 1.32M | variable = mxEnvironment - index; |
1744 | 1.32M | variable->kind = mxStack->kind; |
1745 | 1.32M | variable->value = mxStack->value; |
1746 | 1.32M | mxBreak; |
1747 | | |
1748 | 1.48M | mxCase(XS_CODE_NEW_CLOSURE) |
1749 | 1.48M | offset = mxRunID(1); |
1750 | | #ifdef mxTrace |
1751 | | if (gxDoTrace) fxTraceID(the, (txID)offset, 0); |
1752 | | #endif |
1753 | 1.48M | mxNextCode(1 + sizeof(txID)); |
1754 | 1.48M | slot = --mxScope; |
1755 | | #ifdef mxTrace |
1756 | | if (gxDoTrace) fxTraceIndex(the, mxEnvironment - mxScope - 1); |
1757 | | #endif |
1758 | 1.48M | mxSaveState; |
1759 | 1.48M | variable = fxNewSlot(the); |
1760 | 1.48M | mxRestoreState; |
1761 | 1.48M | slot->flag = XS_DONT_DELETE_FLAG; |
1762 | 1.48M | slot->ID = (txID)offset; |
1763 | 1.48M | slot->kind = XS_CLOSURE_KIND; |
1764 | 1.48M | slot->value.closure = variable; |
1765 | 1.48M | variable->kind = XS_UNINITIALIZED_KIND; |
1766 | 1.48M | mxBreak; |
1767 | 11.6M | mxCase(XS_CODE_NEW_LOCAL) |
1768 | 11.6M | offset = mxRunID(1); |
1769 | | #ifdef mxTrace |
1770 | | if (gxDoTrace) fxTraceID(the, (txID)offset, 0); |
1771 | | #endif |
1772 | 11.6M | mxNextCode(1 + sizeof(txID)); |
1773 | 11.6M | variable = --mxScope; |
1774 | | #ifdef mxTrace |
1775 | | if (gxDoTrace) fxTraceIndex(the, mxEnvironment - mxScope - 1); |
1776 | | #endif |
1777 | 11.6M | variable->flag = XS_DONT_DELETE_FLAG; |
1778 | 11.6M | variable->ID = (txID)offset; |
1779 | 11.6M | variable->kind = XS_UNINITIALIZED_KIND; |
1780 | 11.6M | mxBreak; |
1781 | 33.0M | mxCase(XS_CODE_NEW_TEMPORARY) |
1782 | 33.0M | variable = --mxScope; |
1783 | | #ifdef mxTrace |
1784 | | if (gxDoTrace) fxTraceIndex(the, mxEnvironment - mxScope - 1); |
1785 | | #endif |
1786 | 33.0M | mxInitSlotKind(variable, XS_UNDEFINED_KIND); |
1787 | 33.0M | mxNextCode(1); |
1788 | 33.0M | mxBreak; |
1789 | | |
1790 | 33.0M | mxCase(XS_CODE_PULL_CLOSURE_2) |
1791 | 0 | index = mxRunU2(1); |
1792 | 0 | mxNextCode(3); |
1793 | 0 | goto XS_CODE_PULL_CLOSURE; |
1794 | 524k | mxCase(XS_CODE_PULL_CLOSURE_1) |
1795 | 524k | index = mxRunU1(1); |
1796 | 524k | mxNextCode(2); |
1797 | 524k | XS_CODE_PULL_CLOSURE: |
1798 | | #ifdef mxTrace |
1799 | | if (gxDoTrace) fxTraceIndex(the, index - 1); |
1800 | | #endif |
1801 | 524k | slot = mxEnvironment - index; |
1802 | 524k | if (slot->flag & XS_DONT_SET_FLAG) // import |
1803 | 524k | mxRunDebugID(XS_TYPE_ERROR, "set %s: const", slot->ID); |
1804 | 524k | variable = slot->value.closure; |
1805 | 524k | if (variable->kind < 0) |
1806 | 524k | mxRunDebugID(XS_REFERENCE_ERROR, "set %s: not initialized yet", slot->ID); |
1807 | 524k | if (variable->flag & XS_DONT_SET_FLAG) { |
1808 | 2.10k | if (variable->flag & XS_DONT_ENUM_FLAG) { |
1809 | 2.10k | mxStack++; |
1810 | 2.10k | mxBreak; |
1811 | 2.10k | } |
1812 | 2.10k | mxRunDebugID(XS_TYPE_ERROR, "set %s: const", slot->ID); |
1813 | 0 | } |
1814 | | #if mxAliasInstance |
1815 | | offset = variable->ID; |
1816 | | if (offset) { |
1817 | | variable = the->aliasArray[offset]; |
1818 | | if (!variable) { |
1819 | | mxSaveState; |
1820 | | variable = fxNewSlot(the); |
1821 | | mxRestoreState; |
1822 | | the->aliasArray[offset] = variable; |
1823 | | } |
1824 | | } |
1825 | | #endif |
1826 | 522k | variable->kind = mxStack->kind; |
1827 | 522k | variable->value = mxStack->value; |
1828 | 522k | mxStack++; |
1829 | 522k | mxBreak; |
1830 | 522k | mxCase(XS_CODE_PULL_LOCAL_2) |
1831 | 398k | index = mxRunU2(1); |
1832 | 398k | mxNextCode(3); |
1833 | 398k | goto XS_CODE_PULL_LOCAL; |
1834 | 19.9M | mxCase(XS_CODE_PULL_LOCAL_1) |
1835 | 19.9M | index = mxRunU1(1); |
1836 | 19.9M | mxNextCode(2); |
1837 | 20.3M | XS_CODE_PULL_LOCAL: |
1838 | | #ifdef mxTrace |
1839 | | if (gxDoTrace) fxTraceIndex(the, index - 1); |
1840 | | #endif |
1841 | 20.3M | variable = mxEnvironment - index; |
1842 | 20.3M | if (variable->kind < 0) |
1843 | 20.3M | mxRunDebugID(XS_REFERENCE_ERROR, "set %s: not initialized yet", variable->ID); |
1844 | 20.3M | if (variable->flag & XS_DONT_SET_FLAG) { |
1845 | 789 | if (variable->flag & XS_DONT_ENUM_FLAG) { |
1846 | 789 | mxStack++; |
1847 | 789 | mxBreak; |
1848 | 789 | } |
1849 | 789 | mxRunDebugID(XS_TYPE_ERROR, "set %s: const", variable->ID); |
1850 | 0 | } |
1851 | 20.3M | variable->kind = mxStack->kind; |
1852 | 20.3M | variable->value = mxStack->value; |
1853 | 20.3M | mxStack++; |
1854 | 20.3M | mxBreak; |
1855 | | |
1856 | 20.3M | mxCase(XS_CODE_REFRESH_CLOSURE_2) |
1857 | 0 | index = mxRunU2(1); |
1858 | 0 | mxNextCode(3); |
1859 | 0 | goto XS_CODE_REFRESH_CLOSURE; |
1860 | 76.5k | mxCase(XS_CODE_REFRESH_CLOSURE_1) |
1861 | 76.5k | index = mxRunU1(1); |
1862 | 76.5k | mxNextCode(2); |
1863 | 76.5k | XS_CODE_REFRESH_CLOSURE: |
1864 | | #ifdef mxTrace |
1865 | | if (gxDoTrace) fxTraceIndex(the, index - 1); |
1866 | | #endif |
1867 | 76.5k | variable = mxEnvironment - index; |
1868 | 76.5k | mxSaveState; |
1869 | 76.5k | slot = fxNewSlot(the); |
1870 | 76.5k | mxRestoreState; |
1871 | 76.5k | slot->flag = variable->value.closure->flag; |
1872 | 76.5k | slot->kind = variable->value.closure->kind; |
1873 | 76.5k | slot->value = variable->value.closure->value; |
1874 | 76.5k | variable->value.closure = slot; |
1875 | 76.5k | mxBreak; |
1876 | 76.5k | mxCase(XS_CODE_REFRESH_LOCAL_2) |
1877 | 0 | index = mxRunU2(1); |
1878 | 0 | mxNextCode(3); |
1879 | 0 | goto XS_CODE_REFRESH_LOCAL; |
1880 | 1.16M | mxCase(XS_CODE_REFRESH_LOCAL_1) |
1881 | 1.16M | index = mxRunU1(1); |
1882 | 1.16M | mxNextCode(2); |
1883 | 1.16M | XS_CODE_REFRESH_LOCAL: |
1884 | | #ifdef mxTrace |
1885 | | if (gxDoTrace) fxTraceIndex(the, index - 1); |
1886 | | #endif |
1887 | 1.16M | variable = mxEnvironment - index; |
1888 | 1.16M | mxBreak; |
1889 | | |
1890 | 1.16M | mxCase(XS_CODE_RESERVE_2) |
1891 | 9.86k | index = mxRunU2(1); |
1892 | 9.86k | mxNextCode(3); |
1893 | 9.86k | goto XS_CODE_RESERVE; |
1894 | 6.29M | mxCase(XS_CODE_RESERVE_1) |
1895 | 6.29M | index = mxRunU1(1); |
1896 | 6.29M | mxNextCode(2); |
1897 | 6.30M | XS_CODE_RESERVE: |
1898 | | #ifdef mxTrace |
1899 | | if (gxDoTrace) fxTraceIndex(the, index); |
1900 | | #endif |
1901 | 6.30M | mxAllocStack(index); |
1902 | 6.30M | c_memset(mxStack, 0, index * sizeof(txSlot)); |
1903 | 6.30M | mxBreak; |
1904 | | |
1905 | 6.30M | mxCase(XS_CODE_RESET_CLOSURE_2) |
1906 | 0 | index = mxRunU2(1); |
1907 | 0 | mxNextCode(3); |
1908 | 0 | goto XS_CODE_RESET_CLOSURE; |
1909 | 905 | mxCase(XS_CODE_RESET_CLOSURE_1) |
1910 | 905 | index = mxRunU1(1); |
1911 | 905 | mxNextCode(2); |
1912 | 905 | XS_CODE_RESET_CLOSURE: |
1913 | | #ifdef mxTrace |
1914 | | if (gxDoTrace) fxTraceIndex(the, index); |
1915 | | #endif |
1916 | 905 | slot = mxEnvironment - index; |
1917 | 905 | mxSaveState; |
1918 | 905 | variable = fxNewSlot(the); |
1919 | 905 | mxRestoreState; |
1920 | 905 | variable->kind = XS_UNINITIALIZED_KIND; |
1921 | 905 | slot->value.closure = variable; |
1922 | 905 | mxBreak; |
1923 | 131k | mxCase(XS_CODE_RESET_LOCAL_2) |
1924 | 131k | index = mxRunU2(1); |
1925 | 131k | mxNextCode(3); |
1926 | 131k | goto XS_CODE_RESET_LOCAL; |
1927 | 1.32M | mxCase(XS_CODE_RESET_LOCAL_1) |
1928 | 1.32M | index = mxRunU1(1); |
1929 | 1.32M | mxNextCode(2); |
1930 | 1.45M | XS_CODE_RESET_LOCAL: |
1931 | | #ifdef mxTrace |
1932 | | if (gxDoTrace) fxTraceIndex(the, index); |
1933 | | #endif |
1934 | 1.45M | variable = mxEnvironment - index; |
1935 | 1.45M | variable->flag = XS_NO_FLAG; |
1936 | 1.45M | variable->kind = XS_UNINITIALIZED_KIND; |
1937 | 1.45M | mxBreak; |
1938 | | |
1939 | 1.45M | mxCase(XS_CODE_SET_CLOSURE_2) |
1940 | 0 | index = mxRunU2(1); |
1941 | 0 | mxNextCode(3); |
1942 | 0 | goto XS_CODE_SET_CLOSURE; |
1943 | 675k | mxCase(XS_CODE_SET_CLOSURE_1) |
1944 | 675k | index = mxRunU1(1); |
1945 | 675k | mxNextCode(2); |
1946 | 675k | XS_CODE_SET_CLOSURE: |
1947 | | #ifdef mxTrace |
1948 | | if (gxDoTrace) fxTraceIndex(the, index - 1); |
1949 | | #endif |
1950 | 675k | slot = mxEnvironment - index; |
1951 | 675k | if (slot->flag & XS_DONT_SET_FLAG) // import |
1952 | 675k | mxRunDebugID(XS_TYPE_ERROR, "set %s: const", slot->ID); |
1953 | 675k | variable = slot->value.closure; |
1954 | 675k | if (variable->kind < 0) |
1955 | 675k | mxRunDebugID(XS_REFERENCE_ERROR, "set %s: not initialized yet", slot->ID); |
1956 | 675k | if (variable->flag & XS_DONT_SET_FLAG) { |
1957 | 6.80k | if (variable->flag & XS_DONT_ENUM_FLAG) |
1958 | 2.10k | mxBreak; |
1959 | 6.80k | mxRunDebugID(XS_TYPE_ERROR, "set %s: const", slot->ID); |
1960 | 0 | } |
1961 | | #if mxAliasInstance |
1962 | | offset = variable->ID; |
1963 | | if (offset > 0) { |
1964 | | variable = the->aliasArray[offset]; |
1965 | | if (!variable) { |
1966 | | mxSaveState; |
1967 | | variable = fxNewSlot(the); |
1968 | | mxRestoreState; |
1969 | | the->aliasArray[offset] = variable; |
1970 | | } |
1971 | | } |
1972 | | #endif |
1973 | 668k | variable->kind = mxStack->kind; |
1974 | 668k | variable->value = mxStack->value; |
1975 | 668k | mxBreak; |
1976 | 668k | mxCase(XS_CODE_SET_LOCAL_2) |
1977 | 265k | index = mxRunU2(1); |
1978 | 265k | mxNextCode(3); |
1979 | 265k | goto XS_CODE_SET_LOCAL; |
1980 | 30.4M | mxCase(XS_CODE_SET_LOCAL_1) |
1981 | 30.4M | index = mxRunU1(1); |
1982 | 30.4M | mxNextCode(2); |
1983 | 30.7M | XS_CODE_SET_LOCAL: |
1984 | | #ifdef mxTrace |
1985 | | if (gxDoTrace) fxTraceIndex(the, index - 1); |
1986 | | #endif |
1987 | 30.7M | variable = mxEnvironment - index; |
1988 | 30.7M | if (variable->kind < 0) |
1989 | 30.7M | mxRunDebugID(XS_REFERENCE_ERROR, "set %s: not initialized yet", variable->ID); |
1990 | 30.7M | if (variable->flag & XS_DONT_SET_FLAG) { |
1991 | 2.39k | if (variable->flag & XS_DONT_ENUM_FLAG) |
1992 | 2.12k | mxBreak; |
1993 | 2.39k | mxRunDebugID(XS_TYPE_ERROR, "set %s: const", variable->ID); |
1994 | 0 | } |
1995 | 30.7M | variable->kind = mxStack->kind; |
1996 | 30.7M | variable->value = mxStack->value; |
1997 | 30.7M | mxBreak; |
1998 | | |
1999 | 30.7M | mxCase(XS_CODE_VAR_CLOSURE_2) |
2000 | 1.44k | index = mxRunU2(1); |
2001 | 1.44k | mxNextCode(3); |
2002 | 1.44k | goto XS_CODE_VAR_CLOSURE; |
2003 | 1.03M | mxCase(XS_CODE_VAR_CLOSURE_1) |
2004 | 1.03M | index = mxRunU1(1); |
2005 | 1.03M | mxNextCode(2); |
2006 | 1.03M | XS_CODE_VAR_CLOSURE: |
2007 | | #ifdef mxTrace |
2008 | | if (gxDoTrace) fxTraceIndex(the, index - 1); |
2009 | | #endif |
2010 | 1.03M | variable = (mxEnvironment - index)->value.closure; |
2011 | 1.03M | variable->kind = mxStack->kind; |
2012 | 1.03M | variable->value = mxStack->value; |
2013 | 1.03M | mxBreak; |
2014 | 1.03M | mxCase(XS_CODE_VAR_LOCAL_2) |
2015 | 0 | index = mxRunU2(1); |
2016 | 0 | mxNextCode(3); |
2017 | 0 | goto XS_CODE_VAR_LOCAL; |
2018 | 7.84M | mxCase(XS_CODE_VAR_LOCAL_1) |
2019 | 7.84M | index = mxRunU1(1); |
2020 | 7.84M | mxNextCode(2); |
2021 | 7.84M | XS_CODE_VAR_LOCAL: |
2022 | | #ifdef mxTrace |
2023 | | if (gxDoTrace) fxTraceIndex(the, index - 1); |
2024 | | #endif |
2025 | 7.84M | variable = mxEnvironment - index; |
2026 | 7.84M | variable->kind = mxStack->kind; |
2027 | 7.84M | variable->value = mxStack->value; |
2028 | 7.84M | mxBreak; |
2029 | | |
2030 | 7.84M | mxCase(XS_CODE_UNWIND_2) |
2031 | 0 | index = mxRunU2(1); |
2032 | 0 | mxNextCode(3); |
2033 | 0 | goto XS_CODE_UNWIND; |
2034 | 19.4M | mxCase(XS_CODE_UNWIND_1) |
2035 | 19.4M | index = mxRunU1(1); |
2036 | 19.4M | mxNextCode(2); |
2037 | 19.4M | XS_CODE_UNWIND: |
2038 | | #ifdef mxTrace |
2039 | | if (gxDoTrace) fxTraceIndex(the, index); |
2040 | | #endif |
2041 | 19.4M | slot = mxScope; |
2042 | 19.4M | mxScope += index; |
2043 | 46.1M | while (slot < mxScope) |
2044 | 26.7M | (slot++)->kind = XS_UNDEFINED_KIND; |
2045 | 19.4M | mxBreak; |
2046 | | |
2047 | 19.4M | mxCase(XS_CODE_RETRIEVE_2) |
2048 | 0 | index = mxRunU2(1); |
2049 | 0 | mxNextCode(3); |
2050 | 0 | goto XS_CODE_RETRIEVE; |
2051 | 2.58M | mxCase(XS_CODE_RETRIEVE_1) |
2052 | 2.58M | index = mxRunU1(1); |
2053 | 2.58M | mxNextCode(2); |
2054 | 2.58M | XS_CODE_RETRIEVE: |
2055 | | #ifdef mxTrace |
2056 | | if (gxDoTrace) fxTraceIndex(the, index); |
2057 | | #endif |
2058 | 2.58M | slot = mxEnvironment->value.reference->next->next; |
2059 | 2.58M | variable = mxScope; |
2060 | 5.26M | while (index) { |
2061 | 2.68M | --variable; |
2062 | 2.68M | offset = variable->ID = slot->ID; |
2063 | 2.68M | variable->flag = slot->flag; |
2064 | 2.68M | variable->kind = slot->kind; |
2065 | 2.68M | variable->value = slot->value; |
2066 | | #ifdef mxTrace |
2067 | | if (gxDoTrace) fxTraceID(the, (txID)offset, 0); |
2068 | | #endif |
2069 | 2.68M | index--; |
2070 | 2.68M | slot = slot->next; |
2071 | 2.68M | } |
2072 | 2.58M | mxScope = variable; |
2073 | 2.58M | mxBreak; |
2074 | 2.58M | mxCase(XS_CODE_RETRIEVE_TARGET) |
2075 | 378k | variable = mxFrameTarget; |
2076 | 378k | variable->kind = slot->kind; |
2077 | 378k | variable->value = slot->value; |
2078 | 378k | slot = slot->next; |
2079 | 378k | mxNextCode(1); |
2080 | 378k | mxBreak; |
2081 | 378k | mxCase(XS_CODE_RETRIEVE_THIS) |
2082 | 378k | variable = mxFrameThis; |
2083 | 378k | variable->kind = slot->kind; |
2084 | 378k | variable->value = slot->value; |
2085 | 378k | slot = slot->next; |
2086 | 378k | mxNextCode(1); |
2087 | 378k | mxBreak; |
2088 | | |
2089 | 1.61M | mxCase(XS_CODE_ENVIRONMENT) |
2090 | 1.61M | mxPushKind(XS_UNDEFINED_KIND); |
2091 | 1.61M | mxSaveState; |
2092 | 1.61M | slot = fxNewEnvironmentInstance(the, C_NULL); |
2093 | 1.61M | mxRestoreState; |
2094 | 1.61M | variable = mxFunctionInstanceCode((mxStack + 1)->value.reference); |
2095 | 1.61M | variable->value.code.closures = slot; |
2096 | 1.61M | mxNextCode(1); |
2097 | 1.61M | mxBreak; |
2098 | | |
2099 | 1.61M | mxCase(XS_CODE_STORE_2) |
2100 | 1.45k | index = mxRunU2(1); |
2101 | 1.45k | mxNextCode(3); |
2102 | 1.45k | goto XS_CODE_STORE; |
2103 | 2.65M | mxCase(XS_CODE_STORE_1) |
2104 | 2.65M | index = mxRunU1(1); |
2105 | 2.65M | mxNextCode(2); |
2106 | 2.65M | XS_CODE_STORE: |
2107 | | #ifdef mxTrace |
2108 | | if (gxDoTrace) fxTraceIndex(the, index - 1); |
2109 | | #endif |
2110 | 2.65M | address = &(mxStack->value.reference->next); |
2111 | 8.35M | while ((slot = *address)) { |
2112 | 5.69M | address = &slot->next; |
2113 | 5.69M | } |
2114 | 2.65M | mxSaveState; |
2115 | 2.65M | *address = slot = fxNewSlot(the); |
2116 | 2.65M | mxRestoreState; |
2117 | 2.65M | variable = mxEnvironment - index; |
2118 | 2.65M | offset = slot->ID = variable->ID; |
2119 | 2.65M | slot->flag = variable->flag; |
2120 | 2.65M | slot->kind = variable->kind; |
2121 | 2.65M | slot->value = variable->value; |
2122 | | #ifdef mxTrace |
2123 | | if (gxDoTrace) fxTraceID(the, (txID)offset, 0); |
2124 | | #endif |
2125 | 2.65M | mxBreak; |
2126 | 2.65M | mxCase(XS_CODE_STORE_ARROW) |
2127 | | // super |
2128 | 366k | variable = mxFunctionInstanceHome(mxFrameFunction->value.reference); |
2129 | 366k | slot = mxFunctionInstanceHome((mxStack + 1)->value.reference); |
2130 | 366k | slot->value.home.object = variable->value.home.object; |
2131 | | // target |
2132 | 366k | address = &(mxStack->value.reference->next); |
2133 | 732k | while ((slot = *address)) { |
2134 | 366k | address = &slot->next; |
2135 | 366k | } |
2136 | 366k | mxSaveState; |
2137 | 366k | *address = slot = fxNewSlot(the); |
2138 | 366k | mxRestoreState; |
2139 | 366k | variable = mxFrameTarget; |
2140 | 366k | slot->ID = mxID(_new_target); |
2141 | 366k | slot->kind = variable->kind; |
2142 | 366k | slot->value = variable->value; |
2143 | | // this |
2144 | 366k | address = &slot->next; |
2145 | 366k | mxSaveState; |
2146 | 366k | *address = slot = fxNewSlot(the); |
2147 | 366k | mxRestoreState; |
2148 | 366k | variable = mxFrameThis; |
2149 | 366k | slot->ID = mxID(_this); |
2150 | 366k | slot->kind = variable->kind; |
2151 | 366k | slot->value = variable->value; |
2152 | 366k | mxNextCode(1); |
2153 | 366k | mxBreak; |
2154 | | |
2155 | 366k | mxCase(XS_CODE_USED_2) |
2156 | 0 | index = mxRunU2(1); |
2157 | 0 | mxNextCode(3); |
2158 | 0 | goto XS_CODE_USED; |
2159 | 1 | mxCase(XS_CODE_USED_1) |
2160 | 1 | index = mxRunU1(1); |
2161 | 1 | mxNextCode(2); |
2162 | 1 | XS_CODE_USED: |
2163 | 1 | slot = mxEnvironment - index; |
2164 | 1 | mxSaveState; |
2165 | 1 | fxRunUsed(the, slot); |
2166 | 1 | mxRestoreState; |
2167 | 1 | mxBreak; |
2168 | 1 | mxCase(XS_CODE_USING) |
2169 | 0 | mxNextCode(1); |
2170 | 0 | mxSaveState; |
2171 | 0 | fxRunUsing(the); |
2172 | 0 | mxRestoreState; |
2173 | 0 | mxBreak; |
2174 | 0 | mxCase(XS_CODE_USING_ASYNC) |
2175 | 0 | mxNextCode(1); |
2176 | 0 | mxSaveState; |
2177 | 0 | fxRunUsingAsync(the); |
2178 | 0 | mxRestoreState; |
2179 | 0 | mxBreak; |
2180 | | |
2181 | | /* PROPERTIES */ |
2182 | 6.69M | mxCase(XS_CODE_CHECK_INSTANCE) |
2183 | 6.69M | if (mxStack->kind != XS_REFERENCE_KIND) |
2184 | 6.69M | mxRunDebug(XS_TYPE_ERROR, "iterator result: not an object"); |
2185 | 6.69M | mxNextCode(1); |
2186 | 6.69M | mxBreak; |
2187 | 6.69M | mxCase(XS_CODE_TO_INSTANCE) |
2188 | 261k | mxToInstance(mxStack); |
2189 | 261k | mxNextCode(1); |
2190 | 261k | mxBreak; |
2191 | | |
2192 | 261k | mxCase(XS_CODE_SUPER_AT_2) |
2193 | 47 | slot = mxStack + 2; |
2194 | 47 | goto XS_CODE_SUPER_AT_ALL; |
2195 | 85 | mxCase(XS_CODE_SUPER_AT) |
2196 | 85 | slot = mxStack + 1; |
2197 | | /* continue */ |
2198 | 132 | XS_CODE_SUPER_AT_ALL: |
2199 | 132 | mxToInstance(slot); |
2200 | 132 | slot->value.super.reference = variable; |
2201 | 132 | variable = mxFunctionInstanceHome(mxFrameFunction->value.reference); |
2202 | 132 | if (!variable->value.home.object) |
2203 | 132 | mxRunDebugID(XS_TYPE_ERROR, "super.%s: no home", (txID)offset); |
2204 | 132 | variable = fxGetPrototype(the, variable->value.home.object); |
2205 | 132 | if (!variable) |
2206 | 132 | mxRunDebugID(XS_TYPE_ERROR, "super.%s: no prototype", (txID)offset); |
2207 | 132 | slot->value.super.prototype = variable; |
2208 | 132 | slot--; |
2209 | 132 | goto XS_CODE_AT_ALL; |
2210 | 408k | mxCase(XS_CODE_AT_2) |
2211 | 408k | mxToInstance(mxStack + 2); |
2212 | 408k | slot = mxStack + 1; |
2213 | 408k | goto XS_CODE_AT_ALL; |
2214 | 16.7M | mxCase(XS_CODE_AT) |
2215 | 16.7M | mxToInstance(mxStack + 1); |
2216 | 16.7M | slot = mxStack; |
2217 | | /* continue */ |
2218 | 17.1M | XS_CODE_AT_ALL: |
2219 | 17.1M | if (slot->kind == XS_REFERENCE_KIND) { |
2220 | 2.93k | mxSaveState; |
2221 | 2.93k | fxToPrimitive(the, slot, XS_STRING_HINT); |
2222 | 2.93k | mxRestoreState; |
2223 | 2.93k | } |
2224 | 17.1M | if ((slot->kind == XS_INTEGER_KIND) && fxIntegerToIndex(the, slot->value.integer, &(scratch.value.at.index))) { |
2225 | 13.6M | slot->kind = XS_AT_KIND; |
2226 | 13.6M | slot->value.at.id = XS_NO_ID; |
2227 | 13.6M | slot->value.at.index = scratch.value.at.index; |
2228 | 13.6M | } |
2229 | 3.58M | else if ((slot->kind == XS_NUMBER_KIND) && fxNumberToIndex(the, slot->value.number, &(scratch.value.at.index))) { |
2230 | 363k | slot->kind = XS_AT_KIND; |
2231 | 363k | slot->value.at.id = XS_NO_ID; |
2232 | 363k | slot->value.at.index = scratch.value.at.index; |
2233 | 363k | } |
2234 | 3.22M | else if (slot->kind == XS_SYMBOL_KIND) { |
2235 | 372k | slot->kind = XS_AT_KIND; |
2236 | 372k | slot->value.at.id = slot->value.symbol; |
2237 | 372k | slot->value.at.index = 0; |
2238 | 372k | } |
2239 | 2.84M | else { |
2240 | 2.84M | txFlag flag; |
2241 | | |
2242 | 2.84M | mxToString(slot); |
2243 | 2.84M | mxSaveState; |
2244 | 2.84M | flag = fxStringToIndex(the, slot->value.string, &(scratch.value.at.index)); |
2245 | 2.84M | mxRestoreState; |
2246 | 2.84M | if (flag) { |
2247 | 56.5k | #ifdef mxMetering |
2248 | 56.5k | the->meterIndex += 2 * XS_CODE_METERING; |
2249 | 56.5k | #endif |
2250 | 56.5k | slot->kind = XS_AT_KIND; |
2251 | 56.5k | slot->value.at.id = XS_NO_ID; |
2252 | 56.5k | slot->value.at.index = scratch.value.at.index; |
2253 | 56.5k | } |
2254 | 2.79M | else { |
2255 | 2.79M | txID id; |
2256 | 2.79M | mxSaveState; |
2257 | 2.79M | if (slot->kind == XS_STRING_X_KIND) |
2258 | 0 | id = fxNewNameX(the, slot->value.string); |
2259 | 2.79M | else |
2260 | 2.79M | id = fxNewName(the, slot); |
2261 | 2.79M | mxRestoreState; |
2262 | 2.79M | slot->kind = XS_AT_KIND; |
2263 | 2.79M | slot->value.at.id = id; |
2264 | 2.79M | slot->value.at.index = 0; |
2265 | 2.79M | } |
2266 | 2.84M | } |
2267 | 17.1M | mxNextCode(1); |
2268 | 17.1M | mxBreak; |
2269 | | |
2270 | 17.1M | mxCase(XS_CODE_DELETE_SUPER_AT) |
2271 | 0 | variable = (mxStack + 1)->value.reference; |
2272 | 0 | offset = XS_NO_ID; |
2273 | 0 | index = 0; |
2274 | 0 | mxStack++; |
2275 | 0 | mxNextCode(1); |
2276 | 0 | goto XS_CODE_DELETE_SUPER_ALL; |
2277 | 0 | mxCase(XS_CODE_DELETE_SUPER) |
2278 | 0 | mxToInstance(mxStack); |
2279 | 0 | offset = mxRunID(1); |
2280 | 0 | index = 0; |
2281 | 0 | mxNextCode(1 + sizeof(txID)); |
2282 | | /* continue */ |
2283 | 0 | XS_CODE_DELETE_SUPER_ALL: |
2284 | 0 | mxRunDebugID(XS_REFERENCE_ERROR, "delete super.%s", (txID)offset); |
2285 | 0 | mxBreak; |
2286 | |
|
2287 | 135k | mxCase(XS_CODE_DELETE_PROPERTY_AT) |
2288 | 135k | variable = (mxStack + 1)->value.reference; |
2289 | 135k | offset = mxStack->value.at.id; |
2290 | 135k | index = mxStack->value.at.index; |
2291 | 135k | the->stack = mxStack; |
2292 | 135k | mxStack++; |
2293 | 135k | mxNextCode(1); |
2294 | 135k | goto XS_CODE_DELETE_PROPERTY_ALL; |
2295 | 220k | mxCase(XS_CODE_DELETE_PROPERTY) |
2296 | 220k | mxToInstance(mxStack); |
2297 | 220k | offset = mxRunID(1); |
2298 | 220k | index = 0; |
2299 | 220k | the->stack = mxStack; |
2300 | 220k | mxNextCode(1 + sizeof(txID)); |
2301 | | /* continue */ |
2302 | 356k | XS_CODE_DELETE_PROPERTY_ALL: |
2303 | | #ifdef mxTrace |
2304 | | if (gxDoTrace) fxTraceID(the, (txID)offset, index); |
2305 | | #endif |
2306 | 356k | mxSaveStateKeepStack; |
2307 | 356k | index = (txU4)fxRunDelete(the, variable, (txID)offset, index); |
2308 | 356k | mxRestoreStateKeepStack; |
2309 | 356k | if (!index && (mxFrame->flag & XS_STRICT_FLAG)) |
2310 | 356k | mxRunDebugID(XS_TYPE_ERROR, "delete %s: no permission (strict mode)", (txID)offset); |
2311 | 356k | mxStack->kind = XS_BOOLEAN_KIND; |
2312 | 356k | mxStack->value.boolean = index; |
2313 | 356k | mxBreak; |
2314 | | |
2315 | 80.7M | mxCase(XS_CODE_GET_THIS_VARIABLE) |
2316 | 108M | mxCase(XS_CODE_GET_VARIABLE) |
2317 | 108M | mxToInstance(mxStack); |
2318 | 108M | offset = mxRunID(1); |
2319 | 108M | index = 0; |
2320 | 108M | mxNextCode(1 + sizeof(txID)); |
2321 | 108M | #ifdef mxWithHasGetSequence |
2322 | 108M | if (variable->next && ((variable->next->ID == XS_ENVIRONMENT_BEHAVIOR) || (variable->next->ID == XS_GLOBAL_BEHAVIOR))) { |
2323 | 108M | } |
2324 | 1.02k | else { |
2325 | 1.02k | mxSaveState; |
2326 | 1.02k | index = fxRunHas(the, variable, (txID)offset, index); |
2327 | 1.02k | mxRestoreState; |
2328 | 1.02k | if (index == 0) { |
2329 | 0 | if (the->frame->flag & XS_STRICT_FLAG) |
2330 | 0 | mxRunDebugID(XS_REFERENCE_ERROR, "get %s: undefined property", (txID)offset); |
2331 | 0 | mxStack->kind = XS_UNDEFINED_KIND; |
2332 | 0 | mxBreak; |
2333 | 0 | } |
2334 | 1.02k | else |
2335 | 1.02k | index = 0; |
2336 | 1.02k | } |
2337 | 108M | #endif |
2338 | 108M | slot = mxBehaviorGetProperty(the, variable, (txID)offset, index, XS_ANY); |
2339 | 108M | if (slot) { |
2340 | 108M | if (slot->kind < 0) |
2341 | 108M | mxRunDebugID(XS_REFERENCE_ERROR, "get %s: not initialized yet", (txID)offset); |
2342 | 108M | } |
2343 | 926k | else { |
2344 | 926k | if (byte != XS_CODE_TYPEOF) |
2345 | 634k | mxRunDebugID(XS_REFERENCE_ERROR, "get %s: undefined variable", (txID)offset); |
2346 | 292k | } |
2347 | 108M | goto XS_CODE_GET_ALL; |
2348 | 108M | mxCase(XS_CODE_GET_SUPER_AT) |
2349 | 85 | variable = (mxStack + 1)->value.super.reference; |
2350 | 85 | slot = (mxStack + 1)->value.super.prototype; |
2351 | 85 | offset = mxStack->value.at.id; |
2352 | 85 | index = mxStack->value.at.index; |
2353 | 85 | mxStack++; |
2354 | 85 | mxNextCode(1); |
2355 | 85 | goto XS_CODE_GET_SUPER_ALL; |
2356 | 0 | mxCase(XS_CODE_GET_SUPER) |
2357 | 0 | mxToInstance(mxStack); |
2358 | 0 | offset = mxRunID(1); |
2359 | 0 | index = 0; |
2360 | 0 | mxNextCode(1 + sizeof(txID)); |
2361 | 0 | slot = mxFunctionInstanceHome(mxFrameFunction->value.reference); |
2362 | 0 | if (!slot->value.home.object) |
2363 | 0 | mxRunDebugID(XS_TYPE_ERROR, "get super.%s: no home", (txID)offset); |
2364 | 0 | slot = fxGetPrototype(the, slot->value.home.object); |
2365 | 0 | if (!slot) |
2366 | 0 | mxRunDebugID(XS_TYPE_ERROR, "get super.%s: no prototype", (txID)offset); |
2367 | | /* continue */ |
2368 | 85 | XS_CODE_GET_SUPER_ALL: |
2369 | 85 | slot = mxBehaviorGetProperty(the, slot, (txID)offset, index, XS_ANY); |
2370 | 85 | goto XS_CODE_GET_ALL; |
2371 | 0 | mxCase(XS_CODE_GET_PRIVATE_2) |
2372 | 0 | index = mxRunU2(1); |
2373 | 0 | mxNextCode(3); |
2374 | 0 | goto XS_CODE_GET_PRIVATE; |
2375 | 22.8k | mxCase(XS_CODE_GET_PRIVATE_1) |
2376 | 22.8k | index = mxRunU1(1); |
2377 | 22.8k | mxNextCode(2); |
2378 | 22.8k | XS_CODE_GET_PRIVATE: |
2379 | | #ifdef mxTrace |
2380 | | if (gxDoTrace) fxTraceIndex(the, index - 1); |
2381 | | #endif |
2382 | 22.8k | slot = (mxEnvironment - index); |
2383 | 22.8k | mxToInstance(mxStack); |
2384 | 22.8k | offset = slot->ID; |
2385 | 22.8k | index = 0; |
2386 | 22.8k | if (slot->value.closure->kind < 0) |
2387 | 22.8k | mxRunDebugID(XS_TYPE_ERROR, "get %s: undefined private property", (txID)offset); |
2388 | 22.8k | slot = gxDefaults.getPrivateProperty(the, variable, slot->value.closure->value.reference, (txID)offset); |
2389 | 22.8k | if (!slot) |
2390 | 22.8k | mxRunDebugID(XS_TYPE_ERROR, "get %s: undefined private property", (txID)offset); |
2391 | 22.8k | goto XS_CODE_GET_ALL; |
2392 | 7.73M | mxCase(XS_CODE_GET_PROPERTY_AT) |
2393 | 7.73M | variable = (mxStack + 1)->value.reference; |
2394 | 7.73M | offset = mxStack->value.at.id; |
2395 | 7.73M | index = mxStack->value.at.index; |
2396 | 7.73M | mxStack++; |
2397 | 7.73M | mxNextCode(1); |
2398 | 7.73M | goto XS_CODE_GET_PROPERTY_ALL; |
2399 | 62.5M | mxCase(XS_CODE_GET_PROPERTY) |
2400 | 62.5M | mxToInstance(mxStack); |
2401 | 62.5M | offset = mxRunID(1); |
2402 | 62.5M | index = 0; |
2403 | 62.5M | mxNextCode(1 + sizeof(txID)); |
2404 | | /* continue */ |
2405 | 70.0M | XS_CODE_GET_PROPERTY_ALL: |
2406 | 70.0M | slot = mxBehaviorGetProperty(the, variable, (txID)offset, index, XS_ANY); |
2407 | 178M | XS_CODE_GET_ALL: |
2408 | | #ifdef mxTrace |
2409 | | if (gxDoTrace) fxTraceID(the, (txID)offset, index); |
2410 | | #endif |
2411 | 178M | if (!slot) { |
2412 | 15.5M | mxStack->kind = XS_UNDEFINED_KIND; |
2413 | 15.5M | mxBreak; |
2414 | 15.5M | } |
2415 | 178M | if (slot->kind == XS_ACCESSOR_KIND) { |
2416 | 3.24M | variable = slot->value.accessor.getter; |
2417 | 3.24M | if (!mxIsFunction(variable)) { |
2418 | 4 | mxStack->kind = XS_UNDEFINED_KIND; |
2419 | 4 | mxBreak; |
2420 | 4 | } |
2421 | 3.24M | mxAllocStack(5); |
2422 | 3.24M | slot = mxStack; |
2423 | 3.24M | mxInitSlotKind(slot++, XS_UNINITIALIZED_KIND); |
2424 | 3.24M | mxInitSlotKind(slot++, XS_UNINITIALIZED_KIND); |
2425 | 3.24M | mxInitSlotKind(slot++, XS_UNDEFINED_KIND); |
2426 | 3.24M | mxInitSlotKind(slot++, XS_UNDEFINED_KIND); |
2427 | 3.24M | slot->value.reference = variable; |
2428 | 3.24M | mxInitSlotKind(slot++, XS_REFERENCE_KIND); |
2429 | 3.24M | if (primitive) { |
2430 | 1.44M | variable = slot->value.reference->next; |
2431 | 1.44M | slot->value = variable->value; |
2432 | 1.44M | mxInitSlotKind(slot, variable->kind); |
2433 | 1.44M | } |
2434 | 3.24M | offset = 0; |
2435 | 3.24M | goto XS_CODE_RUN_ALL; |
2436 | 3.24M | } |
2437 | 175M | mxStack->kind = slot->kind; |
2438 | 175M | mxStack->value = slot->value; |
2439 | 175M | mxBreak; |
2440 | | |
2441 | 175M | mxCase(XS_CODE_NEW_PRIVATE_2) |
2442 | 0 | index = mxRunU2(1); |
2443 | 0 | mxNextCode(3); |
2444 | 0 | goto XS_CODE_NEW_PRIVATE; |
2445 | 29.1k | mxCase(XS_CODE_NEW_PRIVATE_1) |
2446 | 29.1k | index = mxRunU1(1); |
2447 | 29.1k | mxNextCode(2); |
2448 | 29.1k | XS_CODE_NEW_PRIVATE: |
2449 | | #ifdef mxTrace |
2450 | | if (gxDoTrace) fxTraceIndex(the, index - 1); |
2451 | | #endif |
2452 | 29.1k | slot = (mxEnvironment - index); |
2453 | 29.1k | mxToInstance(mxStack + 1); |
2454 | 29.1k | offset = slot->ID; |
2455 | 29.1k | index = 0; |
2456 | 29.1k | slot = slot->value.closure->value.reference; |
2457 | 29.1k | the->stack = mxStack; |
2458 | 29.1k | goto XS_CODE_NEW_PROPERTY_ALL; |
2459 | 8.81M | mxCase(XS_CODE_NEW_PROPERTY_AT) |
2460 | 8.81M | mxToInstance(mxStack + 2); |
2461 | 8.81M | offset = (mxStack + 1)->value.at.id; |
2462 | 8.81M | index = (mxStack + 1)->value.at.index; |
2463 | 8.81M | slot = C_NULL; |
2464 | 8.81M | the->stack = mxStack; |
2465 | 8.81M | mxStack++; |
2466 | 8.81M | scratch = *(the->stack); |
2467 | 8.81M | *(the->stack) = *mxStack; |
2468 | 8.81M | *mxStack = scratch; |
2469 | 8.81M | mxNextCode(1); |
2470 | 8.81M | goto XS_CODE_NEW_PROPERTY_ALL; |
2471 | 8.08M | mxCase(XS_CODE_NEW_PROPERTY) |
2472 | 8.08M | mxToInstance(mxStack + 1); |
2473 | 8.08M | offset = mxRunID(1); |
2474 | 8.08M | index = 0; |
2475 | 8.08M | slot = C_NULL; |
2476 | 8.08M | the->stack = mxStack; |
2477 | 8.08M | mxNextCode(1 + sizeof(txID)); |
2478 | 16.9M | XS_CODE_NEW_PROPERTY_ALL: |
2479 | 16.9M | byte = mxRunU1(1); |
2480 | 16.9M | mxSaveStateKeepStack; |
2481 | 16.9M | if (byte & XS_GETTER_FLAG) { |
2482 | 305k | mxStack->value.accessor.getter = fxToInstance(the, mxStack); |
2483 | 305k | mxStack->value.accessor.setter = C_NULL; |
2484 | 305k | mxStack->kind = XS_ACCESSOR_KIND; |
2485 | 305k | } |
2486 | 16.6M | else if (byte & XS_SETTER_FLAG) { |
2487 | 7.16k | mxStack->value.accessor.setter = fxToInstance(the, mxStack); |
2488 | 7.16k | mxStack->value.accessor.getter = C_NULL; |
2489 | 7.16k | mxStack->kind = XS_ACCESSOR_KIND; |
2490 | 7.16k | } |
2491 | 16.9M | mxStack->flag = byte & XS_GET_ONLY; |
2492 | 16.9M | index = fxRunDefine(the, variable, slot, (txID)offset, index, mxStack, byte | XS_GET_ONLY); |
2493 | 16.9M | mxRestoreStateKeepStack; |
2494 | 16.9M | mxStack += 2; |
2495 | 16.9M | if (!index) |
2496 | 16.9M | mxRunDebugID(XS_TYPE_ERROR, "set %s: const", (txID)offset); |
2497 | 16.9M | mxNextCode(2); |
2498 | 16.9M | mxBreak; |
2499 | | |
2500 | 39.6M | mxCase(XS_CODE_SET_VARIABLE) |
2501 | 39.6M | mxToInstance(mxStack + 1); |
2502 | 39.6M | offset = mxRunID(1); |
2503 | 39.6M | index = 0; |
2504 | 39.6M | mxNextCode(1 + sizeof(txID)); |
2505 | 39.6M | if (variable->next && (variable->next->ID == XS_ENVIRONMENT_BEHAVIOR)) { |
2506 | | // nop |
2507 | 619 | } |
2508 | 39.6M | else { |
2509 | 39.6M | mxSaveState; |
2510 | 39.6M | index = fxRunHas(the, variable, (txID)offset, index); |
2511 | 39.6M | mxRestoreState; |
2512 | 39.6M | if (index == 0) { |
2513 | 4.30k | if (the->frame->flag & XS_STRICT_FLAG) |
2514 | 4.18k | mxRunDebugID(XS_REFERENCE_ERROR, "set %s: undefined property", (txID)offset); |
2515 | 4.18k | } |
2516 | 39.6M | else |
2517 | 39.6M | index = 0; |
2518 | 39.6M | } |
2519 | 39.6M | mxSaveState; |
2520 | 39.6M | slot = mxBehaviorSetProperty(the, variable, (txID)offset, index, XS_ANY); |
2521 | 39.6M | mxRestoreState; |
2522 | 39.6M | if (slot && (slot->kind < 0)) |
2523 | 39.6M | mxRunDebugID(XS_REFERENCE_ERROR, "set %s: not initialized yet", (txID)offset); |
2524 | 39.6M | goto XS_CODE_SET_ALL; |
2525 | 86 | mxCase(XS_CODE_SET_SUPER_AT) |
2526 | 86 | variable = (mxStack + 2)->value.super.reference; |
2527 | 86 | slot = (mxStack + 2)->value.super.prototype; |
2528 | 86 | offset = (mxStack + 1)->value.at.id; |
2529 | 86 | index = (mxStack + 1)->value.at.index; |
2530 | 86 | the->stack = mxStack; |
2531 | 86 | mxStack++; |
2532 | 86 | scratch = *(the->stack); |
2533 | 86 | *(the->stack) = *mxStack; |
2534 | 86 | *mxStack = scratch; |
2535 | 86 | mxNextCode(1); |
2536 | 86 | goto XS_CODE_SET_SUPER_ALL; |
2537 | 0 | mxCase(XS_CODE_SET_SUPER) |
2538 | 0 | mxToInstance(mxStack + 1); |
2539 | 0 | offset = mxRunID(1); |
2540 | 0 | index = 0; |
2541 | 0 | the->stack = mxStack; |
2542 | 0 | mxNextCode(1 + sizeof(txID)); |
2543 | 0 | slot = mxFunctionInstanceHome(mxFrameFunction->value.reference); |
2544 | 0 | if (!slot->value.home.object) |
2545 | 0 | mxRunDebugID(XS_TYPE_ERROR, "set super.%s: no home", (txID)offset); |
2546 | 0 | slot = fxGetPrototype(the, slot->value.home.object); |
2547 | 0 | if (!slot) |
2548 | 0 | mxRunDebugID(XS_TYPE_ERROR, "set super.%s: no prototype", (txID)offset); |
2549 | | /* continue */ |
2550 | 86 | XS_CODE_SET_SUPER_ALL: |
2551 | 86 | slot = mxBehaviorGetProperty(the, slot, (txID)offset, index, XS_ANY); |
2552 | 86 | if (!slot || (slot->kind != XS_ACCESSOR_KIND)) { |
2553 | 86 | mxSaveStateKeepStack; |
2554 | 86 | slot = mxBehaviorSetProperty(the, variable, (txID)offset, index, XS_OWN); |
2555 | 86 | mxRestoreStateKeepStack; |
2556 | 86 | } |
2557 | 86 | goto XS_CODE_SET_ALL; |
2558 | 0 | mxCase(XS_CODE_SET_PRIVATE_2) |
2559 | 0 | index = mxRunU2(1); |
2560 | 0 | mxNextCode(3); |
2561 | 0 | goto XS_CODE_SET_PRIVATE; |
2562 | 6 | mxCase(XS_CODE_SET_PRIVATE_1) |
2563 | 6 | index = mxRunU1(1); |
2564 | 6 | mxNextCode(2); |
2565 | 6 | XS_CODE_SET_PRIVATE: |
2566 | | #ifdef mxTrace |
2567 | | if (gxDoTrace) fxTraceIndex(the, index - 1); |
2568 | | #endif |
2569 | 6 | slot = (mxEnvironment - index); |
2570 | 6 | mxToInstance(mxStack + 1); |
2571 | 6 | offset = slot->ID; |
2572 | 6 | index = 0; |
2573 | 6 | if (slot->value.closure->kind < 0) |
2574 | 6 | mxRunDebugID(XS_REFERENCE_ERROR, "set %s: undefined private property", (txID)offset); |
2575 | 6 | slot = gxDefaults.setPrivateProperty(the, variable, slot->value.closure->value.reference, (txID)offset); |
2576 | 6 | if (!slot) |
2577 | 6 | mxRunDebugID(XS_TYPE_ERROR, "set %s: undefined private property", (txID)offset); |
2578 | 6 | goto XS_CODE_SET_ALL; |
2579 | 3.01M | mxCase(XS_CODE_SET_PROPERTY_AT) |
2580 | 3.01M | variable = (mxStack + 2)->value.reference; |
2581 | 3.01M | offset = (mxStack + 1)->value.at.id; |
2582 | 3.01M | index = (mxStack + 1)->value.at.index; |
2583 | 3.01M | the->stack = mxStack; |
2584 | 3.01M | mxStack++; |
2585 | 3.01M | scratch = *(the->stack); |
2586 | 3.01M | *(the->stack) = *mxStack; |
2587 | 3.01M | *mxStack = scratch; |
2588 | 3.01M | mxNextCode(1); |
2589 | 3.01M | goto XS_CODE_SET_PROPERTY_ALL; |
2590 | 9.83M | mxCase(XS_CODE_SET_PROPERTY) |
2591 | 9.83M | mxToInstance(mxStack + 1); |
2592 | 9.83M | offset = mxRunID(1); |
2593 | 9.83M | index = 0; |
2594 | 9.83M | the->stack = mxStack; |
2595 | 9.83M | mxNextCode(1 + sizeof(txID)); |
2596 | | /* continue */ |
2597 | 12.8M | XS_CODE_SET_PROPERTY_ALL: |
2598 | 12.8M | mxSaveStateKeepStack; |
2599 | 12.8M | slot = mxBehaviorSetProperty(the, variable, (txID)offset, index, XS_ANY); |
2600 | 12.8M | mxRestoreStateKeepStack; |
2601 | 52.4M | XS_CODE_SET_ALL: |
2602 | | #ifdef mxTrace |
2603 | | if (gxDoTrace) fxTraceID(the, (txID)offset, index); |
2604 | | #endif |
2605 | 52.4M | if (!slot) { |
2606 | 56.1k | if (mxFrame->flag & XS_STRICT_FLAG) { |
2607 | 6 | mxRunDebugID(XS_TYPE_ERROR, "set %s: not extensible", (txID)offset); |
2608 | 0 | } |
2609 | 56.0k | goto XS_CODE_SET_SKIP; |
2610 | 56.1k | } |
2611 | 52.4M | if (slot->kind == XS_ACCESSOR_KIND) { |
2612 | 5.98M | variable = slot->value.accessor.setter; |
2613 | 5.98M | if (!mxIsFunction(variable)) { |
2614 | 4 | if (mxFrame->flag & XS_STRICT_FLAG) { |
2615 | 0 | mxRunDebugID(XS_TYPE_ERROR, "set %s: no setter", (txID)offset); |
2616 | 0 | } |
2617 | 4 | goto XS_CODE_SET_SKIP; |
2618 | 4 | } |
2619 | 5.98M | slot = mxStack; |
2620 | 5.98M | mxAllocStack(5); |
2621 | 5.98M | mxStack->value = slot->value; |
2622 | 5.98M | mxInitSlotKind(mxStack, slot->kind); |
2623 | 5.98M | slot = mxStack + 1; |
2624 | 5.98M | mxInitSlotKind(slot++, XS_UNINITIALIZED_KIND); |
2625 | 5.98M | mxInitSlotKind(slot++, XS_UNINITIALIZED_KIND); |
2626 | 5.98M | slot->value = mxStack->value; |
2627 | 5.98M | mxInitSlotKind(slot++, mxStack->kind); |
2628 | 5.98M | mxInitSlotKind(slot++, XS_UNDEFINED_KIND); |
2629 | 5.98M | slot->value.reference = variable; |
2630 | 5.98M | mxInitSlotKind(slot++, XS_REFERENCE_KIND); |
2631 | 5.98M | offset = 1; |
2632 | 5.98M | goto XS_CODE_RUN_ALL; |
2633 | 5.98M | } |
2634 | 46.4M | if (slot->flag & (XS_DONT_SET_FLAG | XS_MARK_FLAG)) { |
2635 | 4.48k | if (mxFrame->flag & XS_STRICT_FLAG) { |
2636 | 1 | mxRunDebugID(XS_TYPE_ERROR, "set %s: not writable", (txID)offset); |
2637 | 0 | } |
2638 | 4.48k | goto XS_CODE_SET_SKIP; |
2639 | 4.48k | } |
2640 | 46.4M | slot->kind = mxStack->kind; |
2641 | 46.4M | slot->value = mxStack->value; |
2642 | 46.4M | XS_CODE_SET_SKIP: |
2643 | 46.4M | *(mxStack + 1) = *mxStack; |
2644 | 46.4M | mxStack++; |
2645 | 46.4M | mxBreak; |
2646 | | |
2647 | 46.4M | mxCase(XS_CODE_HAS_PRIVATE_2) |
2648 | 0 | index = mxRunU2(1); |
2649 | 0 | mxNextCode(3); |
2650 | 0 | goto XS_CODE_HAS_PRIVATE; |
2651 | 0 | mxCase(XS_CODE_HAS_PRIVATE_1) |
2652 | 0 | index = mxRunU1(1); |
2653 | 0 | mxNextCode(2); |
2654 | 0 | XS_CODE_HAS_PRIVATE: |
2655 | | #ifdef mxTrace |
2656 | | if (gxDoTrace) fxTraceIndex(the, index - 1); |
2657 | | #endif |
2658 | 0 | slot = (mxEnvironment - index); |
2659 | 0 | if (mxStack->kind == XS_REFERENCE_KIND) |
2660 | 0 | variable = mxStack->value.reference; |
2661 | 0 | else |
2662 | 0 | mxRunDebug(XS_TYPE_ERROR, "in: not an object"); |
2663 | 0 | offset = slot->ID; |
2664 | 0 | index = 0; |
2665 | 0 | if (slot->value.closure->kind < 0) |
2666 | 0 | mxRunDebugID(XS_TYPE_ERROR, "get %s: undefined private property", (txID)offset); |
2667 | 0 | slot = gxDefaults.getPrivateProperty(the, variable, slot->value.closure->value.reference, (txID)offset); |
2668 | 0 | mxStack->kind = XS_BOOLEAN_KIND; |
2669 | 0 | mxStack->value.boolean = (slot) ? 1 : 0; |
2670 | 0 | mxBreak; |
2671 | | |
2672 | | /* INSTANCES */ |
2673 | 5.68M | mxCase(XS_CODE_ARRAY) |
2674 | | // mxAllocStack(1); |
2675 | 5.68M | mxSaveState; |
2676 | 5.68M | fxNewArray(the, 0); |
2677 | 5.68M | mxRestoreState; |
2678 | 5.68M | mxNextCode(1); |
2679 | 5.68M | mxBreak; |
2680 | 5.68M | mxCase(XS_CODE_CLASS) |
2681 | 223k | variable = fxToInstance(the, mxStack); |
2682 | 223k | slot = mxStack + 2; |
2683 | 223k | variable->flag |= XS_CAN_CONSTRUCT_FLAG; |
2684 | 223k | if (slot->kind == XS_NULL_KIND) |
2685 | 165k | variable->next->flag |= XS_BASE_FLAG; |
2686 | 57.2k | else { |
2687 | 57.2k | variable->next->flag |= XS_DERIVED_FLAG; |
2688 | 57.2k | variable->value.instance.prototype = slot->value.reference; |
2689 | 57.2k | } |
2690 | 223k | slot = mxStack + 1; |
2691 | 223k | mxFunctionInstanceHome(variable)->value.home.object = slot->value.reference; |
2692 | 223k | mxSaveState; |
2693 | 223k | slot->flag = XS_GET_ONLY; |
2694 | 223k | fxRunDefine(the, variable, C_NULL, mxID(_prototype), 0, slot, XS_GET_ONLY); |
2695 | 223k | slot = mxBehaviorSetProperty(the, slot->value.reference, mxID(_constructor), 0, XS_OWN); |
2696 | 223k | mxRestoreState; |
2697 | 223k | slot->flag |= XS_DONT_ENUM_FLAG; |
2698 | 223k | slot->kind = mxStack->kind; |
2699 | 223k | slot->value = mxStack->value; |
2700 | 223k | mxStack += 3; |
2701 | 223k | mxNextCode(1); |
2702 | 223k | mxBreak; |
2703 | 223k | mxCase(XS_CODE_COPY_OBJECT) |
2704 | 16.5k | mxNextCode(1); |
2705 | 16.5k | mxAllocStack(1); |
2706 | 16.5k | *mxStack = mxCopyObjectFunction; |
2707 | 16.5k | mxBreak; |
2708 | 57.2k | mxCase(XS_CODE_EXTEND) |
2709 | 57.2k | if (mxStack->kind == XS_NULL_KIND) { |
2710 | 0 | mxSaveState; |
2711 | 0 | fxNewInstance(the); |
2712 | 0 | mxRestoreState; |
2713 | 0 | } |
2714 | 57.2k | else { |
2715 | 57.2k | mxSaveState; |
2716 | 57.2k | fxRunExtends(the); |
2717 | 57.2k | mxRestoreState; |
2718 | 57.2k | } |
2719 | 57.2k | mxNextCode(1); |
2720 | 57.2k | mxBreak; |
2721 | 395k | mxCase(XS_CODE_GLOBAL) |
2722 | 395k | mxPushKind(XS_REFERENCE_KIND); |
2723 | 395k | variable = mxFunctionInstanceHome(mxFrameFunction->value.reference)->value.home.module; |
2724 | 395k | variable = mxModuleInstanceInternal(variable)->value.module.realm; |
2725 | 395k | if (!variable) variable = mxModuleInstanceInternal(mxProgram.value.reference)->value.module.realm; |
2726 | 395k | mxStack->value.reference = mxRealmGlobal(variable)->value.reference; |
2727 | 395k | mxNextCode(1); |
2728 | 395k | mxBreak; |
2729 | 395k | mxCase(XS_CODE_HOST) |
2730 | 0 | index = mxRunU2(1); |
2731 | | #ifdef mxTrace |
2732 | | if (gxDoTrace) fxTraceIndex(the, index); |
2733 | | #endif |
2734 | 0 | mxAllocStack(1); |
2735 | 0 | variable = mxFunctionInstanceHome(mxFrameFunction->value.reference)->value.home.module; |
2736 | 0 | variable = mxModuleInstanceHosts(variable); |
2737 | 0 | *mxStack = *variable; |
2738 | 0 | slot = mxBehaviorGetProperty(the, mxStack->value.reference, 0, index, XS_OWN); |
2739 | 0 | mxStack->kind = slot->kind; |
2740 | 0 | mxStack->value = slot->value; |
2741 | 0 | mxNextCode(3); |
2742 | 0 | mxBreak; |
2743 | 22 | mxCase(XS_CODE_INSTANTIATE) |
2744 | 22 | mxSaveState; |
2745 | 22 | fxRunInstantiate(the); |
2746 | 22 | mxRestoreState; |
2747 | 22 | mxNextCode(1); |
2748 | 22 | mxBreak; |
2749 | 39.6M | mxCase(XS_CODE_CALL) |
2750 | 39.6M | mxNextCode(1); |
2751 | 39.6M | mxAllocStack(4); |
2752 | 39.6M | slot = mxStack; |
2753 | 39.6M | mxInitSlotKind(slot++, XS_UNINITIALIZED_KIND); |
2754 | 39.6M | mxInitSlotKind(slot++, XS_UNINITIALIZED_KIND); |
2755 | 39.6M | mxInitSlotKind(slot++, XS_UNDEFINED_KIND); |
2756 | 39.6M | mxInitSlotKind(slot, XS_UNDEFINED_KIND); |
2757 | 39.6M | mxBreak; |
2758 | 39.6M | mxCase(XS_CODE_NEW) |
2759 | 4.08M | mxNextCode(1); |
2760 | 4.08M | variable = mxStack; |
2761 | 4.08M | mxAllocStack(5); |
2762 | 4.08M | slot = mxStack; |
2763 | 4.08M | mxInitSlotKind(slot++, XS_UNINITIALIZED_KIND); |
2764 | 4.08M | mxInitSlotKind(slot++, XS_UNINITIALIZED_KIND); |
2765 | 4.08M | mxInitSlotKind(slot++, XS_UNDEFINED_KIND); |
2766 | 4.08M | slot->value = variable->value; |
2767 | 4.08M | mxInitSlotKind(slot++, variable->kind); |
2768 | 4.08M | slot->value = variable->value; |
2769 | 4.08M | mxInitSlotKind(slot++, variable->kind); |
2770 | 4.08M | mxInitSlotKind(slot, XS_UNINITIALIZED_KIND); |
2771 | 4.08M | mxBreak; |
2772 | 4.08M | mxCase(XS_CODE_OBJECT) |
2773 | | // mxAllocStack(1); |
2774 | 3.50M | mxSaveState; |
2775 | 3.50M | fxNewObject(the); |
2776 | 3.50M | mxRestoreState; |
2777 | 3.50M | mxNextCode(1); |
2778 | 3.50M | mxBreak; |
2779 | 3.50M | mxCase(XS_CODE_REGEXP) |
2780 | 841k | mxNextCode(1); |
2781 | 841k | mxAllocStack(1); |
2782 | 841k | *mxStack = mxRegExpConstructor; |
2783 | 841k | mxBreak; |
2784 | 841k | mxCase(XS_CODE_SUPER) |
2785 | 3.49k | mxNextCode(1); |
2786 | 3.49k | variable = mxFrameFunction->value.reference; |
2787 | 3.49k | if (mxIsConstructor(variable)) |
2788 | 3.49k | variable = fxGetPrototype(the, variable); |
2789 | 0 | else { |
2790 | 0 | variable = mxFunctionInstanceHome(variable); |
2791 | 0 | variable = mxBehaviorGetProperty(the, variable->value.home.object, mxID(_constructor), 0, XS_ANY); |
2792 | 0 | variable = fxGetPrototype(the, variable->value.reference); |
2793 | 0 | } |
2794 | 3.49k | if (!mxIsConstructor(variable)) |
2795 | 3.49k | mxRunDebug(XS_TYPE_ERROR, "super: not a constructor"); |
2796 | 3.49k | mxAllocStack(6); |
2797 | 3.49k | slot = mxStack; |
2798 | 3.49k | mxInitSlotKind(slot++, XS_UNINITIALIZED_KIND); |
2799 | 3.49k | mxInitSlotKind(slot++, XS_UNINITIALIZED_KIND); |
2800 | 3.49k | mxInitSlotKind(slot++, XS_UNDEFINED_KIND); |
2801 | 3.49k | slot->value = mxFrameTarget->value; |
2802 | 3.49k | mxInitSlotKind(slot++, mxFrameTarget->kind); |
2803 | 3.49k | slot->value.reference = variable; |
2804 | 3.49k | mxInitSlotKind(slot++, XS_REFERENCE_KIND); |
2805 | 3.49k | mxInitSlotKind(slot, XS_UNINITIALIZED_KIND); |
2806 | 3.49k | mxBreak; |
2807 | 4.22k | mxCase(XS_CODE_TEMPLATE) |
2808 | 4.22k | mxNextCode(1); |
2809 | 4.22k | variable = mxStack->value.reference; |
2810 | 4.22k | slot = mxBehaviorGetProperty(the, variable, mxID(_raw), 0, XS_OWN); |
2811 | 4.22k | if (!slot) |
2812 | 4.22k | mxRunDebug(XS_TYPE_ERROR, "template: no raw"); |
2813 | 4.22k | variable->flag |= XS_DONT_PATCH_FLAG; |
2814 | 4.22k | variable->next->flag |= XS_DONT_SET_FLAG; |
2815 | 4.22k | slot->flag |= XS_DONT_DELETE_FLAG | XS_DONT_ENUM_FLAG | XS_DONT_SET_FLAG; |
2816 | 4.22k | variable = slot->value.reference; |
2817 | 4.22k | variable->flag |= XS_DONT_PATCH_FLAG; |
2818 | 4.22k | variable->next->flag |= XS_DONT_SET_FLAG; |
2819 | 4.22k | mxBreak; |
2820 | 3.99M | mxCase(XS_CODE_TEMPLATE_CACHE) |
2821 | 3.99M | mxNextCode(1); |
2822 | 3.99M | variable = mxFunctionInstanceHome(mxFrameFunction->value.reference)->value.home.module; |
2823 | 3.99M | variable = mxModuleInstanceInternal(variable)->value.module.realm; |
2824 | 3.99M | if (!variable) variable = mxModuleInstanceInternal(mxProgram.value.reference)->value.module.realm; |
2825 | 3.99M | slot = mxRealmTemplateCache(variable); |
2826 | 3.99M | mxPushKind(XS_REFERENCE_KIND); |
2827 | 3.99M | mxStack->value.reference = slot->value.reference; |
2828 | 3.99M | mxBreak; |
2829 | | |
2830 | | /* FUNCTIONS */ |
2831 | 3.99M | mxCase(XS_CODE_ASYNC_FUNCTION) |
2832 | 813k | offset = mxRunID(1); |
2833 | | #ifdef mxTrace |
2834 | | if (gxDoTrace) fxTraceID(the, (txID)offset, 0); |
2835 | | #endif |
2836 | 813k | mxAllocStack(1); |
2837 | 813k | *mxStack = mxAsyncFunctionPrototype; |
2838 | 813k | mxSaveState; |
2839 | 813k | fxNewFunctionInstance(the, (txID)offset); |
2840 | 813k | mxRestoreState; |
2841 | 813k | mxNextCode(1 + sizeof(txID)); |
2842 | 813k | mxBreak; |
2843 | 813k | mxCase(XS_CODE_ASYNC_GENERATOR_FUNCTION) |
2844 | 163 | offset = mxRunID(1); |
2845 | | #ifdef mxTrace |
2846 | | if (gxDoTrace) fxTraceID(the, (txID)offset, 0); |
2847 | | #endif |
2848 | 163 | mxAllocStack(1); |
2849 | 163 | *mxStack = mxAsyncGeneratorFunctionPrototype; |
2850 | 163 | mxSaveState; |
2851 | 163 | gxDefaults.newAsyncGeneratorFunctionInstance(the,(txID) offset); |
2852 | 163 | mxRestoreState; |
2853 | 163 | mxNextCode(1 + sizeof(txID)); |
2854 | 163 | mxBreak; |
2855 | 2.38M | mxCase(XS_CODE_CONSTRUCTOR_FUNCTION) |
2856 | 2.38M | offset = mxRunID(1); |
2857 | | #ifdef mxTrace |
2858 | | if (gxDoTrace) fxTraceID(the, (txID)offset, 0); |
2859 | | #endif |
2860 | 2.38M | mxAllocStack(1); |
2861 | 2.38M | *mxStack = mxFunctionPrototype; |
2862 | 2.38M | mxSaveState; |
2863 | 2.38M | fxNewFunctionInstance(the, (txID)offset); |
2864 | 2.38M | fxDefaultFunctionPrototype(the); |
2865 | 2.38M | mxRestoreState; |
2866 | 2.38M | mxNextCode(1 + sizeof(txID)); |
2867 | 2.38M | mxBreak; |
2868 | 2.38M | mxCase(XS_CODE_FUNCTION) |
2869 | 1.46M | offset = mxRunID(1); |
2870 | | #ifdef mxTrace |
2871 | | if (gxDoTrace) fxTraceID(the, (txID)offset, 0); |
2872 | | #endif |
2873 | 1.46M | mxAllocStack(1); |
2874 | 1.46M | *mxStack = mxFunctionPrototype; |
2875 | 1.46M | mxSaveState; |
2876 | 1.46M | fxNewFunctionInstance(the, (txID)offset); |
2877 | 1.46M | mxRestoreState; |
2878 | 1.46M | mxNextCode(1 + sizeof(txID)); |
2879 | 1.46M | mxBreak; |
2880 | 1.46M | mxCase(XS_CODE_GENERATOR_FUNCTION) |
2881 | 33.8k | offset = mxRunID(1); |
2882 | | #ifdef mxTrace |
2883 | | if (gxDoTrace) fxTraceID(the, (txID)offset, 0); |
2884 | | #endif |
2885 | 33.8k | mxAllocStack(1); |
2886 | 33.8k | *mxStack = mxGeneratorFunctionPrototype; |
2887 | 33.8k | mxSaveState; |
2888 | 33.8k | gxDefaults.newGeneratorFunctionInstance(the,(txID) offset); |
2889 | 33.8k | mxRestoreState; |
2890 | 33.8k | mxNextCode(1 + sizeof(txID)); |
2891 | 33.8k | mxBreak; |
2892 | 4.69M | mxCase(XS_CODE_PROFILE) |
2893 | 4.69M | offset = mxRunID(1); |
2894 | 4.69M | variable = mxFunctionInstanceHome(mxStack->value.reference); |
2895 | 4.69M | variable->ID = offset; |
2896 | 4.69M | mxNextCode(1 + sizeof(txID)); |
2897 | 4.69M | mxBreak; |
2898 | 4.69M | mxCase(XS_CODE_NAME) |
2899 | 184k | offset = mxRunID(1); |
2900 | | #ifdef mxTrace |
2901 | | if (gxDoTrace) fxTraceID(the, (txID)offset, 0); |
2902 | | #endif |
2903 | 184k | mxSaveState; |
2904 | 184k | fxRenameFunction(the, mxStack->value.reference, (txID)offset, 0, XS_NO_ID, C_NULL); |
2905 | 184k | mxRestoreState; |
2906 | 184k | mxNextCode(1 + sizeof(txID)); |
2907 | 184k | mxBreak; |
2908 | 184k | mxCase(XS_CODE_SET_HOME) |
2909 | 100k | slot = mxFunctionInstanceHome((mxStack + 1)->value.reference); |
2910 | 100k | slot->value.home.object = mxStack->value.reference; |
2911 | 100k | mxStack++; |
2912 | 100k | mxNextCode(1); |
2913 | 100k | mxBreak; |
2914 | 100k | mxCase(XS_CODE_CODE_4) |
2915 | 9.62k | offset = mxRunS4(1); |
2916 | 9.62k | mxSkipCode(5); |
2917 | 9.62k | goto XS_CODE_CODE; |
2918 | 888k | mxCase(XS_CODE_CODE_2) |
2919 | 888k | offset = mxRunS2(1); |
2920 | 888k | mxSkipCode(3); |
2921 | 888k | goto XS_CODE_CODE; |
2922 | 3.79M | mxCase(XS_CODE_CODE_1) |
2923 | 3.79M | offset = mxRunS1(1); |
2924 | 3.79M | mxSkipCode(2); |
2925 | 4.69M | XS_CODE_CODE: |
2926 | 4.69M | mxSaveState; |
2927 | 4.69M | scratch.value.code.address = (txByte*)fxNewChunk(the, (txSize)offset); |
2928 | 4.69M | mxRestoreState; |
2929 | 4.69M | c_memcpy(scratch.value.code.address, mxCode, offset); |
2930 | 4.69M | variable = mxStack->value.reference; |
2931 | 4.69M | slot = mxFunctionInstanceCode(variable); |
2932 | 4.69M | slot->kind = XS_CODE_KIND; |
2933 | 4.69M | slot->value.code.address = scratch.value.code.address; |
2934 | 4.69M | if (gxDefaults.newFunctionLength) { |
2935 | 4.69M | gxDefaults.newFunctionLength(the, variable, *(((txU1*)scratch.value.code.address + 1))); |
2936 | 4.69M | } |
2937 | 4.69M | mxNextCode(offset); |
2938 | 4.69M | mxBreak; |
2939 | 4.69M | mxCase(XS_CODE_CODE_ARCHIVE_4) |
2940 | 0 | offset = mxRunS4(1); |
2941 | 0 | mxSkipCode(5); |
2942 | 0 | goto XS_CODE_CODE_ARCHIVE; |
2943 | 0 | mxCase(XS_CODE_CODE_ARCHIVE_2) |
2944 | 0 | offset = mxRunS2(1); |
2945 | 0 | mxSkipCode(3); |
2946 | 0 | goto XS_CODE_CODE_ARCHIVE; |
2947 | 0 | mxCase(XS_CODE_CODE_ARCHIVE_1) |
2948 | 0 | offset = mxRunS1(1); |
2949 | 0 | mxSkipCode(2); |
2950 | 0 | XS_CODE_CODE_ARCHIVE: |
2951 | 0 | variable = mxStack->value.reference; |
2952 | 0 | slot = mxFunctionInstanceCode(variable); |
2953 | 0 | slot->kind = XS_CODE_X_KIND; |
2954 | 0 | slot->value.code.address = mxCode; |
2955 | 0 | if (gxDefaults.newFunctionLength) { |
2956 | 0 | gxDefaults.newFunctionLength(the, variable, mxRunU1(1)); |
2957 | 0 | } |
2958 | 0 | mxNextCode(offset); |
2959 | 0 | mxBreak; |
2960 | | |
2961 | | /* VALUES */ |
2962 | 23.0M | mxCase(XS_CODE_UNDEFINED) |
2963 | 23.0M | mxPushKind(XS_UNDEFINED_KIND); |
2964 | 23.0M | mxNextCode(1); |
2965 | 23.0M | mxBreak; |
2966 | 23.0M | mxCase(XS_CODE_NULL) |
2967 | 3.67M | mxPushKind(XS_NULL_KIND); |
2968 | 3.67M | mxNextCode(1); |
2969 | 3.67M | mxBreak; |
2970 | 7.23M | mxCase(XS_CODE_FALSE) |
2971 | 7.23M | mxPushKind(XS_BOOLEAN_KIND); |
2972 | 7.23M | mxStack->value.boolean = 0; |
2973 | 7.23M | mxNextCode(1); |
2974 | 7.23M | mxBreak; |
2975 | 14.9M | mxCase(XS_CODE_TRUE) |
2976 | 14.9M | mxPushKind(XS_BOOLEAN_KIND); |
2977 | 14.9M | mxStack->value.boolean = 1; |
2978 | 14.9M | mxNextCode(1); |
2979 | 14.9M | mxBreak; |
2980 | 100M | mxCase(XS_CODE_INTEGER_1) |
2981 | 100M | mxPushKind(XS_INTEGER_KIND); |
2982 | 100M | mxStack->value.integer = mxRunS1(1); |
2983 | 100M | mxNextCode(2); |
2984 | | #ifdef mxTrace |
2985 | | if (gxDoTrace) fxTraceInteger(the, mxStack->value.integer); |
2986 | | #endif |
2987 | 100M | mxBreak; |
2988 | 100M | mxCase(XS_CODE_INTEGER_2) |
2989 | 11.4M | mxPushKind(XS_INTEGER_KIND); |
2990 | 11.4M | mxStack->value.integer = mxRunS2(1); |
2991 | 11.4M | mxNextCode(3); |
2992 | | #ifdef mxTrace |
2993 | | if (gxDoTrace) fxTraceInteger(the, mxStack->value.integer); |
2994 | | #endif |
2995 | 11.4M | mxBreak; |
2996 | 11.4M | mxCase(XS_CODE_INTEGER_4) |
2997 | 8.62M | mxPushKind(XS_INTEGER_KIND); |
2998 | 8.62M | mxStack->value.integer = mxRunS4(1); |
2999 | 8.62M | mxNextCode(5); |
3000 | | #ifdef mxTrace |
3001 | | if (gxDoTrace) fxTraceInteger(the, mxStack->value.integer); |
3002 | | #endif |
3003 | 8.62M | mxBreak; |
3004 | 13.1M | mxCase(XS_CODE_NUMBER) |
3005 | 13.1M | mxPushKind(XS_NUMBER_KIND); |
3006 | 13.1M | { |
3007 | 13.1M | txByte* number = (txByte*)&(mxStack->value.number); |
3008 | | #if mxBigEndian |
3009 | | number[7] = mxCode[1]; |
3010 | | number[6] = mxCode[2]; |
3011 | | number[5] = mxCode[3]; |
3012 | | number[4] = mxCode[4]; |
3013 | | number[3] = mxCode[5]; |
3014 | | number[2] = mxCode[6]; |
3015 | | number[1] = mxCode[7]; |
3016 | | number[0] = mxCode[8]; |
3017 | | #else |
3018 | 13.1M | number[0] = mxCode[1]; |
3019 | 13.1M | number[1] = mxCode[2]; |
3020 | 13.1M | number[2] = mxCode[3]; |
3021 | 13.1M | number[3] = mxCode[4]; |
3022 | 13.1M | number[4] = mxCode[5]; |
3023 | 13.1M | number[5] = mxCode[6]; |
3024 | 13.1M | number[6] = mxCode[7]; |
3025 | 13.1M | number[7] = mxCode[8]; |
3026 | 13.1M | #endif |
3027 | 13.1M | } |
3028 | 13.1M | mxNextCode(9); |
3029 | | #ifdef mxTrace |
3030 | | if (gxDoTrace) fxTraceNumber(the, mxStack->value.number); |
3031 | | #endif |
3032 | 13.1M | mxBreak; |
3033 | | |
3034 | 13.1M | mxCase(XS_CODE_STRING_4) |
3035 | 0 | index = mxRunS4(1); |
3036 | 0 | mxSkipCode(5); |
3037 | 0 | goto XS_CODE_STRING; |
3038 | 2.12M | mxCase(XS_CODE_STRING_2) |
3039 | 2.12M | index = mxRunU2(1); |
3040 | 2.12M | mxSkipCode(3); |
3041 | 2.12M | goto XS_CODE_STRING; |
3042 | 19.6M | mxCase(XS_CODE_STRING_1) |
3043 | 19.6M | index = mxRunU1(1); |
3044 | 19.6M | mxSkipCode(2); |
3045 | 21.7M | XS_CODE_STRING: |
3046 | 21.7M | mxSaveState; |
3047 | 21.7M | scratch.value.string = (txString)fxNewChunk(the, index); |
3048 | 21.7M | mxRestoreState; |
3049 | 21.7M | c_memcpy(scratch.value.string, mxCode, index); |
3050 | 21.7M | mxPushKind(XS_STRING_KIND); |
3051 | 21.7M | mxStack->value.string = scratch.value.string; |
3052 | 21.7M | mxNextCode(index); |
3053 | | #ifdef mxTrace |
3054 | | if (gxDoTrace) fxTraceString(the, mxStack->value.string); |
3055 | | #endif |
3056 | 21.7M | mxBreak; |
3057 | 21.7M | mxCase(XS_CODE_STRING_ARCHIVE_4) |
3058 | 0 | index = mxRunS4(1); |
3059 | 0 | mxSkipCode(5); |
3060 | 0 | goto XS_CODE_STRING_ARCHIVE; |
3061 | 0 | mxCase(XS_CODE_STRING_ARCHIVE_2) |
3062 | 0 | index = mxRunU2(1); |
3063 | 0 | mxSkipCode(3); |
3064 | 0 | goto XS_CODE_STRING_ARCHIVE; |
3065 | 0 | mxCase(XS_CODE_STRING_ARCHIVE_1) |
3066 | 0 | index = mxRunU1(1); |
3067 | 0 | mxSkipCode(2); |
3068 | 0 | XS_CODE_STRING_ARCHIVE: |
3069 | 0 | mxPushKind(XS_STRING_X_KIND); |
3070 | 0 | mxStack->value.string = (txString)mxCode; |
3071 | 0 | mxNextCode(index); |
3072 | | #ifdef mxTrace |
3073 | | if (gxDoTrace) fxTraceString(the, mxStack->value.string); |
3074 | | #endif |
3075 | 0 | mxBreak; |
3076 | 334k | mxCase(XS_CODE_TO_STRING) |
3077 | 334k | mxToString(mxStack); |
3078 | 334k | mxNextCode(1); |
3079 | 334k | mxBreak; |
3080 | | |
3081 | 334k | mxCase(XS_CODE_SYMBOL) |
3082 | 997 | mxPushKind(XS_SYMBOL_KIND); |
3083 | 997 | mxStack->value.symbol = mxRunID(1); |
3084 | | #ifdef mxTrace |
3085 | | if (gxDoTrace) fxTraceID(the, mxStack->value.symbol, 0); |
3086 | | #endif |
3087 | 997 | mxNextCode(1 + sizeof(txID)); |
3088 | 997 | mxBreak; |
3089 | | |
3090 | 997 | mxCase(XS_CODE_BIGINT_2) |
3091 | 1 | index = mxRunU2(1); |
3092 | 1 | mxSkipCode(3); |
3093 | 1 | goto XS_CODE_BIGINT; |
3094 | 7.54M | mxCase(XS_CODE_BIGINT_1) |
3095 | 7.54M | index = mxRunU1(1); |
3096 | 7.54M | mxSkipCode(2); |
3097 | 7.54M | XS_CODE_BIGINT: |
3098 | 7.54M | mxSaveState; |
3099 | 7.54M | gxTypeBigInt.decode(the, index); |
3100 | 7.54M | mxRestoreState; |
3101 | 7.54M | mxNextCode(index); |
3102 | 7.54M | mxBreak; |
3103 | | |
3104 | | /* EXPRESSIONS */ |
3105 | 7.54M | mxCase(XS_CODE_BIT_NOT) |
3106 | 2.15M | if (mxStack->kind == XS_INTEGER_KIND) |
3107 | 909k | mxStack->value.integer = ~mxStack->value.integer; |
3108 | 1.24M | else if (mxStack->kind == XS_NUMBER_KIND) { |
3109 | 618k | mxStack->kind = XS_INTEGER_KIND; |
3110 | 618k | mxStack->value.integer = ~fxNumberToInteger(mxStack->value.number); |
3111 | 618k | mxFloatingPointOp("not"); |
3112 | 618k | } |
3113 | 630k | else { |
3114 | 630k | mxSaveState; |
3115 | 630k | if (fxToNumericIntegerUnary(the, mxStack, gxTypeBigInt._not)) |
3116 | 288k | mxStack->value.integer = ~mxStack->value.integer; |
3117 | 630k | mxRestoreState; |
3118 | 630k | } |
3119 | 2.15M | mxNextCode(1); |
3120 | 2.15M | mxBreak; |
3121 | 4.14M | mxCase(XS_CODE_BIT_AND) |
3122 | 4.14M | slot = mxStack + 1; |
3123 | 4.14M | if (slot->kind == XS_INTEGER_KIND) { |
3124 | 2.50M | if (mxStack->kind == XS_INTEGER_KIND) |
3125 | 870k | slot->value.integer &= mxStack->value.integer; |
3126 | 1.63M | else if (mxStack->kind == XS_NUMBER_KIND) { |
3127 | 668k | slot->value.integer &= fxNumberToInteger(mxStack->value.number); |
3128 | 668k | mxFloatingPointOp("and"); |
3129 | 668k | } |
3130 | 968k | else |
3131 | 968k | goto XS_CODE_BIT_AND_GENERAL; |
3132 | 2.50M | } |
3133 | 1.64M | else if (slot->kind == XS_NUMBER_KIND) { |
3134 | 310k | if (mxStack->kind == XS_INTEGER_KIND) { |
3135 | 139k | slot->kind = XS_INTEGER_KIND; |
3136 | 139k | slot->value.integer = fxNumberToInteger(slot->value.number) & mxStack->value.integer; |
3137 | 139k | mxFloatingPointOp("and"); |
3138 | 139k | } |
3139 | 171k | else if (mxStack->kind == XS_NUMBER_KIND) { |
3140 | 116k | slot->kind = XS_INTEGER_KIND; |
3141 | 116k | slot->value.integer = fxNumberToInteger(slot->value.number) & fxNumberToInteger(mxStack->value.number); |
3142 | 116k | mxFloatingPointOp("and"); |
3143 | 116k | } |
3144 | 54.9k | else |
3145 | 54.9k | goto XS_CODE_BIT_AND_GENERAL; |
3146 | 310k | } |
3147 | 1.33M | else { |
3148 | 2.35M | XS_CODE_BIT_AND_GENERAL: |
3149 | 2.35M | mxSaveState; |
3150 | 2.35M | if (fxToNumericIntegerBinary(the, slot, mxStack, gxTypeBigInt._and)) |
3151 | 2.29M | slot->value.integer &= mxStack->value.integer; |
3152 | 2.35M | mxRestoreState; |
3153 | 2.35M | } |
3154 | 4.14M | mxStack++; |
3155 | 4.14M | mxNextCode(1); |
3156 | 4.14M | mxBreak; |
3157 | 4.14M | mxCase(XS_CODE_BIT_OR) |
3158 | 3.68M | slot = mxStack + 1; |
3159 | 3.68M | if (slot->kind == XS_INTEGER_KIND) { |
3160 | 2.51M | if (mxStack->kind == XS_INTEGER_KIND) |
3161 | 1.84M | slot->value.integer |= mxStack->value.integer; |
3162 | 668k | else if (mxStack->kind == XS_NUMBER_KIND) { |
3163 | 271k | slot->value.integer |= fxNumberToInteger(mxStack->value.number); |
3164 | 271k | mxFloatingPointOp("or"); |
3165 | 271k | } |
3166 | 396k | else |
3167 | 396k | goto XS_CODE_BIT_OR_GENERAL; |
3168 | 2.51M | } |
3169 | 1.16M | else if (slot->kind == XS_NUMBER_KIND) { |
3170 | 563k | if (mxStack->kind == XS_INTEGER_KIND) { |
3171 | 556k | slot->kind = XS_INTEGER_KIND; |
3172 | 556k | slot->value.integer = fxNumberToInteger(slot->value.number) | mxStack->value.integer; |
3173 | 556k | mxFloatingPointOp("or"); |
3174 | 556k | } |
3175 | 7.04k | else if (mxStack->kind == XS_NUMBER_KIND) { |
3176 | 3.69k | slot->kind = XS_INTEGER_KIND; |
3177 | 3.69k | slot->value.integer = fxNumberToInteger(slot->value.number) | fxNumberToInteger(mxStack->value.number); |
3178 | 3.69k | mxFloatingPointOp("or"); |
3179 | 3.69k | } |
3180 | 3.35k | else |
3181 | 3.35k | goto XS_CODE_BIT_OR_GENERAL; |
3182 | 563k | } |
3183 | 604k | else { |
3184 | 1.00M | XS_CODE_BIT_OR_GENERAL: |
3185 | 1.00M | mxSaveState; |
3186 | 1.00M | if (fxToNumericIntegerBinary(the, slot, mxStack, gxTypeBigInt._or)) |
3187 | 859k | slot->value.integer |= mxStack->value.integer; |
3188 | 1.00M | mxRestoreState; |
3189 | 1.00M | } |
3190 | 3.68M | mxStack++; |
3191 | 3.68M | mxNextCode(1); |
3192 | 3.68M | mxBreak; |
3193 | 3.68M | mxCase(XS_CODE_BIT_XOR) |
3194 | 2.61M | slot = mxStack + 1; |
3195 | 2.61M | if (slot->kind == XS_INTEGER_KIND) { |
3196 | 1.30M | if (mxStack->kind == XS_INTEGER_KIND) |
3197 | 990k | slot->value.integer ^= mxStack->value.integer; |
3198 | 312k | else if (mxStack->kind == XS_NUMBER_KIND) { |
3199 | 2.16k | slot->value.integer ^= fxNumberToInteger(mxStack->value.number); |
3200 | 2.16k | mxFloatingPointOp("xor"); |
3201 | 2.16k | } |
3202 | 310k | else |
3203 | 310k | goto XS_CODE_BIT_XOR_GENERAL; |
3204 | 1.30M | } |
3205 | 1.31M | else if (slot->kind == XS_NUMBER_KIND) { |
3206 | 226k | if (mxStack->kind == XS_INTEGER_KIND) { |
3207 | 219k | slot->kind = XS_INTEGER_KIND; |
3208 | 219k | slot->value.integer = fxNumberToInteger(slot->value.number) ^ mxStack->value.integer; |
3209 | 219k | mxFloatingPointOp("xor"); |
3210 | 219k | } |
3211 | 6.83k | else if (mxStack->kind == XS_NUMBER_KIND) { |
3212 | 2.72k | slot->kind = XS_INTEGER_KIND; |
3213 | 2.72k | slot->value.integer = fxNumberToInteger(slot->value.number) ^ fxNumberToInteger(mxStack->value.number); |
3214 | 2.72k | mxFloatingPointOp("xor"); |
3215 | 2.72k | } |
3216 | 4.10k | else |
3217 | 4.10k | goto XS_CODE_BIT_XOR_GENERAL; |
3218 | 226k | } |
3219 | 1.08M | else { |
3220 | 1.40M | XS_CODE_BIT_XOR_GENERAL: |
3221 | 1.40M | mxSaveState; |
3222 | 1.40M | if (fxToNumericIntegerBinary(the, slot, mxStack, gxTypeBigInt._xor)) |
3223 | 1.34M | slot->value.integer ^= mxStack->value.integer; |
3224 | 1.40M | mxRestoreState; |
3225 | 1.40M | } |
3226 | 2.61M | mxStack++; |
3227 | 2.61M | mxNextCode(1); |
3228 | 2.61M | mxBreak; |
3229 | | |
3230 | 2.61M | mxCase(XS_CODE_LEFT_SHIFT) |
3231 | 1.81M | slot = mxStack + 1; |
3232 | 1.81M | if (slot->kind == XS_INTEGER_KIND) { |
3233 | 1.17M | if (mxStack->kind == XS_INTEGER_KIND) |
3234 | 901k | slot->value.integer = (txInteger)(((txUnsigned)slot->value.integer) << (mxStack->value.integer & 0x1f)); |
3235 | 274k | else if (mxStack->kind == XS_NUMBER_KIND) { |
3236 | 176k | slot->value.integer = (txInteger)(((txUnsigned)slot->value.integer) << (fxNumberToInteger(mxStack->value.number) & 0x1f)); |
3237 | 176k | mxFloatingPointOp("left shift"); |
3238 | 176k | } |
3239 | 97.9k | else |
3240 | 97.9k | goto XS_CODE_LEFT_SHIFT_GENERAL; |
3241 | 1.17M | } |
3242 | 635k | else if (slot->kind == XS_NUMBER_KIND) { |
3243 | 497k | if (mxStack->kind == XS_INTEGER_KIND) { |
3244 | 5.64k | slot->kind = XS_INTEGER_KIND; |
3245 | 5.64k | slot->value.integer = (txInteger)(((txUnsigned)fxNumberToInteger(slot->value.number)) << (mxStack->value.integer & 0x1f)); |
3246 | 5.64k | mxFloatingPointOp("left shift"); |
3247 | 5.64k | } |
3248 | 492k | else if (mxStack->kind == XS_NUMBER_KIND) { |
3249 | 67.9k | slot->kind = XS_INTEGER_KIND; |
3250 | 67.9k | slot->value.integer = (txInteger)(((txUnsigned)fxNumberToInteger(slot->value.number)) << (fxNumberToInteger(mxStack->value.number) & 0x1f)); |
3251 | 67.9k | mxFloatingPointOp("left shift"); |
3252 | 67.9k | } |
3253 | 424k | else |
3254 | 424k | goto XS_CODE_LEFT_SHIFT_GENERAL; |
3255 | 497k | } |
3256 | 137k | else { |
3257 | 660k | XS_CODE_LEFT_SHIFT_GENERAL: |
3258 | 660k | mxSaveState; |
3259 | 660k | if (fxToNumericIntegerBinary(the, slot, mxStack, gxTypeBigInt._lsl)) |
3260 | 644k | slot->value.integer = (txInteger)(((txUnsigned)slot->value.integer) << (mxStack->value.integer & 0x1f)); |
3261 | 660k | mxRestoreState; |
3262 | 660k | } |
3263 | 1.81M | mxStack++; |
3264 | 1.81M | mxNextCode(1); |
3265 | 1.81M | mxBreak; |
3266 | 1.81M | mxCase(XS_CODE_SIGNED_RIGHT_SHIFT) |
3267 | 1.54M | slot = mxStack + 1; |
3268 | 1.54M | if (slot->kind == XS_INTEGER_KIND) { |
3269 | 721k | if (mxStack->kind == XS_INTEGER_KIND) |
3270 | 354k | slot->value.integer >>= mxStack->value.integer & 0x1f; |
3271 | 367k | else if (mxStack->kind == XS_NUMBER_KIND) { |
3272 | 25.1k | slot->value.integer >>= fxNumberToInteger(mxStack->value.number) & 0x1f; |
3273 | 25.1k | mxFloatingPointOp("signed right shift"); |
3274 | 25.1k | } |
3275 | 341k | else |
3276 | 341k | goto XS_CODE_SIGNED_RIGHT_SHIFT_GENERAL; |
3277 | 721k | } |
3278 | 828k | else if (slot->kind == XS_NUMBER_KIND) { |
3279 | 707k | if (mxStack->kind == XS_INTEGER_KIND) { |
3280 | 422k | slot->kind = XS_INTEGER_KIND; |
3281 | 422k | slot->value.integer = fxNumberToInteger(slot->value.number) >> (mxStack->value.integer & 0x1f); |
3282 | 422k | mxFloatingPointOp("signed right shift"); |
3283 | 422k | } |
3284 | 285k | else if (mxStack->kind == XS_NUMBER_KIND) { |
3285 | 284k | slot->kind = XS_INTEGER_KIND; |
3286 | 284k | slot->value.integer = fxNumberToInteger(slot->value.number) >> (fxNumberToInteger(mxStack->value.number) & 0x1f); |
3287 | 284k | mxFloatingPointOp("signed right shift"); |
3288 | 284k | } |
3289 | 941 | else |
3290 | 941 | goto XS_CODE_SIGNED_RIGHT_SHIFT_GENERAL; |
3291 | 707k | } |
3292 | 120k | else { |
3293 | 463k | XS_CODE_SIGNED_RIGHT_SHIFT_GENERAL: |
3294 | 463k | mxSaveState; |
3295 | 463k | if (fxToNumericIntegerBinary(the, slot, mxStack, gxTypeBigInt._lsr)) |
3296 | 440k | slot->value.integer >>= mxStack->value.integer & 0x1f; |
3297 | 463k | mxRestoreState; |
3298 | 463k | } |
3299 | 1.54M | mxStack++; |
3300 | 1.54M | mxNextCode(1); |
3301 | 1.54M | mxBreak; |
3302 | 1.59M | mxCase(XS_CODE_UNSIGNED_RIGHT_SHIFT) |
3303 | 1.59M | slot = mxStack + 1; |
3304 | 1.59M | if (((slot->kind == XS_INTEGER_KIND) || (slot->kind == XS_NUMBER_KIND)) && ((mxStack->kind == XS_INTEGER_KIND) || (mxStack->kind == XS_NUMBER_KIND))) { |
3305 | 1.28M | fxUnsigned(the, slot, fxToUnsigned(the, slot) >> (fxToUnsigned(the, mxStack) & 0x1F)); |
3306 | 1.28M | } |
3307 | 303k | else { |
3308 | 303k | mxSaveState; |
3309 | 303k | if (fxToNumericNumberBinary(the, slot, mxStack, gxTypeBigInt._nop)) |
3310 | 303k | fxUnsigned(the, slot, fxToUnsigned(the, slot) >> (fxToUnsigned(the, mxStack) & 0x1F)); |
3311 | 303k | mxRestoreState; |
3312 | 303k | } |
3313 | 1.59M | mxStack++; |
3314 | 1.59M | mxNextCode(1); |
3315 | 1.59M | mxBreak; |
3316 | | |
3317 | 18.6M | mxCase(XS_CODE_MINUS) |
3318 | 18.6M | if (mxStack->kind == XS_INTEGER_KIND) { |
3319 | 10.1M | if (mxStack->value.integer & 0x7FFFFFFF) |
3320 | 7.50M | mxStack->value.integer = -mxStack->value.integer; |
3321 | 2.68M | else { |
3322 | 2.68M | mxStack->kind = XS_NUMBER_KIND; |
3323 | 2.68M | mxStack->value.number = -((txNumber)(mxStack->value.integer)); |
3324 | 2.68M | mxFloatingPointOp("minus"); |
3325 | 2.68M | } |
3326 | 10.1M | } |
3327 | 8.42M | else if (mxStack->kind == XS_NUMBER_KIND) { |
3328 | 2.43M | mxStack->value.number = -mxStack->value.number; |
3329 | 2.43M | mxFloatingPointOp("minus"); |
3330 | 2.43M | } |
3331 | 5.98M | else { |
3332 | 5.98M | mxSaveState; |
3333 | 5.98M | if (fxToNumericNumberUnary(the, mxStack, gxTypeBigInt._neg)) { |
3334 | 1.63M | mxStack->value.number = -mxStack->value.number; |
3335 | 1.63M | mxFloatingPointOp("minus"); |
3336 | 1.63M | } |
3337 | 5.98M | mxRestoreState; |
3338 | 5.98M | } |
3339 | 18.6M | mxNextCode(1); |
3340 | 18.6M | mxBreak; |
3341 | 18.6M | mxCase(XS_CODE_PLUS) |
3342 | 6.21M | if (mxStack->kind != XS_INTEGER_KIND) { |
3343 | 2.88M | mxToNumber(mxStack); |
3344 | 2.88M | } |
3345 | 6.21M | mxNextCode(1); |
3346 | 6.21M | mxBreak; |
3347 | | |
3348 | 6.21M | mxCase(XS_CODE_TO_NUMERIC) |
3349 | 4.20M | if ((mxStack->kind != XS_INTEGER_KIND) && (mxStack->kind != XS_NUMBER_KIND)) { |
3350 | 1.58M | mxSaveState; |
3351 | 1.58M | fxToNumericNumber(the, mxStack); |
3352 | 1.58M | mxRestoreState; |
3353 | 1.58M | } |
3354 | 4.20M | mxNextCode(1); |
3355 | 4.20M | mxBreak; |
3356 | 4.20M | mxCase(XS_CODE_DECREMENT) |
3357 | 3.86M | if (mxStack->kind == XS_INTEGER_KIND) { |
3358 | 655k | if (mxStack->value.integer != -2147483647) |
3359 | 655k | mxStack->value.integer--; |
3360 | 0 | else { |
3361 | 0 | mxStack->kind = XS_NUMBER_KIND; |
3362 | 0 | mxStack->value.number = mxStack->value.integer; |
3363 | 0 | mxStack->value.number--; |
3364 | 0 | mxFloatingPointOp("decrement"); |
3365 | 0 | } |
3366 | 655k | } |
3367 | 3.21M | else if (mxStack->kind == XS_NUMBER_KIND) { |
3368 | 2.68M | mxStack->value.number--; |
3369 | 2.68M | mxFloatingPointOp("decrement"); |
3370 | 2.68M | } |
3371 | 524k | else { |
3372 | 524k | mxSaveState; |
3373 | 524k | if (fxToNumericNumberUnary(the, mxStack, gxTypeBigInt._dec)) { |
3374 | 393k | mxStack->value.number--; |
3375 | 393k | mxFloatingPointOp("decrement"); |
3376 | 393k | } |
3377 | 524k | mxRestoreState; |
3378 | 524k | } |
3379 | 3.86M | mxNextCode(1); |
3380 | 3.86M | mxBreak; |
3381 | 24.8M | mxCase(XS_CODE_INCREMENT) |
3382 | 24.8M | if (mxStack->kind == XS_INTEGER_KIND) { |
3383 | 16.5M | if (mxStack->value.integer != 2147483647) |
3384 | 16.5M | mxStack->value.integer++; |
3385 | 8 | else { |
3386 | 8 | mxStack->kind = XS_NUMBER_KIND; |
3387 | 8 | mxStack->value.number = mxStack->value.integer; |
3388 | 8 | mxStack->value.number++; |
3389 | 8 | mxFloatingPointOp("increment"); |
3390 | 8 | } |
3391 | 16.5M | } |
3392 | 8.36M | else if (mxStack->kind == XS_NUMBER_KIND) { |
3393 | 4.89M | mxStack->value.number++; |
3394 | 4.89M | mxFloatingPointOp("increment"); |
3395 | 4.89M | } |
3396 | 3.47M | else { |
3397 | 3.47M | mxSaveState; |
3398 | 3.47M | if (fxToNumericNumberUnary(the, mxStack, gxTypeBigInt._inc)) { |
3399 | 2.66M | mxStack->value.number++; |
3400 | 2.66M | mxFloatingPointOp("increment"); |
3401 | 2.66M | } |
3402 | 3.47M | mxRestoreState; |
3403 | 3.47M | } |
3404 | 24.8M | mxNextCode(1); |
3405 | 24.8M | mxBreak; |
3406 | | |
3407 | 24.8M | mxCase(XS_CODE_ADD) |
3408 | 11.2M | slot = mxStack + 1; |
3409 | 11.2M | if (slot->kind == XS_INTEGER_KIND) { |
3410 | 5.13M | if (mxStack->kind == XS_INTEGER_KIND) { |
3411 | 4.11M | #if __has_builtin(__builtin_add_overflow) |
3412 | 4.11M | if (__builtin_add_overflow(slot->value.integer, mxStack->value.integer, &scratch.value.integer)) { |
3413 | 1.82k | slot->kind = XS_NUMBER_KIND; |
3414 | 1.82k | slot->value.number = (txNumber)(slot->value.integer) + (txNumber)(mxStack->value.integer); |
3415 | 1.82k | mxFloatingPointOp("add"); |
3416 | 1.82k | } |
3417 | 4.10M | else |
3418 | 4.10M | slot->value.integer = scratch.value.integer; |
3419 | | #else |
3420 | | txInteger a = slot->value.integer; |
3421 | | txInteger b = mxStack->value.integer; |
3422 | | txInteger c = a + b; |
3423 | | if (((a ^ c) & (b ^ c)) < 0) { |
3424 | | slot->kind = XS_NUMBER_KIND; |
3425 | | slot->value.number = (txNumber)(slot->value.integer) + (txNumber)(mxStack->value.integer); |
3426 | | mxFloatingPointOp("add"); |
3427 | | } |
3428 | | else |
3429 | | slot->value.integer = c; |
3430 | | #endif |
3431 | 4.11M | } |
3432 | 1.02M | else if (mxStack->kind == XS_NUMBER_KIND) { |
3433 | 627k | slot->kind = XS_NUMBER_KIND; |
3434 | 627k | slot->value.number = (txNumber)(slot->value.integer) + mxStack->value.number; |
3435 | 627k | mxFloatingPointOp("add"); |
3436 | 627k | } |
3437 | 400k | else |
3438 | 400k | goto XS_CODE_ADD_GENERAL; |
3439 | 5.13M | } |
3440 | 6.12M | else if (slot->kind == XS_NUMBER_KIND) { |
3441 | 1.94M | if (mxStack->kind == XS_INTEGER_KIND) { |
3442 | 964k | slot->value.number += (txNumber)(mxStack->value.integer); |
3443 | 964k | mxFloatingPointOp("add"); |
3444 | 964k | } |
3445 | 984k | else if (mxStack->kind == XS_NUMBER_KIND) { |
3446 | 457k | slot->value.number += mxStack->value.number; |
3447 | 457k | mxFloatingPointOp("add"); |
3448 | 457k | } |
3449 | 526k | else |
3450 | 526k | goto XS_CODE_ADD_GENERAL; |
3451 | 1.94M | } |
3452 | 4.17M | else { |
3453 | 5.10M | XS_CODE_ADD_GENERAL: |
3454 | 5.10M | mxSaveState; |
3455 | 5.10M | fxToPrimitive(the, slot, XS_NO_HINT); |
3456 | 5.10M | fxToPrimitive(the, mxStack, XS_NO_HINT); |
3457 | 5.10M | if ((slot->kind == XS_STRING_KIND) || (slot->kind == XS_STRING_X_KIND) || (mxStack->kind == XS_STRING_KIND) || (mxStack->kind == XS_STRING_X_KIND)) { |
3458 | 4.69M | fxToString(the, slot); |
3459 | 4.69M | fxToString(the, mxStack); |
3460 | 4.69M | fxConcatString(the, slot, mxStack); |
3461 | 4.69M | } |
3462 | 408k | else { |
3463 | 408k | if (fxToNumericNumberBinary(the, slot, mxStack, gxTypeBigInt._add)) { |
3464 | 402k | slot->value.number += mxStack->value.number; |
3465 | 402k | mxFloatingPointOp("add"); |
3466 | 402k | } |
3467 | 408k | } |
3468 | 5.10M | mxRestoreState; |
3469 | 5.10M | } |
3470 | 11.2M | mxStack++; |
3471 | 11.2M | mxNextCode(1); |
3472 | 11.2M | mxBreak; |
3473 | 11.2M | mxCase(XS_CODE_SUBTRACT) |
3474 | 10.9M | slot = mxStack + 1; |
3475 | 10.9M | if (slot->kind == XS_INTEGER_KIND) { |
3476 | 5.90M | if (mxStack->kind == XS_INTEGER_KIND) { |
3477 | 3.55M | #if __has_builtin(__builtin_sub_overflow) |
3478 | 3.55M | if (__builtin_sub_overflow(slot->value.integer, mxStack->value.integer, &scratch.value.integer)) { |
3479 | 1.25k | slot->kind = XS_NUMBER_KIND; |
3480 | 1.25k | slot->value.number = (txNumber)(slot->value.integer) - (txNumber)(mxStack->value.integer); |
3481 | 1.25k | mxFloatingPointOp("subtract"); |
3482 | 1.25k | } |
3483 | 3.55M | else |
3484 | 3.55M | slot->value.integer = scratch.value.integer; |
3485 | | #else |
3486 | | txInteger a = slot->value.integer; |
3487 | | txInteger b = -mxStack->value.integer; |
3488 | | txInteger c = a + b; |
3489 | | if (((a ^ c) & (b ^ c)) < 0) { |
3490 | | slot->kind = XS_NUMBER_KIND; |
3491 | | slot->value.number = (txNumber)(slot->value.integer) - (txNumber)(mxStack->value.integer); |
3492 | | mxFloatingPointOp("subtract"); |
3493 | | } |
3494 | | else |
3495 | | slot->value.integer = c; |
3496 | | #endif |
3497 | 3.55M | } |
3498 | 2.35M | else if (mxStack->kind == XS_NUMBER_KIND) { |
3499 | 1.28M | slot->kind = XS_NUMBER_KIND; |
3500 | 1.28M | slot->value.number = (txNumber)(slot->value.integer) - mxStack->value.number; |
3501 | 1.28M | mxFloatingPointOp("subtract"); |
3502 | 1.28M | } |
3503 | 1.06M | else |
3504 | 1.06M | goto XS_CODE_SUBTRACT_GENERAL; |
3505 | 5.90M | } |
3506 | 4.99M | else if (slot->kind == XS_NUMBER_KIND) { |
3507 | 2.92M | if (mxStack->kind == XS_INTEGER_KIND) { |
3508 | 555k | slot->value.number -= (txNumber)(mxStack->value.integer); |
3509 | 555k | mxFloatingPointOp("subtract"); |
3510 | 555k | } |
3511 | 2.36M | else if (mxStack->kind == XS_NUMBER_KIND) { |
3512 | 1.94M | slot->value.number -= mxStack->value.number; |
3513 | 1.94M | mxFloatingPointOp("subtract"); |
3514 | 1.94M | } |
3515 | 417k | else |
3516 | 417k | goto XS_CODE_SUBTRACT_GENERAL; |
3517 | 2.92M | } |
3518 | 2.07M | else { |
3519 | 3.55M | XS_CODE_SUBTRACT_GENERAL: |
3520 | 3.55M | mxSaveState; |
3521 | 3.55M | if (fxToNumericNumberBinary(the, slot, mxStack, gxTypeBigInt._sub)) { |
3522 | 3.37M | slot->value.number -= mxStack->value.number; |
3523 | 3.37M | mxFloatingPointOp("subtract"); |
3524 | 3.37M | } |
3525 | 3.55M | mxRestoreState; |
3526 | 3.55M | } |
3527 | 10.9M | mxStack++; |
3528 | 10.9M | mxNextCode(1); |
3529 | 10.9M | mxBreak; |
3530 | | |
3531 | 10.9M | mxCase(XS_CODE_DIVIDE) |
3532 | 7.33M | slot = mxStack + 1; |
3533 | 7.33M | if (slot->kind == XS_INTEGER_KIND) { |
3534 | 4.06M | if (mxStack->kind == XS_INTEGER_KIND) { |
3535 | 3.34M | slot->kind = XS_NUMBER_KIND; |
3536 | 3.34M | slot->value.number = (txNumber)(slot->value.integer) / (txNumber)(mxStack->value.integer); |
3537 | 3.34M | } |
3538 | 720k | else if (mxStack->kind == XS_NUMBER_KIND) { |
3539 | 563k | slot->kind = XS_NUMBER_KIND; |
3540 | 563k | slot->value.number = (txNumber)(slot->value.integer) / mxStack->value.number; |
3541 | 563k | } |
3542 | 156k | else |
3543 | 156k | goto XS_CODE_DIVIDE_GENERAL; |
3544 | 4.06M | } |
3545 | 3.27M | else if (slot->kind == XS_NUMBER_KIND) { |
3546 | 1.78M | if (mxStack->kind == XS_INTEGER_KIND) |
3547 | 1.10M | slot->value.number /= (txNumber)(mxStack->value.integer); |
3548 | 686k | else if (mxStack->kind == XS_NUMBER_KIND) |
3549 | 216k | slot->value.number /= mxStack->value.number; |
3550 | 469k | else |
3551 | 469k | goto XS_CODE_DIVIDE_GENERAL; |
3552 | 1.78M | } |
3553 | 1.48M | else { |
3554 | 2.11M | XS_CODE_DIVIDE_GENERAL: |
3555 | 2.11M | mxSaveState; |
3556 | 2.11M | if (fxToNumericNumberBinary(the, slot, mxStack, gxTypeBigInt._div)) |
3557 | 1.84M | slot->value.number /= mxStack->value.number; |
3558 | 2.11M | mxRestoreState; |
3559 | 2.11M | } |
3560 | 7.33M | mxFloatingPointOp("divide"); |
3561 | 7.33M | mxStack++; |
3562 | 7.33M | mxNextCode(1); |
3563 | 7.33M | mxBreak; |
3564 | 7.33M | mxCase(XS_CODE_EXPONENTIATION) |
3565 | 3.03M | slot = mxStack + 1; |
3566 | 3.03M | if (slot->kind == XS_INTEGER_KIND) { |
3567 | 1.47M | if (mxStack->kind == XS_INTEGER_KIND) { |
3568 | 275k | slot->kind = XS_NUMBER_KIND; |
3569 | 275k | slot->value.number = fx_pow((txNumber)(slot->value.integer), (txNumber)(mxStack->value.integer)); |
3570 | 275k | } |
3571 | 1.19M | else if (mxStack->kind == XS_NUMBER_KIND) { |
3572 | 633k | slot->kind = XS_NUMBER_KIND; |
3573 | 633k | slot->value.number = fx_pow((txNumber)(slot->value.integer), mxStack->value.number); |
3574 | 633k | } |
3575 | 564k | else |
3576 | 564k | goto XS_CODE_EXPONENTIATION_GENERAL; |
3577 | 1.47M | } |
3578 | 1.56M | else if (slot->kind == XS_NUMBER_KIND) { |
3579 | 1.38M | if (mxStack->kind == XS_INTEGER_KIND) |
3580 | 24.1k | slot->value.number = fx_pow(slot->value.number, (txNumber)(mxStack->value.integer)); |
3581 | 1.35M | else if (mxStack->kind == XS_NUMBER_KIND) |
3582 | 395k | slot->value.number = fx_pow(slot->value.number, mxStack->value.number); |
3583 | 960k | else |
3584 | 960k | goto XS_CODE_EXPONENTIATION_GENERAL; |
3585 | 1.38M | } |
3586 | 184k | else { |
3587 | 1.70M | XS_CODE_EXPONENTIATION_GENERAL: |
3588 | 1.70M | mxSaveState; |
3589 | 1.70M | if (fxToNumericNumberBinary(the, slot, mxStack, gxTypeBigInt._exp)) |
3590 | 1.55M | slot->value.number = fx_pow(slot->value.number, mxStack->value.number); |
3591 | 1.70M | mxRestoreState; |
3592 | 1.70M | } |
3593 | 3.03M | mxFloatingPointOp("exponent"); |
3594 | 3.03M | mxStack++; |
3595 | 3.03M | mxNextCode(1); |
3596 | 3.03M | mxBreak; |
3597 | 3.03M | mxCase(XS_CODE_MULTIPLY) |
3598 | 2.28M | slot = mxStack + 1; |
3599 | 2.28M | if (slot->kind == XS_INTEGER_KIND) { |
3600 | 1.46M | if (mxStack->kind == XS_INTEGER_KIND) { |
3601 | 689k | #ifdef mxMinusZero |
3602 | 689k | if (slot->value.integer == 0) { |
3603 | 183k | if (mxStack->value.integer < 0) { |
3604 | 7.67k | slot->kind = XS_NUMBER_KIND; |
3605 | 7.67k | slot->value.number = -0.0; |
3606 | 7.67k | } |
3607 | 183k | } |
3608 | 506k | else if (mxStack->value.integer == 0) { |
3609 | 98.3k | if (slot->value.integer < 0) { |
3610 | 298 | slot->kind = XS_NUMBER_KIND; |
3611 | 298 | slot->value.number = -0.0; |
3612 | 298 | } |
3613 | 98.0k | else |
3614 | 98.0k | slot->value.integer = 0; |
3615 | 98.3k | } |
3616 | 408k | else { |
3617 | 408k | #endif |
3618 | 408k | #if __has_builtin(__builtin_mul_overflow) |
3619 | 408k | if (__builtin_mul_overflow(slot->value.integer, mxStack->value.integer, &scratch.value.integer)) { |
3620 | 216k | slot->kind = XS_NUMBER_KIND; |
3621 | 216k | slot->value.number = (txNumber)(slot->value.integer) * (txNumber)(mxStack->value.integer); |
3622 | 216k | mxFloatingPointOp("multiply"); |
3623 | 216k | } |
3624 | 191k | else |
3625 | 191k | slot->value.integer = scratch.value.integer; |
3626 | | #else |
3627 | | slot->kind = XS_NUMBER_KIND; |
3628 | | slot->value.number = (txNumber)(slot->value.integer) * (txNumber)(mxStack->value.integer); |
3629 | | mxFloatingPointOp("multiply"); |
3630 | | #endif |
3631 | 408k | #ifdef mxMinusZero |
3632 | 408k | } |
3633 | 689k | #endif |
3634 | 689k | } |
3635 | 779k | else if (mxStack->kind == XS_NUMBER_KIND) { |
3636 | 572k | slot->kind = XS_NUMBER_KIND; |
3637 | 572k | slot->value.number = (txNumber)(slot->value.integer) * mxStack->value.number; |
3638 | 572k | mxFloatingPointOp("multiply"); |
3639 | 572k | } |
3640 | 206k | else |
3641 | 206k | goto XS_CODE_MULTIPLY_GENERAL; |
3642 | 1.46M | } |
3643 | 819k | else if (slot->kind == XS_NUMBER_KIND) { |
3644 | 598k | if (mxStack->kind == XS_INTEGER_KIND) { |
3645 | 465k | slot->value.number *= (txNumber)(mxStack->value.integer); |
3646 | 465k | mxFloatingPointOp("multiply"); |
3647 | 465k | } |
3648 | 133k | else if (mxStack->kind == XS_NUMBER_KIND) { |
3649 | 70.6k | slot->value.number *= mxStack->value.number; |
3650 | 70.6k | mxFloatingPointOp("multiply"); |
3651 | 70.6k | } |
3652 | 62.4k | else |
3653 | 62.4k | goto XS_CODE_MULTIPLY_GENERAL; |
3654 | 598k | } |
3655 | 220k | else { |
3656 | 489k | XS_CODE_MULTIPLY_GENERAL: |
3657 | 489k | mxSaveState; |
3658 | 489k | if (fxToNumericNumberBinary(the, slot, mxStack, gxTypeBigInt._mul)) |
3659 | 340k | slot->value.number *= mxStack->value.number; |
3660 | 489k | mxRestoreState; |
3661 | 489k | } |
3662 | 2.28M | mxStack++; |
3663 | 2.28M | mxNextCode(1); |
3664 | 2.28M | mxBreak; |
3665 | 4.72M | mxCase(XS_CODE_MODULO) |
3666 | 4.72M | slot = mxStack + 1; |
3667 | 4.72M | if (slot->kind == XS_INTEGER_KIND) { |
3668 | 2.34M | if (mxStack->kind == XS_INTEGER_KIND) { |
3669 | 2.05M | if (mxStack->value.integer == 0) { |
3670 | 547k | slot->kind = XS_NUMBER_KIND; |
3671 | 547k | slot->value.number = C_NAN; |
3672 | 547k | } |
3673 | 1.51M | #if mxIntegerDivideOverflowException |
3674 | 1.51M | else if ((-1 == mxStack->value.integer) && ((txInteger)0x80000000 == slot->value.integer)) { |
3675 | 4 | slot->kind = XS_NUMBER_KIND; |
3676 | 4 | slot->value.number = -0.0; |
3677 | 4 | } |
3678 | 1.51M | #endif |
3679 | 1.51M | #ifdef mxMinusZero |
3680 | 1.51M | else if (slot->value.integer < 0) { |
3681 | 172k | slot->value.integer %= mxStack->value.integer; |
3682 | 172k | if (slot->value.integer == 0) { |
3683 | 1.04k | slot->kind = XS_NUMBER_KIND; |
3684 | 1.04k | slot->value.number = -0.0; |
3685 | 1.04k | } |
3686 | 172k | } |
3687 | 1.34M | #endif |
3688 | 1.34M | else |
3689 | 1.34M | slot->value.integer %= mxStack->value.integer; |
3690 | 2.05M | } |
3691 | 281k | else if (mxStack->kind == XS_NUMBER_KIND) { |
3692 | 279k | slot->kind = XS_NUMBER_KIND; |
3693 | 279k | slot->value.number = c_fmod((txNumber)(slot->value.integer), mxStack->value.number); |
3694 | 279k | mxFloatingPointOp("modulo"); |
3695 | 279k | } |
3696 | 2.43k | else |
3697 | 2.43k | goto XS_CODE_MODULO_GENERAL; |
3698 | 2.34M | } |
3699 | 2.38M | else if (slot->kind == XS_NUMBER_KIND) { |
3700 | 556k | if (mxStack->kind == XS_INTEGER_KIND) { |
3701 | 215k | slot->value.number = c_fmod(slot->value.number, (txNumber)(mxStack->value.integer)); |
3702 | 215k | mxFloatingPointOp("modulo"); |
3703 | 215k | } |
3704 | 340k | else if (mxStack->kind == XS_NUMBER_KIND) { |
3705 | 172k | slot->value.number = c_fmod(slot->value.number, mxStack->value.number); |
3706 | 172k | mxFloatingPointOp("modulo"); |
3707 | 172k | } |
3708 | 167k | else |
3709 | 167k | goto XS_CODE_MODULO_GENERAL; |
3710 | 556k | } |
3711 | 1.83M | else { |
3712 | 2.00M | XS_CODE_MODULO_GENERAL: |
3713 | 2.00M | mxSaveState; |
3714 | 2.00M | if (fxToNumericNumberBinary(the, slot, mxStack, gxTypeBigInt._rem)) { |
3715 | 1.36M | slot->value.number = c_fmod(slot->value.number, mxStack->value.number); |
3716 | 1.36M | mxFloatingPointOp("modulo"); |
3717 | 1.36M | } |
3718 | 2.00M | mxRestoreState; |
3719 | 2.00M | } |
3720 | 4.72M | mxStack++; |
3721 | 4.72M | mxNextCode(1); |
3722 | 4.72M | mxBreak; |
3723 | | |
3724 | 8.23M | mxCase(XS_CODE_NOT) |
3725 | 8.23M | mxToBoolean(mxStack); |
3726 | 8.23M | mxStack->value.boolean = !mxStack->value.boolean; |
3727 | 8.23M | mxNextCode(1); |
3728 | 8.23M | mxBreak; |
3729 | 17.9M | mxCase(XS_CODE_LESS) |
3730 | 17.9M | slot = mxStack + 1; |
3731 | 17.9M | if (slot->kind == XS_INTEGER_KIND) { |
3732 | 13.8M | if (mxStack->kind == XS_INTEGER_KIND) |
3733 | 11.2M | offset = slot->value.integer < mxStack->value.integer; |
3734 | 2.67M | else if (mxStack->kind == XS_NUMBER_KIND) { |
3735 | 1.53M | offset = (!c_isnan(mxStack->value.number)) && ((txNumber)(slot->value.integer) < mxStack->value.number); |
3736 | 1.53M | mxFloatingPointOp("less"); |
3737 | 1.53M | } |
3738 | 1.13M | else |
3739 | 1.13M | goto XS_CODE_LESS_GENERAL; |
3740 | 13.8M | } |
3741 | 4.04M | else if (slot->kind == XS_NUMBER_KIND) { |
3742 | 1.56M | if (mxStack->kind == XS_INTEGER_KIND) { |
3743 | 473k | offset = (!c_isnan(slot->value.number)) && (slot->value.number < (txNumber)(mxStack->value.integer)); |
3744 | 473k | mxFloatingPointOp("less"); |
3745 | 473k | } |
3746 | 1.08M | else if (mxStack->kind == XS_NUMBER_KIND) { |
3747 | 435k | offset = (!c_isnan(slot->value.number)) && (!c_isnan(mxStack->value.number)) && (slot->value.number < mxStack->value.number); |
3748 | 435k | mxFloatingPointOp("less"); |
3749 | 435k | } |
3750 | 651k | else |
3751 | 651k | goto XS_CODE_LESS_GENERAL; |
3752 | 1.56M | } |
3753 | 2.48M | else { |
3754 | 4.27M | XS_CODE_LESS_GENERAL: |
3755 | 4.27M | mxSaveState; |
3756 | 4.27M | fxToPrimitive(the, slot, XS_NUMBER_HINT); |
3757 | 4.27M | fxToPrimitive(the, mxStack, XS_NUMBER_HINT); |
3758 | 4.27M | if (((slot->kind == XS_STRING_KIND) || (slot->kind == XS_STRING_X_KIND)) && ((mxStack->kind == XS_STRING_KIND) || (mxStack->kind == XS_STRING_X_KIND))) |
3759 | 86.8k | offset = fxUTF8Compare(slot->value.string, mxStack->value.string) < 0; |
3760 | 4.18M | else if ((slot->kind == XS_BIGINT_KIND) || (slot->kind == XS_BIGINT_X_KIND)) |
3761 | 807k | offset = gxTypeBigInt.compare(the, 1, 0, 0, slot, mxStack); |
3762 | 3.37M | else if ((mxStack->kind == XS_BIGINT_KIND) || (mxStack->kind == XS_BIGINT_X_KIND)) |
3763 | 1.54M | offset = gxTypeBigInt.compare(the, 0, 0, 1, mxStack, slot); |
3764 | 1.83M | else { |
3765 | 1.83M | fxToNumber(the, slot); |
3766 | 1.83M | fxToNumber(the, mxStack); |
3767 | 1.83M | offset = (!c_isnan(slot->value.number)) && (!c_isnan(mxStack->value.number)) && (slot->value.number < mxStack->value.number); |
3768 | 1.83M | mxFloatingPointOp("less"); |
3769 | 1.83M | } |
3770 | 4.27M | mxRestoreState; |
3771 | 4.27M | } |
3772 | 17.9M | slot->kind = XS_BOOLEAN_KIND; |
3773 | 17.9M | slot->value.boolean = offset; |
3774 | 17.9M | mxStack++; |
3775 | 17.9M | mxNextCode(1); |
3776 | 17.9M | mxBreak; |
3777 | 17.9M | mxCase(XS_CODE_LESS_EQUAL) |
3778 | 1.39M | slot = mxStack + 1; |
3779 | 1.39M | if (slot->kind == XS_INTEGER_KIND) { |
3780 | 1.03M | if (mxStack->kind == XS_INTEGER_KIND) |
3781 | 982k | offset = slot->value.integer <= mxStack->value.integer; |
3782 | 53.2k | else if (mxStack->kind == XS_NUMBER_KIND) { |
3783 | 1.09k | offset = (!c_isnan(mxStack->value.number)) && ((txNumber)(slot->value.integer) <= mxStack->value.number); |
3784 | 1.09k | mxFloatingPointOp("less or equal"); |
3785 | 1.09k | } |
3786 | 52.1k | else |
3787 | 52.1k | goto XS_CODE_LESS_EQUAL_GENERAL; |
3788 | 1.03M | } |
3789 | 362k | else if (slot->kind == XS_NUMBER_KIND) { |
3790 | 81.3k | if (mxStack->kind == XS_INTEGER_KIND) { |
3791 | 2.74k | offset = (!c_isnan(slot->value.number)) && (slot->value.number <= (txNumber)(mxStack->value.integer)); |
3792 | 2.74k | mxFloatingPointOp("less or equal"); |
3793 | 2.74k | } |
3794 | 78.5k | else if (mxStack->kind == XS_NUMBER_KIND) { |
3795 | 77.9k | offset = (!c_isnan(slot->value.number)) && (!c_isnan(mxStack->value.number)) && (slot->value.number <= mxStack->value.number); |
3796 | 77.9k | mxFloatingPointOp("less or equal"); |
3797 | 77.9k | } |
3798 | 660 | else |
3799 | 660 | goto XS_CODE_LESS_EQUAL_GENERAL; |
3800 | 81.3k | } |
3801 | 280k | else { |
3802 | 333k | XS_CODE_LESS_EQUAL_GENERAL: |
3803 | 333k | mxSaveState; |
3804 | 333k | fxToPrimitive(the, slot, XS_NUMBER_HINT); |
3805 | 333k | fxToPrimitive(the, mxStack, XS_NUMBER_HINT); |
3806 | 333k | if (((slot->kind == XS_STRING_KIND) || (slot->kind == XS_STRING_X_KIND)) && ((mxStack->kind == XS_STRING_KIND) || (mxStack->kind == XS_STRING_X_KIND))) |
3807 | 5.18k | offset = fxUTF8Compare(slot->value.string, mxStack->value.string) <= 0; |
3808 | 328k | else if ((slot->kind == XS_BIGINT_KIND) || (slot->kind == XS_BIGINT_X_KIND)) |
3809 | 62 | offset = gxTypeBigInt.compare(the, 1, 1, 0, slot, mxStack); |
3810 | 328k | else if ((mxStack->kind == XS_BIGINT_KIND) || (mxStack->kind == XS_BIGINT_X_KIND)) |
3811 | 15.2k | offset = gxTypeBigInt.compare(the, 0, 1, 1, mxStack, slot); |
3812 | 313k | else { |
3813 | 313k | fxToNumber(the, slot); |
3814 | 313k | fxToNumber(the, mxStack); |
3815 | 313k | offset = (!c_isnan(slot->value.number)) && (!c_isnan(mxStack->value.number)) && (slot->value.number <= mxStack->value.number); |
3816 | 313k | mxFloatingPointOp("less or equal"); |
3817 | 313k | } |
3818 | 333k | mxRestoreState; |
3819 | 333k | } |
3820 | 1.39M | slot->kind = XS_BOOLEAN_KIND; |
3821 | 1.39M | slot->value.boolean = offset; |
3822 | 1.39M | mxStack++; |
3823 | 1.39M | mxNextCode(1); |
3824 | 1.39M | mxBreak; |
3825 | 1.87M | mxCase(XS_CODE_MORE) |
3826 | 1.87M | slot = mxStack + 1; |
3827 | 1.87M | if (slot->kind == XS_INTEGER_KIND) { |
3828 | 777k | if (mxStack->kind == XS_INTEGER_KIND) |
3829 | 493k | offset = slot->value.integer > mxStack->value.integer; |
3830 | 283k | else if (mxStack->kind == XS_NUMBER_KIND) { |
3831 | 243k | offset = (!c_isnan(mxStack->value.number)) && ((txNumber)(slot->value.integer) > mxStack->value.number); |
3832 | 243k | mxFloatingPointOp("more"); |
3833 | 243k | } |
3834 | 40.2k | else |
3835 | 40.2k | goto XS_CODE_MORE_GENERAL; |
3836 | 777k | } |
3837 | 1.10M | else if (slot->kind == XS_NUMBER_KIND) { |
3838 | 328k | if (mxStack->kind == XS_INTEGER_KIND) { |
3839 | 58.8k | offset = (!c_isnan(slot->value.number)) && (slot->value.number > (txNumber)(mxStack->value.integer)); |
3840 | 58.8k | mxFloatingPointOp("more"); |
3841 | 58.8k | } |
3842 | 269k | else if (mxStack->kind == XS_NUMBER_KIND) { |
3843 | 259k | offset = (!c_isnan(slot->value.number)) && (!c_isnan(mxStack->value.number)) && (slot->value.number > mxStack->value.number); |
3844 | 259k | mxFloatingPointOp("more"); |
3845 | 259k | } |
3846 | 10.1k | else |
3847 | 10.1k | goto XS_CODE_MORE_GENERAL; |
3848 | 328k | } |
3849 | 771k | else { |
3850 | 822k | XS_CODE_MORE_GENERAL: |
3851 | 822k | mxSaveState; |
3852 | 822k | fxToPrimitive(the, slot, XS_NUMBER_HINT); |
3853 | 822k | fxToPrimitive(the, mxStack, XS_NUMBER_HINT); |
3854 | 822k | if (((slot->kind == XS_STRING_KIND) || (slot->kind == XS_STRING_X_KIND)) && ((mxStack->kind == XS_STRING_KIND) || (mxStack->kind == XS_STRING_X_KIND))) |
3855 | 5.51k | offset = fxUTF8Compare(slot->value.string, mxStack->value.string) > 0; |
3856 | 816k | else if ((slot->kind == XS_BIGINT_KIND) || (slot->kind == XS_BIGINT_X_KIND)) |
3857 | 5.64k | offset = gxTypeBigInt.compare(the, 0, 0, 1, slot, mxStack); |
3858 | 810k | else if ((mxStack->kind == XS_BIGINT_KIND) || (mxStack->kind == XS_BIGINT_X_KIND)) |
3859 | 6.44k | offset = gxTypeBigInt.compare(the, 1, 0, 0, mxStack, slot); |
3860 | 804k | else { |
3861 | 804k | fxToNumber(the, slot); |
3862 | 804k | fxToNumber(the, mxStack); |
3863 | 804k | offset = (!c_isnan(slot->value.number)) && (!c_isnan(mxStack->value.number)) && (slot->value.number > mxStack->value.number); |
3864 | 804k | mxFloatingPointOp("more"); |
3865 | 804k | } |
3866 | 822k | mxRestoreState; |
3867 | 822k | } |
3868 | 1.87M | slot->kind = XS_BOOLEAN_KIND; |
3869 | 1.87M | slot->value.boolean = offset; |
3870 | 1.87M | mxStack++; |
3871 | 1.87M | mxNextCode(1); |
3872 | 1.87M | mxBreak; |
3873 | 2.55M | mxCase(XS_CODE_MORE_EQUAL) |
3874 | 2.55M | slot = mxStack + 1; |
3875 | 2.55M | if (slot->kind == XS_INTEGER_KIND) { |
3876 | 928k | if (mxStack->kind == XS_INTEGER_KIND) |
3877 | 446k | offset = slot->value.integer >= mxStack->value.integer; |
3878 | 481k | else if (mxStack->kind == XS_NUMBER_KIND) { |
3879 | 392k | offset = (!c_isnan(mxStack->value.number)) && ((txNumber)(slot->value.integer) >= mxStack->value.number); |
3880 | 392k | mxFloatingPointOp("more or equal"); |
3881 | 392k | } |
3882 | 89.3k | else |
3883 | 89.3k | goto XS_CODE_MORE_EQUAL_GENERAL; |
3884 | 928k | } |
3885 | 1.62M | else if (slot->kind == XS_NUMBER_KIND) { |
3886 | 981k | if (mxStack->kind == XS_INTEGER_KIND) { |
3887 | 396k | offset = (!c_isnan(slot->value.number)) && (slot->value.number >= (txNumber)(mxStack->value.integer)); |
3888 | 396k | mxFloatingPointOp("more or equal"); |
3889 | 396k | } |
3890 | 584k | else if (mxStack->kind == XS_NUMBER_KIND) { |
3891 | 526k | offset = (!c_isnan(slot->value.number)) && (!c_isnan(mxStack->value.number)) && (slot->value.number >= mxStack->value.number); |
3892 | 526k | mxFloatingPointOp("more or equal"); |
3893 | 526k | } |
3894 | 57.3k | else |
3895 | 57.3k | goto XS_CODE_MORE_EQUAL_GENERAL; |
3896 | 981k | } |
3897 | 647k | else { |
3898 | 794k | XS_CODE_MORE_EQUAL_GENERAL: |
3899 | 794k | mxSaveState; |
3900 | 794k | fxToPrimitive(the, slot, XS_NUMBER_HINT); |
3901 | 794k | fxToPrimitive(the, mxStack, XS_NUMBER_HINT); |
3902 | 794k | if (((slot->kind == XS_STRING_KIND) || (slot->kind == XS_STRING_X_KIND)) && ((mxStack->kind == XS_STRING_KIND) || (mxStack->kind == XS_STRING_X_KIND))) |
3903 | 56.4k | offset = fxUTF8Compare(slot->value.string, mxStack->value.string) >= 0; |
3904 | 738k | else if ((slot->kind == XS_BIGINT_KIND) || (slot->kind == XS_BIGINT_X_KIND)) |
3905 | 22.5k | offset = gxTypeBigInt.compare(the, 0, 1, 1, slot, mxStack); |
3906 | 715k | else if ((mxStack->kind == XS_BIGINT_KIND) || (mxStack->kind == XS_BIGINT_X_KIND)) |
3907 | 1.76k | offset = gxTypeBigInt.compare(the, 1, 1, 0, mxStack, slot); |
3908 | 713k | else { |
3909 | 713k | fxToNumber(the, slot); |
3910 | 713k | fxToNumber(the, mxStack); |
3911 | 713k | offset = (!c_isnan(slot->value.number)) && (!c_isnan(mxStack->value.number)) && (slot->value.number >= mxStack->value.number); |
3912 | 713k | mxFloatingPointOp("more or equal"); |
3913 | 713k | } |
3914 | 794k | mxRestoreState; |
3915 | 794k | } |
3916 | 2.55M | slot->kind = XS_BOOLEAN_KIND; |
3917 | 2.55M | slot->value.boolean = offset; |
3918 | 2.55M | mxStack++; |
3919 | 2.55M | mxNextCode(1); |
3920 | 2.55M | mxBreak; |
3921 | | |
3922 | 2.55M | mxCase(XS_CODE_EQUAL) |
3923 | 2.14M | mxCase(XS_CODE_STRICT_EQUAL) |
3924 | 2.14M | slot = mxStack + 1; |
3925 | 2.79M | XS_CODE_EQUAL_AGAIN: |
3926 | 2.79M | if (slot->kind == mxStack->kind) { |
3927 | 687k | if ((XS_UNDEFINED_KIND == slot->kind) || (XS_NULL_KIND == slot->kind)) |
3928 | 54.7k | offset = 1; |
3929 | 632k | else if (XS_BOOLEAN_KIND == slot->kind) |
3930 | 15.5k | offset = slot->value.boolean == stack->value.boolean; |
3931 | 617k | else if (XS_INTEGER_KIND == slot->kind) |
3932 | 361k | offset = slot->value.integer == stack->value.integer; |
3933 | 255k | else if (XS_NUMBER_KIND == slot->kind) { |
3934 | 135k | offset = (!c_isnan(slot->value.number)) && (!c_isnan(mxStack->value.number)) && (slot->value.number == mxStack->value.number); |
3935 | 135k | mxFloatingPointOp("equal"); |
3936 | 135k | } |
3937 | 119k | else if ((XS_STRING_KIND == slot->kind) || (XS_STRING_X_KIND == slot->kind)) |
3938 | 53.3k | offset = c_strcmp(slot->value.string, mxStack->value.string) == 0; |
3939 | 66.3k | else if (XS_SYMBOL_KIND == slot->kind) |
3940 | 56.1k | offset = slot->value.symbol == mxStack->value.symbol; |
3941 | 10.2k | else if (XS_REFERENCE_KIND == slot->kind) |
3942 | 10.1k | offset = fxIsSameReference(the, slot, mxStack); |
3943 | | #if mxHostFunctionPrimitive |
3944 | | else if (XS_HOST_FUNCTION_KIND == slot->kind) |
3945 | | offset = slot->value.hostFunction.builder == mxStack->value.hostFunction.builder; |
3946 | | #endif |
3947 | 99 | else if ((XS_BIGINT_KIND == slot->kind) || (XS_BIGINT_X_KIND == slot->kind)) |
3948 | 99 | offset = gxTypeBigInt.compare(the, 0, 1, 0, slot, mxStack); |
3949 | 0 | else |
3950 | 0 | offset = 0; |
3951 | 687k | } |
3952 | 2.10M | else if ((XS_INTEGER_KIND == slot->kind) && (XS_NUMBER_KIND == mxStack->kind)) { |
3953 | 74.0k | offset = (!c_isnan(mxStack->value.number)) && ((txNumber)(slot->value.integer) == stack->value.number); |
3954 | 74.0k | mxFloatingPointOp("equal"); |
3955 | 74.0k | } |
3956 | 2.03M | else if ((XS_NUMBER_KIND == slot->kind) && (XS_INTEGER_KIND == mxStack->kind)) { |
3957 | 43.8k | offset = (!c_isnan(slot->value.number)) && (slot->value.number == (txNumber)(mxStack->value.integer)); |
3958 | 43.8k | mxFloatingPointOp("equal"); |
3959 | 43.8k | } |
3960 | 1.98M | else if ((XS_STRING_KIND == slot->kind) && (XS_STRING_X_KIND == mxStack->kind)) |
3961 | 0 | offset = c_strcmp(slot->value.string, mxStack->value.string) == 0; |
3962 | 1.98M | else if ((XS_STRING_X_KIND == slot->kind) && (XS_STRING_KIND == mxStack->kind)) |
3963 | 0 | offset = c_strcmp(slot->value.string, mxStack->value.string) == 0; |
3964 | 1.98M | else if (XS_CODE_EQUAL == byte) { |
3965 | 1.41M | if ((slot->kind == XS_UNDEFINED_KIND) && (mxStack->kind == XS_NULL_KIND)) |
3966 | 51.1k | offset = 1; |
3967 | 1.36M | else if ((slot->kind == XS_NULL_KIND) && (mxStack->kind == XS_UNDEFINED_KIND)) |
3968 | 8 | offset = 1; |
3969 | 1.36M | else if (((XS_INTEGER_KIND == slot->kind) || (XS_NUMBER_KIND == slot->kind)) && ((mxStack->kind == XS_STRING_KIND) || (mxStack->kind == XS_STRING_X_KIND))) { |
3970 | 189k | mxToNumber(mxStack); |
3971 | 189k | goto XS_CODE_EQUAL_AGAIN; |
3972 | 189k | } |
3973 | 1.17M | else if (((slot->kind == XS_STRING_KIND) || (slot->kind == XS_STRING_X_KIND)) && ((XS_INTEGER_KIND == mxStack->kind) || (XS_NUMBER_KIND == mxStack->kind))) { |
3974 | 43.1k | mxToNumber(slot); |
3975 | 43.1k | goto XS_CODE_EQUAL_AGAIN; |
3976 | 43.1k | } |
3977 | 1.13M | else if (XS_BOOLEAN_KIND == slot->kind) { |
3978 | 180k | mxToNumber(slot); |
3979 | 180k | goto XS_CODE_EQUAL_AGAIN; |
3980 | 180k | } |
3981 | 954k | else if (XS_BOOLEAN_KIND == mxStack->kind) { |
3982 | 1.82k | mxToNumber(mxStack); |
3983 | 1.82k | goto XS_CODE_EQUAL_AGAIN; |
3984 | 1.82k | } |
3985 | 952k | else if (((slot->kind == XS_INTEGER_KIND) || (slot->kind == XS_NUMBER_KIND) || (slot->kind == XS_STRING_KIND) || (slot->kind == XS_STRING_X_KIND) || (slot->kind == XS_SYMBOL_KIND) || (slot->kind == XS_BIGINT_KIND) || (slot->kind == XS_BIGINT_X_KIND)) && mxIsReference(mxStack)) { |
3986 | 188k | mxSaveState; |
3987 | 188k | fxToPrimitive(the, mxStack, XS_NO_HINT); |
3988 | 188k | mxRestoreState; |
3989 | 188k | goto XS_CODE_EQUAL_AGAIN; |
3990 | 188k | } |
3991 | 764k | else if (mxIsReference(slot) && ((mxStack->kind == XS_INTEGER_KIND) || (mxStack->kind == XS_NUMBER_KIND) || (mxStack->kind == XS_STRING_KIND) || (mxStack->kind == XS_STRING_X_KIND) || (mxStack->kind == XS_SYMBOL_KIND) || (mxStack->kind == XS_BIGINT_KIND) || (mxStack->kind == XS_BIGINT_X_KIND))) { |
3992 | 45.8k | mxSaveState; |
3993 | 45.8k | fxToPrimitive(the, slot, XS_NO_HINT); |
3994 | 45.8k | mxRestoreState; |
3995 | 45.8k | goto XS_CODE_EQUAL_AGAIN; |
3996 | 45.8k | } |
3997 | 718k | else if (((XS_BIGINT_KIND == slot->kind) || (XS_BIGINT_X_KIND == slot->kind)) && ((mxStack->kind == XS_INTEGER_KIND) || (mxStack->kind == XS_NUMBER_KIND) || (mxStack->kind == XS_STRING_KIND) || (mxStack->kind == XS_STRING_X_KIND))) { |
3998 | 83.4k | mxSaveState; |
3999 | 83.4k | offset = gxTypeBigInt.compare(the, 0, 1, 0, slot, mxStack); |
4000 | 83.4k | mxRestoreState; |
4001 | 83.4k | } |
4002 | 635k | else if (((slot->kind == XS_INTEGER_KIND) || (slot->kind == XS_NUMBER_KIND) || (slot->kind == XS_STRING_KIND) || (slot->kind == XS_STRING_X_KIND)) && ((XS_BIGINT_KIND == mxStack->kind) || (XS_BIGINT_X_KIND == mxStack->kind))) { |
4003 | 112 | mxSaveState; |
4004 | 112 | offset = gxTypeBigInt.compare(the, 0, 1, 0, mxStack, slot); |
4005 | 112 | mxRestoreState; |
4006 | 112 | } |
4007 | 635k | else |
4008 | 635k | offset = 0; |
4009 | 1.41M | } |
4010 | 570k | else |
4011 | 570k | offset = 0; |
4012 | 2.14M | slot->kind = XS_BOOLEAN_KIND; |
4013 | 2.14M | slot->value.boolean = offset; |
4014 | 2.14M | mxStack++; |
4015 | 2.14M | mxNextCode(1); |
4016 | 2.14M | mxBreak; |
4017 | 3.74M | mxCase(XS_CODE_NOT_EQUAL) |
4018 | 4.83M | mxCase(XS_CODE_STRICT_NOT_EQUAL) |
4019 | 4.83M | slot = mxStack + 1; |
4020 | 6.37M | XS_CODE_NOT_EQUAL_AGAIN: |
4021 | 6.37M | if (slot->kind == mxStack->kind) { |
4022 | 1.85M | if ((XS_UNDEFINED_KIND == slot->kind) || (XS_NULL_KIND == slot->kind)) |
4023 | 60.2k | offset = 0; |
4024 | 1.79M | else if (XS_BOOLEAN_KIND == slot->kind) |
4025 | 624k | offset = slot->value.boolean != stack->value.boolean; |
4026 | 1.16M | else if (XS_INTEGER_KIND == slot->kind) |
4027 | 489k | offset = slot->value.integer != stack->value.integer; |
4028 | 676k | else if (XS_NUMBER_KIND == slot->kind) { |
4029 | 252k | offset = (c_isnan(slot->value.number)) || (c_isnan(mxStack->value.number)) || (slot->value.number != mxStack->value.number); |
4030 | 252k | mxFloatingPointOp("not equal"); |
4031 | 252k | } |
4032 | 424k | else if ((XS_STRING_KIND == slot->kind) || (XS_STRING_X_KIND == slot->kind)) |
4033 | 356k | offset = c_strcmp(slot->value.string, mxStack->value.string) != 0; |
4034 | 67.8k | else if (XS_SYMBOL_KIND == slot->kind) |
4035 | 33.6k | offset = slot->value.symbol != mxStack->value.symbol; |
4036 | 34.2k | else if (XS_REFERENCE_KIND == slot->kind) |
4037 | 34.2k | offset = !fxIsSameReference(the, slot, mxStack); |
4038 | | #if mxHostFunctionPrimitive |
4039 | | else if (XS_HOST_FUNCTION_KIND == slot->kind) |
4040 | | offset = slot->value.hostFunction.builder != mxStack->value.hostFunction.builder; |
4041 | | #endif |
4042 | 9 | else if ((XS_BIGINT_KIND == slot->kind) || (XS_BIGINT_X_KIND == slot->kind)) |
4043 | 9 | offset = gxTypeBigInt.compare(the, 1, 0, 1, slot, mxStack); |
4044 | 0 | else |
4045 | 0 | offset = 1; |
4046 | 1.85M | } |
4047 | 4.52M | else if ((XS_INTEGER_KIND == slot->kind) && (XS_NUMBER_KIND == mxStack->kind)) { |
4048 | 390k | offset = (c_isnan(mxStack->value.number)) || ((txNumber)(slot->value.integer) != stack->value.number); |
4049 | 390k | mxFloatingPointOp("not equal"); |
4050 | 390k | } |
4051 | 4.13M | else if ((XS_NUMBER_KIND == slot->kind) && (XS_INTEGER_KIND == mxStack->kind)) { |
4052 | 461k | offset = (c_isnan(slot->value.number)) || (slot->value.number != (txNumber)(mxStack->value.integer)); |
4053 | 461k | mxFloatingPointOp("not equal"); |
4054 | 461k | } |
4055 | 3.67M | else if ((XS_STRING_KIND == slot->kind) && (XS_STRING_X_KIND == mxStack->kind)) |
4056 | 0 | offset = c_strcmp(slot->value.string, mxStack->value.string) != 0; |
4057 | 3.67M | else if ((XS_STRING_X_KIND == slot->kind) && (XS_STRING_KIND == mxStack->kind)) |
4058 | 0 | offset = c_strcmp(slot->value.string, mxStack->value.string) != 0; |
4059 | 3.67M | else if (XS_CODE_NOT_EQUAL == byte) { |
4060 | 3.64M | if ((slot->kind == XS_UNDEFINED_KIND) && (mxStack->kind == XS_NULL_KIND)) |
4061 | 116k | offset = 0; |
4062 | 3.52M | else if ((slot->kind == XS_NULL_KIND) && (mxStack->kind == XS_UNDEFINED_KIND)) |
4063 | 1.84k | offset = 0; |
4064 | 3.52M | else if (((slot->kind == XS_STRING_KIND) || (slot->kind == XS_STRING_X_KIND)) && ((XS_INTEGER_KIND == mxStack->kind) || (XS_NUMBER_KIND == mxStack->kind))) { |
4065 | 5.94k | mxToNumber(slot); |
4066 | 5.94k | goto XS_CODE_NOT_EQUAL_AGAIN; |
4067 | 5.94k | } |
4068 | 3.51M | else if (((mxStack->kind == XS_STRING_KIND) || (mxStack->kind == XS_STRING_X_KIND)) && ((XS_INTEGER_KIND == slot->kind) || (XS_NUMBER_KIND == slot->kind))) { |
4069 | 158k | mxToNumber(mxStack); |
4070 | 158k | goto XS_CODE_NOT_EQUAL_AGAIN; |
4071 | 158k | } |
4072 | 3.36M | else if (XS_BOOLEAN_KIND == slot->kind) { |
4073 | 508k | mxToNumber(slot); |
4074 | 508k | goto XS_CODE_NOT_EQUAL_AGAIN; |
4075 | 508k | } |
4076 | 2.85M | else if (XS_BOOLEAN_KIND == mxStack->kind) { |
4077 | 693k | mxToNumber(mxStack); |
4078 | 693k | goto XS_CODE_NOT_EQUAL_AGAIN; |
4079 | 693k | } |
4080 | 2.15M | else if (((slot->kind == XS_INTEGER_KIND) || (slot->kind == XS_NUMBER_KIND) || (slot->kind == XS_STRING_KIND) || (slot->kind == XS_STRING_X_KIND) || (slot->kind == XS_SYMBOL_KIND) || (slot->kind == XS_BIGINT_KIND) || (slot->kind == XS_BIGINT_X_KIND)) && mxIsReference(mxStack)) { |
4081 | 159k | mxSaveState; |
4082 | 159k | fxToPrimitive(the, mxStack, XS_NO_HINT); |
4083 | 159k | mxRestoreState; |
4084 | 159k | goto XS_CODE_NOT_EQUAL_AGAIN; |
4085 | 159k | } |
4086 | 1.99M | else if (mxIsReference(slot) && ((mxStack->kind == XS_INTEGER_KIND) || (mxStack->kind == XS_NUMBER_KIND) || (mxStack->kind == XS_STRING_KIND) || (mxStack->kind == XS_STRING_X_KIND) || (mxStack->kind == XS_SYMBOL_KIND) || (mxStack->kind == XS_BIGINT_KIND) || (mxStack->kind == XS_BIGINT_X_KIND))) { |
4087 | 11.9k | mxSaveState; |
4088 | 11.9k | fxToPrimitive(the, slot, XS_NO_HINT); |
4089 | 11.9k | mxRestoreState; |
4090 | 11.9k | goto XS_CODE_NOT_EQUAL_AGAIN; |
4091 | 11.9k | } |
4092 | 1.98M | else if (((XS_BIGINT_KIND == slot->kind) || (XS_BIGINT_X_KIND == slot->kind)) && ((mxStack->kind == XS_INTEGER_KIND) || (mxStack->kind == XS_NUMBER_KIND) || (mxStack->kind == XS_STRING_KIND) || (mxStack->kind == XS_STRING_X_KIND))) { |
4093 | 950k | mxSaveState; |
4094 | 950k | offset = gxTypeBigInt.compare(the, 1, 0, 1, slot, mxStack); |
4095 | 950k | mxRestoreState; |
4096 | 950k | } |
4097 | 1.03M | else if (((slot->kind == XS_INTEGER_KIND) || (slot->kind == XS_NUMBER_KIND) || (slot->kind == XS_STRING_KIND) || (slot->kind == XS_STRING_X_KIND)) && ((XS_BIGINT_KIND == mxStack->kind) || (XS_BIGINT_X_KIND == mxStack->kind))) { |
4098 | 134k | mxSaveState; |
4099 | 134k | offset = gxTypeBigInt.compare(the, 1, 0, 1, mxStack, slot); |
4100 | 134k | mxRestoreState; |
4101 | 134k | } |
4102 | 901k | else |
4103 | 901k | offset = 1; |
4104 | 3.64M | } |
4105 | 30.9k | else |
4106 | 30.9k | offset = 1; |
4107 | 4.83M | slot->kind = XS_BOOLEAN_KIND; |
4108 | 4.83M | slot->value.boolean = offset; |
4109 | 4.83M | mxStack++; |
4110 | 4.83M | mxNextCode(1); |
4111 | 4.83M | mxBreak; |
4112 | | |
4113 | 4.83M | mxCase(XS_CODE_FOR_AWAIT_OF) |
4114 | 12 | mxNextCode(1); |
4115 | 12 | mxSaveState; |
4116 | 12 | gxDefaults.runForAwaitOf(the); |
4117 | 12 | mxRestoreState; |
4118 | 12 | mxBreak; |
4119 | 164k | mxCase(XS_CODE_FOR_IN) |
4120 | 164k | mxSkipCode(1); |
4121 | | /* FUNCTION */ |
4122 | 164k | mxAllocStack(1); |
4123 | 164k | *mxStack = mxEnumeratorFunction; |
4124 | 164k | slot = fxGetInstance(the, mxStack); |
4125 | | /* TARGET */ |
4126 | 164k | mxPushKind(XS_UNDEFINED_KIND); |
4127 | | /* RESULT */ |
4128 | 164k | mxPushKind(XS_UNDEFINED_KIND); |
4129 | 164k | mxPushKind(XS_UNDEFINED_KIND); |
4130 | 164k | mxPushKind(XS_UNDEFINED_KIND); |
4131 | 164k | offset = 0; |
4132 | 164k | goto XS_CODE_RUN_ALL; |
4133 | | |
4134 | 62.2k | mxCase(XS_CODE_FOR_OF) |
4135 | 62.2k | mxNextCode(1); |
4136 | 62.2k | mxSaveState; |
4137 | 62.2k | fxRunForOf(the); |
4138 | 62.2k | mxRestoreState; |
4139 | 62.2k | mxBreak; |
4140 | | |
4141 | 330k | mxCase(XS_CODE_IN) |
4142 | 330k | mxNextCode(1); |
4143 | 330k | if (!mxIsReference(mxStack)) |
4144 | 329k | mxRunDebug(XS_TYPE_ERROR, "in: not an object"); |
4145 | 329k | mxSaveState; |
4146 | 329k | fxRunIn(the); |
4147 | 329k | mxRestoreState; |
4148 | 329k | mxBreak; |
4149 | 329k | mxCase(XS_CODE_INSTANCEOF) |
4150 | 309k | mxNextCode(1); |
4151 | 309k | mxSaveState; |
4152 | 309k | fxRunInstanceOf(the); |
4153 | 309k | mxRestoreState; |
4154 | 309k | mxBreak; |
4155 | 1.72M | mxCase(XS_CODE_TYPEOF) |
4156 | 1.72M | byte = mxStack->kind; |
4157 | 1.72M | if (XS_UNDEFINED_KIND == byte) |
4158 | 304k | *mxStack = mxUndefinedString; |
4159 | 1.42M | else if (XS_NULL_KIND == byte) |
4160 | 1.68k | *mxStack = mxObjectString; |
4161 | 1.42M | else if (XS_BOOLEAN_KIND == byte) |
4162 | 1.15M | *mxStack = mxBooleanString; |
4163 | 268k | else if ((XS_INTEGER_KIND == byte) || (XS_NUMBER_KIND == byte)) |
4164 | 264k | *mxStack = mxNumberString; |
4165 | 3.43k | else if ((XS_STRING_KIND == byte) || (XS_STRING_X_KIND == byte)) |
4166 | 1.32k | *mxStack = mxStringString; |
4167 | 2.11k | else if (XS_SYMBOL_KIND == byte) |
4168 | 554 | *mxStack = mxSymbolString; |
4169 | 1.55k | else if ((XS_BIGINT_KIND == byte) || (XS_BIGINT_X_KIND == byte)) |
4170 | 17 | *mxStack = mxBigIntString; |
4171 | 1.54k | else if (XS_REFERENCE_KIND == byte) { |
4172 | 1.54k | slot = fxGetInstance(the, mxStack); |
4173 | 1.54k | if (slot->flag & XS_CAN_CALL_FLAG) |
4174 | 1.21k | *mxStack = mxFunctionString; |
4175 | 325 | else |
4176 | 325 | *mxStack = mxObjectString; |
4177 | 1.54k | } |
4178 | | #if mxHostFunctionPrimitive |
4179 | | else if (XS_HOST_FUNCTION_KIND == byte) |
4180 | | *mxStack = mxFunctionString; |
4181 | | #endif |
4182 | 1.72M | mxNextCode(1); |
4183 | 1.72M | mxBreak; |
4184 | 1.72M | mxCase(XS_CODE_VOID) |
4185 | 340k | mxNextCode(1); |
4186 | 340k | mxStack->kind = XS_UNDEFINED_KIND; |
4187 | 340k | mxBreak; |
4188 | | |
4189 | | /* DEBUG */ |
4190 | 340k | mxCase(XS_CODE_DEBUGGER) |
4191 | 4.63k | mxNextCode(1); |
4192 | 4.63k | #ifdef mxDebug |
4193 | 4.63k | if (!the->debugEval) { |
4194 | 4.63k | mxSaveState; |
4195 | 4.63k | fxDebugLoop(the, C_NULL, 0, "debugger"); |
4196 | 4.63k | mxRestoreState; |
4197 | 4.63k | } |
4198 | 4.63k | #endif |
4199 | 4.63k | mxBreak; |
4200 | 7.99M | mxCase(XS_CODE_FILE) |
4201 | 7.99M | #ifdef mxDebug |
4202 | 7.99M | count = mxRunID(1); |
4203 | | #ifdef mxTrace |
4204 | | if (gxDoTrace) fxTraceID(the, count, 0); |
4205 | | #endif |
4206 | 7.99M | mxEnvironment->ID = count; |
4207 | 7.99M | mxEnvironment->value.environment.line = 0; |
4208 | 7.99M | #endif |
4209 | 7.99M | mxNextCode(1 + sizeof(txID)); |
4210 | 7.99M | mxBreak; |
4211 | 101M | mxCase(XS_CODE_LINE) |
4212 | 101M | #ifdef mxDebug |
4213 | 101M | count = mxRunS2(1); |
4214 | | #ifdef mxTrace |
4215 | | if (gxDoTrace) fxTraceInteger(the, count); |
4216 | | #endif |
4217 | 101M | if (count == 0) { |
4218 | 8.47M | count = mxFunctionInstanceCode(mxFrameFunction->value.reference)->ID; |
4219 | 8.47M | if ((mxEnvironment->ID != XS_NO_ID) && (count != XS_NO_ID) && mxBreakpoints.value.list.first) { |
4220 | 0 | mxSaveState; |
4221 | 0 | fxDebugLine(the, mxEnvironment->ID, mxEnvironment->value.environment.line, count); |
4222 | 0 | mxRestoreState; |
4223 | 0 | } |
4224 | 8.47M | } |
4225 | 93.0M | else { |
4226 | 93.0M | mxEnvironment->value.environment.line = count; |
4227 | 93.0M | if (fxIsReadable(the)) { |
4228 | 0 | mxSaveState; |
4229 | 0 | fxDebugCommand(the); |
4230 | 0 | mxRestoreState; |
4231 | 0 | } |
4232 | 93.0M | if ((mxEnvironment->ID != XS_NO_ID) && ((mxFrame->flag & XS_STEP_OVER_FLAG) || mxBreakpoints.value.list.first)) { |
4233 | 0 | mxSaveState; |
4234 | 0 | fxDebugLine(the, mxEnvironment->ID, mxEnvironment->value.environment.line, XS_NO_ID); |
4235 | 0 | mxRestoreState; |
4236 | 0 | } |
4237 | 93.0M | } |
4238 | 101M | #endif |
4239 | 101M | #if defined(mxInstrument) || defined(mxProfile) |
4240 | 101M | fxCheckProfiler(the, mxFrame); |
4241 | 101M | #endif |
4242 | 101M | mxNextCode(3); |
4243 | 101M | mxBreak; |
4244 | | |
4245 | | /* MODULE */ |
4246 | 101M | mxCase(XS_CODE_IMPORT) |
4247 | 25.7k | slot = mxFunctionInstanceHome(mxFrameFunction->value.reference)->value.home.module; |
4248 | 25.7k | variable = mxModuleInstanceInternal(slot); |
4249 | 25.7k | variable = variable->value.module.realm; |
4250 | 25.7k | if (!variable) variable = mxModuleInstanceInternal(mxProgram.value.reference)->value.module.realm; |
4251 | 25.7k | mxSaveState; |
4252 | 25.7k | gxDefaults.runImport(the, variable, slot); |
4253 | 25.7k | mxRestoreState; |
4254 | 25.7k | mxNextCode(1); |
4255 | 25.7k | mxBreak; |
4256 | 25.7k | mxCase(XS_CODE_IMPORT_META) |
4257 | 50 | slot = mxFunctionInstanceHome(mxFrameFunction->value.reference)->value.home.module; |
4258 | 50 | mxSaveState; |
4259 | 50 | fxRunImportMeta(the, slot); |
4260 | 50 | mxRestoreState; |
4261 | 50 | mxNextCode(1); |
4262 | 50 | mxBreak; |
4263 | 534 | mxCase(XS_CODE_TRANSFER) |
4264 | 534 | mxSaveState; |
4265 | 534 | fxPrepareTransfer(the, XS_NO_FLAG); |
4266 | 534 | mxRestoreState; |
4267 | 534 | mxNextCode(1); |
4268 | 534 | mxBreak; |
4269 | 534 | mxCase(XS_CODE_TRANSFER_JSON) |
4270 | 0 | mxSaveState; |
4271 | 0 | fxPrepareTransfer(the, XS_JSON_MODULE_FLAG); |
4272 | 0 | mxRestoreState; |
4273 | 0 | mxNextCode(1); |
4274 | 0 | mxBreak; |
4275 | 2.48k | mxCase(XS_CODE_MODULE) |
4276 | 2.48k | byte = mxRunU1(1); |
4277 | 2.48k | mxSaveState; |
4278 | 2.48k | fxPrepareModule(the, byte); |
4279 | 2.48k | mxRestoreState; |
4280 | 2.48k | mxNextCode(2); |
4281 | 2.48k | mxBreak; |
4282 | | |
4283 | | /* EVAL, PROGRAM & WITH */ |
4284 | 395k | mxCase(XS_CODE_EVAL) |
4285 | 395k | offset = mxStack->value.integer; |
4286 | 395k | slot = mxStack + 1 + offset + 4; |
4287 | 395k | if (mxIsReference(slot) && mxIsFunction(slot->value.reference) && (mxFunctionInstanceCode(slot->value.reference)->value.callback.address == mxFunctionInstanceCode(mxEvalFunction.value.reference)->value.callback.address)) { |
4288 | 395k | mxSaveState; |
4289 | 395k | gxDefaults.runEval(the); |
4290 | 395k | mxRestoreState; |
4291 | 395k | mxNextCode(1); |
4292 | 395k | mxBreak; |
4293 | 395k | } |
4294 | 395k | mxSkipCode(1); |
4295 | 395k | mxStack++; |
4296 | 395k | goto XS_CODE_RUN_ALL; |
4297 | 2 | mxCase(XS_CODE_EVAL_TAIL) |
4298 | 2 | offset = mxStack->value.integer; |
4299 | 2 | slot = mxStack + 1 + offset + 4; |
4300 | 2 | if (mxIsReference(slot) && mxIsFunction(slot->value.reference) && (mxFunctionInstanceCode(slot->value.reference)->value.callback.address == mxFunctionInstanceCode(mxEvalFunction.value.reference)->value.callback.address)) { |
4301 | 2 | mxSaveState; |
4302 | 2 | gxDefaults.runEval(the); |
4303 | 2 | mxRestoreState; |
4304 | 2 | mxNextCode(1); |
4305 | 2 | mxBreak; |
4306 | 2 | } |
4307 | 2 | mxSkipCode(1); |
4308 | 2 | mxStack++; |
4309 | 2 | goto XS_CODE_RUN_TAIL_ALL; |
4310 | 96.7k | mxCase(XS_CODE_EVAL_ENVIRONMENT) |
4311 | 96.7k | mxNextCode(1); |
4312 | 96.7k | mxSaveState; |
4313 | 96.7k | gxDefaults.runEvalEnvironment(the); |
4314 | 96.7k | mxRestoreState; |
4315 | 96.7k | mxBreak; |
4316 | 96.7k | mxCase(XS_CODE_EVAL_PRIVATE) |
4317 | 0 | offset = mxRunID(1); |
4318 | | #ifdef mxTrace |
4319 | | if (gxDoTrace) fxTraceID(the, (txID)offset, 0); |
4320 | | #endif |
4321 | 0 | mxNextCode(1 + sizeof(txID)); |
4322 | 0 | variable = mxEnvironment; |
4323 | 0 | if (variable->kind == XS_REFERENCE_KIND) { |
4324 | 0 | variable = variable->value.reference; |
4325 | 0 | XS_CODE_EVAL_PRIVATE_AGAIN: |
4326 | 0 | if (variable) { |
4327 | 0 | slot = mxBehaviorGetProperty(the, variable, (txID)offset, 0, XS_OWN); |
4328 | 0 | if (slot) { |
4329 | 0 | mxPushKind(slot->kind); |
4330 | 0 | mxStack->value = slot->value; |
4331 | 0 | mxBreak; |
4332 | 0 | } |
4333 | 0 | variable = variable->value.instance.prototype; |
4334 | 0 | goto XS_CODE_EVAL_PRIVATE_AGAIN; |
4335 | 0 | } |
4336 | 0 | } |
4337 | 0 | mxRunDebugID(XS_SYNTAX_ERROR, "eval %s: undefined private property", (txID)offset); |
4338 | 0 | mxBreak; |
4339 | 2.65M | mxCase(XS_CODE_EVAL_REFERENCE) |
4340 | 2.65M | offset = mxRunID(1); |
4341 | | #ifdef mxTrace |
4342 | | if (gxDoTrace) fxTraceID(the, (txID)offset, 0); |
4343 | | #endif |
4344 | 2.65M | mxNextCode(1 + sizeof(txID)); |
4345 | 2.65M | variable = mxEnvironment; |
4346 | 2.65M | if (variable->kind == XS_REFERENCE_KIND) { |
4347 | 2.65M | variable = variable->value.reference; |
4348 | 10.0M | XS_CODE_EVAL_REFERENCE_AGAIN: |
4349 | 10.0M | if (variable->value.instance.prototype) { |
4350 | 7.93M | slot = variable->next; |
4351 | 7.93M | if (slot->kind == XS_REFERENCE_KIND) { |
4352 | 1.76M | slot = slot->value.reference; |
4353 | 1.76M | mxSaveState; |
4354 | 1.76M | index = fxIsScopableSlot(the, slot, (txID)offset); |
4355 | 1.76M | mxRestoreState; |
4356 | 1.76M | if (index) { |
4357 | | // if (fxRunHas(the, slot, (txID)offset, 0)) { |
4358 | 248k | if (XS_CODE_GET_THIS_VARIABLE == byte) { |
4359 | 48.2k | mxStack->kind = XS_REFERENCE_KIND; |
4360 | 48.2k | mxStack->value.reference = slot; |
4361 | 48.2k | } |
4362 | 248k | mxPushKind(XS_REFERENCE_KIND); |
4363 | 248k | mxStack->value.reference = slot; |
4364 | 248k | mxBreak; |
4365 | | // } |
4366 | 248k | } |
4367 | 1.76M | } |
4368 | 6.16M | else if (mxBehaviorHasProperty(the, variable, (txID)offset, 0)) { |
4369 | 324k | mxPushKind(XS_REFERENCE_KIND); |
4370 | 324k | mxStack->value.reference = variable; |
4371 | 324k | mxBreak; |
4372 | 324k | } |
4373 | 7.93M | variable = variable->value.instance.prototype; |
4374 | 7.93M | goto XS_CODE_EVAL_REFERENCE_AGAIN; |
4375 | 7.93M | } |
4376 | 2.08M | if (mxBehaviorHasProperty(the, variable, (txID)offset, 0)) { |
4377 | 41.1k | mxPushKind(XS_REFERENCE_KIND); |
4378 | 41.1k | mxStack->value.reference = variable; |
4379 | 41.1k | mxBreak; |
4380 | 41.1k | } |
4381 | 2.08M | } |
4382 | 4.16M | mxPushKind(XS_REFERENCE_KIND); |
4383 | 4.16M | variable = mxFunctionInstanceHome(mxFrameFunction->value.reference)->value.home.module; |
4384 | 4.16M | variable = mxModuleInstanceInternal(variable)->value.module.realm; |
4385 | 4.16M | if (!variable) variable = mxModuleInstanceInternal(mxProgram.value.reference)->value.module.realm; |
4386 | 4.16M | mxStack->value.reference = mxRealmGlobal(variable)->value.reference; |
4387 | 4.16M | mxBreak; |
4388 | 4.16M | mxCase(XS_CODE_FUNCTION_ENVIRONMENT) |
4389 | 394k | variable = mxEnvironment; |
4390 | 394k | mxPushKind(XS_UNDEFINED_KIND); |
4391 | 394k | mxSaveState; |
4392 | 394k | slot = fxNewEnvironmentInstance(the, variable); |
4393 | 394k | mxRestoreState; |
4394 | 394k | variable = mxFunctionInstanceCode((mxStack + 1)->value.reference); |
4395 | 394k | variable->value.code.closures = slot; |
4396 | 394k | mxNextCode(1); |
4397 | 394k | mxBreak; |
4398 | 394k | mxCase(XS_CODE_PROGRAM_ENVIRONMENT) |
4399 | 13.5k | mxNextCode(1); |
4400 | 13.5k | mxSaveState; |
4401 | 13.5k | gxDefaults.runProgramEnvironment(the); |
4402 | 13.5k | mxRestoreState; |
4403 | 13.5k | mxBreak; |
4404 | 123M | mxCase(XS_CODE_PROGRAM_REFERENCE) |
4405 | 123M | offset = mxRunID(1); |
4406 | | #ifdef mxTrace |
4407 | | if (gxDoTrace) fxTraceID(the, (txID)offset, 0); |
4408 | | #endif |
4409 | 123M | mxNextCode(1 + sizeof(txID)); |
4410 | 123M | variable = mxFunctionInstanceHome(mxFrameFunction->value.reference)->value.home.module; |
4411 | 123M | variable = mxModuleInstanceInternal(variable)->value.module.realm; |
4412 | 123M | if (!variable) variable = mxModuleInstanceInternal(mxProgram.value.reference)->value.module.realm; |
4413 | 123M | slot = mxRealmClosures(variable)->value.reference; |
4414 | 123M | if (mxBehaviorHasProperty(the, slot, (txID)offset, 0)) { |
4415 | 44 | mxPushKind(XS_REFERENCE_KIND); |
4416 | 44 | mxStack->value.reference = slot; |
4417 | 44 | mxBreak; |
4418 | 44 | } |
4419 | 246M | mxPushKind(XS_REFERENCE_KIND); |
4420 | 246M | mxStack->value.reference = mxRealmGlobal(variable)->value.reference; |
4421 | 246M | mxBreak; |
4422 | 246M | mxCase(XS_CODE_WITH) |
4423 | 1.64M | variable = mxEnvironment; |
4424 | 1.64M | mxSaveState; |
4425 | 1.64M | slot = fxNewEnvironmentInstance(the, variable); |
4426 | 1.64M | mxRestoreState; |
4427 | 1.64M | variable->kind = XS_REFERENCE_KIND; |
4428 | 1.64M | variable->value.reference = slot; |
4429 | 1.64M | mxNextCode(1); |
4430 | 1.64M | mxBreak; |
4431 | 1.64M | mxCase(XS_CODE_WITHOUT) |
4432 | 127k | variable = mxEnvironment; |
4433 | 127k | slot = variable->value.reference->value.instance.prototype; |
4434 | 127k | if (slot) { |
4435 | 127k | variable->kind = XS_REFERENCE_KIND; |
4436 | 127k | variable->value.reference = slot; |
4437 | 127k | } |
4438 | 0 | else |
4439 | 0 | variable->kind = XS_NULL_KIND; |
4440 | 127k | mxNextCode(1); |
4441 | 127k | mxBreak; |
4442 | 127k | } |
4443 | 127k | } |
4444 | | |
4445 | 127k | STACK_OVERFLOW: |
4446 | 101 | mxSaveState; |
4447 | 101 | fxAbort(the, XS_JAVASCRIPT_STACK_OVERFLOW_EXIT); |
4448 | 101 | } |
4449 | | |
4450 | | #ifdef mxMetering |
4451 | | |
4452 | | void fxBeginMetering(txMachine* the, txBoolean (*callback)(txMachine*, txU8), txU8 interval) |
4453 | 31.0k | { |
4454 | 31.0k | the->meterCallback = callback; |
4455 | 31.0k | the->meterCount = ((txU8)interval) << 16; |
4456 | 31.0k | the->meterIndex = 0; |
4457 | 31.0k | the->meterInterval = ((txU8)interval) << 16; |
4458 | 31.0k | } |
4459 | | |
4460 | | void fxEndMetering(txMachine* the) |
4461 | 30.0k | { |
4462 | 30.0k | the->meterCallback = C_NULL; |
4463 | 30.0k | the->meterIndex = 0; |
4464 | 30.0k | the->meterInterval = 0; |
4465 | 30.0k | the->meterCount = 0; |
4466 | 30.0k | } |
4467 | | |
4468 | | void fxCheckMetering(txMachine* the) |
4469 | 38.3k | { |
4470 | 38.3k | txU8 interval = the->meterInterval; |
4471 | 38.3k | the->meterInterval = 0; |
4472 | 38.3k | if ((*the->meterCallback)(the, the->meterIndex >> 16)) { |
4473 | 37.5k | the->meterCount = the->meterIndex + interval; |
4474 | 37.5k | if (the->meterCount < the->meterIndex) { |
4475 | 0 | the->meterIndex = 0; |
4476 | 0 | the->meterCount = interval; |
4477 | 0 | } |
4478 | 37.5k | the->meterInterval = interval; |
4479 | 37.5k | } |
4480 | 808 | else { |
4481 | 808 | fxAbort(the, XS_TOO_MUCH_COMPUTATION_EXIT); |
4482 | 808 | } |
4483 | 38.3k | } |
4484 | | #endif |
4485 | | |
4486 | | void fxRunArguments(txMachine* the, txIndex offset) |
4487 | 150k | { |
4488 | 150k | txSlot* array; |
4489 | 150k | txIndex length = (txIndex)mxArgc; |
4490 | 150k | txIndex index; |
4491 | 150k | txSlot* address; |
4492 | 150k | mxPush(mxArrayPrototype); |
4493 | 150k | array = fxNewArrayInstance(the)->next; |
4494 | 150k | if (offset < length) { |
4495 | 322 | length -= offset; |
4496 | 322 | fxSetIndexSize(the, array, length, XS_CHUNK); |
4497 | 322 | index = 0; |
4498 | 322 | address = array->value.array.address; |
4499 | 945 | while (index < length) { |
4500 | 623 | txSlot* property = mxArgv(offset + index); |
4501 | 623 | *((txIndex*)address) = index; |
4502 | 623 | address->ID = XS_NO_ID; |
4503 | 623 | address->kind = property->kind; |
4504 | 623 | address->value = property->value; |
4505 | 623 | index++; |
4506 | 623 | address++; |
4507 | 623 | } |
4508 | 322 | } |
4509 | 150k | } |
4510 | | |
4511 | | void fxRunBase(txMachine* the) |
4512 | 35.1k | { |
4513 | 35.1k | if (mxIsUndefined(mxTarget)) |
4514 | 42 | mxTypeError("call: class"); |
4515 | 35.1k | fxRunConstructor(the); |
4516 | 35.1k | } |
4517 | | |
4518 | | void fxRunConstructor(txMachine* the) |
4519 | 88.9k | { |
4520 | 88.9k | txSlot* target; |
4521 | 88.9k | txSlot* prototype; |
4522 | 88.9k | target = mxTarget; |
4523 | 88.9k | mxPushUndefined(); |
4524 | 88.9k | prototype = the->stack; |
4525 | 88.9k | fxBeginHost(the); |
4526 | 88.9k | mxPushSlot(target); |
4527 | 88.9k | fxGetPrototypeFromConstructor(the, &mxObjectPrototype); |
4528 | 88.9k | *prototype = *the->stack; |
4529 | 88.9k | fxEndHost(the); |
4530 | 88.9k | fxNewHostInstance(the); |
4531 | 88.9k | mxPullSlot(mxThis); |
4532 | 88.9k | } |
4533 | | |
4534 | | txBoolean fxRunDefine(txMachine* the, txSlot* instance, txSlot* check, txID id, txIndex index, txSlot* slot, txFlag mask) |
4535 | 17.1M | { |
4536 | 17.1M | txBoolean result; |
4537 | 17.1M | if (check) { |
4538 | 29.1k | result = gxDefaults.definePrivateProperty(the, instance, check, id, slot, mask); |
4539 | 29.1k | } |
4540 | 17.1M | else { |
4541 | 17.1M | fxBeginHost(the); |
4542 | 17.1M | mxCheck(the, instance->kind == XS_INSTANCE_KIND); |
4543 | 17.1M | result = mxBehaviorDefineOwnProperty(the, instance, id, index, slot, mask); |
4544 | 17.1M | fxEndHost(the); |
4545 | 17.1M | } |
4546 | 17.1M | return result; |
4547 | 17.1M | } |
4548 | | |
4549 | | |
4550 | | txBoolean fxRunDelete(txMachine* the, txSlot* instance, txID id, txIndex index) |
4551 | 356k | { |
4552 | 356k | txBoolean result; |
4553 | 356k | fxBeginHost(the); |
4554 | 356k | mxCheck(the, instance->kind == XS_INSTANCE_KIND); |
4555 | 356k | result = mxBehaviorDeleteProperty(the, instance, id, index); |
4556 | 356k | fxEndHost(the); |
4557 | 356k | return result; |
4558 | 356k | } |
4559 | | |
4560 | | void fxRunDerived(txMachine* the) |
4561 | 3.52k | { |
4562 | 3.52k | txSlot* slot; |
4563 | 3.52k | if (mxIsUndefined(mxTarget)) |
4564 | 3 | mxTypeError("call: class"); |
4565 | 3.52k | slot = fxNewSlot(the); |
4566 | 3.52k | slot->kind = XS_UNINITIALIZED_KIND; |
4567 | 3.52k | mxPushClosure(slot); |
4568 | 3.52k | mxPullSlot(mxThis); |
4569 | 3.52k | } |
4570 | | |
4571 | | void fxRunExtends(txMachine* the) |
4572 | 57.2k | { |
4573 | 57.2k | txSlot* constructor; |
4574 | 57.2k | txSlot* prototype; |
4575 | | |
4576 | 57.2k | constructor = fxGetInstance(the, the->stack); |
4577 | 57.2k | if (!mxIsConstructor(constructor)) |
4578 | 2 | mxTypeError("extends: class is not a constructor"); |
4579 | 57.2k | mxPushUndefined(); |
4580 | 57.2k | prototype = the->stack; |
4581 | 57.2k | fxBeginHost(the); |
4582 | 57.2k | mxPushReference(constructor); |
4583 | 57.2k | mxGetID(mxID(_prototype)); |
4584 | 57.2k | *prototype = *the->stack; |
4585 | 57.2k | fxEndHost(the); |
4586 | 57.2k | if (the->stack->kind == XS_NULL_KIND) { |
4587 | 0 | mxPop(); |
4588 | 0 | fxNewInstance(the); |
4589 | 0 | } |
4590 | 57.2k | else if (the->stack->kind == XS_REFERENCE_KIND) { |
4591 | 57.2k | if (the->stack->value.reference->value.instance.prototype == mxGeneratorPrototype.value.reference) |
4592 | 0 | mxTypeError("extends: class is a generator"); |
4593 | 57.2k | fxNewHostInstance(the); |
4594 | 57.2k | } |
4595 | 0 | else |
4596 | 0 | mxTypeError("extends: class prototype is not an object"); |
4597 | 57.2k | } |
4598 | | |
4599 | | void fxRunEval(txMachine* the) |
4600 | 395k | { |
4601 | 395k | txStringStream aStream; |
4602 | 395k | txUnsigned flags; |
4603 | 395k | txSlot* function; |
4604 | 395k | txSlot* home; |
4605 | 395k | txSlot* closures; |
4606 | 395k | if (the->stack->value.integer == 0) |
4607 | 250 | the->stack->kind = XS_UNDEFINED_KIND; |
4608 | 395k | else |
4609 | 395k | the->stack += the->stack->value.integer; |
4610 | 395k | the->stack[6] = the->stack[0]; |
4611 | 395k | the->stack += 6; |
4612 | 395k | if ((the->stack->kind == XS_STRING_KIND) || (the->stack->kind == XS_STRING_X_KIND)) { |
4613 | 349k | aStream.slot = the->stack; |
4614 | 349k | aStream.offset = 0; |
4615 | 349k | aStream.size = mxStringLength(fxToString(the, aStream.slot)); |
4616 | 349k | flags = mxProgramFlag | mxEvalFlag; |
4617 | 349k | if (the->frame->flag & XS_STRICT_FLAG) |
4618 | 12 | flags |= mxStrictFlag; |
4619 | 349k | if (the->frame->flag & XS_FIELD_FLAG) |
4620 | 0 | flags |= mxFieldFlag; |
4621 | 349k | function = mxFunction->value.reference; |
4622 | 349k | if (function->flag & XS_CAN_CONSTRUCT_FLAG) |
4623 | 1.41k | flags |= mxTargetFlag; |
4624 | 349k | home = mxFunctionInstanceHome(function); |
4625 | 349k | if (home->value.home.object) |
4626 | 0 | flags |= mxSuperFlag; |
4627 | 349k | closures = mxFrameToEnvironment(the->frame); |
4628 | 349k | if (closures->kind == XS_REFERENCE_KIND) |
4629 | 349k | closures = closures->value.reference; |
4630 | 0 | else |
4631 | 0 | closures = C_NULL; |
4632 | 349k | fxRunScript(the, fxParseScript(the, &aStream, fxStringGetter, flags), mxThis, mxTarget, closures, home->value.home.object, home->value.home.module); |
4633 | 349k | aStream.slot->kind = the->stack->kind; |
4634 | 349k | aStream.slot->value = the->stack->value; |
4635 | 349k | mxPop(); |
4636 | 349k | } |
4637 | 395k | } |
4638 | | |
4639 | | void fxRunForAwaitOf(txMachine* the) |
4640 | 12 | { |
4641 | 12 | txSlot* slot = the->stack; |
4642 | 12 | fxBeginHost(the); |
4643 | 12 | mxPushSlot(slot); |
4644 | 12 | mxDub(); |
4645 | 12 | mxGetID(mxID(_Symbol_asyncIterator)); |
4646 | 12 | if (mxIsUndefined(the->stack) || mxIsNull(the->stack)) { |
4647 | 5 | mxPop(); |
4648 | 5 | mxPop(); |
4649 | 5 | fxGetIterator(the, slot, the->stack, C_NULL, 0); |
4650 | 5 | fxNewAsyncFromSyncIteratorInstance(the); |
4651 | 5 | } |
4652 | 7 | else { |
4653 | 7 | mxCall(); |
4654 | 7 | mxRunCount(0); |
4655 | 7 | } |
4656 | 12 | mxPullSlot(slot); |
4657 | 12 | fxEndHost(the); |
4658 | 12 | } |
4659 | | |
4660 | | void fxRunForOf(txMachine* the) |
4661 | 62.2k | { |
4662 | 62.2k | txSlot* slot = the->stack; |
4663 | 62.2k | fxBeginHost(the); |
4664 | 62.2k | fxGetIterator(the, slot, slot, C_NULL, 0); |
4665 | 62.2k | fxEndHost(the); |
4666 | 62.2k | } |
4667 | | |
4668 | | txBoolean fxRunHas(txMachine* the, txSlot* instance, txID id, txIndex index) |
4669 | 39.6M | { |
4670 | 39.6M | txBoolean result; |
4671 | 39.6M | fxBeginHost(the); |
4672 | 39.6M | result = mxBehaviorHasProperty(the, instance, id, index); |
4673 | 39.6M | fxEndHost(the); |
4674 | 39.6M | return result; |
4675 | 39.6M | } |
4676 | | |
4677 | | void fxRunIn(txMachine* the) |
4678 | 329k | { |
4679 | 329k | txSlot* left = the->stack + 1; |
4680 | 329k | txSlot* right = the->stack; |
4681 | 329k | fxBeginHost(the); |
4682 | 329k | mxPushSlot(right); |
4683 | 329k | mxPushSlot(left); |
4684 | 329k | left->value.boolean = fxHasAt(the); |
4685 | 329k | left->kind = XS_BOOLEAN_KIND; |
4686 | 329k | fxEndHost(the); |
4687 | 329k | mxPop(); |
4688 | 329k | } |
4689 | | |
4690 | | void fxRunInstanceOf(txMachine* the) |
4691 | 309k | { |
4692 | 309k | txSlot* left = the->stack + 1; |
4693 | 309k | txSlot* right = the->stack; |
4694 | 309k | fxBeginHost(the); |
4695 | 309k | mxPushSlot(right); |
4696 | 309k | mxDub(); |
4697 | 309k | mxGetID(mxID(_Symbol_hasInstance)); |
4698 | 309k | mxCall(); |
4699 | 309k | mxPushSlot(left); |
4700 | 309k | mxRunCount(1); |
4701 | 309k | fxToBoolean(the, the->stack); |
4702 | 309k | mxPullSlot(left); |
4703 | 309k | fxEndHost(the); |
4704 | 309k | mxPop(); |
4705 | 309k | } |
4706 | | |
4707 | | void fxRunInstantiate(txMachine* the) |
4708 | 22 | { |
4709 | 22 | if (the->stack->kind == XS_NULL_KIND) { |
4710 | 3 | mxPop(); |
4711 | 3 | fxNewInstance(the); |
4712 | 3 | } |
4713 | 19 | else if (the->stack->kind == XS_REFERENCE_KIND) { |
4714 | 18 | fxNewHostInstance(the); |
4715 | 18 | } |
4716 | 1 | else { |
4717 | 1 | mxPop(); |
4718 | 1 | mxPush(mxObjectPrototype); |
4719 | 1 | fxNewObjectInstance(the); |
4720 | 1 | } |
4721 | 22 | } |
4722 | | |
4723 | | void fxRunProxy(txMachine* the, txSlot* instance) |
4724 | 28 | { |
4725 | 28 | txSlot* array; |
4726 | 28 | txIndex length = (txIndex)mxArgc; |
4727 | 28 | txIndex index; |
4728 | 28 | txSlot* address; |
4729 | 28 | mxPush(mxArrayPrototype); |
4730 | 28 | array = fxNewArrayInstance(the)->next; |
4731 | 28 | fxSetIndexSize(the, array, length, XS_CHUNK); |
4732 | 28 | index = 0; |
4733 | 28 | address = array->value.array.address; |
4734 | 69 | while (index < length) { |
4735 | 41 | txSlot* property = mxArgv(index); |
4736 | 41 | *((txIndex*)address) = index; |
4737 | 41 | address->ID = XS_NO_ID; |
4738 | 41 | address->kind = property->kind; |
4739 | 41 | address->value = property->value; |
4740 | 41 | index++; |
4741 | 41 | address++; |
4742 | 41 | } |
4743 | 28 | if (mxTarget->kind == XS_UNDEFINED_KIND) |
4744 | 21 | mxBehaviorCall(the, instance, mxThis, the->stack); |
4745 | 7 | else if (instance->flag & XS_CAN_CONSTRUCT_FLAG) |
4746 | 6 | mxBehaviorConstruct(the, instance, the->stack, mxTarget); |
4747 | 1 | else |
4748 | 1 | mxTypeError("new: proxy is not a constructor"); |
4749 | 27 | mxPop(); |
4750 | 27 | } |
4751 | | |
4752 | | txBoolean fxIsSameReference(txMachine* the, txSlot* a, txSlot* b) |
4753 | 155k | { |
4754 | 155k | a = a->value.reference; |
4755 | 155k | b = b->value.reference; |
4756 | 155k | if (a == b) |
4757 | 115k | return 1; |
4758 | | #if mxAliasInstance |
4759 | | if (a->ID) { |
4760 | | txSlot* alias = the->aliasArray[a->ID]; |
4761 | | if (alias) { |
4762 | | a = alias; |
4763 | | if (a == b) |
4764 | | return 1; |
4765 | | } |
4766 | | } |
4767 | | if (b->ID) { |
4768 | | txSlot* alias = the->aliasArray[b->ID]; |
4769 | | if (alias) { |
4770 | | b = alias; |
4771 | | if (a == b) |
4772 | | return 1; |
4773 | | } |
4774 | | } |
4775 | | #endif |
4776 | 40.4k | return 0; |
4777 | 155k | } |
4778 | | |
4779 | | txBoolean fxIsSameSlot(txMachine* the, txSlot* a, txSlot* b) |
4780 | 997k | { |
4781 | 997k | txBoolean result = 0; |
4782 | 997k | if (a->kind == b->kind) { |
4783 | 799k | if ((XS_UNDEFINED_KIND == a->kind) || (XS_NULL_KIND == a->kind)) |
4784 | 3.52k | result = 1; |
4785 | 795k | else if (XS_BOOLEAN_KIND == a->kind) |
4786 | 1.57k | result = a->value.boolean == b->value.boolean; |
4787 | 794k | else if (XS_INTEGER_KIND == a->kind) |
4788 | 659k | result = a->value.integer == b->value.integer; |
4789 | 134k | else if (XS_NUMBER_KIND == a->kind) { |
4790 | 22.7k | result = (!c_isnan(a->value.number)) && (!c_isnan(b->value.number)) && (a->value.number == b->value.number); |
4791 | 22.7k | mxFloatingPointOp("same slot"); |
4792 | 22.7k | } |
4793 | 111k | else if ((XS_STRING_KIND == a->kind) || (XS_STRING_X_KIND == a->kind)) |
4794 | 760 | result = c_strcmp(a->value.string, b->value.string) == 0; |
4795 | 110k | else if (XS_SYMBOL_KIND == a->kind) |
4796 | 0 | result = a->value.symbol == b->value.symbol; |
4797 | 110k | else if ((XS_BIGINT_KIND == a->kind) || (XS_BIGINT_X_KIND == a->kind)) |
4798 | 0 | result = gxTypeBigInt.compare(the, 0, 1, 0, a, b); |
4799 | 110k | else if (XS_REFERENCE_KIND == a->kind) |
4800 | 110k | result = fxIsSameReference(the, a, b); |
4801 | 799k | } |
4802 | 198k | else if ((XS_INTEGER_KIND == a->kind) && (XS_NUMBER_KIND == b->kind)) { |
4803 | 116k | result = (!c_isnan(b->value.number)) && ((txNumber)(a->value.integer) == b->value.number); |
4804 | 116k | mxFloatingPointOp("same slot"); |
4805 | 116k | } |
4806 | 81.6k | else if ((XS_NUMBER_KIND == a->kind) && (XS_INTEGER_KIND == b->kind)) { |
4807 | 7.01k | result = (!c_isnan(a->value.number)) && (a->value.number == (txNumber)(b->value.integer)); |
4808 | 7.01k | mxFloatingPointOp("same slot"); |
4809 | 7.01k | } |
4810 | 74.6k | else if ((XS_STRING_KIND == a->kind) && (XS_STRING_X_KIND == b->kind)) |
4811 | 0 | result = c_strcmp(a->value.string, b->value.string) == 0; |
4812 | 74.6k | else if ((XS_STRING_X_KIND == a->kind) && (XS_STRING_KIND == b->kind)) |
4813 | 0 | result = c_strcmp(a->value.string, b->value.string) == 0; |
4814 | 74.6k | else if ((XS_BIGINT_KIND == a->kind) && (XS_BIGINT_X_KIND == b->kind)) |
4815 | 0 | result = gxTypeBigInt.compare(the, 0, 1, 0, a, b); |
4816 | 74.6k | else if ((XS_BIGINT_X_KIND == a->kind) && (XS_BIGINT_KIND == b->kind)) |
4817 | 0 | result = gxTypeBigInt.compare(the, 0, 1, 0, a, b); |
4818 | 997k | return result; |
4819 | 997k | } |
4820 | | |
4821 | | txBoolean fxIsSameValue(txMachine* the, txSlot* a, txSlot* b, txBoolean zero) |
4822 | 5.82M | { |
4823 | 5.82M | txBoolean result = 0; |
4824 | 5.82M | if (a->kind == b->kind) { |
4825 | 756k | if ((XS_UNDEFINED_KIND == a->kind) || (XS_NULL_KIND == a->kind)) |
4826 | 24.6k | result = 1; |
4827 | 731k | else if (XS_BOOLEAN_KIND == a->kind) |
4828 | 7 | result = a->value.boolean == b->value.boolean; |
4829 | 731k | else if (XS_INTEGER_KIND == a->kind) |
4830 | 89.5k | result = a->value.integer == b->value.integer; |
4831 | 642k | else if (XS_NUMBER_KIND == a->kind) { |
4832 | 260k | result = ((c_isnan(a->value.number) && c_isnan(b->value.number)) || ((a->value.number == b->value.number) && (zero || (c_signbit(a->value.number) == c_signbit(b->value.number))))); |
4833 | 260k | mxFloatingPointOp("same value"); |
4834 | 260k | } |
4835 | 381k | else if ((XS_STRING_KIND == a->kind) || (XS_STRING_X_KIND == a->kind)) |
4836 | 330k | result = c_strcmp(a->value.string, b->value.string) == 0; |
4837 | 50.6k | else if (XS_SYMBOL_KIND == a->kind) |
4838 | 50.3k | result = a->value.symbol == b->value.symbol; |
4839 | 309 | else if ((XS_BIGINT_KIND == a->kind) || (XS_BIGINT_X_KIND == a->kind)) |
4840 | 0 | result = gxTypeBigInt.compare(the, 0, 1, 0, a, b); |
4841 | 309 | else if (XS_REFERENCE_KIND == a->kind) |
4842 | 309 | result = fxIsSameReference(the, a, b); |
4843 | 756k | } |
4844 | 5.07M | else if ((XS_INTEGER_KIND == a->kind) && (XS_NUMBER_KIND == b->kind)) { |
4845 | 151k | txNumber aNumber = a->value.integer; |
4846 | 151k | result = (aNumber == b->value.number) && (zero || (signbit(aNumber) == signbit(b->value.number))); |
4847 | 151k | mxFloatingPointOp("same value"); |
4848 | 151k | } |
4849 | 4.92M | else if ((XS_NUMBER_KIND == a->kind) && (XS_INTEGER_KIND == b->kind)) { |
4850 | 71.5k | txNumber bNumber = b->value.integer; |
4851 | 71.5k | result = (a->value.number == bNumber) && (zero || (signbit(a->value.number) == signbit(bNumber))); |
4852 | 71.5k | mxFloatingPointOp("same value"); |
4853 | 71.5k | } |
4854 | 4.84M | else if ((XS_STRING_KIND == a->kind) && (XS_STRING_X_KIND == b->kind)) |
4855 | 0 | result = c_strcmp(a->value.string, b->value.string) == 0; |
4856 | 4.84M | else if ((XS_STRING_X_KIND == a->kind) && (XS_STRING_KIND == b->kind)) |
4857 | 0 | result = c_strcmp(a->value.string, b->value.string) == 0; |
4858 | 4.84M | else if ((XS_BIGINT_KIND == a->kind) && (XS_BIGINT_X_KIND == b->kind)) |
4859 | 0 | result = gxTypeBigInt.compare(the, 0, 1, 0, a, b); |
4860 | 4.84M | else if ((XS_BIGINT_X_KIND == a->kind) && (XS_BIGINT_KIND == b->kind)) |
4861 | 0 | result = gxTypeBigInt.compare(the, 0, 1, 0, a, b); |
4862 | 5.82M | return result; |
4863 | 5.82M | } |
4864 | | |
4865 | | txBoolean fxIsScopableSlot(txMachine* the, txSlot* instance, txID id) |
4866 | 1.76M | { |
4867 | 1.76M | txBoolean result; |
4868 | 1.76M | fxBeginHost(the); |
4869 | 1.76M | mxPushReference(instance); |
4870 | 1.76M | result = mxHasID(id); |
4871 | 1.76M | if (result) { |
4872 | 248k | mxPushReference(instance); |
4873 | 248k | mxGetID(mxID(_Symbol_unscopables)); |
4874 | 248k | if (mxIsReference(the->stack)) { |
4875 | 44 | mxGetID(id); |
4876 | 44 | result = fxToBoolean(the, the->stack) ? 0 : 1; |
4877 | 44 | } |
4878 | 248k | mxPop(); |
4879 | 248k | } |
4880 | 1.76M | fxEndHost(the); |
4881 | 1.76M | return result; |
4882 | 1.76M | } |
4883 | | |
4884 | | void fxRemapIDs(txMachine* the, txByte* codeBuffer, txSize codeSize, txID* theIDs) |
4885 | 557k | { |
4886 | 557k | register const txS1* bytes = gxCodeSizes; |
4887 | 557k | register txByte* p = codeBuffer; |
4888 | 557k | register txByte* q = codeBuffer + codeSize; |
4889 | 557k | register txS1 offset; |
4890 | 557k | txID id; |
4891 | 23.7M | while (p < q) { |
4892 | | //fprintf(stderr, "%s", gxCodeNames[*((txU1*)p)]); |
4893 | 23.2M | offset = (txS1)c_read8(bytes + c_read8(p)); |
4894 | 23.2M | if (0 < offset) |
4895 | 18.5M | p += offset; |
4896 | 4.68M | else if (0 == offset) { |
4897 | 3.57M | p++; |
4898 | 3.57M | mxDecodeID(p, id); |
4899 | 3.57M | if (id != XS_NO_ID) { |
4900 | 3.51M | id = theIDs[id]; |
4901 | 3.51M | p -= sizeof(txID); |
4902 | 3.51M | mxEncodeID(p, id); |
4903 | 3.51M | } |
4904 | 3.57M | } |
4905 | 1.11M | else if (-1 == offset) { |
4906 | 1.09M | txU1 index; |
4907 | 1.09M | p++; |
4908 | 1.09M | index = *((txU1*)p); |
4909 | 1.09M | p += 1 + index; |
4910 | 1.09M | } |
4911 | 15.0k | else if (-2 == offset) { |
4912 | 15.0k | txU2 index; |
4913 | 15.0k | p++; |
4914 | 15.0k | mxDecode2(p, index); |
4915 | 15.0k | p += index; |
4916 | 15.0k | } |
4917 | 0 | else if (-4 == offset) { |
4918 | 0 | txS4 index; |
4919 | 0 | p++; |
4920 | 0 | mxDecode4(p, index); |
4921 | 0 | p += index; |
4922 | 0 | } |
4923 | | //fprintf(stderr, "\n"); |
4924 | 23.2M | } |
4925 | 557k | } |
4926 | | |
4927 | | void fxRemapScript(txMachine* the, txScript* script) |
4928 | 557k | { |
4929 | 557k | mxPushUndefined(); |
4930 | 557k | if (script->symbolsBuffer) { |
4931 | 557k | txByte* p = script->symbolsBuffer; |
4932 | 557k | txID c, i; |
4933 | 557k | mxDecodeID(p, c); |
4934 | 557k | the->stack->value.callback.address = C_NULL; |
4935 | 557k | the->stack->value.IDs = (txID*)fxNewChunk(the, c * sizeof(txID)); |
4936 | 557k | the->stack->kind = XS_IDS_KIND; |
4937 | 557k | the->stack->value.IDs[0] = XS_NO_ID; |
4938 | 1.86M | for (i = 1; i < c; i++) { |
4939 | 1.30M | txID id = fxNewNameC(the, (txString)p); |
4940 | 1.30M | the->stack->value.IDs[i] = id; |
4941 | 1.30M | p += mxStringLength((char*)p) + 1; |
4942 | 1.30M | } |
4943 | 557k | fxRemapIDs(the, script->codeBuffer, script->codeSize, the->stack->value.IDs); |
4944 | 557k | the->stack->value.IDs = C_NULL; |
4945 | 557k | } |
4946 | 0 | else { |
4947 | 0 | the->stack->value.IDs = C_NULL; |
4948 | 0 | the->stack->kind = XS_IDS_KIND; |
4949 | 0 | } |
4950 | 557k | } |
4951 | | |
4952 | | txBoolean fxToNumericInteger(txMachine* the, txSlot* theSlot) |
4953 | 12.3M | { |
4954 | 12.3M | if (theSlot->kind == XS_REFERENCE_KIND) |
4955 | 324k | fxToPrimitive(the, theSlot, XS_NUMBER_HINT); |
4956 | 12.3M | if ((theSlot->kind == XS_BIGINT_KIND) || (theSlot->kind == XS_BIGINT_X_KIND)) |
4957 | 925k | return 0; |
4958 | 11.4M | fxToInteger(the, theSlot); |
4959 | 11.4M | return 1; |
4960 | 12.3M | } |
4961 | | |
4962 | | txBoolean fxToNumericIntegerUnary(txMachine* the, txSlot* a, txBigIntUnary op) |
4963 | 630k | { |
4964 | 630k | if (fxToNumericInteger(the, a)) |
4965 | 288k | return 1; |
4966 | 342k | a->value.bigint = *(*op)(the, C_NULL, &a->value.bigint); |
4967 | 342k | a->kind = XS_BIGINT_KIND; |
4968 | 342k | the->stack = a; |
4969 | 342k | return 0; |
4970 | 630k | } |
4971 | | |
4972 | | txBoolean fxToNumericIntegerBinary(txMachine* the, txSlot* a, txSlot* b, txBigIntBinary op) |
4973 | 5.88M | { |
4974 | 5.88M | txBoolean ra = fxToNumericInteger(the, a); |
4975 | 5.88M | txBoolean rb = fxToNumericInteger(the, b); |
4976 | 5.88M | if (ra) { |
4977 | 5.59M | if (rb) |
4978 | 5.58M | return 1; |
4979 | 5.59M | mxTypeError("cannot coerce left operand to bigint"); |
4980 | 5.59M | } |
4981 | 292k | else if (rb) |
4982 | 2.42k | mxTypeError("cannot coerce right operand to bigint"); |
4983 | 290k | a->value.bigint = *(*op)(the, C_NULL, &a->value.bigint, &b->value.bigint); |
4984 | 290k | a->kind = XS_BIGINT_KIND; |
4985 | 290k | the->stack = b; |
4986 | 290k | return 0; |
4987 | 5.88M | } |
4988 | | |
4989 | | txBoolean fxToNumericNumber(txMachine* the, txSlot* theSlot) |
4990 | 32.7M | { |
4991 | 32.7M | if (theSlot->kind == XS_REFERENCE_KIND) |
4992 | 3.23M | fxToPrimitive(the, theSlot, XS_NUMBER_HINT); |
4993 | 32.7M | if ((theSlot->kind == XS_BIGINT_KIND) || (theSlot->kind == XS_BIGINT_X_KIND)) |
4994 | 8.08M | return 0; |
4995 | 24.6M | fxToNumber(the, theSlot); |
4996 | 24.6M | return 1; |
4997 | 32.7M | } |
4998 | | |
4999 | | txBoolean fxToNumericNumberUnary(txMachine* the, txSlot* a, txBigIntUnary op) |
5000 | 9.98M | { |
5001 | 9.98M | if (fxToNumericNumber(the, a)) |
5002 | 4.69M | return 1; |
5003 | 5.29M | a->value.bigint = *(*op)(the, C_NULL, &a->value.bigint); |
5004 | 5.29M | a->kind = XS_BIGINT_KIND; |
5005 | 5.29M | the->stack = a; |
5006 | 5.29M | return 0; |
5007 | 9.98M | } |
5008 | | |
5009 | | txBoolean fxToNumericNumberBinary(txMachine* the, txSlot* a, txSlot* b, txBigIntBinary op) |
5010 | 10.5M | { |
5011 | 10.5M | txBoolean ra = fxToNumericNumber(the, a); |
5012 | 10.5M | txBoolean rb = fxToNumericNumber(the, b); |
5013 | 10.5M | if (ra) { |
5014 | 9.18M | if (rb) |
5015 | 9.18M | return 1; |
5016 | 9.18M | mxTypeError("cannot coerce left operand to bigint"); |
5017 | 9.18M | } |
5018 | 1.39M | else if (rb) |
5019 | 1.55k | mxTypeError("cannot coerce right operand to bigint"); |
5020 | 1.39M | a->value.bigint = *(*op)(the, C_NULL, &a->value.bigint, &b->value.bigint); |
5021 | 1.39M | a->kind = XS_BIGINT_KIND; |
5022 | 1.39M | the->stack = b; |
5023 | 1.39M | return 0; |
5024 | 10.5M | } |
5025 | | |
5026 | | void fxRunScript(txMachine* the, txScript* script, txSlot* _this, txSlot* _target, txSlot* closures, txSlot* object, txSlot* module) |
5027 | 557k | { |
5028 | 557k | if (script) { |
5029 | 557k | mxTry(the) { |
5030 | 557k | txSlot* instance; |
5031 | 557k | txSlot* property; |
5032 | 557k | __JUMP__.code = C_NULL; |
5033 | 557k | fxRemapScript(the, script); |
5034 | 557k | if (script->callback) { |
5035 | 0 | property = the->stack; |
5036 | | /* THIS */ |
5037 | 0 | if (_this) |
5038 | 0 | mxPushSlot(_this); |
5039 | 0 | else |
5040 | 0 | mxPushUndefined(); |
5041 | 0 | the->stack->ID = XS_NO_ID; |
5042 | | /* FUNCTION */ |
5043 | 0 | mxPush(mxFunctionPrototype); |
5044 | 0 | instance = fxNewFunctionInstance(the, closures ? mxID(_eval) : XS_NO_ID); |
5045 | 0 | instance->next->kind = XS_CALLBACK_KIND; |
5046 | 0 | instance->next->value.callback.address = script->callback; |
5047 | 0 | instance->next->value.callback.closures = C_NULL; |
5048 | 0 | property = mxFunctionInstanceHome(instance); |
5049 | 0 | property->value.home.object = object; |
5050 | 0 | property->value.home.module = module; |
5051 | | /* TARGET */ |
5052 | 0 | mxPushUndefined(); |
5053 | | /* RESULT */ |
5054 | 0 | mxPushUndefined(); |
5055 | | /* FRAME */ |
5056 | 0 | mxPushUninitialized(); |
5057 | | /* COUNT */ |
5058 | 0 | mxPushUninitialized(); |
5059 | 0 | mxRunCount(0); |
5060 | 0 | } |
5061 | 557k | else { |
5062 | 557k | mxPushUndefined(); |
5063 | 557k | } |
5064 | 557k | mxPull(mxHosts); |
5065 | 557k | mxPop(); |
5066 | | |
5067 | | /* THIS */ |
5068 | 557k | if (_this) |
5069 | 381k | mxPushSlot(_this); |
5070 | 175k | else |
5071 | 175k | mxPushUndefined(); |
5072 | 557k | the->stack->ID = XS_NO_ID; |
5073 | | /* FUNCTION */ |
5074 | 557k | mxPush(mxFunctionPrototype); |
5075 | 557k | instance = fxNewFunctionInstance(the, XS_NO_ID); |
5076 | 557k | instance->next->kind = XS_CODE_X_KIND; |
5077 | 557k | instance->next->value.code.address = script->codeBuffer; |
5078 | 557k | instance->next->value.code.closures = closures; |
5079 | 557k | property = mxFunctionInstanceHome(instance); |
5080 | 557k | property->ID = fxGenerateProfileID(the); |
5081 | 557k | property->value.home.object = object; |
5082 | 557k | property->value.home.module = module; |
5083 | | /* TARGET */ |
5084 | 557k | if (_target) |
5085 | 349k | mxPushSlot(_target); |
5086 | 207k | else |
5087 | 207k | mxPushUndefined(); |
5088 | | /* RESULT */ |
5089 | 557k | mxPushUndefined(); |
5090 | | /* FRAME */ |
5091 | 557k | mxPushUninitialized(); |
5092 | | /* COUNT */ |
5093 | 557k | mxPushUninitialized(); |
5094 | 557k | mxRunCount(0); |
5095 | | |
5096 | 557k | mxPushUndefined(); |
5097 | 557k | mxPull(mxHosts); |
5098 | 557k | if (script->symbolsBuffer) |
5099 | 101k | fxDeleteScript(script); |
5100 | 557k | } |
5101 | 557k | mxCatch(the) { |
5102 | 454k | if (script->symbolsBuffer) |
5103 | 454k | fxDeleteScript(script); |
5104 | 454k | fxJump(the); |
5105 | 454k | } |
5106 | 557k | } |
5107 | 0 | else { |
5108 | 0 | mxSyntaxError("invalid script"); |
5109 | 0 | } |
5110 | 557k | } |
5111 | | |
5112 | | void fxRunUsed(txMachine* the, txSlot* selector) |
5113 | 1 | { |
5114 | 1 | #if mxExplicitResourceManagement |
5115 | 1 | txSlot* exception = selector + 1; |
5116 | 1 | fxBeginHost(the); |
5117 | 1 | { |
5118 | 1 | if (selector->value.integer == 0) { |
5119 | 1 | mxPush(mxSuppressedErrorConstructor); |
5120 | 1 | mxNew(); |
5121 | 1 | mxPush(mxException); |
5122 | 1 | mxPushSlot(exception); |
5123 | 1 | mxRunCount(2); |
5124 | 1 | mxPullSlot(exception); |
5125 | 1 | } |
5126 | 0 | else { |
5127 | 0 | *exception = mxException; |
5128 | 0 | selector->value.integer = 0; |
5129 | 0 | } |
5130 | 1 | mxException = mxUndefined; |
5131 | 1 | } |
5132 | 1 | fxEndHost(the); |
5133 | | #else |
5134 | | mxTypeError("using: unavailable feature"); |
5135 | | #endif |
5136 | 1 | } |
5137 | | |
5138 | | void fxRunUsing(txMachine* the) |
5139 | 0 | { |
5140 | 0 | #if mxExplicitResourceManagement |
5141 | 0 | txSlot* resource = the->stack; |
5142 | 0 | fxBeginHost(the); |
5143 | 0 | mxPushSlot(resource); |
5144 | 0 | if (!mxIsNull(resource) && !mxIsUndefined(resource)) { |
5145 | 0 | mxGetID(mxID(_Symbol_dispose)); |
5146 | 0 | if (!fxIsCallable(the, the->stack)) |
5147 | 0 | mxTypeError("using: [Symbol.dispose] is not a function"); |
5148 | 0 | } |
5149 | 0 | else |
5150 | 0 | the->stack->kind = XS_NULL_KIND; |
5151 | 0 | mxPullSlot(resource); |
5152 | 0 | fxEndHost(the); |
5153 | | #else |
5154 | | mxTypeError("using: unavailable feature"); |
5155 | | #endif |
5156 | 0 | } |
5157 | | |
5158 | | void fxRunUsingAsync(txMachine* the) |
5159 | 0 | { |
5160 | 0 | #if mxExplicitResourceManagement |
5161 | 0 | txSlot* resource = the->stack; |
5162 | 0 | fxBeginHost(the); |
5163 | 0 | mxPushSlot(resource); |
5164 | 0 | if (!mxIsNull(resource) && !mxIsUndefined(resource)) { |
5165 | 0 | mxGetID(mxID(_Symbol_asyncDispose)); |
5166 | 0 | if (!fxIsCallable(the, the->stack)) { |
5167 | 0 | mxPop(); |
5168 | 0 | mxPushSlot(resource); |
5169 | 0 | mxGetID(mxID(_Symbol_dispose)); |
5170 | 0 | } |
5171 | 0 | if (!fxIsCallable(the, the->stack)) |
5172 | 0 | mxTypeError("using: neither [Symbol.asyncDispose] nor [Symbol.dispose] are function"); |
5173 | 0 | } |
5174 | 0 | else |
5175 | 0 | the->stack->kind = XS_NULL_KIND; |
5176 | 0 | mxPullSlot(resource); |
5177 | 0 | fxEndHost(the); |
5178 | | #else |
5179 | | mxTypeError("using: unavailable feature"); |
5180 | | #endif |
5181 | 0 | } |
5182 | | |
5183 | | #ifdef mxMetering |
5184 | | void fxCheckMeter(void* console) |
5185 | 0 | { |
5186 | 0 | txMachine* the = console; |
5187 | 0 | if (the->meterInterval && (the->meterIndex > the->meterCount)) { |
5188 | 0 | fxCheckMetering(the); |
5189 | 0 | } |
5190 | 0 | } |
5191 | | void fxMeterSome(void* console, txU4 count) |
5192 | 557k | { |
5193 | 557k | txMachine* the = console; |
5194 | 557k | the->meterIndex += count * XS_PARSE_CODE_METERING; |
5195 | 557k | } |
5196 | | #endif |
5197 | | |
5198 | | |
5199 | | |
5200 | | |
5201 | | |
5202 | | |
5203 | | |
5204 | | |