-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathJIT_Execute.c
More file actions
3165 lines (2837 loc) · 77.9 KB
/
JIT_Execute.c
File metadata and controls
3165 lines (2837 loc) · 77.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright (c) 2012 DotNetAnywhere
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#include "Compat.h"
#include "Sys.h"
#include "JIT.h"
#include "JIT_OpCodes.h"
#include "MetaData.h"
#include "MetaDataTables.h"
#include "Heap.h"
#include "Type.h"
#include "MethodState.h"
#include "Finalizer.h"
#include "Delegate.h"
#include "PInvoke.h"
#include "System.String.h"
#include "System.Array.h"
// Global array which stores the absolute addresses of the start and end of all JIT code
// fragment machine code.
tJITCodeInfo jitCodeInfo[JIT_OPCODE_MAXNUM];
tJITCodeInfo jitCodeGoNext;
// Get the next op-code
#define GET_OP() *(pCurOp++)
// Push a PTR value on the top of the stack
#define PUSH_PTR(ptr) *(PTR*)pCurEvalStack = (PTR)(ptr); pCurEvalStack += sizeof(void*)
// Push an arbitrarily-sized value-type onto the top of the stack
#define PUSH_VALUETYPE(ptr, valueSize, stackInc) memcpy(pCurEvalStack, ptr, valueSize); pCurEvalStack += stackInc
// Push a U32 value on the top of the stack
#define PUSH_U32(value) *(U32*)pCurEvalStack = (U32)(value); pCurEvalStack += 4
// Push a U64 value on the top of the stack
#define PUSH_U64(value) *(U64*)pCurEvalStack = (U64)(value); pCurEvalStack += 8
// Push a float value on the top of the stack
#define PUSH_FLOAT(value) *(float*)pCurEvalStack = (float)(value); pCurEvalStack += 4;
// Push a double value on the top of the stack
#define PUSH_DOUBLE(value) *(double*)pCurEvalStack = (double)(value); pCurEvalStack += 8;
// Push a 4-byte heap pointer on to the top of the stack
#define PUSH_O(pHeap) *(void**)pCurEvalStack = (void*)(pHeap); pCurEvalStack += sizeof(void*)
// DUP4() duplicates the top 4 bytes on the eval stack
#define DUP4() *(U32*)pCurEvalStack = *(U32*)(pCurEvalStack - 4); pCurEvalStack += 4
// DUP8() duplicates the top 4 bytes on the eval stack
#define DUP8() *(U64*)pCurEvalStack = *(U64*)(pCurEvalStack - 8); pCurEvalStack += 8
// DUP() duplicates numBytes bytes from the top of the stack
#define DUP(numBytes) memcpy(pCurEvalStack, pCurEvalStack - numBytes, numBytes); pCurEvalStack += numBytes
// Pop a U32 value from the stack
#define POP_U32() (*(U32*)(pCurEvalStack -= 4))
// Pop a U64 value from the stack
#define POP_U64() (*(U64*)(pCurEvalStack -= 8))
// Pop a float value from the stack
#define POP_FLOAT() (*(float*)(pCurEvalStack -= 4))
// Pop a double value from the stack
#define POP_DOUBLE() (*(double*)(pCurEvalStack -= 8))
// Pop 2 U32's from the stack
#define POP_U32_U32(v1,v2) pCurEvalStack -= 8; v1 = *(U32*)pCurEvalStack; v2 = *(U32*)(pCurEvalStack + 4)
// Pop 2 U64's from the stack
#define POP_U64_U64(v1,v2) pCurEvalStack -= 16; v1 = *(U64*)pCurEvalStack; v2 = *(U64*)(pCurEvalStack + 8)
// Pop 2 F32's from the stack
#define POP_F32_F32(v1,v2) pCurEvalStack -= 8; v1 = *(float*)pCurEvalStack; v2 = *(float*)(pCurEvalStack + 4)
// Pop 2 F64's from the stack
#define POP_F64_F64(v1,v2) pCurEvalStack -= 16; v1 = *(double*)pCurEvalStack; v2 = *(double*)(pCurEvalStack + 8)
// Pop a PTR value from the stack
#define POP_PTR() (*(PTR*)(pCurEvalStack -= sizeof(void*)))
// Pop an arbitrarily-sized value-type from the stack (copies it to the specified memory location)
#define POP_VALUETYPE(ptr, valueSize, stackDec) memcpy(ptr, pCurEvalStack -= stackDec, valueSize)
// Pop a Object (heap) pointer value from the stack
#define POP_O() (*(HEAP_PTR*)(pCurEvalStack -= 4))
// POP() returns nothing - it just alters the stack offset correctly
#define POP(numBytes) pCurEvalStack -= numBytes
// POP_ALL() empties the evaluation stack
#define POP_ALL() pCurEvalStack = pCurrentMethodState->pEvalStack
#define STACK_ADDR(type) *(type*)(pCurEvalStack - sizeof(type))
// General binary ops
#define BINARY_OP(returnType, type1, type2, op) \
pCurEvalStack -= sizeof(type1) + sizeof(type2) - sizeof(returnType); \
*(returnType*)(pCurEvalStack - sizeof(returnType)) = \
*(type1*)(pCurEvalStack - sizeof(returnType)) op \
*(type2*)(pCurEvalStack - sizeof(returnType) + sizeof(type1))
// General unary ops
#define UNARY_OP(type, op) STACK_ADDR(type) = op STACK_ADDR(type)
// Set the new method state (for use when the method state changes - in calls mainly)
#define SAVE_METHOD_STATE() \
pCurrentMethodState->stackOfs = (U32)(pCurEvalStack - pCurrentMethodState->pEvalStack); \
pCurrentMethodState->ipOffset = (U32)(pCurOp - pOps)
#define LOAD_METHOD_STATE() \
pCurrentMethodState = pThread->pCurrentMethodState; \
pParamsLocals = pCurrentMethodState->pParamsLocals; \
pCurEvalStack = pCurrentMethodState->pEvalStack + pCurrentMethodState->stackOfs; \
pJIT = pCurrentMethodState->pJIT; \
pOps = pJIT->pOps; \
pCurOp = pOps + pCurrentMethodState->ipOffset
#define CHANGE_METHOD_STATE(pNewMethodState) \
SAVE_METHOD_STATE(); \
pThread->pCurrentMethodState = pNewMethodState; \
LOAD_METHOD_STATE()
// Easy access to method parameters and local variables
#define PARAMLOCAL_U32(offset) *(U32*)(pParamsLocals + offset)
#define PARAMLOCAL_U64(offset) *(U64*)(pParamsLocals + offset)
#define THROW(exType) heapPtr = Heap_AllocType(exType); goto throwHeapPtr
// Note: newObj is only set if a constructor is being called
static void CreateParameters(PTR pParamsLocals, tMD_MethodDef *pCallMethod, PTR *ppCurEvalStack, HEAP_PTR newObj) {
U32 ofs;
if (newObj != NULL) {
// If this is being called from JIT_NEW_OBJECT then need to specially push the new object
// onto parameter stack position 0
*(HEAP_PTR*)pParamsLocals = newObj;
ofs = 4;
} else {
ofs = 0;
}
*ppCurEvalStack -= pCallMethod->parameterStackSize - ofs;
memcpy(pParamsLocals + ofs, *ppCurEvalStack, pCallMethod->parameterStackSize - ofs);
}
static tMethodState* RunFinalizer(tThread *pThread) {
HEAP_PTR heapPtr = GetNextFinalizer();
if (heapPtr != NULL) {
// There is a pending finalizer, so create a MethodState for it and put it as next-to-run on the stack
tMethodState *pFinalizerMethodState;
tMD_TypeDef *pFinalizerType = Heap_GetType(heapPtr);
pFinalizerMethodState = MethodState_Direct(pThread, pFinalizerType->pFinalizer, pThread->pCurrentMethodState, 0);
// Mark this methodState as a Finalizer
pFinalizerMethodState->finalizerThis = heapPtr;
// Put the object on the stack (the object that is being Finalized)
// Finalizers always have no parameters
*(HEAP_PTR*)(pFinalizerMethodState->pParamsLocals) = heapPtr;
//printf("--- FINALIZE ---\n");
return pFinalizerMethodState;
}
return NULL;
}
#ifdef DIAG_OPCODE_TIMES
U64 opcodeTimes[JIT_OPCODE_MAXNUM];
static __inline unsigned __int64 __cdecl rdtsc() {
__asm {
rdtsc
}
}
#endif
#ifdef DIAG_OPCODE_USE
U32 opcodeNumUses[JIT_OPCODE_MAXNUM];
#define OPCODE_USE(op) opcodeNumUses[op]++;
#else
#define OPCODE_USE(op)
#endif
#ifdef __GNUC__
#define GET_LABEL(var, label) var = &&label
#define GO_NEXT() goto **(void**)(pCurOp++)
#else
#ifdef WIN32
#define GET_LABEL(var, label) \
{ __asm mov edi, label \
__asm mov var, edi }
#define GO_NEXT() \
{ __asm mov edi, pCurOp \
__asm add edi, 4 \
__asm mov pCurOp, edi \
__asm jmp DWORD PTR [edi - 4] }
#endif
#endif
#define GO_NEXT_CHECK() \
if (--numInst == 0) goto done; \
GO_NEXT()
#define GET_LABELS(op) \
GET_LABEL(pAddr, op##_start); \
jitCodeInfo[op].pStart = pAddr; \
GET_LABEL(pAddr, op##_end); \
jitCodeInfo[op].pEnd = pAddr; \
jitCodeInfo[op].isDynamic = 0
#define GET_LABELS_DYNAMIC(op, extraBytes) \
GET_LABEL(pAddr, op##_start); \
jitCodeInfo[op].pStart = pAddr; \
GET_LABEL(pAddr, op##_end); \
jitCodeInfo[op].pEnd = pAddr; \
jitCodeInfo[op].isDynamic = 0x100 | (extraBytes & 0xff)
#define RUN_FINALIZER() {tMethodState *pMS = RunFinalizer(pThread);if(pMS) {CHANGE_METHOD_STATE(pMS);}}
U32 JIT_Execute(tThread *pThread, U32 numInst) {
tJITted *pJIT;
tMethodState *pCurrentMethodState;
PTR pParamsLocals;
// Local copies of thread state variables, to speed up execution
// Pointer to next op-code
U32 *pOps;
register U32 *pCurOp;
// Pointer to eval-stack position
register PTR pCurEvalStack;
PTR pTempPtr;
U32 op;
// General purpose variables
//I32 i32Value;
U32 u32Value; //, u32Value2;
//U64 u64Value;
//double dValue;
//float fValue;
//uConvDouble convDouble;
U32 ofs;
HEAP_PTR heapPtr;
PTR pMem;
if (pThread == NULL) {
void *pAddr;
// Special case to get all the label addresses
// Default all op-codes to noCode.
GET_LABEL(pAddr, noCode);
for (u32Value = 0; u32Value < JIT_OPCODE_MAXNUM; u32Value++) {
jitCodeInfo[u32Value].pStart = pAddr;
jitCodeInfo[u32Value].pEnd = NULL;
jitCodeInfo[u32Value].isDynamic = 0;
}
// Get GoNext code
GET_LABEL(jitCodeGoNext.pStart, JIT_GoNext_start);
GET_LABEL(jitCodeGoNext.pEnd, JIT_GoNext_end);
jitCodeGoNext.isDynamic = 0;
// Get all defined opcodes
GET_LABELS_DYNAMIC(JIT_NOP, 0);
GET_LABELS(JIT_RETURN);
GET_LABELS_DYNAMIC(JIT_LOAD_I32, 4);
GET_LABELS(JIT_BRANCH);
GET_LABELS(JIT_LOAD_STRING);
GET_LABELS(JIT_CALLVIRT_O);
GET_LABELS(JIT_CALL_NATIVE);
GET_LABELS(JIT_CALL_O);
GET_LABELS(JIT_NEWOBJECT);
GET_LABELS(JIT_LOAD_PARAMLOCAL_ADDR);
GET_LABELS(JIT_CALL_PTR);
GET_LABELS(JIT_BOX_CALLVIRT);
GET_LABELS(JIT_INIT_VALUETYPE);
GET_LABELS(JIT_NEW_VECTOR);
GET_LABELS(JIT_NEWOBJECT_VALUETYPE);
GET_LABELS(JIT_IS_INSTANCE);
GET_LABELS(JIT_LOAD_NULL);
GET_LABELS(JIT_UNBOX2VALUETYPE);
GET_LABELS(JIT_UNBOX2OBJECT);
GET_LABELS(JIT_LOAD_FIELD_ADDR);
GET_LABELS(JIT_DUP_GENERAL);
GET_LABELS_DYNAMIC(JIT_POP, 4);
GET_LABELS(JIT_STORE_OBJECT_VALUETYPE);
GET_LABELS(JIT_DEREF_CALLVIRT);
GET_LABELS(JIT_STORE_ELEMENT);
GET_LABELS(JIT_LEAVE);
GET_LABELS(JIT_END_FINALLY);
GET_LABELS(JIT_THROW);
GET_LABELS(JIT_RETHROW);
GET_LABELS(JIT_LOADOBJECT);
GET_LABELS(JIT_LOAD_VECTOR_LEN);
GET_LABELS(JIT_SWITCH);
GET_LABELS(JIT_LOAD_ELEMENT_ADDR);
GET_LABELS(JIT_CALL_INTERFACE);
GET_LABELS(JIT_CAST_CLASS);
GET_LABELS(JIT_LOAD_ELEMENT);
GET_LABELS(JIT_LOADFIELD_VALUETYPE);
GET_LABELS(JIT_LOADFIELD);
GET_LABELS(JIT_LOADFUNCTION);
GET_LABELS(JIT_INVOKE_DELEGATE);
GET_LABELS(JIT_CALL_PINVOKE);
GET_LABELS_DYNAMIC(JIT_LOAD_I64, 8);
GET_LABELS(JIT_INIT_OBJECT);
GET_LABELS_DYNAMIC(JIT_DUP_4, 0);
GET_LABELS_DYNAMIC(JIT_DUP_8, 0);
GET_LABELS(JIT_LOADSTATICFIELDADDRESS_CHECKTYPEINIT);
GET_LABELS_DYNAMIC(JIT_POP_4, 0);
GET_LABELS_DYNAMIC(JIT_LOAD_F32, 4);
GET_LABELS_DYNAMIC(JIT_LOADPARAMLOCAL_INT64, 4);
GET_LABELS_DYNAMIC(JIT_LOADPARAMLOCAL_INT32, 4);
GET_LABELS_DYNAMIC(JIT_LOADPARAMLOCAL_INTNATIVE, 4);
GET_LABELS_DYNAMIC(JIT_LOADPARAMLOCAL_F32, 4);
GET_LABELS_DYNAMIC(JIT_LOADPARAMLOCAL_F64, 4);
GET_LABELS_DYNAMIC(JIT_LOADPARAMLOCAL_PTR, 4);
GET_LABELS_DYNAMIC(JIT_LOADPARAMLOCAL_O, 4);
GET_LABELS(JIT_LOADPARAMLOCAL_VALUETYPE);
GET_LABELS_DYNAMIC(JIT_LOADPARAMLOCAL_0, 0);
GET_LABELS_DYNAMIC(JIT_LOADPARAMLOCAL_1, 0);
GET_LABELS_DYNAMIC(JIT_LOADPARAMLOCAL_2, 0);
GET_LABELS_DYNAMIC(JIT_LOADPARAMLOCAL_3, 0);
GET_LABELS_DYNAMIC(JIT_LOADPARAMLOCAL_4, 0);
GET_LABELS_DYNAMIC(JIT_LOADPARAMLOCAL_5, 0);
GET_LABELS_DYNAMIC(JIT_LOADPARAMLOCAL_6, 0);
GET_LABELS_DYNAMIC(JIT_LOADPARAMLOCAL_7, 0);
GET_LABELS_DYNAMIC(JIT_STOREPARAMLOCAL_INT64, 4);
GET_LABELS_DYNAMIC(JIT_STOREPARAMLOCAL_INT32, 4);
GET_LABELS_DYNAMIC(JIT_STOREPARAMLOCAL_INTNATIVE, 4);
GET_LABELS_DYNAMIC(JIT_STOREPARAMLOCAL_F32, 4);
GET_LABELS_DYNAMIC(JIT_STOREPARAMLOCAL_F64, 4);
GET_LABELS_DYNAMIC(JIT_STOREPARAMLOCAL_PTR, 4);
GET_LABELS_DYNAMIC(JIT_STOREPARAMLOCAL_O, 4);
GET_LABELS(JIT_STOREPARAMLOCAL_VALUETYPE);
GET_LABELS_DYNAMIC(JIT_STOREPARAMLOCAL_0, 0);
GET_LABELS_DYNAMIC(JIT_STOREPARAMLOCAL_1, 0);
GET_LABELS_DYNAMIC(JIT_STOREPARAMLOCAL_2, 0);
GET_LABELS_DYNAMIC(JIT_STOREPARAMLOCAL_3, 0);
GET_LABELS_DYNAMIC(JIT_STOREPARAMLOCAL_4, 0);
GET_LABELS_DYNAMIC(JIT_STOREPARAMLOCAL_5, 0);
GET_LABELS_DYNAMIC(JIT_STOREPARAMLOCAL_6, 0);
GET_LABELS_DYNAMIC(JIT_STOREPARAMLOCAL_7, 0);
GET_LABELS(JIT_STOREFIELD_INT64);
GET_LABELS(JIT_STOREFIELD_INT32);
GET_LABELS(JIT_STOREFIELD_INTNATIVE);
GET_LABELS(JIT_STOREFIELD_F32);
GET_LABELS(JIT_STOREFIELD_F64);
GET_LABELS(JIT_STOREFIELD_PTR);
GET_LABELS(JIT_STOREFIELD_O);
GET_LABELS(JIT_STOREFIELD_VALUETYPE);
GET_LABELS(JIT_LOADSTATICFIELD_CHECKTYPEINIT_INT32);
GET_LABELS(JIT_LOADSTATICFIELD_CHECKTYPEINIT_VALUETYPE);
GET_LABELS(JIT_LOADSTATICFIELD_CHECKTYPEINIT_O);
GET_LABELS(JIT_LOADSTATICFIELD_CHECKTYPEINIT_INTNATIVE);
GET_LABELS(JIT_LOADSTATICFIELD_CHECKTYPEINIT_PTR);
GET_LABELS(JIT_LOADSTATICFIELD_CHECKTYPEINIT_F32);
GET_LABELS(JIT_LOADSTATICFIELD_CHECKTYPEINIT_F64);
GET_LABELS(JIT_STORESTATICFIELD_INT32);
GET_LABELS(JIT_STORESTATICFIELD_INT64);
GET_LABELS(JIT_STORESTATICFIELD_O);
GET_LABELS(JIT_STORESTATICFIELD_F32);
GET_LABELS(JIT_STORESTATICFIELD_F64);
GET_LABELS(JIT_STORESTATICFIELD_INTNATIVE);
GET_LABELS(JIT_STORESTATICFIELD_PTR);
GET_LABELS(JIT_STORESTATICFIELD_VALUETYPE);
GET_LABELS(JIT_BOX_INT64);
GET_LABELS(JIT_BOX_INT32);
GET_LABELS(JIT_BOX_INTNATIVE);
GET_LABELS(JIT_BOX_F32);
GET_LABELS(JIT_BOX_F64);
GET_LABELS(JIT_BOX_O);
GET_LABELS(JIT_BOX_VALUETYPE);
GET_LABELS_DYNAMIC(JIT_CEQ_I32I32, 0);
GET_LABELS_DYNAMIC(JIT_CGT_I32I32, 0);
GET_LABELS_DYNAMIC(JIT_CGT_UN_I32I32, 0);
GET_LABELS_DYNAMIC(JIT_CLT_I32I32, 0);
GET_LABELS_DYNAMIC(JIT_CLT_UN_I32I32, 0);
GET_LABELS_DYNAMIC(JIT_CEQ_I64I64, 0);
GET_LABELS_DYNAMIC(JIT_CGT_I64I64, 0);
GET_LABELS_DYNAMIC(JIT_CGT_UN_I64I64, 0);
GET_LABELS_DYNAMIC(JIT_CLT_I64I64, 0);
GET_LABELS_DYNAMIC(JIT_CLT_UN_I64I64, 0);
GET_LABELS_DYNAMIC(JIT_ADD_OVF_I32I32, 0);
GET_LABELS_DYNAMIC(JIT_ADD_OVF_UN_I32I32, 0);
GET_LABELS_DYNAMIC(JIT_MUL_OVF_I32I32, 0);
GET_LABELS_DYNAMIC(JIT_MUL_OVF_UN_I32I32, 0);
GET_LABELS_DYNAMIC(JIT_SUB_OVF_I32I32, 0);
GET_LABELS_DYNAMIC(JIT_SUB_OVF_UN_I32I32, 0);
GET_LABELS_DYNAMIC(JIT_ADD_I32I32, 0);
GET_LABELS_DYNAMIC(JIT_SUB_I32I32, 0);
GET_LABELS_DYNAMIC(JIT_MUL_I32I32, 0);
GET_LABELS_DYNAMIC(JIT_DIV_I32I32, 0);
GET_LABELS_DYNAMIC(JIT_DIV_UN_I32I32, 0);
GET_LABELS_DYNAMIC(JIT_REM_I32I32, 0);
GET_LABELS_DYNAMIC(JIT_REM_UN_I32I32, 0);
GET_LABELS_DYNAMIC(JIT_AND_I32I32, 0);
GET_LABELS_DYNAMIC(JIT_OR_I32I32, 0);
GET_LABELS_DYNAMIC(JIT_XOR_I32I32, 0);
GET_LABELS_DYNAMIC(JIT_NEG_I32, 0);
GET_LABELS_DYNAMIC(JIT_NOT_I32, 0);
GET_LABELS_DYNAMIC(JIT_NEG_I64, 0);
GET_LABELS_DYNAMIC(JIT_NOT_I64, 0);
GET_LABELS(JIT_BOX_NULLABLE);
GET_LABELS_DYNAMIC(JIT_LOAD_F64, 8);
GET_LABELS(JIT_UNBOX_NULLABLE);
GET_LABELS(JIT_BEQ_I32I32);
GET_LABELS(JIT_BEQ_I64I64);
GET_LABELS(JIT_BEQ_F32F32);
GET_LABELS(JIT_BEQ_F64F64);
GET_LABELS(JIT_BGE_I32I32);
GET_LABELS(JIT_BGE_I64I64);
GET_LABELS(JIT_BGE_F32F32);
GET_LABELS(JIT_BGE_F64F64);
GET_LABELS(JIT_BGE_UN_F32F32);
GET_LABELS(JIT_BGE_UN_F64F64);
GET_LABELS(JIT_BGT_I32I32);
GET_LABELS(JIT_BGT_I64I64);
GET_LABELS(JIT_BGT_F32F32);
GET_LABELS(JIT_BGT_F64F64);
GET_LABELS(JIT_BGT_UN_F32F32);
GET_LABELS(JIT_BGT_UN_F64F64);
GET_LABELS(JIT_BLE_I32I32);
GET_LABELS(JIT_BLE_I64I64);
GET_LABELS(JIT_BLE_F32F32);
GET_LABELS(JIT_BLE_F64F64);
GET_LABELS(JIT_BLE_UN_F32F32);
GET_LABELS(JIT_BLE_UN_F64F64);
GET_LABELS(JIT_BLT_I32I32);
GET_LABELS(JIT_BLT_I64I64);
GET_LABELS(JIT_BLT_F32F32);
GET_LABELS(JIT_BLT_F64F64);
GET_LABELS(JIT_BLT_UN_F32F32);
GET_LABELS(JIT_BLT_UN_F64F64);
GET_LABELS(JIT_BNE_UN_I32I32);
GET_LABELS(JIT_BNE_UN_I64I64);
GET_LABELS(JIT_BNE_UN_F32F32);
GET_LABELS(JIT_BNE_UN_F64F64);
GET_LABELS(JIT_BGE_UN_I32I32);
GET_LABELS(JIT_BGT_UN_I32I32);
GET_LABELS(JIT_BLE_UN_I32I32);
GET_LABELS(JIT_BLT_UN_I32I32);
GET_LABELS_DYNAMIC(JIT_SHL_I32, 0);
GET_LABELS_DYNAMIC(JIT_SHR_I32, 0);
GET_LABELS_DYNAMIC(JIT_SHR_UN_I32, 0);
GET_LABELS_DYNAMIC(JIT_SHL_I64, 0);
GET_LABELS_DYNAMIC(JIT_SHR_I64, 0);
GET_LABELS_DYNAMIC(JIT_SHR_UN_I64, 0);
GET_LABELS(JIT_BRANCH_FALSE);
GET_LABELS(JIT_BRANCH_TRUE);
GET_LABELS(JIT_LOADTOKEN_TYPE);
GET_LABELS(JIT_LOADTOKEN_FIELD);
GET_LABELS(JIT_LOADINDIRECT_I8);
GET_LABELS(JIT_LOADINDIRECT_U8);
GET_LABELS(JIT_LOADINDIRECT_I16);
GET_LABELS(JIT_LOADINDIRECT_U16);
GET_LABELS(JIT_LOADINDIRECT_I32);
GET_LABELS(JIT_LOADINDIRECT_U32);
GET_LABELS(JIT_LOADINDIRECT_I64);
GET_LABELS(JIT_LOADINDIRECT_R32);
GET_LABELS(JIT_LOADINDIRECT_R64);
GET_LABELS(JIT_LOADINDIRECT_REF);
GET_LABELS(JIT_STOREINDIRECT_REF);
GET_LABELS(JIT_STOREINDIRECT_U8);
GET_LABELS(JIT_STOREINDIRECT_U16);
GET_LABELS(JIT_STOREINDIRECT_U32);
GET_LABELS_DYNAMIC(JIT_CONV_I32_I32, 4);
GET_LABELS_DYNAMIC(JIT_CONV_I32_U32, 4);
GET_LABELS_DYNAMIC(JIT_CONV_I32_I64, 0);
GET_LABELS_DYNAMIC(JIT_CONV_I32_U64, 0);
GET_LABELS_DYNAMIC(JIT_CONV_I32_R32, 0);
GET_LABELS_DYNAMIC(JIT_CONV_I32_R64, 0);
GET_LABELS_DYNAMIC(JIT_CONV_U32_I32, 4);
GET_LABELS_DYNAMIC(JIT_CONV_U32_U32, 4);
GET_LABELS_DYNAMIC(JIT_CONV_U32_I64, 0);
GET_LABELS_DYNAMIC(JIT_CONV_U32_U64, 0);
GET_LABELS_DYNAMIC(JIT_CONV_U32_R32, 0);
GET_LABELS_DYNAMIC(JIT_CONV_U32_R64, 0);
GET_LABELS_DYNAMIC(JIT_CONV_I64_I32, 4);
GET_LABELS_DYNAMIC(JIT_CONV_I64_U32, 4);
GET_LABELS_DYNAMIC(JIT_CONV_I64_U64, 0);
GET_LABELS_DYNAMIC(JIT_CONV_I64_R32, 0);
GET_LABELS_DYNAMIC(JIT_CONV_I64_R64, 0);
GET_LABELS_DYNAMIC(JIT_CONV_U64_I32, 4);
GET_LABELS_DYNAMIC(JIT_CONV_U64_U32, 4);
GET_LABELS_DYNAMIC(JIT_CONV_U64_I64, 0);
GET_LABELS_DYNAMIC(JIT_CONV_U64_R32, 0);
GET_LABELS_DYNAMIC(JIT_CONV_U64_R64, 0);
GET_LABELS_DYNAMIC(JIT_CONV_R32_I32, 4);
GET_LABELS_DYNAMIC(JIT_CONV_R32_U32, 4);
GET_LABELS_DYNAMIC(JIT_CONV_R32_I64, 0);
GET_LABELS_DYNAMIC(JIT_CONV_R32_U64, 0);
GET_LABELS_DYNAMIC(JIT_CONV_R32_R32, 0);
GET_LABELS_DYNAMIC(JIT_CONV_R32_R64, 0);
GET_LABELS_DYNAMIC(JIT_CONV_R64_I32, 4);
GET_LABELS_DYNAMIC(JIT_CONV_R64_U32, 4);
GET_LABELS_DYNAMIC(JIT_CONV_R64_I64, 0);
GET_LABELS_DYNAMIC(JIT_CONV_R64_U64, 0);
GET_LABELS_DYNAMIC(JIT_CONV_R64_R32, 0);
GET_LABELS_DYNAMIC(JIT_CONV_R64_R64, 0);
GET_LABELS(JIT_STORE_ELEMENT_32);
GET_LABELS(JIT_STORE_ELEMENT_64);
GET_LABELS(JIT_LOAD_ELEMENT_I8);
GET_LABELS(JIT_LOAD_ELEMENT_U8);
GET_LABELS(JIT_LOAD_ELEMENT_I16);
GET_LABELS(JIT_LOAD_ELEMENT_U16);
GET_LABELS(JIT_LOAD_ELEMENT_I32);
GET_LABELS(JIT_LOAD_ELEMENT_U32);
GET_LABELS(JIT_LOAD_ELEMENT_I64);
GET_LABELS(JIT_LOAD_ELEMENT_R32);
GET_LABELS(JIT_LOAD_ELEMENT_R64);
GET_LABELS_DYNAMIC(JIT_ADD_I64I64, 0);
GET_LABELS_DYNAMIC(JIT_SUB_I64I64, 0);
GET_LABELS_DYNAMIC(JIT_MUL_I64I64, 0);
GET_LABELS_DYNAMIC(JIT_DIV_I64I64, 0);
GET_LABELS_DYNAMIC(JIT_DIV_UN_I64I64, 0);
GET_LABELS_DYNAMIC(JIT_REM_I64I64, 0);
GET_LABELS_DYNAMIC(JIT_REM_UN_I64I64, 0);
GET_LABELS_DYNAMIC(JIT_AND_I64I64, 0);
GET_LABELS_DYNAMIC(JIT_OR_I64I64, 0);
GET_LABELS_DYNAMIC(JIT_XOR_I64I64, 0);
GET_LABELS_DYNAMIC(JIT_CEQ_F32F32, 0);
GET_LABELS_DYNAMIC(JIT_CGT_F32F32, 0);
GET_LABELS_DYNAMIC(JIT_CLT_F32F32, 0);
GET_LABELS_DYNAMIC(JIT_CEQ_F64F64, 0);
GET_LABELS_DYNAMIC(JIT_CGT_F64F64, 0);
GET_LABELS_DYNAMIC(JIT_CLT_F64F64, 0);
GET_LABELS_DYNAMIC(JIT_ADD_F32F32, 0);
GET_LABELS_DYNAMIC(JIT_ADD_F64F64, 0);
GET_LABELS_DYNAMIC(JIT_SUB_F32F32, 0);
GET_LABELS_DYNAMIC(JIT_SUB_F64F64, 0);
GET_LABELS_DYNAMIC(JIT_MUL_F32F32, 0);
GET_LABELS_DYNAMIC(JIT_MUL_F64F64, 0);
GET_LABELS_DYNAMIC(JIT_DIV_F32F32, 0);
GET_LABELS_DYNAMIC(JIT_DIV_F64F64, 0);
GET_LABELS_DYNAMIC(JIT_LOAD_I4_M1, 0);
GET_LABELS_DYNAMIC(JIT_LOAD_I4_0, 0);
GET_LABELS_DYNAMIC(JIT_LOAD_I4_1, 0);
GET_LABELS_DYNAMIC(JIT_LOAD_I4_2, 0);
GET_LABELS_DYNAMIC(JIT_LOADFIELD_4, 4);
return 0;
}
#ifdef DIAG_OPCODE_TIMES
U64 opcodeStartTime = rdtsc();
U32 realOp;
#endif
LOAD_METHOD_STATE();
GO_NEXT();
noCode:
Crash("No code for op-code");
JIT_NOP_start:
JIT_CONV_R32_R32_start:
JIT_CONV_R64_R64_start:
JIT_CONV_I64_U64_start:
JIT_CONV_U64_I64_start:
OPCODE_USE(JIT_NOP);
JIT_NOP_end:
JIT_CONV_R32_R32_end:
JIT_CONV_R64_R64_end:
JIT_CONV_I64_U64_end:
JIT_CONV_U64_I64_end:
JIT_GoNext_start:
GO_NEXT();
JIT_GoNext_end:
JIT_LOAD_NULL_start:
OPCODE_USE(JIT_LOAD_NULL);
PUSH_O(NULL);
JIT_LOAD_NULL_end:
GO_NEXT();
JIT_DUP_4_start:
OPCODE_USE(JIT_DUP_4);
DUP4();
JIT_DUP_4_end:
GO_NEXT();
JIT_DUP_8_start:
OPCODE_USE(JIT_DUP_8);
DUP8();
JIT_DUP_8_end:
GO_NEXT();
JIT_DUP_GENERAL_start:
OPCODE_USE(JIT_DUP_GENERAL);
{
U32 dupSize = GET_OP();
DUP(dupSize);
}
JIT_DUP_GENERAL_end:
GO_NEXT();
JIT_POP_start:
OPCODE_USE(JIT_POP);
{
U32 popSize = GET_OP();
POP(popSize);
}
JIT_POP_end:
GO_NEXT();
JIT_POP_4_start:
OPCODE_USE(JIT_POP_4);
POP(4);
JIT_POP_4_end:
GO_NEXT();
JIT_LOAD_I32_start:
JIT_LOAD_F32_start:
OPCODE_USE(JIT_LOAD_I32);
{
I32 value = GET_OP();
PUSH_U32(value);
}
JIT_LOAD_I32_end:
JIT_LOAD_F32_end:
GO_NEXT();
JIT_LOAD_I4_M1_start:
OPCODE_USE(JIT_LOAD_I4_M1);
PUSH_U32(-1);
JIT_LOAD_I4_M1_end:
GO_NEXT();
JIT_LOAD_I4_0_start:
OPCODE_USE(JIT_LOAD_I4_0);
PUSH_U32(0);
JIT_LOAD_I4_0_end:
GO_NEXT();
JIT_LOAD_I4_1_start:
OPCODE_USE(JIT_LOAD_I4_1);
PUSH_U32(1);
JIT_LOAD_I4_1_end:
GO_NEXT();
JIT_LOAD_I4_2_start:
OPCODE_USE(JIT_LOAD_I4_2);
PUSH_U32(2);
JIT_LOAD_I4_2_end:
GO_NEXT();
JIT_LOAD_I64_start:
JIT_LOAD_F64_start:
OPCODE_USE(JIT_LOAD_I64);
{
U64 value = *(U64*)pCurOp;
pCurOp += 2;
PUSH_U64(value);
}
JIT_LOAD_I64_end:
JIT_LOAD_F64_end:
GO_NEXT();
JIT_LOADPARAMLOCAL_INT32_start:
JIT_LOADPARAMLOCAL_F32_start:
JIT_LOADPARAMLOCAL_O_start:
JIT_LOADPARAMLOCAL_INTNATIVE_start: // Only on 32-bit
JIT_LOADPARAMLOCAL_PTR_start: // Only on 32-bit
OPCODE_USE(JIT_LOADPARAMLOCAL_INT32);
{
U32 ofs = GET_OP();
U32 value = PARAMLOCAL_U32(ofs);
PUSH_U32(value);
}
JIT_LOADPARAMLOCAL_INT32_end:
JIT_LOADPARAMLOCAL_F32_end:
JIT_LOADPARAMLOCAL_O_end:
JIT_LOADPARAMLOCAL_INTNATIVE_end:
JIT_LOADPARAMLOCAL_PTR_end:
GO_NEXT();
JIT_LOADPARAMLOCAL_INT64_start:
JIT_LOADPARAMLOCAL_F64_start:
OPCODE_USE(JIT_LOADPARAMLOCAL_INT64);
{
U32 ofs = GET_OP();
U64 value = PARAMLOCAL_U64(ofs);
PUSH_U64(value);
}
JIT_LOADPARAMLOCAL_INT64_end:
JIT_LOADPARAMLOCAL_F64_end:
GO_NEXT();
JIT_LOADPARAMLOCAL_VALUETYPE_start:
OPCODE_USE(JIT_LOADPARAMLOCAL_VALUETYPE);
{
tMD_TypeDef *pTypeDef;
U32 ofs;
PTR pMem;
ofs = GET_OP();
pTypeDef = (tMD_TypeDef*)GET_OP();
pMem = pParamsLocals + ofs;
PUSH_VALUETYPE(pMem, pTypeDef->stackSize, pTypeDef->stackSize);
}
JIT_LOADPARAMLOCAL_VALUETYPE_end:
GO_NEXT();
JIT_LOADPARAMLOCAL_0_start:
OPCODE_USE(JIT_LOADPARAMLOCAL_0);
PUSH_U32(PARAMLOCAL_U32(0));
JIT_LOADPARAMLOCAL_0_end:
GO_NEXT();
JIT_LOADPARAMLOCAL_1_start:
OPCODE_USE(JIT_LOADPARAMLOCAL_1);
PUSH_U32(PARAMLOCAL_U32(4));
JIT_LOADPARAMLOCAL_1_end:
GO_NEXT();
JIT_LOADPARAMLOCAL_2_start:
OPCODE_USE(JIT_LOADPARAMLOCAL_2);
PUSH_U32(PARAMLOCAL_U32(8));
JIT_LOADPARAMLOCAL_2_end:
GO_NEXT();
JIT_LOADPARAMLOCAL_3_start:
OPCODE_USE(JIT_LOADPARAMLOCAL_3);
PUSH_U32(PARAMLOCAL_U32(12));
JIT_LOADPARAMLOCAL_3_end:
GO_NEXT();
JIT_LOADPARAMLOCAL_4_start:
OPCODE_USE(JIT_LOADPARAMLOCAL_4);
PUSH_U32(PARAMLOCAL_U32(16));
JIT_LOADPARAMLOCAL_4_end:
GO_NEXT();
JIT_LOADPARAMLOCAL_5_start:
OPCODE_USE(JIT_LOADPARAMLOCAL_5);
PUSH_U32(PARAMLOCAL_U32(20));
JIT_LOADPARAMLOCAL_5_end:
GO_NEXT();
JIT_LOADPARAMLOCAL_6_start:
OPCODE_USE(JIT_LOADPARAMLOCAL_6);
PUSH_U32(PARAMLOCAL_U32(24));
JIT_LOADPARAMLOCAL_6_end:
GO_NEXT();
JIT_LOADPARAMLOCAL_7_start:
OPCODE_USE(JIT_LOADPARAMLOCAL_7);
PUSH_U32(PARAMLOCAL_U32(28));
JIT_LOADPARAMLOCAL_7_end:
GO_NEXT();
JIT_LOAD_PARAMLOCAL_ADDR_start:
OPCODE_USE(JIT_LOAD_PARAMLOCAL_ADDR);
{
U32 ofs = GET_OP();
PTR pMem = pParamsLocals + ofs;
PUSH_PTR(pMem);
}
JIT_LOAD_PARAMLOCAL_ADDR_end:
GO_NEXT();
JIT_STOREPARAMLOCAL_INT32_start:
JIT_STOREPARAMLOCAL_F32_start:
JIT_STOREPARAMLOCAL_O_start:
JIT_STOREPARAMLOCAL_INTNATIVE_start: // Only on 32-bit
JIT_STOREPARAMLOCAL_PTR_start: // Onlt on 32-bit
OPCODE_USE(JIT_STOREPARAMLOCAL_INT32);
{
U32 ofs = GET_OP();
U32 value = POP_U32();
PARAMLOCAL_U32(ofs) = value;
}
JIT_STOREPARAMLOCAL_INT32_end:
JIT_STOREPARAMLOCAL_F32_end:
JIT_STOREPARAMLOCAL_O_end:
JIT_STOREPARAMLOCAL_INTNATIVE_end:
JIT_STOREPARAMLOCAL_PTR_end:
GO_NEXT();
JIT_STOREPARAMLOCAL_INT64_start:
JIT_STOREPARAMLOCAL_F64_start:
OPCODE_USE(JIT_STOREPARAMLOCAL_INT64);
{
U32 ofs = GET_OP();
U64 value = POP_U64();
PARAMLOCAL_U64(ofs) = value;
}
JIT_STOREPARAMLOCAL_INT64_end:
JIT_STOREPARAMLOCAL_F64_end:
GO_NEXT();
JIT_STOREPARAMLOCAL_VALUETYPE_start:
OPCODE_USE(JIT_STOREPARAMLOCAL_VALUETYPE);
{
tMD_TypeDef *pTypeDef;
U32 ofs;
PTR pMem;
ofs = GET_OP();
pTypeDef = (tMD_TypeDef*)GET_OP();
pMem = pParamsLocals + ofs;
POP_VALUETYPE(pMem, pTypeDef->stackSize, pTypeDef->stackSize);
}
JIT_STOREPARAMLOCAL_VALUETYPE_end:
GO_NEXT();
JIT_STOREPARAMLOCAL_0_start:
OPCODE_USE(JIT_STOREPARAMLOCAL_0);
PARAMLOCAL_U32(0) = POP_U32();
JIT_STOREPARAMLOCAL_0_end:
GO_NEXT();
JIT_STOREPARAMLOCAL_1_start:
OPCODE_USE(JIT_STOREPARAMLOCAL_1);
PARAMLOCAL_U32(4) = POP_U32();
JIT_STOREPARAMLOCAL_1_end:
GO_NEXT();
JIT_STOREPARAMLOCAL_2_start:
OPCODE_USE(JIT_STOREPARAMLOCAL_2);
PARAMLOCAL_U32(8) = POP_U32();
JIT_STOREPARAMLOCAL_2_end:
GO_NEXT();
JIT_STOREPARAMLOCAL_3_start:
OPCODE_USE(JIT_STOREPARAMLOCAL_3);
PARAMLOCAL_U32(12) = POP_U32();
JIT_STOREPARAMLOCAL_3_end:
GO_NEXT();
JIT_STOREPARAMLOCAL_4_start:
OPCODE_USE(JIT_STOREPARAMLOCAL_4);
PARAMLOCAL_U32(16) = POP_U32();
JIT_STOREPARAMLOCAL_4_end:
GO_NEXT();
JIT_STOREPARAMLOCAL_5_start:
OPCODE_USE(JIT_STOREPARAMLOCAL_5);
PARAMLOCAL_U32(20) = POP_U32();
JIT_STOREPARAMLOCAL_5_end:
GO_NEXT();
JIT_STOREPARAMLOCAL_6_start:
OPCODE_USE(JIT_STOREPARAMLOCAL_6);
PARAMLOCAL_U32(24) = POP_U32();
JIT_STOREPARAMLOCAL_6_end:
GO_NEXT();
JIT_STOREPARAMLOCAL_7_start:
OPCODE_USE(JIT_STOREPARAMLOCAL_7);
PARAMLOCAL_U32(28) = POP_U32();
JIT_STOREPARAMLOCAL_7_end:
GO_NEXT();
JIT_LOADINDIRECT_I8_start:
JIT_LOADINDIRECT_I16_start:
JIT_LOADINDIRECT_I32_start:
JIT_LOADINDIRECT_U8_start:
JIT_LOADINDIRECT_U16_start:
JIT_LOADINDIRECT_U32_start:
JIT_LOADINDIRECT_R32_start:
JIT_LOADINDIRECT_REF_start:
OPCODE_USE(JIT_LOADINDIRECT_U32);
{
PTR pMem = POP_PTR();
U32 value = *(U32*)pMem;
PUSH_U32(value);
}
JIT_LOADINDIRECT_I8_end:
JIT_LOADINDIRECT_I16_end:
JIT_LOADINDIRECT_I32_end:
JIT_LOADINDIRECT_U8_end:
JIT_LOADINDIRECT_U16_end:
JIT_LOADINDIRECT_U32_end:
JIT_LOADINDIRECT_R32_end:
JIT_LOADINDIRECT_REF_end:
GO_NEXT();
JIT_LOADINDIRECT_R64_start:
JIT_LOADINDIRECT_I64_start:
OPCODE_USE(JIT_LOADINDIRECT_I64);
{
PTR pMem = POP_PTR();
U64 value = *(U64*)pMem;
PUSH_U64(value);
}
JIT_LOADINDIRECT_R64_end:
JIT_LOADINDIRECT_I64_end:
GO_NEXT();
JIT_STOREINDIRECT_U8_start:
JIT_STOREINDIRECT_U16_start:
JIT_STOREINDIRECT_U32_start:
JIT_STOREINDIRECT_REF_start:
OPCODE_USE(JIT_STOREINDIRECT_U32);
{
U32 value = POP_U32(); // The value to store
PTR pMem = POP_PTR(); // The address to store to
*(U32*)pMem = value;
}
JIT_STOREINDIRECT_U8_end:
JIT_STOREINDIRECT_U16_end:
JIT_STOREINDIRECT_U32_end:
JIT_STOREINDIRECT_REF_end:
GO_NEXT();
JIT_STORE_OBJECT_VALUETYPE_start:
OPCODE_USE(JIT_STORE_OBJECT_VALUETYPE);
{
U32 size = GET_OP(); // The size, in bytes, of the value-type to store
U32 memSize = (size<4)?4:size;
PTR pMem = pCurEvalStack - memSize - sizeof(void*);
POP_VALUETYPE(*(void**)pMem, size, memSize);
POP(4);
}
JIT_STORE_OBJECT_VALUETYPE_end:
GO_NEXT();
JIT_CALL_PINVOKE_start:
OPCODE_USE(JIT_CALL_PINVOKE);
{
tJITCallPInvoke *pCallPInvoke;
U32 res;
pCallPInvoke = (tJITCallPInvoke*)(pCurOp - 1);
res = PInvoke_Call(pCallPInvoke, pParamsLocals, pCurrentMethodState->pEvalStack);
pCurrentMethodState->stackOfs = res;
}
goto JIT_RETURN_start;
JIT_CALL_PINVOKE_end:
JIT_CALL_NATIVE_start:
OPCODE_USE(JIT_CALL_NATIVE);
{
tJITCallNative *pCallNative;
PTR pThis;
U32 thisOfs;
tAsyncCall *pAsync;
//pCallNative = (tJITCallNative*)&(pJIT->pOps[pCurrentMethodState->ipOffset - 1]);
pCallNative = (tJITCallNative*)(pCurOp - 1);
if (METHOD_ISSTATIC(pCallNative->pMethodDef)) {
pThis = NULL;
thisOfs = 0;
} else {
pThis = *(PTR*)pCurrentMethodState->pParamsLocals;
thisOfs = 4;
}
// Internal constructors MUST leave the newly created object in the return value
// (ie on top of the evaluation stack)
pAsync = pCallNative->fn(pThis, pCurrentMethodState->pParamsLocals + thisOfs, pCurrentMethodState->pEvalStack);
if (pAsync != NULL) {
// Save the method state
SAVE_METHOD_STATE();
// Change the IP pointer to point to the return instruction
pCurrentMethodState->ipOffset = 3;
// Handle special async codes
if (pAsync == ASYNC_LOCK_EXIT) {
return THREAD_STATUS_LOCK_EXIT;
}
// Set the async in the thread
pThread->pAsync = pAsync;
return THREAD_STATUS_ASYNC;
}