forked from phoboslab/JavaScriptCore-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLowLevelInterpreter32_64.asm
More file actions
2390 lines (2052 loc) · 69.1 KB
/
LowLevelInterpreter32_64.asm
File metadata and controls
2390 lines (2052 loc) · 69.1 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, 2013 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.
# Crash course on the language that this is written in (which I just call
# "assembly" even though it's more than that):
#
# - Mostly gas-style operand ordering. The last operand tends to be the
# destination. So "a := b" is written as "mov b, a". But unlike gas,
# comparisons are in-order, so "if (a < b)" is written as
# "bilt a, b, ...".
#
# - "b" = byte, "h" = 16-bit word, "i" = 32-bit word, "p" = pointer.
# Currently this is just 32-bit so "i" and "p" are interchangeable
# except when an op supports one but not the other.
#
# - In general, valid operands for macro invocations and instructions are
# registers (eg "t0"), addresses (eg "4[t0]"), base-index addresses
# (eg "7[t0, t1, 2]"), absolute addresses (eg "0xa0000000[]"), or labels
# (eg "_foo" or ".foo"). Macro invocations can also take anonymous
# macros as operands. Instructions cannot take anonymous macros.
#
# - Labels must have names that begin with either "_" or ".". A "." label
# is local and gets renamed before code gen to minimize namespace
# pollution. A "_" label is an extern symbol (i.e. ".globl"). The "_"
# may or may not be removed during code gen depending on whether the asm
# conventions for C name mangling on the target platform mandate a "_"
# prefix.
#
# - A "macro" is a lambda expression, which may be either anonymous or
# named. But this has caveats. "macro" can take zero or more arguments,
# which may be macros or any valid operands, but it can only return
# code. But you can do Turing-complete things via continuation passing
# style: "macro foo (a, b) b(a) end foo(foo, foo)". Actually, don't do
# that, since you'll just crash the assembler.
#
# - An "if" is a conditional on settings. Any identifier supplied in the
# predicate of an "if" is assumed to be a #define that is available
# during code gen. So you can't use "if" for computation in a macro, but
# you can use it to select different pieces of code for different
# platforms.
#
# - Arguments to macros follow lexical scoping rather than dynamic scoping.
# Const's also follow lexical scoping and may override (hide) arguments
# or other consts. All variables (arguments and constants) can be bound
# to operands. Additionally, arguments (but not constants) can be bound
# to macros.
# Below we have a bunch of constant declarations. Each constant must have
# a corresponding ASSERT() in LLIntData.cpp.
# Utilities
macro dispatch(advance)
addp advance * 4, PC
jmp [PC]
end
macro dispatchBranchWithOffset(pcOffset)
lshifti 2, pcOffset
addp pcOffset, PC
jmp [PC]
end
macro dispatchBranch(pcOffset)
loadi pcOffset, t0
dispatchBranchWithOffset(t0)
end
macro dispatchAfterCall()
loadi ArgumentCount + TagOffset[cfr], PC
loadi 4[PC], t2
storei t1, TagOffset[cfr, t2, 8]
storei t0, PayloadOffset[cfr, t2, 8]
valueProfile(t1, t0, 28, t3)
dispatch(8)
end
macro cCall2(function, arg1, arg2)
if ARM or ARMv7 or ARMv7_TRADITIONAL or MIPS
move arg1, a0
move arg2, a1
call function
elsif X86
poke arg1, 0
poke arg2, 1
call function
elsif SH4
setargs arg1, arg2
call function
elsif C_LOOP
cloopCallSlowPath function, arg1, arg2
else
error
end
end
# This barely works. arg3 and arg4 should probably be immediates.
macro cCall4(function, arg1, arg2, arg3, arg4)
if ARM or ARMv7 or ARMv7_TRADITIONAL or MIPS
move arg1, a0
move arg2, a1
move arg3, a2
move arg4, a3
call function
elsif X86
poke arg1, 0
poke arg2, 1
poke arg3, 2
poke arg4, 3
call function
elsif SH4
setargs arg1, arg2, arg3, arg4
call function
elsif C_LOOP
error
else
error
end
end
macro callSlowPath(slowPath)
cCall2(slowPath, cfr, PC)
move t0, PC
move t1, cfr
end
macro functionPrologue(extraStackSpace)
if X86
push cfr
move sp, cfr
end
pushCalleeSaves
if ARM or ARMv7 or ARMv7_TRADITIONAL or MIPS
push cfr
push lr
end
subp extraStackSpace, sp
end
macro functionEpilogue(extraStackSpace)
addp extraStackSpace, sp
if ARM or ARMv7 or ARMv7_TRADITIONAL or MIPS
pop lr
pop cfr
end
popCalleeSaves
if X86
pop cfr
end
end
macro doCallToJavaScript(makeCall, doReturn)
if X86
const entry = t5
const vmTopCallFrame = t2
const protoCallFrame = t4
const extraStackSpace = 28
const previousCFR = t0
const previousPC = t1
const temp1 = t0 # Same as previousCFR
const temp2 = t1 # Same as previousPC
const temp3 = t2 # same as vmTopCallFrame
const temp4 = t3
elsif ARM or ARMv7_TRADITIONAL
const entry = a0
const vmTopCallFrame = a1
const protoCallFrame = a2
const topOfStack = a3
const extraStackSpace = 16
const previousCFR = t3
const previousPC = lr
const temp1 = t3 # Same as previousCFR
const temp2 = a3 # Same as topOfStack
const temp3 = t4
const temp4 = t5
elsif ARMv7
const entry = a0
const vmTopCallFrame = a1
const protoCallFrame = a2
const topOfStack = a3
const extraStackSpace = 28
const previousCFR = t3
const previousPC = lr
const temp1 = t3 # Same as previousCFR
const temp2 = a3 # Same as topOfStack
const temp3 = t4
const temp4 = t5
elsif MIPS
const entry = a0
const vmTopCallFrame = a1
const protoCallFrame = a2
const topOfStack = a3
const extraStackSpace = 36
const previousCFR = t2
const previousPC = lr
const temp1 = t3
const temp2 = t4
const temp3 = t5
const temp4 = t6
elsif SH4
const entry = a0
const vmTopCallFrame = a1
const protoCallFrame = a2
const topOfStack = a3
const extraStackSpace = 20
const previousCFR = t3
const previousPC = lr
const temp1 = t3 # Same as previousCFR
const temp2 = a3 # Same as topOfStack
const temp3 = t8
const temp4 = t9
end
if X86
loadp [sp], previousPC
move cfr, previousCFR
end
functionPrologue(extraStackSpace)
if X86
loadp extraStackSpace+20[sp], entry
loadp extraStackSpace+24[sp], vmTopCallFrame
loadp extraStackSpace+28[sp], protoCallFrame
loadp extraStackSpace+32[sp], cfr
else
move cfr, previousCFR
move topOfStack, cfr
end
subp (CallFrameHeaderSlots-1)*8, cfr
storep 0, ArgumentCount+4[cfr]
storep 0, ArgumentCount[cfr]
storep 0, Callee+4[cfr]
storep vmTopCallFrame, Callee[cfr]
loadp [vmTopCallFrame], temp4
storep 0, ScopeChain+4[cfr]
storep temp4, ScopeChain[cfr]
storep 0, CodeBlock+4[cfr]
storep 1, CodeBlock[cfr]
storep previousPC, ReturnPC[cfr]
storep previousCFR, CallerFrame[cfr]
move cfr, temp1
loadi ProtoCallFrame::paddedArgCount[protoCallFrame], temp2
addp CallFrameHeaderSlots, temp2, temp2
lshiftp 3, temp2
subp temp2, cfr
storep temp1, CallerFrame[cfr]
move 5, temp1
.copyHeaderLoop:
subi 1, temp1
loadp [protoCallFrame, temp1, 8], temp3
storep temp3, CodeBlock[cfr, temp1, 8]
loadp 4[protoCallFrame, temp1, 8], temp3
storep temp3, CodeBlock+4[cfr, temp1, 8]
btinz temp1, .copyHeaderLoop
loadi ProtoCallFrame::argCountAndCodeOriginValue[protoCallFrame], temp2
subi 1, temp2
loadi ProtoCallFrame::paddedArgCount[protoCallFrame], temp3
subi 1, temp3
bieq temp2, temp3, .copyArgs
move 0, temp1
move UndefinedTag, temp4
.fillExtraArgsLoop:
subi 1, temp3
storep temp1, ThisArgumentOffset+8+PayloadOffset[cfr, temp3, 8]
storep temp4, ThisArgumentOffset+8+TagOffset[cfr, temp3, 8]
bineq temp2, temp3, .fillExtraArgsLoop
.copyArgs:
loadp ProtoCallFrame::args[protoCallFrame], temp1
.copyArgsLoop:
btiz temp2, .copyArgsDone
subi 1, temp2
loadp PayloadOffset[temp1, temp2, 8], temp3
loadp TagOffset[temp1, temp2, 8], temp4
storep temp3, ThisArgumentOffset+8+PayloadOffset[cfr, temp2, 8]
storep temp4, ThisArgumentOffset+8+TagOffset[cfr, temp2, 8]
jmp .copyArgsLoop
.copyArgsDone:
if X86
loadp extraStackSpace+24[sp], vmTopCallFrame
end
storep cfr, [vmTopCallFrame]
makeCall(entry, temp1)
bpeq CodeBlock[cfr], 1, .calleeFramePopped
loadp CallerFrame[cfr], cfr
.calleeFramePopped:
loadp Callee[cfr], temp3 # VM.topCallFrame
loadp ScopeChain[cfr], temp4
storep temp4, [temp3]
doReturn(extraStackSpace)
end
macro makeJavaScriptCall(entry, temp)
call entry
end
macro makeHostFunctionCall(entry, temp)
move entry, temp
if X86
# Put cfr on stack as arg0, also put it in ecx for "fastcall" targets
poke cfr, 0
move cfr, t2
else
move cfr, a0
end
call temp
end
macro doReturnFromJavaScript(extraStackSpace)
_returnFromJavaScript:
functionEpilogue(extraStackSpace)
ret
end
macro doReturnFromHostFunction(extraStackSpace)
functionEpilogue(extraStackSpace)
ret
end
# Debugging operation if you'd like to print an operand in the instruction stream. fromWhere
# should be an immediate integer - any integer you like; use it to identify the place you're
# debugging from. operand should likewise be an immediate, and should identify the operand
# in the instruction stream you'd like to print out.
macro traceOperand(fromWhere, operand)
cCall4(_llint_trace_operand, cfr, PC, fromWhere, operand)
move t0, PC
move t1, cfr
end
# Debugging operation if you'd like to print the value of an operand in the instruction
# stream. Same as traceOperand(), but assumes that the operand is a register, and prints its
# value.
macro traceValue(fromWhere, operand)
cCall4(_llint_trace_value, cfr, PC, fromWhere, operand)
move t0, PC
move t1, cfr
end
# Call a slowPath for call opcodes.
macro callCallSlowPath(slowPath, action)
storep PC, ArgumentCount + TagOffset[cfr]
cCall2(slowPath, cfr, PC)
move t1, cfr
action(t0)
end
macro callWatchdogTimerHandler(throwHandler)
storei PC, ArgumentCount + TagOffset[cfr]
cCall2(_llint_slow_path_handle_watchdog_timer, cfr, PC)
move t1, cfr
btpnz t0, throwHandler
loadi ArgumentCount + TagOffset[cfr], PC
end
macro checkSwitchToJITForLoop()
checkSwitchToJIT(
1,
macro ()
storei PC, ArgumentCount + TagOffset[cfr]
cCall2(_llint_loop_osr, cfr, PC)
move t1, cfr
btpz t0, .recover
jmp t0
.recover:
loadi ArgumentCount + TagOffset[cfr], PC
end)
end
macro loadVariable(operand, index, tag, payload)
loadisFromInstruction(operand, index)
loadi TagOffset[cfr, index, 8], tag
loadi PayloadOffset[cfr, index, 8], payload
end
# Index, tag, and payload must be different registers. Index is not
# changed.
macro loadConstantOrVariable(index, tag, payload)
bigteq index, FirstConstantRegisterIndex, .constant
loadi TagOffset[cfr, index, 8], tag
loadi PayloadOffset[cfr, index, 8], payload
jmp .done
.constant:
loadp CodeBlock[cfr], payload
loadp CodeBlock::m_constantRegisters + VectorBufferOffset[payload], payload
# There is a bit of evil here: if the index contains a value >= FirstConstantRegisterIndex,
# then value << 3 will be equal to (value - FirstConstantRegisterIndex) << 3.
loadp TagOffset[payload, index, 8], tag
loadp PayloadOffset[payload, index, 8], payload
.done:
end
macro loadConstantOrVariableTag(index, tag)
bigteq index, FirstConstantRegisterIndex, .constant
loadi TagOffset[cfr, index, 8], tag
jmp .done
.constant:
loadp CodeBlock[cfr], tag
loadp CodeBlock::m_constantRegisters + VectorBufferOffset[tag], tag
# There is a bit of evil here: if the index contains a value >= FirstConstantRegisterIndex,
# then value << 3 will be equal to (value - FirstConstantRegisterIndex) << 3.
loadp TagOffset[tag, index, 8], tag
.done:
end
# Index and payload may be the same register. Index may be clobbered.
macro loadConstantOrVariable2Reg(index, tag, payload)
bigteq index, FirstConstantRegisterIndex, .constant
loadi TagOffset[cfr, index, 8], tag
loadi PayloadOffset[cfr, index, 8], payload
jmp .done
.constant:
loadp CodeBlock[cfr], tag
loadp CodeBlock::m_constantRegisters + VectorBufferOffset[tag], tag
# There is a bit of evil here: if the index contains a value >= FirstConstantRegisterIndex,
# then value << 3 will be equal to (value - FirstConstantRegisterIndex) << 3.
lshifti 3, index
addp index, tag
loadp PayloadOffset[tag], payload
loadp TagOffset[tag], tag
.done:
end
macro loadConstantOrVariablePayloadTagCustom(index, tagCheck, payload)
bigteq index, FirstConstantRegisterIndex, .constant
tagCheck(TagOffset[cfr, index, 8])
loadi PayloadOffset[cfr, index, 8], payload
jmp .done
.constant:
loadp CodeBlock[cfr], payload
loadp CodeBlock::m_constantRegisters + VectorBufferOffset[payload], payload
# There is a bit of evil here: if the index contains a value >= FirstConstantRegisterIndex,
# then value << 3 will be equal to (value - FirstConstantRegisterIndex) << 3.
tagCheck(TagOffset[payload, index, 8])
loadp PayloadOffset[payload, index, 8], payload
.done:
end
# Index and payload must be different registers. Index is not mutated. Use
# this if you know what the tag of the variable should be. Doing the tag
# test as part of loading the variable reduces register use, but may not
# be faster than doing loadConstantOrVariable followed by a branch on the
# tag.
macro loadConstantOrVariablePayload(index, expectedTag, payload, slow)
loadConstantOrVariablePayloadTagCustom(
index,
macro (actualTag) bineq actualTag, expectedTag, slow end,
payload)
end
macro loadConstantOrVariablePayloadUnchecked(index, payload)
loadConstantOrVariablePayloadTagCustom(
index,
macro (actualTag) end,
payload)
end
macro writeBarrier(tag, payload)
# Nothing to do, since we don't have a generational or incremental collector.
end
macro valueProfile(tag, payload, operand, scratch)
if VALUE_PROFILER
loadp operand[PC], scratch
storei tag, ValueProfile::m_buckets + TagOffset[scratch]
storei payload, ValueProfile::m_buckets + PayloadOffset[scratch]
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
cCall2(slow_path, cfr, PC) # This slow_path has a simple protocol: t0 = 0 => no error, t0 != 0 => error
btiz t0, .isArityFixupNeeded
move t1, cfr # t1 contains caller frame
jmp _llint_throw_from_slow_path_trampoline
.isArityFixupNeeded:
btiz t1, .continue
// Move frame up "t1" slots
negi t1
move cfr, t3
loadi PayloadOffset + ArgumentCount[cfr], t2
addi CallFrameHeaderSlots, t2
.copyLoop:
loadi PayloadOffset[t3], t0
storei t0, PayloadOffset[t3, t1, 8]
loadi TagOffset[t3], t0
storei t0, TagOffset[t3, t1, 8]
addp 8, t3
bsubinz 1, t2, .copyLoop
// Fill new slots with JSUndefined
move t1, t2
.fillLoop:
move 0, t0
storei t0, PayloadOffset[t3, t1, 8]
move UndefinedTag, t0
storei t0, TagOffset[t3, t1, 8]
addp 8, t3
baddinz 1, t2, .fillLoop
lshiftp 3, t1
addp t1, cfr
.continue:
# Reload CodeBlock and PC, since the slow_path clobbered it.
loadp CodeBlock[cfr], t1
loadp CodeBlock::m_instructions[t1], PC
jmp doneLabel
end
macro branchIfException(label)
loadp ScopeChain[cfr], t3
andp MarkedBlockMask, t3
loadp MarkedBlock::m_weakSet + WeakSet::m_vm[t3], t3
bieq VM::m_exception + TagOffset[t3], EmptyValueTag, .noException
jmp label
.noException:
end
# Instruction implementations
_llint_op_enter:
traceExecution()
loadp CodeBlock[cfr], t2 // t2<CodeBlock> = cfr.CodeBlock
loadi CodeBlock::m_numVars[t2], t2 // t2<size_t> = t2<CodeBlock>.m_numVars
btiz t2, .opEnterDone
move UndefinedTag, t0
move 0, t1
negi t2
.opEnterLoop:
storei t0, TagOffset[cfr, t2, 8]
storei t1, PayloadOffset[cfr, t2, 8]
addi 1, t2
btinz t2, .opEnterLoop
.opEnterDone:
dispatch(1)
_llint_op_create_activation:
traceExecution()
loadi 4[PC], t0
bineq TagOffset[cfr, t0, 8], EmptyValueTag, .opCreateActivationDone
callSlowPath(_llint_slow_path_create_activation)
.opCreateActivationDone:
dispatch(2)
_llint_op_init_lazy_reg:
traceExecution()
loadi 4[PC], t0
storei EmptyValueTag, TagOffset[cfr, t0, 8]
storei 0, PayloadOffset[cfr, t0, 8]
dispatch(2)
_llint_op_create_arguments:
traceExecution()
loadi 4[PC], t0
bineq TagOffset[cfr, t0, 8], EmptyValueTag, .opCreateArgumentsDone
callSlowPath(_slow_path_create_arguments)
.opCreateArgumentsDone:
dispatch(2)
_llint_op_create_this:
traceExecution()
loadi 8[PC], t0
loadp PayloadOffset[cfr, t0, 8], t0
loadp JSFunction::m_allocationProfile + ObjectAllocationProfile::m_allocator[t0], t1
loadp JSFunction::m_allocationProfile + ObjectAllocationProfile::m_structure[t0], t2
btpz t1, .opCreateThisSlow
allocateJSObject(t1, t2, t0, t3, .opCreateThisSlow)
loadi 4[PC], t1
storei CellTag, TagOffset[cfr, t1, 8]
storei t0, PayloadOffset[cfr, t1, 8]
dispatch(4)
.opCreateThisSlow:
callSlowPath(_slow_path_create_this)
dispatch(4)
_llint_op_get_callee:
traceExecution()
loadi 4[PC], t0
loadp PayloadOffset + Callee[cfr], t1
loadpFromInstruction(2, t2)
bpneq t1, t2, .opGetCalleeSlow
storei CellTag, TagOffset[cfr, t0, 8]
storei t1, PayloadOffset[cfr, t0, 8]
dispatch(3)
.opGetCalleeSlow:
callSlowPath(_slow_path_get_callee)
dispatch(3)
_llint_op_to_this:
traceExecution()
loadi 4[PC], t0
bineq TagOffset[cfr, t0, 8], CellTag, .opToThisSlow
loadi PayloadOffset[cfr, t0, 8], t0
loadp JSCell::m_structure[t0], t0
bbneq Structure::m_typeInfo + TypeInfo::m_type[t0], FinalObjectType, .opToThisSlow
loadpFromInstruction(2, t2)
bpneq t0, t2, .opToThisSlow
dispatch(3)
.opToThisSlow:
callSlowPath(_slow_path_to_this)
dispatch(3)
_llint_op_new_object:
traceExecution()
loadpFromInstruction(3, t0)
loadp ObjectAllocationProfile::m_allocator[t0], t1
loadp ObjectAllocationProfile::m_structure[t0], t2
allocateJSObject(t1, t2, t0, t3, .opNewObjectSlow)
loadi 4[PC], t1
storei CellTag, TagOffset[cfr, t1, 8]
storei t0, PayloadOffset[cfr, t1, 8]
dispatch(4)
.opNewObjectSlow:
callSlowPath(_llint_slow_path_new_object)
dispatch(4)
_llint_op_mov:
traceExecution()
loadi 8[PC], t1
loadi 4[PC], t0
loadConstantOrVariable(t1, t2, t3)
storei t2, TagOffset[cfr, t0, 8]
storei t3, PayloadOffset[cfr, t0, 8]
dispatch(3)
macro notifyWrite(set, valueTag, valuePayload, scratch, slow)
loadb VariableWatchpointSet::m_state[set], scratch
bieq scratch, IsInvalidated, .done
bineq scratch, ClearWatchpoint, .overwrite
storei valueTag, VariableWatchpointSet::m_inferredValue + TagOffset[set]
storei valuePayload, VariableWatchpointSet::m_inferredValue + PayloadOffset[set]
storeb IsWatched, VariableWatchpointSet::m_state[set]
jmp .done
.overwrite:
bineq valuePayload, VariableWatchpointSet::m_inferredValue + PayloadOffset[set], .definitelyDifferent
bieq valueTag, VariableWatchpointSet::m_inferredValue + TagOffset[set], .done
.definitelyDifferent:
btbnz VariableWatchpointSet::m_setIsNotEmpty[set], slow
storei EmptyValueTag, VariableWatchpointSet::m_inferredValue + TagOffset[set]
storei 0, VariableWatchpointSet::m_inferredValue + PayloadOffset[set]
storeb IsInvalidated, VariableWatchpointSet::m_state[set]
.done:
end
_llint_op_captured_mov:
traceExecution()
loadi 8[PC], t1
loadConstantOrVariable(t1, t2, t3)
loadpFromInstruction(3, t0)
btpz t0, .opCapturedMovReady
notifyWrite(t0, t2, t3, t1, .opCapturedMovSlow)
.opCapturedMovReady:
loadi 4[PC], t0
storei t2, TagOffset[cfr, t0, 8]
storei t3, PayloadOffset[cfr, t0, 8]
dispatch(4)
.opCapturedMovSlow:
callSlowPath(_slow_path_captured_mov)
dispatch(4)
_llint_op_not:
traceExecution()
loadi 8[PC], t0
loadi 4[PC], t1
loadConstantOrVariable(t0, t2, t3)
bineq t2, BooleanTag, .opNotSlow
xori 1, t3
storei t2, TagOffset[cfr, t1, 8]
storei t3, PayloadOffset[cfr, t1, 8]
dispatch(3)
.opNotSlow:
callSlowPath(_slow_path_not)
dispatch(3)
_llint_op_eq:
traceExecution()
loadi 12[PC], t2
loadi 8[PC], t0
loadConstantOrVariable(t2, t3, t1)
loadConstantOrVariable2Reg(t0, t2, t0)
bineq t2, t3, .opEqSlow
bieq t2, CellTag, .opEqSlow
bib t2, LowestTag, .opEqSlow
loadi 4[PC], t2
cieq t0, t1, t0
storei BooleanTag, TagOffset[cfr, t2, 8]
storei t0, PayloadOffset[cfr, t2, 8]
dispatch(4)
.opEqSlow:
callSlowPath(_slow_path_eq)
dispatch(4)
_llint_op_eq_null:
traceExecution()
loadi 8[PC], t0
loadi 4[PC], t3
assertNotConstant(t0)
loadi TagOffset[cfr, t0, 8], t1
loadi PayloadOffset[cfr, t0, 8], t0
bineq t1, CellTag, .opEqNullImmediate
loadp JSCell::m_structure[t0], t1
btbnz Structure::m_typeInfo + TypeInfo::m_flags[t1], MasqueradesAsUndefined, .opEqNullMasqueradesAsUndefined
move 0, t1
jmp .opEqNullNotImmediate
.opEqNullMasqueradesAsUndefined:
loadp CodeBlock[cfr], t0
loadp CodeBlock::m_globalObject[t0], t0
cpeq Structure::m_globalObject[t1], t0, t1
jmp .opEqNullNotImmediate
.opEqNullImmediate:
cieq t1, NullTag, t2
cieq t1, UndefinedTag, t1
ori t2, t1
.opEqNullNotImmediate:
storei BooleanTag, TagOffset[cfr, t3, 8]
storei t1, PayloadOffset[cfr, t3, 8]
dispatch(3)
_llint_op_neq:
traceExecution()
loadi 12[PC], t2
loadi 8[PC], t0
loadConstantOrVariable(t2, t3, t1)
loadConstantOrVariable2Reg(t0, t2, t0)
bineq t2, t3, .opNeqSlow
bieq t2, CellTag, .opNeqSlow
bib t2, LowestTag, .opNeqSlow
loadi 4[PC], t2
cineq t0, t1, t0
storei BooleanTag, TagOffset[cfr, t2, 8]
storei t0, PayloadOffset[cfr, t2, 8]
dispatch(4)
.opNeqSlow:
callSlowPath(_slow_path_neq)
dispatch(4)
_llint_op_neq_null:
traceExecution()
loadi 8[PC], t0
loadi 4[PC], t3
assertNotConstant(t0)
loadi TagOffset[cfr, t0, 8], t1
loadi PayloadOffset[cfr, t0, 8], t0
bineq t1, CellTag, .opNeqNullImmediate
loadp JSCell::m_structure[t0], t1
btbnz Structure::m_typeInfo + TypeInfo::m_flags[t1], MasqueradesAsUndefined, .opNeqNullMasqueradesAsUndefined
move 1, t1
jmp .opNeqNullNotImmediate
.opNeqNullMasqueradesAsUndefined:
loadp CodeBlock[cfr], t0
loadp CodeBlock::m_globalObject[t0], t0
cpneq Structure::m_globalObject[t1], t0, t1
jmp .opNeqNullNotImmediate
.opNeqNullImmediate:
cineq t1, NullTag, t2
cineq t1, UndefinedTag, t1
andi t2, t1
.opNeqNullNotImmediate:
storei BooleanTag, TagOffset[cfr, t3, 8]
storei t1, PayloadOffset[cfr, t3, 8]
dispatch(3)
macro strictEq(equalityOperation, slowPath)
loadi 12[PC], t2
loadi 8[PC], t0
loadConstantOrVariable(t2, t3, t1)
loadConstantOrVariable2Reg(t0, t2, t0)
bineq t2, t3, .slow
bib t2, LowestTag, .slow
bineq t2, CellTag, .notString
loadp JSCell::m_structure[t0], t2
loadp JSCell::m_structure[t1], t3
bbneq Structure::m_typeInfo + TypeInfo::m_type[t2], StringType, .notString
bbeq Structure::m_typeInfo + TypeInfo::m_type[t3], StringType, .slow
.notString:
loadi 4[PC], t2
equalityOperation(t0, t1, t0)
storei BooleanTag, TagOffset[cfr, t2, 8]
storei t0, PayloadOffset[cfr, t2, 8]
dispatch(4)
.slow:
callSlowPath(slowPath)
dispatch(4)
end
_llint_op_stricteq:
traceExecution()
strictEq(macro (left, right, result) cieq left, right, result end, _slow_path_stricteq)
_llint_op_nstricteq:
traceExecution()
strictEq(macro (left, right, result) cineq left, right, result end, _slow_path_nstricteq)
_llint_op_inc:
traceExecution()
loadi 4[PC], t0
bineq TagOffset[cfr, t0, 8], Int32Tag, .opIncSlow
loadi PayloadOffset[cfr, t0, 8], t1
baddio 1, t1, .opIncSlow
storei t1, PayloadOffset[cfr, t0, 8]
dispatch(2)
.opIncSlow:
callSlowPath(_slow_path_inc)
dispatch(2)
_llint_op_dec:
traceExecution()
loadi 4[PC], t0
bineq TagOffset[cfr, t0, 8], Int32Tag, .opDecSlow
loadi PayloadOffset[cfr, t0, 8], t1
bsubio 1, t1, .opDecSlow
storei t1, PayloadOffset[cfr, t0, 8]
dispatch(2)
.opDecSlow:
callSlowPath(_slow_path_dec)
dispatch(2)
_llint_op_to_number:
traceExecution()
loadi 8[PC], t0
loadi 4[PC], t1
loadConstantOrVariable(t0, t2, t3)
bieq t2, Int32Tag, .opToNumberIsInt
biaeq t2, LowestTag, .opToNumberSlow
.opToNumberIsInt:
storei t2, TagOffset[cfr, t1, 8]
storei t3, PayloadOffset[cfr, t1, 8]
dispatch(3)
.opToNumberSlow:
callSlowPath(_slow_path_to_number)
dispatch(3)
_llint_op_negate:
traceExecution()
loadi 8[PC], t0
loadi 4[PC], t3
loadConstantOrVariable(t0, t1, t2)
bineq t1, Int32Tag, .opNegateSrcNotInt
btiz t2, 0x7fffffff, .opNegateSlow
negi t2
storei Int32Tag, TagOffset[cfr, t3, 8]
storei t2, PayloadOffset[cfr, t3, 8]
dispatch(3)
.opNegateSrcNotInt:
bia t1, LowestTag, .opNegateSlow
xori 0x80000000, t1
storei t1, TagOffset[cfr, t3, 8]
storei t2, PayloadOffset[cfr, t3, 8]
dispatch(3)
.opNegateSlow:
callSlowPath(_slow_path_negate)
dispatch(3)
macro binaryOpCustomStore(integerOperationAndStore, doubleOperation, slowPath)
loadi 12[PC], t2
loadi 8[PC], t0
loadConstantOrVariable(t2, t3, t1)
loadConstantOrVariable2Reg(t0, t2, t0)
bineq t2, Int32Tag, .op1NotInt
bineq t3, Int32Tag, .op2NotInt
loadi 4[PC], t2
integerOperationAndStore(t3, t1, t0, .slow, t2)
dispatch(5)
.op1NotInt:
# First operand is definitely not an int, the second operand could be anything.
bia t2, LowestTag, .slow
bib t3, LowestTag, .op1NotIntOp2Double
bineq t3, Int32Tag, .slow
ci2d t1, ft1
jmp .op1NotIntReady
.op1NotIntOp2Double:
fii2d t1, t3, ft1
.op1NotIntReady:
loadi 4[PC], t1
fii2d t0, t2, ft0
doubleOperation(ft1, ft0)
stored ft0, [cfr, t1, 8]
dispatch(5)
.op2NotInt:
# First operand is definitely an int, the second operand is definitely not.
loadi 4[PC], t2
bia t3, LowestTag, .slow
ci2d t0, ft0
fii2d t1, t3, ft1
doubleOperation(ft1, ft0)
stored ft0, [cfr, t2, 8]
dispatch(5)
.slow:
callSlowPath(slowPath)
dispatch(5)
end
macro binaryOp(integerOperation, doubleOperation, slowPath)
binaryOpCustomStore(
macro (int32Tag, left, right, slow, index)
integerOperation(left, right, slow)
storei int32Tag, TagOffset[cfr, index, 8]
storei right, PayloadOffset[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,
_slow_path_add)
_llint_op_mul:
traceExecution()
binaryOpCustomStore(
macro (int32Tag, left, right, slow, index)
const scratch = int32Tag # We know that we can reuse the int32Tag register since it has a constant.
move right, scratch
bmulio left, scratch, slow