-
Notifications
You must be signed in to change notification settings - Fork 67
/
DruidJIT.class.st
14864 lines (14127 loc) · 441 KB
/
DruidJIT.class.st
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
Class {
#name : #DruidJIT,
#superclass : #StackToRegisterMappingCogit,
#instVars : [
'ceDereferenceSelectorIndex',
'ceStoreTrampolines',
'ceNewHashTrampoline',
'ceInlineNewHashTrampoline',
'ceStoreCheckTrampoline',
'ceStoreCheckContextReceiverTrampoline',
'ceScheduleScavengeTrampoline',
'ceSmallActiveContextInMethodTrampoline',
'ceSmallActiveContextInFullBlockTrampoline',
'ceLargeActiveContextInMethodTrampoline',
'ceLargeActiveContextInFullBlockTrampoline'
],
#classVars : [
'CheckRememberedInTrampoline',
'NumStoreTrampolines'
],
#category : #'VMMaker-JIT'
}
{ #category : #'class initialization' }
DruidJIT class >> bytecodeTable [
<generated>
^ {
{ 1. 0. 0. #gen_PushReceiverVariableBytecode0.
#isInstVarRef }.
{ 1. 1. 1. #gen_PushReceiverVariableBytecode1.
#isInstVarRef }.
{ 1. 2. 2. #gen_PushReceiverVariableBytecode2.
#isInstVarRef }.
{ 1. 3. 3. #gen_PushReceiverVariableBytecode3.
#isInstVarRef }.
{ 1. 4. 4. #gen_PushReceiverVariableBytecode4.
#isInstVarRef }.
{ 1. 5. 5. #gen_PushReceiverVariableBytecode5.
#isInstVarRef }.
{ 1. 6. 6. #gen_PushReceiverVariableBytecode6.
#isInstVarRef }.
{ 1. 7. 7. #gen_PushReceiverVariableBytecode7.
#isInstVarRef }.
{ 1. 8. 8. #gen_PushReceiverVariableBytecode8.
#isInstVarRef }.
{ 1. 9. 9. #gen_PushReceiverVariableBytecode9.
#isInstVarRef }.
{ 1. 10. 10. #gen_PushReceiverVariableBytecode10.
#isInstVarRef }.
{ 1. 11. 11. #gen_PushReceiverVariableBytecode11.
#isInstVarRef }.
{ 1. 12. 12. #gen_PushReceiverVariableBytecode12.
#isInstVarRef }.
{ 1. 13. 13. #gen_PushReceiverVariableBytecode13.
#isInstVarRef }.
{ 1. 14. 14. #gen_PushReceiverVariableBytecode14.
#isInstVarRef }.
{ 1. 15. 15. #gen_PushReceiverVariableBytecode15.
#isInstVarRef }.
{ 1. 16. 16. #gen_PushLiteralVariable16CasesBytecode0.
#needsFrameNever:. 1 }.
{ 1. 17. 17. #gen_PushLiteralVariable16CasesBytecode1.
#needsFrameNever:. 1 }.
{ 1. 18. 18. #gen_PushLiteralVariable16CasesBytecode2.
#needsFrameNever:. 1 }.
{ 1. 19. 19. #gen_PushLiteralVariable16CasesBytecode3.
#needsFrameNever:. 1 }.
{ 1. 20. 20. #gen_PushLiteralVariable16CasesBytecode4.
#needsFrameNever:. 1 }.
{ 1. 21. 21. #gen_PushLiteralVariable16CasesBytecode5.
#needsFrameNever:. 1 }.
{ 1. 22. 22. #gen_PushLiteralVariable16CasesBytecode6.
#needsFrameNever:. 1 }.
{ 1. 23. 23. #gen_PushLiteralVariable16CasesBytecode7.
#needsFrameNever:. 1 }.
{ 1. 24. 24. #gen_PushLiteralVariable16CasesBytecode8.
#needsFrameNever:. 1 }.
{ 1. 25. 25. #gen_PushLiteralVariable16CasesBytecode9.
#needsFrameNever:. 1 }.
{ 1. 26. 26. #gen_PushLiteralVariable16CasesBytecode10.
#needsFrameNever:. 1 }.
{ 1. 27. 27. #gen_PushLiteralVariable16CasesBytecode11.
#needsFrameNever:. 1 }.
{ 1. 28. 28. #gen_PushLiteralVariable16CasesBytecode12.
#needsFrameNever:. 1 }.
{ 1. 29. 29. #gen_PushLiteralVariable16CasesBytecode13.
#needsFrameNever:. 1 }.
{ 1. 30. 30. #gen_PushLiteralVariable16CasesBytecode14.
#needsFrameNever:. 1 }.
{ 1. 31. 31. #gen_PushLiteralVariable16CasesBytecode15.
#needsFrameNever:. 1 }.
{ 1. 32. 32. #gen_PushLiteralConstantBytecode0.
#needsFrameNever:. 1 }.
{ 1. 33. 33. #gen_PushLiteralConstantBytecode1.
#needsFrameNever:. 1 }.
{ 1. 34. 34. #gen_PushLiteralConstantBytecode2.
#needsFrameNever:. 1 }.
{ 1. 35. 35. #gen_PushLiteralConstantBytecode3.
#needsFrameNever:. 1 }.
{ 1. 36. 36. #gen_PushLiteralConstantBytecode4.
#needsFrameNever:. 1 }.
{ 1. 37. 37. #gen_PushLiteralConstantBytecode5.
#needsFrameNever:. 1 }.
{ 1. 38. 38. #gen_PushLiteralConstantBytecode6.
#needsFrameNever:. 1 }.
{ 1. 39. 39. #gen_PushLiteralConstantBytecode7.
#needsFrameNever:. 1 }.
{ 1. 40. 40. #gen_PushLiteralConstantBytecode8.
#needsFrameNever:. 1 }.
{ 1. 41. 41. #gen_PushLiteralConstantBytecode9.
#needsFrameNever:. 1 }.
{ 1. 42. 42. #gen_PushLiteralConstantBytecode10.
#needsFrameNever:. 1 }.
{ 1. 43. 43. #gen_PushLiteralConstantBytecode11.
#needsFrameNever:. 1 }.
{ 1. 44. 44. #gen_PushLiteralConstantBytecode12.
#needsFrameNever:. 1 }.
{ 1. 45. 45. #gen_PushLiteralConstantBytecode13.
#needsFrameNever:. 1 }.
{ 1. 46. 46. #gen_PushLiteralConstantBytecode14.
#needsFrameNever:. 1 }.
{ 1. 47. 47. #gen_PushLiteralConstantBytecode15.
#needsFrameNever:. 1 }.
{ 1. 48. 48. #gen_PushLiteralConstantBytecode16.
#needsFrameNever:. 1 }.
{ 1. 49. 49. #gen_PushLiteralConstantBytecode17.
#needsFrameNever:. 1 }.
{ 1. 50. 50. #gen_PushLiteralConstantBytecode18.
#needsFrameNever:. 1 }.
{ 1. 51. 51. #gen_PushLiteralConstantBytecode19.
#needsFrameNever:. 1 }.
{ 1. 52. 52. #gen_PushLiteralConstantBytecode20.
#needsFrameNever:. 1 }.
{ 1. 53. 53. #gen_PushLiteralConstantBytecode21.
#needsFrameNever:. 1 }.
{ 1. 54. 54. #gen_PushLiteralConstantBytecode22.
#needsFrameNever:. 1 }.
{ 1. 55. 55. #gen_PushLiteralConstantBytecode23.
#needsFrameNever:. 1 }.
{ 1. 56. 56. #gen_PushLiteralConstantBytecode24.
#needsFrameNever:. 1 }.
{ 1. 57. 57. #gen_PushLiteralConstantBytecode25.
#needsFrameNever:. 1 }.
{ 1. 58. 58. #gen_PushLiteralConstantBytecode26.
#needsFrameNever:. 1 }.
{ 1. 59. 59. #gen_PushLiteralConstantBytecode27.
#needsFrameNever:. 1 }.
{ 1. 60. 60. #gen_PushLiteralConstantBytecode28.
#needsFrameNever:. 1 }.
{ 1. 61. 61. #gen_PushLiteralConstantBytecode29.
#needsFrameNever:. 1 }.
{ 1. 62. 62. #gen_PushLiteralConstantBytecode30.
#needsFrameNever:. 1 }.
{ 1. 63. 63. #gen_PushLiteralConstantBytecode31.
#needsFrameNever:. 1 }.
{ 1. 64. 64. #gen_PushTemporaryVariableBytecode0 }.
{ 1. 65. 65. #gen_PushTemporaryVariableBytecode1 }.
{ 1. 66. 66. #gen_PushTemporaryVariableBytecode2 }.
{ 1. 67. 67. #gen_PushTemporaryVariableBytecode3 }.
{ 1. 68. 68. #gen_PushTemporaryVariableBytecode4 }.
{ 1. 69. 69. #gen_PushTemporaryVariableBytecode5 }.
{ 1. 70. 70. #gen_PushTemporaryVariableBytecode6 }.
{ 1. 71. 71. #gen_PushTemporaryVariableBytecode7 }.
{ 1. 72. 72. #gen_PushTemporaryVariableBytecode8 }.
{ 1. 73. 73. #gen_PushTemporaryVariableBytecode9 }.
{ 1. 74. 74. #gen_PushTemporaryVariableBytecode10 }.
{ 1. 75. 75. #gen_PushTemporaryVariableBytecode11 }.
{ 1. 76. 76. #gen_PushReceiverBytecode }.
{ 1. 77. 77. #gen_PushConstantTrueBytecode.
#needsFrameNever:. 1 }.
{ 1. 78. 78. #gen_PushConstantFalseBytecode.
#needsFrameNever:. 1 }.
{ 1. 79. 79. #gen_PushConstantNilBytecode.
#needsFrameNever:. 1 }.
{ 1. 80. 80. #gen_PushConstantZeroBytecode.
#needsFrameNever:. 1 }.
{ 1. 81. 81. #gen_PushConstantOneBytecode.
#needsFrameNever:. 1 }.
{ 1. 82. 82. #unknownBytecode }.
{ 1. 83. 83. #gen_DuplicateTopBytecode. #needsFrameNever:.
1 }.
{ 1. 84. 84. #unknownBytecode }.
{ 1. 85. 85. #unknownBytecode }.
{ 1. 86. 86. #unknownBytecode }.
{ 1. 87. 87. #unknownBytecode }.
{ 1. 88. 88. #gen_ReturnReceiver. #return. #isMappedInBlock.
#needsFrameIfInBlock:. 0 }.
{ 1. 89. 89. #gen_ReturnTrue. #return. #isMappedInBlock.
#needsFrameIfInBlock:. 0 }.
{ 1. 90. 90. #gen_ReturnFalse. #return. #isMappedInBlock.
#needsFrameIfInBlock:. 0 }.
{ 1. 91. 91. #gen_ReturnNil. #return. #isMappedInBlock.
#needsFrameIfInBlock:. 0 }.
{ 1. 92. 92. #gen_ReturnTopFromMethod. #return. #isMappedInBlock.
#needsFrameIfInBlock:. -1 }.
{ 1. 93. 93. #gen_ReturnNilFromBlock. #return. #needsFrameNever:.
-1 }.
{ 1. 94. 94. #gen_ReturnTopFromBlock. #return. #needsFrameNever:.
-1 }.
{ 1. 95. 95. #gen_ExtNopBytecode. #needsFrameNever:.
0 }.
{ 1. 96. 96. #gen_BytecodePrimAdd. #isMapped }.
{ 1. 97. 97. #gen_BytecodePrimSubtract. #isMapped }.
{ 1. 98. 98. #gen_BytecodePrimLessThanSistaV1.
#isMapped }.
{ 1. 99. 99. #gen_BytecodePrimGreaterThanSistaV1.
#isMapped }.
{ 1. 100. 100. #gen_BytecodePrimLessOrEqualSistaV1.
#isMapped }.
{ 1. 101. 101. #gen_BytecodePrimGreaterOrEqualSistaV1.
#isMapped }.
{ 1. 102. 102. #gen_BytecodePrimEqualSistaV1.
#isMapped }.
{ 1. 103. 103. #gen_BytecodePrimNotEqualSistaV1.
#isMapped }.
{ 1. 104. 104. #gen_BytecodePrimMultiply. #isMapped }.
{ 1. 105. 105. #gen_BytecodePrimDivide. #isMapped }.
{ 1. 106. 106. #gen_BytecodePrimMod. #isMapped }.
{ 1. 107. 107. #gen_BytecodePrimMakePoint.
#isMapped }.
{ 1. 108. 108. #gen_BytecodePrimBitShift. #isMapped }.
{ 1. 109. 109. #gen_BytecodePrimDiv. #isMapped }.
{ 1. 110. 110. #gen_BytecodePrimBitAnd. #isMapped }.
{ 1. 111. 111. #gen_BytecodePrimBitOr. #isMapped }.
{ 1. 112. 112. #gen_BytecodePrimAt. #isMapped }.
{ 1. 113. 113. #gen_BytecodePrimAtPut. #isMapped }.
{ 1. 114. 114. #gen_BytecodePrimSize. #isMapped }.
{ 1. 115. 115. #gen_BytecodePrimNext. #isMapped }.
{ 1. 116. 116. #gen_BytecodePrimNextPut. #isMapped }.
{ 1. 117. 117. #gen_BytecodePrimAtEnd. #isMapped }.
{ 1. 118. 118. #gen_BytecodePrimIdenticalSistaV1 }.
{ 1. 119. 119. #unknownBytecode }.
{ 1. 120. 120. #gen_BytecodePrimNotIdenticalSistaV1 }.
{ 1. 121. 121. #gen_BytecodePrimValue. #isMapped }.
{ 1. 122. 122. #gen_BytecodePrimValueWithArg.
#isMapped }.
{ 1. 123. 123. #gen_BytecodePrimDo. #isMapped }.
{ 1. 124. 124. #gen_BytecodePrimNew. #isMapped }.
{ 1. 125. 125. #gen_BytecodePrimNewWithArg.
#isMapped }.
{ 1. 126. 126. #gen_BytecodePrimPointX. #isMapped }.
{ 1. 127. 127. #gen_BytecodePrimPointY. #isMapped }.
{ 1. 128. 128. #gen_SendLiteralSelector0ArgsBytecode0.
#isMapped }.
{ 1. 129. 129. #gen_SendLiteralSelector0ArgsBytecode1.
#isMapped }.
{ 1. 130. 130. #gen_SendLiteralSelector0ArgsBytecode2.
#isMapped }.
{ 1. 131. 131. #gen_SendLiteralSelector0ArgsBytecode3.
#isMapped }.
{ 1. 132. 132. #gen_SendLiteralSelector0ArgsBytecode4.
#isMapped }.
{ 1. 133. 133. #gen_SendLiteralSelector0ArgsBytecode5.
#isMapped }.
{ 1. 134. 134. #gen_SendLiteralSelector0ArgsBytecode6.
#isMapped }.
{ 1. 135. 135. #gen_SendLiteralSelector0ArgsBytecode7.
#isMapped }.
{ 1. 136. 136. #gen_SendLiteralSelector0ArgsBytecode8.
#isMapped }.
{ 1. 137. 137. #gen_SendLiteralSelector0ArgsBytecode9.
#isMapped }.
{ 1. 138. 138. #gen_SendLiteralSelector0ArgsBytecode10.
#isMapped }.
{ 1. 139. 139. #gen_SendLiteralSelector0ArgsBytecode11.
#isMapped }.
{ 1. 140. 140. #gen_SendLiteralSelector0ArgsBytecode12.
#isMapped }.
{ 1. 141. 141. #gen_SendLiteralSelector0ArgsBytecode13.
#isMapped }.
{ 1. 142. 142. #gen_SendLiteralSelector0ArgsBytecode14.
#isMapped }.
{ 1. 143. 143. #gen_SendLiteralSelector0ArgsBytecode15.
#isMapped }.
{ 1. 144. 144. #gen_SendLiteralSelector1ArgBytecode0.
#isMapped }.
{ 1. 145. 145. #gen_SendLiteralSelector1ArgBytecode1.
#isMapped }.
{ 1. 146. 146. #gen_SendLiteralSelector1ArgBytecode2.
#isMapped }.
{ 1. 147. 147. #gen_SendLiteralSelector1ArgBytecode3.
#isMapped }.
{ 1. 148. 148. #gen_SendLiteralSelector1ArgBytecode4.
#isMapped }.
{ 1. 149. 149. #gen_SendLiteralSelector1ArgBytecode5.
#isMapped }.
{ 1. 150. 150. #gen_SendLiteralSelector1ArgBytecode6.
#isMapped }.
{ 1. 151. 151. #gen_SendLiteralSelector1ArgBytecode7.
#isMapped }.
{ 1. 152. 152. #gen_SendLiteralSelector1ArgBytecode8.
#isMapped }.
{ 1. 153. 153. #gen_SendLiteralSelector1ArgBytecode9.
#isMapped }.
{ 1. 154. 154. #gen_SendLiteralSelector1ArgBytecode10.
#isMapped }.
{ 1. 155. 155. #gen_SendLiteralSelector1ArgBytecode11.
#isMapped }.
{ 1. 156. 156. #gen_SendLiteralSelector1ArgBytecode12.
#isMapped }.
{ 1. 157. 157. #gen_SendLiteralSelector1ArgBytecode13.
#isMapped }.
{ 1. 158. 158. #gen_SendLiteralSelector1ArgBytecode14.
#isMapped }.
{ 1. 159. 159. #gen_SendLiteralSelector1ArgBytecode15.
#isMapped }.
{ 1. 160. 160. #gen_SendLiteralSelector2ArgsBytecode0.
#isMapped }.
{ 1. 161. 161. #gen_SendLiteralSelector2ArgsBytecode1.
#isMapped }.
{ 1. 162. 162. #gen_SendLiteralSelector2ArgsBytecode2.
#isMapped }.
{ 1. 163. 163. #gen_SendLiteralSelector2ArgsBytecode3.
#isMapped }.
{ 1. 164. 164. #gen_SendLiteralSelector2ArgsBytecode4.
#isMapped }.
{ 1. 165. 165. #gen_SendLiteralSelector2ArgsBytecode5.
#isMapped }.
{ 1. 166. 166. #gen_SendLiteralSelector2ArgsBytecode6.
#isMapped }.
{ 1. 167. 167. #gen_SendLiteralSelector2ArgsBytecode7.
#isMapped }.
{ 1. 168. 168. #gen_SendLiteralSelector2ArgsBytecode8.
#isMapped }.
{ 1. 169. 169. #gen_SendLiteralSelector2ArgsBytecode9.
#isMapped }.
{ 1. 170. 170. #gen_SendLiteralSelector2ArgsBytecode10.
#isMapped }.
{ 1. 171. 171. #gen_SendLiteralSelector2ArgsBytecode11.
#isMapped }.
{ 1. 172. 172. #gen_SendLiteralSelector2ArgsBytecode12.
#isMapped }.
{ 1. 173. 173. #gen_SendLiteralSelector2ArgsBytecode13.
#isMapped }.
{ 1. 174. 174. #gen_SendLiteralSelector2ArgsBytecode14.
#isMapped }.
{ 1. 175. 175. #gen_SendLiteralSelector2ArgsBytecode15.
#isMapped }.
{ 1. 176. 176. #gen_ShortUnconditionalJump0.
#branch. #v3:ShortForward:Branch:Distance: }.
{ 1. 177. 177. #gen_ShortUnconditionalJump1.
#branch. #v3:ShortForward:Branch:Distance: }.
{ 1. 178. 178. #gen_ShortUnconditionalJump2.
#branch. #v3:ShortForward:Branch:Distance: }.
{ 1. 179. 179. #gen_ShortUnconditionalJump3.
#branch. #v3:ShortForward:Branch:Distance: }.
{ 1. 180. 180. #gen_ShortUnconditionalJump4.
#branch. #v3:ShortForward:Branch:Distance: }.
{ 1. 181. 181. #gen_ShortUnconditionalJump5.
#branch. #v3:ShortForward:Branch:Distance: }.
{ 1. 182. 182. #gen_ShortUnconditionalJump6.
#branch. #v3:ShortForward:Branch:Distance: }.
{ 1. 183. 183. #gen_ShortUnconditionalJump7.
#branch. #v3:ShortForward:Branch:Distance: }.
{ 1. 184. 184. #gen_ShortConditionalJumpTrue0.
#branch. #isBranchTrue. #isMapped. #v3:ShortForward:Branch:Distance: }.
{ 1. 185. 185. #gen_ShortConditionalJumpTrue1.
#branch. #isBranchTrue. #isMapped. #v3:ShortForward:Branch:Distance: }.
{ 1. 186. 186. #gen_ShortConditionalJumpTrue2.
#branch. #isBranchTrue. #isMapped. #v3:ShortForward:Branch:Distance: }.
{ 1. 187. 187. #gen_ShortConditionalJumpTrue3.
#branch. #isBranchTrue. #isMapped. #v3:ShortForward:Branch:Distance: }.
{ 1. 188. 188. #gen_ShortConditionalJumpTrue4.
#branch. #isBranchTrue. #isMapped. #v3:ShortForward:Branch:Distance: }.
{ 1. 189. 189. #gen_ShortConditionalJumpTrue5.
#branch. #isBranchTrue. #isMapped. #v3:ShortForward:Branch:Distance: }.
{ 1. 190. 190. #gen_ShortConditionalJumpTrue6.
#branch. #isBranchTrue. #isMapped. #v3:ShortForward:Branch:Distance: }.
{ 1. 191. 191. #gen_ShortConditionalJumpTrue7.
#branch. #isBranchTrue. #isMapped. #v3:ShortForward:Branch:Distance: }.
{ 1. 192. 192. #gen_ShortConditionalJumpFalse0.
#branch. #isBranchFalse. #isMapped. #v3:ShortForward:Branch:Distance: }.
{ 1. 193. 193. #gen_ShortConditionalJumpFalse1.
#branch. #isBranchFalse. #isMapped. #v3:ShortForward:Branch:Distance: }.
{ 1. 194. 194. #gen_ShortConditionalJumpFalse2.
#branch. #isBranchFalse. #isMapped. #v3:ShortForward:Branch:Distance: }.
{ 1. 195. 195. #gen_ShortConditionalJumpFalse3.
#branch. #isBranchFalse. #isMapped. #v3:ShortForward:Branch:Distance: }.
{ 1. 196. 196. #gen_ShortConditionalJumpFalse4.
#branch. #isBranchFalse. #isMapped. #v3:ShortForward:Branch:Distance: }.
{ 1. 197. 197. #gen_ShortConditionalJumpFalse5.
#branch. #isBranchFalse. #isMapped. #v3:ShortForward:Branch:Distance: }.
{ 1. 198. 198. #gen_ShortConditionalJumpFalse6.
#branch. #isBranchFalse. #isMapped. #v3:ShortForward:Branch:Distance: }.
{ 1. 199. 199. #gen_ShortConditionalJumpFalse7.
#branch. #isBranchFalse. #isMapped. #v3:ShortForward:Branch:Distance: }.
{ 1. 200. 200. #gen_StoreAndPopReceiverVariableBytecode0.
#isInstVarRef. #isMappedIfImmutability. #needsFrameIfImmutability:.
-1 }.
{ 1. 201. 201. #gen_StoreAndPopReceiverVariableBytecode1.
#isInstVarRef. #isMappedIfImmutability. #needsFrameIfImmutability:.
-1 }.
{ 1. 202. 202. #gen_StoreAndPopReceiverVariableBytecode2.
#isInstVarRef. #isMappedIfImmutability. #needsFrameIfImmutability:.
-1 }.
{ 1. 203. 203. #gen_StoreAndPopReceiverVariableBytecode3.
#isInstVarRef. #isMappedIfImmutability. #needsFrameIfImmutability:.
-1 }.
{ 1. 204. 204. #gen_StoreAndPopReceiverVariableBytecode4.
#isInstVarRef. #isMappedIfImmutability. #needsFrameIfImmutability:.
-1 }.
{ 1. 205. 205. #gen_StoreAndPopReceiverVariableBytecode5.
#isInstVarRef. #isMappedIfImmutability. #needsFrameIfImmutability:.
-1 }.
{ 1. 206. 206. #gen_StoreAndPopReceiverVariableBytecode6.
#isInstVarRef. #isMappedIfImmutability. #needsFrameIfImmutability:.
-1 }.
{ 1. 207. 207. #gen_StoreAndPopReceiverVariableBytecode7.
#isInstVarRef. #isMappedIfImmutability. #needsFrameIfImmutability:.
-1 }.
{ 1. 208. 208. #gen_StoreAndPopTemporaryVariableBytecode0 }.
{ 1. 209. 209. #gen_StoreAndPopTemporaryVariableBytecode1 }.
{ 1. 210. 210. #gen_StoreAndPopTemporaryVariableBytecode2 }.
{ 1. 211. 211. #gen_StoreAndPopTemporaryVariableBytecode3 }.
{ 1. 212. 212. #gen_StoreAndPopTemporaryVariableBytecode4 }.
{ 1. 213. 213. #gen_StoreAndPopTemporaryVariableBytecode5 }.
{ 1. 214. 214. #gen_StoreAndPopTemporaryVariableBytecode6 }.
{ 1. 215. 215. #gen_StoreAndPopTemporaryVariableBytecode7 }.
{ 1. 216. 216. #gen_PopStackBytecode. #needsFrameNever:.
-1 }.
{ 1. 217. 217. #unknownBytecode }.
{ 1. 218. 218. #unknownBytecode }.
{ 1. 219. 219. #unknownBytecode }.
{ 1. 220. 220. #unknownBytecode }.
{ 1. 221. 221. #unknownBytecode }.
{ 1. 222. 222. #unknownBytecode }.
{ 1. 223. 223. #unknownBytecode }.
{ 2. 224. 224. #gen_ExtABytecode. #extension }.
{ 2. 225. 225. #gen_ExtBBytecode. #extension }.
{ 2. 226. 226. #gen_ExtPushReceiverVariableBytecode.
#isInstVarRef. #isMappedIfImmutability }.
{ 2. 227. 227. #gen_ExtPushLiteralVariableBytecode.
#needsFrameNever:. 1 }.
{ 2. 228. 228. #gen_ExtPushLiteralBytecode.
#needsFrameNever:. 1 }.
{ 2. 229. 229. #gen_LongPushTemporaryVariableBytecode }.
{ 2. 230. 230. #unknownBytecode }.
{ 2. 231. 231. #gen_PushNewArrayBytecode }.
{ 2. 232. 232. #gen_ExtPushIntegerBytecode.
#needsFrameNever:. 1 }.
{ 2. 233. 233. #gen_ExtPushCharacterBytecode.
#needsFrameNever:. 1 }.
{ 2. 234. 234. #gen_ExtSendBytecode. #isMapped }.
{ 2. 235. 235. #gen_ExtSendSuperBytecode. #isMapped }.
{ 2. 236. 236. #unknownBytecode }.
{ 2. 237. 237. #gen_ExtUnconditionalJump. #branch. #isMapped.
#v4:Long:Branch:Distance: }.
{ 2. 238. 238. #gen_ExtJumpIfTrue. #branch. #isBranchTrue.
#isMapped. #v4:Long:Branch:Distance: }.
{ 2. 239. 239. #gen_ExtJumpIfFalse. #branch. #isBranchFalse.
#isMapped. #v4:Long:Branch:Distance: }.
{ 2. 240. 240. #unknownBytecode }.
{ 2. 241. 241. #gen_ExtStoreAndPopLiteralVariableBytecode.
#isMappedIfImmutability }.
{ 2. 242. 242. #gen_LongStoreAndPopTemporaryVariableBytecode }.
{ 2. 243. 243. #gen_ExtStoreReceiverVariableBytecode.
#isInstVarRef. #isMappedIfImmutability. #needsFrameIfImmutability:.
0 }.
{ 2. 244. 244. #gen_ExtStoreLiteralVariableBytecode.
#isMappedIfImmutability }.
{ 2. 245. 245. #gen_LongStoreTemporaryVariableBytecode }.
{ 2. 246. 246. #unknownBytecode }.
{ 2. 247. 247. #unknownBytecode }.
{ 3. 248. 248. #gen_CallPrimitiveBytecode }.
{ 3. 249. 249. #gen_ExtPushFullClosureBytecode }.
{ 3. 250. 250. #unknownBytecode }.
{ 3. 251. 251. #gen_PushRemoteTempLongBytecode }.
{ 3. 252. 252. #gen_StoreRemoteTempLongBytecode.
#isMappedIfImmutability. #needsFrameIfImmutability:.
0 }.
{ 3. 253. 253. #unknownBytecode }.
{ 3. 254. 254. #unknownBytecode }.
{ 3. 255. 255. #unknownBytecode } }
]
{ #category : #translation }
DruidJIT class >> declareCVarsIn: aCodeGen [
"Deal wuth the fact that the number of trampolines depends on IMMUTABILITY
and that IMMUTABILITY can be defined at compile time. Yes, this is a mess."
| current values |
current := InitializationOptions at: #IMMUTABILITY ifAbsent: nil.
values := #(true false) collect:
[:bool|
InitializationOptions at: #IMMUTABILITY put: bool.
self initializeNumTrampolines.
(Cogit classPool at: #NumTrampolines) printString].
current
ifNil: [InitializationOptions removeKey: #IMMUTABILITY]
ifNotNil: [InitializationOptions at: #IMMUTABILITY put: current].
values first ~= values last ifTrue:
[aCodeGen addConstantForBinding: #NumTrampolines -> ('(IMMUTABILITY ? ' , values first , ' : ' , values last , ')')].
aCodeGen
var: #ceStoreTrampolines
declareC: ('#if IMMUTABILITY\sqInt ceStoreTrampolines[', NumStoreTrampolines printString, '];\#endif') withCRs
]
{ #category : #initialization }
DruidJIT class >> initialize [
NumStoreTrampolines := 5
]
{ #category : #'class initialization' }
DruidJIT class >> initializeBytecodeTableForSistaV1 [
<generated>
numPushNilsFunction := #sistaV1:Num:Push:Nils:.
pushNilSizeFunction := #sistaV1PushNilSize:numInitialNils:.
BytecodeSetHasDirectedSuperSend := true.
BytecodeSetHasExtensions := true.
FirstSpecialSelector := 96.
NumSpecialSelectors := 32.
self generatorTableFrom: self bytecodeTable
]
{ #category : #'class initialization' }
DruidJIT class >> initializePrimitiveTable [
<generated>
MaxCompiledPrimitiveIndex := 549.
primitiveTable := CArrayAccessor on:
(Array new: MaxCompiledPrimitiveIndex + 1).
self table: primitiveTable from: self primitiveTableArray.
^ primitiveTable
]
{ #category : #translation }
DruidJIT class >> objectRepresentationAncilliaryClasses [
^ Array empty
]
{ #category : #'accessing class hierarchy' }
DruidJIT class >> objectRepresentationClass [
]
{ #category : #'class initialization' }
DruidJIT class >> primitiveTableArray [
<generated>
^ {
{ 1. #gen_PrimitiveAdd. 1 }.
{ 2. #gen_PrimitiveSubtract. 1 }.
{ 3. #gen_PrimitiveLessThan. 1 }.
{ 4. #gen_PrimitiveGreaterThan. 1 }.
{ 5. #gen_PrimitiveLessOrEqual. 1 }.
{ 6. #gen_PrimitiveGreaterOrEqual. 1 }.
{ 7. #gen_PrimitiveEqual. 1 }.
{ 8. #gen_PrimitiveNotEqual. 1 }.
{ 9. #gen_PrimitiveMultiply. 1 }.
{ 10. #gen_PrimitiveDivide. 1 }.
{ 11. #gen_PrimitiveMod. 1 }.
{ 12. #gen_PrimitiveDiv. 1 }.
{ 13. #gen_PrimitiveQuo. 1 }.
{ 14. #gen_PrimitiveBitAnd. 1 }.
{ 15. #gen_PrimitiveBitOr. 1 }.
{ 16. #gen_PrimitiveBitXor. 1 }.
{ 17. #gen_PrimitiveBitShift. 1 }.
{ 40. #gen_PrimitiveAsFloat. 0 }.
{ 41. #gen_PrimitiveFloatAdd. 1 }.
{ 42. #gen_PrimitiveFloatSubtract. 1 }.
{ 43. #gen_PrimitiveFloatLessThan. 1 }.
{ 44. #gen_PrimitiveFloatGreaterThan.
1 }.
{ 45. #gen_PrimitiveFloatLessOrEqual.
1 }.
{ 46. #gen_PrimitiveFloatGreaterOrEqual.
1 }.
{ 47. #gen_PrimitiveFloatEqual. 1 }.
{ 48. #gen_PrimitiveFloatNotEqual. 1 }.
{ 49. #gen_PrimitiveFloatMultiply. 1 }.
{ 60. #gen_PrimitiveAt. 1 }.
{ 62. #gen_PrimitiveSize. 0 }.
{ 70. #gen_PrimitiveNew. 0 }.
{ 71. #gen_PrimitiveNewWithArg. 1 }.
{ 73. #genNonImplementedPrimitive. -1. #maycallback }.
{ 75. #gen_PrimitiveIdentityHash. 0 }.
{ 110. #gen_PrimitiveIdentical. 1 }.
{ 111. #gen_PrimitiveClass. 0 }.
{ 117. #genNonImplementedPrimitive. -1. #maycallback }.
{ 120. #genNonImplementedPrimitive. -1. #maycallback }.
{ 148. #genNonImplementedPrimitive. -1. #maycallback }.
{ 160. #genNonImplementedPrimitive. -1. #maycallback }.
{ 170. #gen_PrimitiveAsCharacter. 0 }.
{ 171. #gen_PrimitiveImmediateAsInteger.
0 }.
{ 173. #genNonImplementedPrimitive. -1. #maycallback }.
{ 207. #gen_PrimitiveFullClosureValue.
0 }.
{ 216. #genNonImplementedPrimitive. -1. #maycallback }.
{ 541. #gen_PrimitiveSmallFloatAdd. 1 }.
{ 542. #gen_PrimitiveSmallFloatSubtract.
1 }.
{ 543. #gen_PrimitiveSmallFloatLessThan.
1 }.
{ 544. #gen_PrimitiveSmallFloatGreaterThan.
1 }.
{ 545. #gen_PrimitiveSmallFloatLessOrEqual.
1 }.
{ 546. #gen_PrimitiveSmallFloatGreaterOrEqual.
1 }.
{ 547. #gen_PrimitiveSmallFloatEqual. 1 }.
{ 548. #gen_PrimitiveSmallFloatNotEqual.
1 }.
{ 549. #gen_PrimitiveSmallFloatMultiply.
1 } }
]
{ #category : #'trait candidates' }
DruidJIT >> allYoungObjectsAgeInFullGC [
^false
]
{ #category : #'trait candidates' }
DruidJIT >> bitAndByteOffsetOfIsFullBlockBitInto: aBlock [
"This supplies the bitmask for the isFullBlock bit, and the offset of the byte containing
that bit in a CogMethod header to aBlock. We don't have named variables holding this
offset. The following assert tests whether the values are correct by creating a surrogate
on an empty ByteArray, setting the bit, and checking that the expected values are set
in the ByteArray."
aBlock value: 16 value: objectMemory baseHeaderSize + 1 "zero-relative"
]
{ #category : #'trait candidates' }
DruidJIT >> cacheTagIsMarked: cacheTag [
"Answer if the cacheTag is not unmarked, i.e. answer true for compact class
indices and immediates; only answer false for unmarked objects. In Spur
linked send cache tags are class indices so effectively they're always marked."
^true
]
{ #category : #accessing }
DruidJIT >> ceNewHashTrampoline: anInteger [
<doNotGenerate>
ceNewHashTrampoline := anInteger
]
{ #category : #accessing }
DruidJIT >> ceStoreCheckTrampoline: anAddress [
<doNotGenerate>
ceStoreCheckTrampoline := anAddress
]
{ #category : #'trait candidates' }
DruidJIT >> checkValidObjectReference: anOop [
^(objectMemory isImmediate: anOop) not
and: [(objectMemory heapMapAtWord: (self pointerForOop: anOop)) ~= 0]
]
{ #category : #'trait candidates' }
DruidJIT >> checkValidOopReference: anOop [
^(objectMemory isImmediate: anOop)
or: [(objectMemory heapMapAtWord: (self pointerForOop: anOop)) ~= 0]
]
{ #category : #'trait candidates' }
DruidJIT >> classForInlineCacheTag: classIndex [
^objectMemory classOrNilAtIndex: classIndex
]
{ #category : #'trait candidates' }
DruidJIT >> couldBeObject: literal [
^(objectMemory isNonImmediate: literal)
and: [self oop: literal isGreaterThanOrEqualTo: objectMemory getMemoryMap startOfObjectMemory]
]
{ #category : #'trait candidates' }
DruidJIT >> genActiveContextTrampolineLarge: isLarge inBlock: isInBlock called: aString [
<var: #aString type: #'char *'>
"Create a trampoline to answer the active context that will
answer it if a frame is already married, and create it otherwise.
Assume numArgs is in SendNumArgsReg and ClassReg is free."
| startAddress |
startAddress := self methodZoneBase.
self zeroOpcodeIndex.
self genGetActiveContextLarge: isLarge inBlock: isInBlock.
self outputInstructionsForGeneratedRuntimeAt: startAddress.
self recordGeneratedRunTime: aString address: startAddress.
self recordRunTimeObjectReferences.
^startAddress
]
{ #category : #'trait candidates' }
DruidJIT >> genCheckObjectPosition: destReg scratchReg: scratchReg valueReg: valueReg results: resultBlock [
| isDestYoung isOldAndOld isPermAndPerm recvIsPerm exit valueIsMachineCode|
<inline: true>
<var: #recvIsPerm type: #'AbstractInstruction *'>
<var: #exit type: #'AbstractInstruction *'>
self CmpCq: objectMemory getMemoryMap getNewSpaceStart R: valueReg.
valueIsMachineCode := self JumpBelow: 0.
self CmpCq: objectMemory getMemoryMap fixedPermSpaceStart R: destReg.
recvIsPerm := self JumpAboveOrEqual: 0.
self CmpCq: objectMemory getMemoryMap getOldSpaceStart R: destReg.
isDestYoung := self JumpBelow: 0.
self CmpCq: objectMemory getMemoryMap getOldSpaceStart R: valueReg.
isOldAndOld := self JumpAboveOrEqual: 0.
exit := self Jump: 0.
recvIsPerm jmpTarget: (self Label).
self CmpCq: objectMemory getMemoryMap fixedPermSpaceStart R: valueReg.
isPermAndPerm := self JumpAbove: 0.
exit jmpTarget: (self Label).
resultBlock value: isDestYoung value: isOldAndOld value: isPermAndPerm value: valueIsMachineCode.
^ 0
]
{ #category : #'trait candidates' }
DruidJIT >> genCheckRememberedBitOf: objReg scratch: scratchReg [
"Check the remembered bit of the object in objReg; answer the jump taken if the bit is already set.
Only need to fetch the byte containing it, which reduces the size of the mask constant."
| rememberedBitByteOffset mask |
rememberedBitByteOffset := self backEnd isBigEndian
ifTrue: [objectMemory baseHeaderSize - 1 - (objectMemory rememberedBitShift // 8)]
ifFalse:[objectMemory rememberedBitShift // 8].
mask := 1 << (objectMemory rememberedBitShift \\ 8).
self MoveMb: rememberedBitByteOffset r: objReg R: scratchReg.
self TstCq: mask R: scratchReg.
^self JumpNonZero: 0
]
{ #category : #'trait candidates' }
DruidJIT >> genConvertIntegerToSmallIntegerInReg: reg [
self LogicalShiftLeftCq: objectMemory numTagBits R: reg.
self AddCq: 1 R: reg.
^0
]
{ #category : #'trait candidates' }
DruidJIT >> genCreateFullClosureInIndex: anIndex numCopied: numCopied ignoreContext: ignoreContext contextNumArgs: contextNumArgs large: contextIsLarge inBlock: contextIsBlock intoRegister: destinationRegister [
"Create a full closure with the given values."
<var: #skip type: #'AbstractInstruction *'>
| numSlots byteSize header skip numArgs compiledBlock |
compiledBlock := self getLiteral: anIndex.
numArgs := coInterpreter argumentCountOf: compiledBlock.
"First get thisContext into destinationRegister and thence in ClassReg."
ignoreContext
ifTrue: [ self genMoveNilR: ClassReg ]
ifFalse: [
self voidReceiverResultRegContainsSelf.
self
genGetActiveContextNumArgs: contextNumArgs
large: contextIsLarge
inBlock: contextIsBlock.
self MoveR: ReceiverResultReg R: ClassReg ].
numSlots := FullClosureFirstCopiedValueIndex + numCopied.
byteSize := objectMemory smallObjectBytesForSlots: numSlots.
self assert: ClassFullBlockClosureCompactIndex ~= 0.
header := objectMemory
headerForSlots: numSlots
format: objectMemory indexablePointersFormat
classIndex: ClassFullBlockClosureCompactIndex.
self MoveAw: objectMemory freeStartAddress R: destinationRegister.
self
genStoreHeader: header
intoNewInstance: destinationRegister
using: TempReg.
self
LoadEffectiveAddressMw: byteSize r: destinationRegister R: TempReg;
MoveR: TempReg Aw: objectMemory freeStartAddress;
CmpCq: objectMemory getScavengeThreshold R: TempReg.
skip := self JumpBelow: 0.
self CallRT: ceScheduleScavengeTrampoline.
skip jmpTarget: self Label.
self
MoveR: ClassReg
Mw: FullClosureOuterContextIndex * objectMemory bytesPerOop
+ objectMemory baseHeaderSize
r: destinationRegister;
genMoveConstant: compiledBlock R: TempReg;
MoveR: TempReg
Mw: FullClosureCompiledBlockIndex * objectMemory bytesPerOop
+ objectMemory baseHeaderSize
r: destinationRegister;
MoveCq: (objectMemory integerObjectOf: numArgs) R: TempReg;
MoveR: TempReg
Mw: FullClosureNumArgsIndex * objectMemory bytesPerOop
+ objectMemory baseHeaderSize
r: destinationRegister.
^ 0
]
{ #category : #'trait candidates' }
DruidJIT >> genEnsureObjInRegNotForwarded: reg scratchReg: scratch [
"Make sure that the object in reg is not forwarded. This routine assumes the object will
never be forwarded to an immediate, as it is used to unforward literal variables (associations).
Use the fact that isForwardedObjectClassIndexPun is a power of two to save an instruction."
| loop ok |
<var: #ok type: #'AbstractInstruction *'>
<var: #loop type: #'AbstractInstruction *'>
self assert: reg ~= scratch.
loop := self Label.
"notionally
self genGetClassIndexOfNonImm: reg into: scratch.
cogit CmpCq: objectMemory isForwardedObjectClassIndexPun R: TempReg.
but the following is an instruction shorter:"
self MoveMw: 0 r: reg R: scratch.
self
AndCq: objectMemory classIndexMask - objectMemory isForwardedObjectClassIndexPun
R: scratch.
ok := self JumpNonZero: 0.
self genLoadSlot: 0 sourceReg: reg destReg: reg.
self Jump: loop.
ok jmpTarget: self Label.
^0
]
{ #category : #'trait candidates' }
DruidJIT >> genEnsureOopInRegNotForwarded: reg scratchReg: scratch [
^ self
genEnsureOopInRegNotForwarded: reg
scratchReg: scratch
jumpBackTo: self Label "label is just before the forwarder check"
]
{ #category : #'trait candidates' }
DruidJIT >> genEnsureOopInRegNotForwarded: reg scratchReg: scratch ifForwarder: fwdJumpTarget ifNotForwarder: nonFwdJumpTargetOrZero [
"Make sure that the oop in reg is not forwarded.
Use the fact that isForwardedObjectClassIndexPun is a power of two to save an instruction."
| imm ok finished |
self assert: reg ~= scratch.
imm := self genJumpImmediate: reg.
"notionally
self genGetClassIndexOfNonImm: reg into: scratch.
cogit CmpCq: objectMemory isForwardedObjectClassIndexPun R: TempReg.
but the following is an instruction shorter:"
self MoveMw: 0 r: reg R: scratch.
self
AndCq: objectMemory classIndexMask - objectMemory isForwardedObjectClassIndexPun
R: scratch.
ok := self JumpNonZero: 0.
self genLoadSlot: 0 sourceReg: reg destReg: reg.
self Jump: fwdJumpTarget.
finished := nonFwdJumpTargetOrZero asUnsignedInteger = 0
ifTrue: [self Label]
ifFalse: [nonFwdJumpTargetOrZero].
imm jmpTarget: (ok jmpTarget: finished).
^0
]
{ #category : #'trait candidates' }
DruidJIT >> genEnsureOopInRegNotForwarded: reg scratchReg: scratch jumpBackTo: instruction [
<var: #instruction type: #'AbstractInstruction *'>
<inline: true>
^ self
genEnsureOopInRegNotForwarded: reg
scratchReg: scratch
ifForwarder: instruction
ifNotForwarder: 0
]
{ #category : #'trait candidates' }
DruidJIT >> genEnsureOopInRegNotForwarded: reg scratchReg: scratch updatingSlot: index in: objReg [
"Make sure that the oop in reg is not forwarded, updating the slot in objReg with the value."
| loop imm ok |
<var: #ok type: #'AbstractInstruction *'>
<var: #imm type: #'AbstractInstruction *'>
<var: #loop type: #'AbstractInstruction *'>
"Open-code
self genEnsureOopInRegNotForwarded: reg
scratchReg: scratch
updatingMw: index * objectMemory wordSize + objectMemory baseHeaderSize
r: objReg.
to avoid calling the store check unless the receiver is forwarded."
self assert: (reg ~= scratch and: [objReg ~= scratch]).
loop := self Label.
imm := self genJumpImmediate: reg.
"notionally
self genGetClassIndexOfNonImm: reg into: scratch.
cogit CmpCq: objectMemory isForwardedObjectClassIndexPun R: TempReg.
but the following is an instruction shorter:"
self MoveMw: 0 r: reg R: scratch.
self
AndCq: objectMemory classIndexMask - objectMemory isForwardedObjectClassIndexPun
R: scratch.
ok := self JumpNonZero: 0.
self genLoadSlot: 0 sourceReg: reg destReg: reg.
self MoveR: reg Mw: index * objectMemory wordSize + objectMemory baseHeaderSize r: objReg.
"Check that we're meeting the contract of ceStoreCheckContextReceiverTrampoline."
self assert: (reg = Arg0Reg and: [scratch = TempReg and: [objReg = ReceiverResultReg]]).
self CallRT: ceStoreCheckContextReceiverTrampoline.
self Jump: loop.
ok jmpTarget: (imm jmpTarget: self Label).
^0
]
{ #category : #'trait candidates' }
DruidJIT >> genGetActiveContextLarge: isLarge inBlock: isInBlock [
"Create a trampoline to answer the active context that will
answer it if a frame is already married, and create it otherwise.
Assume numArgs is in SendNumArgsReg and ClassReg is free."
| header slotSize jumpSingle loopHead jumpNeedScavenge continuation exit |
<var: #jumpNeedScavenge type: #'AbstractInstruction *'>
<var: #continuation type: #'AbstractInstruction *'>
<var: #jumpSingle type: #'AbstractInstruction *'>
<var: #loopHead type: #'AbstractInstruction *'>
<var: #exit type: #'AbstractInstruction *'>
self "load the flag; stash it in both TempReg & ClassReg; do the compare (a prime candidated for use of AndCq:R:R:)"
MoveMw: FoxMethod r: FPReg R: ClassReg;
AndCq: MFMethodFlagHasContextFlag R: ClassReg R: TempReg.
jumpSingle := self JumpZero: 0. "jump if flag bit not set"
self "since the flag bit was set, get the context in the receiver reg and return"
MoveMw: FoxThisContext r: FPReg R: ReceiverResultReg;
RetN: 0.
jumpSingle jmpTarget: self Label.
"OK, it doesn't exist; instantiate and initialize it"
"set the hasContext flag; See CoInterpreter class>>initializeFrameIndices"
self
OrCq: MFMethodFlagHasContextFlag R: ClassReg;
MoveR: ClassReg Mw: FoxMethod r: FPReg.
"now get the home CogMethod into ClassReg and save for post-instantiation."
isInBlock caseOf: {
[InFullBlock] -> [self SubCq: 3 R: ClassReg]. "-3 is -(hasContext+isBlock) flags"
[0] -> [self SubCq: 1 R: ClassReg]. "-1 is hasContext flag" }.
"instantiate the context..."
slotSize := isLarge ifTrue: [LargeContextSlots] ifFalse: [SmallContextSlots].
header := objectMemory
headerForSlots: slotSize
format: objectMemory indexablePointersFormat
classIndex: ClassMethodContextCompactIndex.
self flag: #endianness.
self MoveAw: objectMemory freeStartAddress R: ReceiverResultReg.
self genStoreHeader: header intoNewInstance: ReceiverResultReg using: TempReg.
self
MoveR: ReceiverResultReg R: TempReg;
AddCq: (objectMemory smallObjectBytesForSlots: slotSize) R: TempReg;
MoveR: TempReg Aw: objectMemory freeStartAddress;
CmpCq: objectMemory getScavengeThreshold R: TempReg.
jumpNeedScavenge := self JumpAboveOrEqual: 0.
"Now initialize the fields of the context. See CoInterpreter>>marryFrame:SP:copyTemps:"
"sender gets frame pointer as a SmallInteger"
continuation :=
self MoveR: FPReg R: TempReg.
self genSetSmallIntegerTagsIn: TempReg.
self MoveR: TempReg Mw: objectMemory baseHeaderSize + (SenderIndex * objectMemory bytesPerOop) r: ReceiverResultReg.
"pc gets frame caller as a SmallInteger"
self MoveMw: FoxSavedFP r: FPReg R: TempReg.
self genSetSmallIntegerTagsIn: TempReg.
self MoveR: TempReg Mw: objectMemory baseHeaderSize + (InstructionPointerIndex * objectMemory bytesPerOop) r: ReceiverResultReg.
"Set the method field, freeing up ClassReg again, and frame's context field,"
self
MoveMw: (self offset: CogMethod of: #methodObject) r: ClassReg R: TempReg;
MoveR: TempReg Mw: objectMemory baseHeaderSize + (MethodIndex * objectMemory wordSize) r: ReceiverResultReg;
MoveR: ReceiverResultReg Mw: FoxThisContext r: FPReg.
"Now compute stack pointer; this is stackPointer (- 1 for return pc if a CISC) - framePointer - wordSize (1 each for saved pc, method, context, receiver) + 1 (1-relative) + numArgs"
"TPR note - the code here is actually doing
context stackPointer := ((((fp - sp) / wordSize) - [3|4]) + num args) asSmallInteger"
self
MoveR: FPReg R: TempReg;
SubR: SPReg R: TempReg;
LogicalShiftRightCq: self log2BytesPerWord R: TempReg;
SubCq: (self backEnd hasLinkRegister ifTrue: [3] ifFalse: [4]) R: TempReg;
AddR: SendNumArgsReg R: TempReg.
self genConvertIntegerToSmallIntegerInReg: TempReg.
self MoveR: TempReg Mw: objectMemory baseHeaderSize + (StackPointerIndex * objectMemory bytesPerOop) r: ReceiverResultReg.
"Set closureOrNil to either the stacked receiver or nil"
isInBlock > 0
ifTrue:
[self
MoveR: SendNumArgsReg R: TempReg;
AddCq: 2 R: TempReg; "+2 for saved fp and saved pc"
MoveXwr: TempReg R: FPReg R: TempReg]
ifFalse:
[self genMoveNilR: TempReg].
self MoveR: TempReg Mw: objectMemory baseHeaderSize + (ClosureIndex * objectMemory bytesPerOop) r: ReceiverResultReg.
"Set the receiver"
self
MoveMw: FoxMFReceiver r: FPReg R: TempReg;
MoveR: TempReg Mw: objectMemory baseHeaderSize + (ReceiverIndex * objectMemory bytesPerOop) r: ReceiverResultReg.
"Now copy the arguments. This is tricky because of the shortage of registers,. ClassReg ranges
from 1 to numArgs (SendNumArgsReg), and from ReceiverIndex + 1 to ReceiverIndex + numArgs.