forked from phoboslab/JavaScriptCore-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLowLevelInterpreter64.asm
More file actions
1548 lines (1308 loc) · 41.2 KB
/
LowLevelInterpreter64.asm
File metadata and controls
1548 lines (1308 loc) · 41.2 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) 2011, 2012 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
# THE POSSIBILITY OF SUCH DAMAGE.
# Some value representation constants.
const TagBitTypeOther = 0x2
const TagBitBool = 0x4
const TagBitUndefined = 0x8
const ValueEmpty = 0x0
const ValueFalse = TagBitTypeOther | TagBitBool
const ValueTrue = TagBitTypeOther | TagBitBool | 1
const ValueUndefined = TagBitTypeOther | TagBitUndefined
const ValueNull = TagBitTypeOther
# Utilities.
macro dispatch(advance)
addp advance, PC
jmp [PB, PC, 8]
end
macro dispatchInt(advance)
addi advance, PC
jmp [PB, PC, 8]
end
macro dispatchAfterCall()
loadi ArgumentCount + TagOffset[cfr], PC
loadp CodeBlock[cfr], PB
loadp CodeBlock::m_instructions[PB], PB
jmp [PB, PC, 8]
end
macro cCall2(function, arg1, arg2)
move arg1, t5
move arg2, t4
call function
end
# This barely works. arg3 and arg4 should probably be immediates.
macro cCall4(function, arg1, arg2, arg3, arg4)
move arg1, t5
move arg2, t4
move arg3, t1
move arg4, t2
call function
end
macro prepareStateForCCall()
leap [PB, PC, 8], PC
move PB, t3
end
macro restoreStateAfterCCall()
move t0, PC
move t1, cfr
move t3, PB
subp PB, PC
urshiftp 3, PC
end
macro callSlowPath(slowPath)
prepareStateForCCall()
cCall2(slowPath, cfr, PC)
restoreStateAfterCCall()
end
macro traceOperand(fromWhere, operand)
prepareStateForCCall()
cCall4(_llint_trace_operand, cfr, PC, fromWhere, operand)
restoreStateAfterCCall()
end
macro traceValue(fromWhere, operand)
prepareStateForCCall()
cCall4(_llint_trace_value, cfr, PC, fromWhere, operand)
restoreStateAfterCCall()
end
# Call a slow path for call call opcodes.
macro callCallSlowPath(advance, slowPath, action)
addi advance, PC, t0
storei t0, ArgumentCount + TagOffset[cfr]
prepareStateForCCall()
cCall2(slowPath, cfr, PC)
move t1, cfr
action(t0)
end
macro checkSwitchToJITForLoop()
checkSwitchToJIT(
1,
macro()
storei PC, ArgumentCount + TagOffset[cfr]
prepareStateForCCall()
cCall2(_llint_loop_osr, cfr, PC)
move t1, cfr
btpz t0, .recover
jmp t0
.recover:
move t3, PB
loadi ArgumentCount + TagOffset[cfr], PC
end)
end
# Index and value must be different registers. Index may be clobbered.
macro loadConstantOrVariable(index, value)
bpgteq index, FirstConstantRegisterIndex, .constant
loadp [cfr, index, 8], value
jmp .done
.constant:
loadp CodeBlock[cfr], value
loadp CodeBlock::m_constantRegisters + VectorBufferOffset[value], value
subp FirstConstantRegisterIndex, index
loadp [value, index, 8], value
.done:
end
macro loadConstantOrVariableInt32(index, value, slow)
loadConstantOrVariable(index, value)
bpb value, tagTypeNumber, slow
end
macro loadConstantOrVariableCell(index, value, slow)
loadConstantOrVariable(index, value)
btpnz value, tagMask, slow
end
macro writeBarrier(value)
# Nothing to do, since we don't have a generational or incremental collector.
end
macro valueProfile(value, profile)
if VALUE_PROFILER
storep value, ValueProfile::m_buckets[profile]
end
end
# Entrypoints into the interpreter.
# Expects that CodeBlock is in t1, which is what prologue() leaves behind.
macro functionArityCheck(doneLabel, slow_path)
loadi PayloadOffset + ArgumentCount[cfr], t0
biaeq t0, CodeBlock::m_numParameters[t1], doneLabel
prepareStateForCCall()
cCall2(slow_path, cfr, PC) # This slow_path has a simple protocol: t0 = 0 => no error, t0 != 0 => error
move t1, cfr
btiz t0, .continue
loadp JITStackFrame::globalData[sp], t1
loadp JSGlobalData::callFrameForThrow[t1], t0
jmp JSGlobalData::targetMachinePCForThrow[t1]
.continue:
# Reload CodeBlock and reset PC, since the slow_path clobbered them.
loadp CodeBlock[cfr], t1
loadp CodeBlock::m_instructions[t1], PB
move 0, PC
jmp doneLabel
end
# Instruction implementations
_llint_op_enter:
traceExecution()
loadp CodeBlock[cfr], t2
loadi CodeBlock::m_numVars[t2], t2
btiz t2, .opEnterDone
move ValueUndefined, t0
.opEnterLoop:
subi 1, t2
storep t0, [cfr, t2, 8]
btinz t2, .opEnterLoop
.opEnterDone:
dispatch(1)
_llint_op_create_activation:
traceExecution()
loadis 8[PB, PC, 8], t0
bpneq [cfr, t0, 8], ValueEmpty, .opCreateActivationDone
callSlowPath(_llint_slow_path_create_activation)
.opCreateActivationDone:
dispatch(2)
_llint_op_init_lazy_reg:
traceExecution()
loadis 8[PB, PC, 8], t0
storep ValueEmpty, [cfr, t0, 8]
dispatch(2)
_llint_op_create_arguments:
traceExecution()
loadis 8[PB, PC, 8], t0
bpneq [cfr, t0, 8], ValueEmpty, .opCreateArgumentsDone
callSlowPath(_llint_slow_path_create_arguments)
.opCreateArgumentsDone:
dispatch(2)
_llint_op_create_this:
traceExecution()
loadis 16[PB, PC, 8], t0
assertNotConstant(t0)
loadp [cfr, t0, 8], t0
btpnz t0, tagMask, .opCreateThisSlow
loadp JSCell::m_structure[t0], t1
bbb Structure::m_typeInfo + TypeInfo::m_type[t1], ObjectType, .opCreateThisSlow
loadp JSObject::m_inheritorID[t0], t2
btpz t2, .opCreateThisSlow
allocateBasicJSObject(JSFinalObjectSizeClassIndex, JSGlobalData::jsFinalObjectClassInfo, t2, t0, t1, t3, .opCreateThisSlow)
loadis 8[PB, PC, 8], t1
storep t0, [cfr, t1, 8]
dispatch(3)
.opCreateThisSlow:
callSlowPath(_llint_slow_path_create_this)
dispatch(3)
_llint_op_get_callee:
traceExecution()
loadis 8[PB, PC, 8], t0
loadp Callee[cfr], t1
storep t1, [cfr, t0, 8]
dispatch(2)
_llint_op_convert_this:
traceExecution()
loadis 8[PB, PC, 8], t0
loadp [cfr, t0, 8], t0
btpnz t0, tagMask, .opConvertThisSlow
loadp JSCell::m_structure[t0], t0
bbb Structure::m_typeInfo + TypeInfo::m_type[t0], ObjectType, .opConvertThisSlow
dispatch(2)
.opConvertThisSlow:
callSlowPath(_llint_slow_path_convert_this)
dispatch(2)
_llint_op_new_object:
traceExecution()
loadp CodeBlock[cfr], t0
loadp CodeBlock::m_globalObject[t0], t0
loadp JSGlobalObject::m_emptyObjectStructure[t0], t1
allocateBasicJSObject(JSFinalObjectSizeClassIndex, JSGlobalData::jsFinalObjectClassInfo, t1, t0, t2, t3, .opNewObjectSlow)
loadis 8[PB, PC, 8], t1
storep t0, [cfr, t1, 8]
dispatch(2)
.opNewObjectSlow:
callSlowPath(_llint_slow_path_new_object)
dispatch(2)
_llint_op_mov:
traceExecution()
loadis 16[PB, PC, 8], t1
loadis 8[PB, PC, 8], t0
loadConstantOrVariable(t1, t2)
storep t2, [cfr, t0, 8]
dispatch(3)
_llint_op_not:
traceExecution()
loadis 16[PB, PC, 8], t0
loadis 8[PB, PC, 8], t1
loadConstantOrVariable(t0, t2)
xorp ValueFalse, t2
btpnz t2, ~1, .opNotSlow
xorp ValueTrue, t2
storep t2, [cfr, t1, 8]
dispatch(3)
.opNotSlow:
callSlowPath(_llint_slow_path_not)
dispatch(3)
macro equalityComparison(integerComparison, slowPath)
traceExecution()
loadis 24[PB, PC, 8], t0
loadis 16[PB, PC, 8], t2
loadis 8[PB, PC, 8], t3
loadConstantOrVariableInt32(t0, t1, .slow)
loadConstantOrVariableInt32(t2, t0, .slow)
integerComparison(t0, t1, t0)
orp ValueFalse, t0
storep t0, [cfr, t3, 8]
dispatch(4)
.slow:
callSlowPath(slowPath)
dispatch(4)
end
_llint_op_eq:
equalityComparison(
macro (left, right, result) cieq left, right, result end,
_llint_slow_path_eq)
_llint_op_neq:
equalityComparison(
macro (left, right, result) cineq left, right, result end,
_llint_slow_path_neq)
macro equalNullComparison()
loadis 16[PB, PC, 8], t0
loadp [cfr, t0, 8], t0
btpnz t0, tagMask, .immediate
loadp JSCell::m_structure[t0], t2
tbnz Structure::m_typeInfo + TypeInfo::m_flags[t2], MasqueradesAsUndefined, t0
jmp .done
.immediate:
andp ~TagBitUndefined, t0
cpeq t0, ValueNull, t0
.done:
end
_llint_op_eq_null:
traceExecution()
equalNullComparison()
loadis 8[PB, PC, 8], t1
orp ValueFalse, t0
storep t0, [cfr, t1, 8]
dispatch(3)
_llint_op_neq_null:
traceExecution()
equalNullComparison()
loadis 8[PB, PC, 8], t1
xorp ValueTrue, t0
storep t0, [cfr, t1, 8]
dispatch(3)
macro strictEq(equalityOperation, slowPath)
traceExecution()
loadis 24[PB, PC, 8], t0
loadis 16[PB, PC, 8], t2
loadConstantOrVariable(t0, t1)
loadConstantOrVariable(t2, t0)
move t0, t2
orp t1, t2
btpz t2, tagMask, .slow
bpaeq t0, tagTypeNumber, .leftOK
btpnz t0, tagTypeNumber, .slow
.leftOK:
bpaeq t1, tagTypeNumber, .rightOK
btpnz t1, tagTypeNumber, .slow
.rightOK:
equalityOperation(t0, t1, t0)
loadis 8[PB, PC, 8], t1
orp ValueFalse, t0
storep t0, [cfr, t1, 8]
dispatch(4)
.slow:
callSlowPath(slowPath)
dispatch(4)
end
_llint_op_stricteq:
strictEq(
macro (left, right, result) cpeq left, right, result end,
_llint_slow_path_stricteq)
_llint_op_nstricteq:
strictEq(
macro (left, right, result) cpneq left, right, result end,
_llint_slow_path_nstricteq)
macro preOp(arithmeticOperation, slowPath)
traceExecution()
loadis 8[PB, PC, 8], t0
loadp [cfr, t0, 8], t1
bpb t1, tagTypeNumber, .slow
arithmeticOperation(t1, .slow)
orp tagTypeNumber, t1
storep t1, [cfr, t0, 8]
dispatch(2)
.slow:
callSlowPath(slowPath)
dispatch(2)
end
_llint_op_pre_inc:
preOp(
macro (value, slow) baddio 1, value, slow end,
_llint_slow_path_pre_inc)
_llint_op_pre_dec:
preOp(
macro (value, slow) bsubio 1, value, slow end,
_llint_slow_path_pre_dec)
macro postOp(arithmeticOperation, slowPath)
traceExecution()
loadis 16[PB, PC, 8], t0
loadis 8[PB, PC, 8], t1
loadp [cfr, t0, 8], t2
bieq t0, t1, .done
bpb t2, tagTypeNumber, .slow
move t2, t3
arithmeticOperation(t3, .slow)
orp tagTypeNumber, t3
storep t2, [cfr, t1, 8]
storep t3, [cfr, t0, 8]
.done:
dispatch(3)
.slow:
callSlowPath(slowPath)
dispatch(3)
end
_llint_op_post_inc:
postOp(
macro (value, slow) baddio 1, value, slow end,
_llint_slow_path_post_inc)
_llint_op_post_dec:
postOp(
macro (value, slow) bsubio 1, value, slow end,
_llint_slow_path_post_dec)
_llint_op_to_jsnumber:
traceExecution()
loadis 16[PB, PC, 8], t0
loadis 8[PB, PC, 8], t1
loadConstantOrVariable(t0, t2)
bpaeq t2, tagTypeNumber, .opToJsnumberIsImmediate
btpz t2, tagTypeNumber, .opToJsnumberSlow
.opToJsnumberIsImmediate:
storep t2, [cfr, t1, 8]
dispatch(3)
.opToJsnumberSlow:
callSlowPath(_llint_slow_path_to_jsnumber)
dispatch(3)
_llint_op_negate:
traceExecution()
loadis 16[PB, PC, 8], t0
loadis 8[PB, PC, 8], t1
loadConstantOrVariable(t0, t2)
bpb t2, tagTypeNumber, .opNegateNotInt
btiz t2, 0x7fffffff, .opNegateSlow
negi t2
orp tagTypeNumber, t2
storep t2, [cfr, t1, 8]
dispatch(3)
.opNegateNotInt:
btpz t2, tagTypeNumber, .opNegateSlow
xorp 0x8000000000000000, t2
storep t2, [cfr, t1, 8]
dispatch(3)
.opNegateSlow:
callSlowPath(_llint_slow_path_negate)
dispatch(3)
macro binaryOpCustomStore(integerOperationAndStore, doubleOperation, slowPath)
loadis 24[PB, PC, 8], t0
loadis 16[PB, PC, 8], t2
loadConstantOrVariable(t0, t1)
loadConstantOrVariable(t2, t0)
bpb t0, tagTypeNumber, .op1NotInt
bpb t1, tagTypeNumber, .op2NotInt
loadis 8[PB, PC, 8], t2
integerOperationAndStore(t1, t0, .slow, t2)
dispatch(5)
.op1NotInt:
# First operand is definitely not an int, the second operand could be anything.
btpz t0, tagTypeNumber, .slow
bpaeq t1, tagTypeNumber, .op1NotIntOp2Int
btpz t1, tagTypeNumber, .slow
addp tagTypeNumber, t1
fp2d t1, ft1
jmp .op1NotIntReady
.op1NotIntOp2Int:
ci2d t1, ft1
.op1NotIntReady:
loadis 8[PB, PC, 8], t2
addp tagTypeNumber, t0
fp2d t0, ft0
doubleOperation(ft1, ft0)
fd2p ft0, t0
subp tagTypeNumber, t0
storep t0, [cfr, t2, 8]
dispatch(5)
.op2NotInt:
# First operand is definitely an int, the second is definitely not.
loadis 8[PB, PC, 8], t2
btpz t1, tagTypeNumber, .slow
ci2d t0, ft0
addp tagTypeNumber, t1
fp2d t1, ft1
doubleOperation(ft1, ft0)
fd2p ft0, t0
subp tagTypeNumber, t0
storep t0, [cfr, t2, 8]
dispatch(5)
.slow:
callSlowPath(slowPath)
dispatch(5)
end
macro binaryOp(integerOperation, doubleOperation, slowPath)
binaryOpCustomStore(
macro (left, right, slow, index)
integerOperation(left, right, slow)
orp tagTypeNumber, right
storep right, [cfr, index, 8]
end,
doubleOperation, slowPath)
end
_llint_op_add:
traceExecution()
binaryOp(
macro (left, right, slow) baddio left, right, slow end,
macro (left, right) addd left, right end,
_llint_slow_path_add)
_llint_op_mul:
traceExecution()
binaryOpCustomStore(
macro (left, right, slow, index)
# Assume t3 is scratchable.
move right, t3
bmulio left, t3, slow
btinz t3, .done
bilt left, 0, slow
bilt right, 0, slow
.done:
orp tagTypeNumber, t3
storep t3, [cfr, index, 8]
end,
macro (left, right) muld left, right end,
_llint_slow_path_mul)
_llint_op_sub:
traceExecution()
binaryOp(
macro (left, right, slow) bsubio left, right, slow end,
macro (left, right) subd left, right end,
_llint_slow_path_sub)
_llint_op_div:
traceExecution()
binaryOpCustomStore(
macro (left, right, slow, index)
# Assume t3 is scratchable.
btiz left, slow
bineq left, -1, .notNeg2TwoThe31DivByNeg1
bieq right, -2147483648, .slow
.notNeg2TwoThe31DivByNeg1:
btinz right, .intOK
bilt left, 0, slow
.intOK:
move left, t3
move right, t0
cdqi
idivi t3
btinz t1, slow
orp tagTypeNumber, t0
storep t0, [cfr, index, 8]
end,
macro (left, right) divd left, right end,
_llint_slow_path_div)
macro bitOp(operation, slowPath, advance)
loadis 24[PB, PC, 8], t0
loadis 16[PB, PC, 8], t2
loadis 8[PB, PC, 8], t3
loadConstantOrVariable(t0, t1)
loadConstantOrVariable(t2, t0)
bpb t0, tagTypeNumber, .slow
bpb t1, tagTypeNumber, .slow
operation(t1, t0, .slow)
orp tagTypeNumber, t0
storep t0, [cfr, t3, 8]
dispatch(advance)
.slow:
callSlowPath(slowPath)
dispatch(advance)
end
_llint_op_lshift:
traceExecution()
bitOp(
macro (left, right, slow) lshifti left, right end,
_llint_slow_path_lshift,
4)
_llint_op_rshift:
traceExecution()
bitOp(
macro (left, right, slow) rshifti left, right end,
_llint_slow_path_rshift,
4)
_llint_op_urshift:
traceExecution()
bitOp(
macro (left, right, slow)
urshifti left, right
bilt right, 0, slow
end,
_llint_slow_path_urshift,
4)
_llint_op_bitand:
traceExecution()
bitOp(
macro (left, right, slow) andi left, right end,
_llint_slow_path_bitand,
5)
_llint_op_bitxor:
traceExecution()
bitOp(
macro (left, right, slow) xori left, right end,
_llint_slow_path_bitxor,
5)
_llint_op_bitor:
traceExecution()
bitOp(
macro (left, right, slow) ori left, right end,
_llint_slow_path_bitor,
5)
_llint_op_check_has_instance:
traceExecution()
loadis 8[PB, PC, 8], t1
loadConstantOrVariableCell(t1, t0, .opCheckHasInstanceSlow)
loadp JSCell::m_structure[t0], t0
btbz Structure::m_typeInfo + TypeInfo::m_flags[t0], ImplementsHasInstance, .opCheckHasInstanceSlow
dispatch(2)
.opCheckHasInstanceSlow:
callSlowPath(_llint_slow_path_check_has_instance)
dispatch(2)
_llint_op_instanceof:
traceExecution()
# Check that baseVal implements the default HasInstance behavior.
# FIXME: This should be deprecated.
loadis 24[PB, PC, 8], t1
loadConstantOrVariable(t1, t0)
loadp JSCell::m_structure[t0], t0
btbz Structure::m_typeInfo + TypeInfo::m_flags[t0], ImplementsDefaultHasInstance, .opInstanceofSlow
# Actually do the work.
loadis 32[PB, PC, 8], t0
loadis 8[PB, PC, 8], t3
loadConstantOrVariableCell(t0, t1, .opInstanceofSlow)
loadp JSCell::m_structure[t1], t2
bbb Structure::m_typeInfo + TypeInfo::m_type[t2], ObjectType, .opInstanceofSlow
loadis 16[PB, PC, 8], t0
loadConstantOrVariableCell(t0, t2, .opInstanceofSlow)
# Register state: t1 = prototype, t2 = value
move 1, t0
.opInstanceofLoop:
loadp JSCell::m_structure[t2], t2
loadp Structure::m_prototype[t2], t2
bpeq t2, t1, .opInstanceofDone
btpz t2, tagMask, .opInstanceofLoop
move 0, t0
.opInstanceofDone:
orp ValueFalse, t0
storep t0, [cfr, t3, 8]
dispatch(5)
.opInstanceofSlow:
callSlowPath(_llint_slow_path_instanceof)
dispatch(5)
_llint_op_is_undefined:
traceExecution()
loadis 16[PB, PC, 8], t1
loadis 8[PB, PC, 8], t2
loadConstantOrVariable(t1, t0)
btpz t0, tagMask, .opIsUndefinedCell
cpeq t0, ValueUndefined, t3
orp ValueFalse, t3
storep t3, [cfr, t2, 8]
dispatch(3)
.opIsUndefinedCell:
loadp JSCell::m_structure[t0], t0
tbnz Structure::m_typeInfo + TypeInfo::m_flags[t0], MasqueradesAsUndefined, t1
orp ValueFalse, t1
storep t1, [cfr, t2, 8]
dispatch(3)
_llint_op_is_boolean:
traceExecution()
loadis 16[PB, PC, 8], t1
loadis 8[PB, PC, 8], t2
loadConstantOrVariable(t1, t0)
xorp ValueFalse, t0
tpz t0, ~1, t0
orp ValueFalse, t0
storep t0, [cfr, t2, 8]
dispatch(3)
_llint_op_is_number:
traceExecution()
loadis 16[PB, PC, 8], t1
loadis 8[PB, PC, 8], t2
loadConstantOrVariable(t1, t0)
tpnz t0, tagTypeNumber, t1
orp ValueFalse, t1
storep t1, [cfr, t2, 8]
dispatch(3)
_llint_op_is_string:
traceExecution()
loadis 16[PB, PC, 8], t1
loadis 8[PB, PC, 8], t2
loadConstantOrVariable(t1, t0)
btpnz t0, tagMask, .opIsStringNotCell
loadp JSCell::m_structure[t0], t0
cbeq Structure::m_typeInfo + TypeInfo::m_type[t0], StringType, t1
orp ValueFalse, t1
storep t1, [cfr, t2, 8]
dispatch(3)
.opIsStringNotCell:
storep ValueFalse, [cfr, t2, 8]
dispatch(3)
macro resolveGlobal(size, slow)
# Operands are as follows:
# 8[PB, PC, 8] Destination for the load.
# 16[PB, PC, 8] Property identifier index in the code block.
# 24[PB, PC, 8] Structure pointer, initialized to 0 by bytecode generator.
# 32[PB, PC, 8] Offset in global object, initialized to 0 by bytecode generator.
loadp CodeBlock[cfr], t0
loadp CodeBlock::m_globalObject[t0], t0
loadp JSCell::m_structure[t0], t1
bpneq t1, 24[PB, PC, 8], slow
loadis 32[PB, PC, 8], t1
loadp JSObject::m_propertyStorage[t0], t0
loadp [t0, t1, 8], t2
loadis 8[PB, PC, 8], t0
storep t2, [cfr, t0, 8]
loadp (size - 1) * 8[PB, PC, 8], t0
valueProfile(t2, t0)
end
_llint_op_resolve_global:
traceExecution()
resolveGlobal(6, .opResolveGlobalSlow)
dispatch(6)
.opResolveGlobalSlow:
callSlowPath(_llint_slow_path_resolve_global)
dispatch(6)
# Gives you the scope in t0, while allowing you to optionally perform additional checks on the
# scopes as they are traversed. scopeCheck() is called with two arguments: the register
# holding the scope, and a register that can be used for scratch. Note that this does not
# use t3, so you can hold stuff in t3 if need be.
macro getScope(deBruijinIndexOperand, scopeCheck)
loadp ScopeChain[cfr], t0
loadis deBruijinIndexOperand, t2
btiz t2, .done
loadp CodeBlock[cfr], t1
bineq CodeBlock::m_codeType[t1], FunctionCode, .loop
btbz CodeBlock::m_needsFullScopeChain[t1], .loop
loadis CodeBlock::m_activationRegister[t1], t1
# Need to conditionally skip over one scope.
btpz [cfr, t1, 8], .noActivation
scopeCheck(t0, t1)
loadp ScopeChainNode::next[t0], t0
.noActivation:
subi 1, t2
btiz t2, .done
.loop:
scopeCheck(t0, t1)
loadp ScopeChainNode::next[t0], t0
subi 1, t2
btinz t2, .loop
.done:
end
_llint_op_resolve_global_dynamic:
traceExecution()
loadp JITStackFrame::globalData[sp], t3
loadp JSGlobalData::activationStructure[t3], t3
getScope(
40[PB, PC, 8],
macro (scope, scratch)
loadp ScopeChainNode::object[scope], scratch
bpneq JSCell::m_structure[scratch], t3, .opResolveGlobalDynamicSuperSlow
end)
resolveGlobal(7, .opResolveGlobalDynamicSlow)
dispatch(7)
.opResolveGlobalDynamicSuperSlow:
callSlowPath(_llint_slow_path_resolve_for_resolve_global_dynamic)
dispatch(7)
.opResolveGlobalDynamicSlow:
callSlowPath(_llint_slow_path_resolve_global_dynamic)
dispatch(7)
_llint_op_get_scoped_var:
traceExecution()
# Operands are as follows:
# 8[PB, PC, 8] Destination for the load
# 16[PB, PC, 8] Index of register in the scope
# 24[PB, PC, 8] De Bruijin index.
getScope(24[PB, PC, 8], macro (scope, scratch) end)
loadis 8[PB, PC, 8], t1
loadis 16[PB, PC, 8], t2
loadp ScopeChainNode::object[t0], t0
loadp JSVariableObject::m_registers[t0], t0
loadp [t0, t2, 8], t3
storep t3, [cfr, t1, 8]
loadp 32[PB, PC, 8], t1
valueProfile(t3, t1)
dispatch(5)
_llint_op_put_scoped_var:
traceExecution()
getScope(16[PB, PC, 8], macro (scope, scratch) end)
loadis 24[PB, PC, 8], t1
loadConstantOrVariable(t1, t3)
loadis 8[PB, PC, 8], t1
writeBarrier(t3)
loadp ScopeChainNode::object[t0], t0
loadp JSVariableObject::m_registers[t0], t0
storep t3, [t0, t1, 8]
dispatch(4)
_llint_op_get_global_var:
traceExecution()
loadis 16[PB, PC, 8], t1
loadis 8[PB, PC, 8], t3
loadp CodeBlock[cfr], t0
loadp CodeBlock::m_globalObject[t0], t0
loadp JSGlobalObject::m_registers[t0], t0
loadp [t0, t1, 8], t2
storep t2, [cfr, t3, 8]
loadp 24[PB, PC, 8], t3
valueProfile(t2, t3)
dispatch(4)
_llint_op_put_global_var:
traceExecution()
loadis 16[PB, PC, 8], t1
loadp CodeBlock[cfr], t0
loadp CodeBlock::m_globalObject[t0], t0
loadp JSGlobalObject::m_registers[t0], t0
loadConstantOrVariable(t1, t2)
loadis 8[PB, PC, 8], t1
writeBarrier(t2)
storep t2, [t0, t1, 8]
dispatch(3)
_llint_op_get_by_id:
traceExecution()
# We only do monomorphic get_by_id caching for now, and we do not modify the
# opcode. We do, however, allow for the cache to change anytime if fails, since
# ping-ponging is free. At best we get lucky and the get_by_id will continue
# to take fast path on the new cache. At worst we take slow path, which is what
# we would have been doing anyway.
loadis 16[PB, PC, 8], t0
loadp 32[PB, PC, 8], t1
loadConstantOrVariableCell(t0, t3, .opGetByIdSlow)
loadis 40[PB, PC, 8], t2
loadp JSObject::m_propertyStorage[t3], t0
bpneq JSCell::m_structure[t3], t1, .opGetByIdSlow
loadis 8[PB, PC, 8], t1
loadp [t0, t2], t3
storep t3, [cfr, t1, 8]
loadp 64[PB, PC, 8], t1
valueProfile(t3, t1)
dispatch(9)
.opGetByIdSlow:
callSlowPath(_llint_slow_path_get_by_id)
dispatch(9)
_llint_op_get_arguments_length:
traceExecution()
loadis 16[PB, PC, 8], t0
loadis 8[PB, PC, 8], t1
btpnz [cfr, t0, 8], .opGetArgumentsLengthSlow
loadi ArgumentCount + PayloadOffset[cfr], t2
subi 1, t2
orp tagTypeNumber, t2
storep t2, [cfr, t1, 8]
dispatch(4)
.opGetArgumentsLengthSlow:
callSlowPath(_llint_slow_path_get_arguments_length)
dispatch(4)
_llint_op_put_by_id:
traceExecution()
loadis 8[PB, PC, 8], t3
loadp 32[PB, PC, 8], t1
loadConstantOrVariableCell(t3, t0, .opPutByIdSlow)
loadis 24[PB, PC, 8], t2
loadp JSObject::m_propertyStorage[t0], t3
bpneq JSCell::m_structure[t0], t1, .opPutByIdSlow
loadis 40[PB, PC, 8], t1
loadConstantOrVariable(t2, t0)
writeBarrier(t0)
storep t0, [t3, t1]
dispatch(9)
.opPutByIdSlow:
callSlowPath(_llint_slow_path_put_by_id)
dispatch(9)
macro putByIdTransition(additionalChecks)
traceExecution()
loadis 8[PB, PC, 8], t3
loadp 32[PB, PC, 8], t1
loadConstantOrVariableCell(t3, t0, .opPutByIdSlow)
loadis 24[PB, PC, 8], t2
bpneq JSCell::m_structure[t0], t1, .opPutByIdSlow