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