forked from qt/qtwebkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLowLevelInterpreter64.asm
More file actions
2327 lines (1958 loc) · 63.3 KB
/
Copy pathLowLevelInterpreter64.asm
File metadata and controls
2327 lines (1958 loc) · 63.3 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-2016 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.
# Utilities.
macro jumpToInstruction()
jmp [PB, PC, 8]
end
macro dispatch(advance)
addp advance, PC
jumpToInstruction()
end
macro dispatchInt(advance)
addi advance, PC
jumpToInstruction()
end
macro dispatchIntIndirect(offset)
dispatchInt(offset * 8[PB, PC, 8])
end
macro dispatchAfterCall()
loadi ArgumentCount + TagOffset[cfr], PC
loadp CodeBlock[cfr], PB
loadp CodeBlock::m_instructions[PB], PB
loadisFromInstruction(1, t1)
storeq r0, [cfr, t1, 8]
valueProfile(r0, (CallOpCodeSize - 1), t3)
dispatch(CallOpCodeSize)
end
macro cCall2(function)
checkStackPointerAlignment(t4, 0xbad0c002)
if X86_64 or ARM64
call function
elsif X86_64_WIN
# Note: this implementation is only correct if the return type size is > 8 bytes.
# See macro cCall2Void for an implementation when the return type <= 8 bytes.
# On Win64, when the return type is larger than 8 bytes, we need to allocate space on the stack for the return value.
# On entry rcx (a0), should contain a pointer to this stack space. The other parameters are shifted to the right,
# rdx (a1) should contain the first argument, and r8 (a2) should contain the second argument.
# On return, rax contains a pointer to this stack value, and we then need to copy the 16 byte return value into rax (r0) and rdx (r1)
# since the return value is expected to be split between the two.
# See http://msdn.microsoft.com/en-us/library/7572ztz4.aspx
move a1, a2
move a0, a1
subp 48, sp
move sp, a0
addp 32, a0
call function
addp 48, sp
move 8[r0], r1
move [r0], r0
elsif C_LOOP
cloopCallSlowPath function, a0, a1
else
error
end
end
macro cCall2Void(function)
if C_LOOP
cloopCallSlowPathVoid function, a0, a1
elsif X86_64_WIN
# Note: we cannot use the cCall2 macro for Win64 in this case,
# as the Win64 cCall2 implemenation is only correct when the return type size is > 8 bytes.
# On Win64, rcx and rdx are used for passing the first two parameters.
# We also need to make room on the stack for all four parameter registers.
# See http://msdn.microsoft.com/en-us/library/ms235286.aspx
subp 32, sp
call function
addp 32, sp
else
cCall2(function)
end
end
# This barely works. arg3 and arg4 should probably be immediates.
macro cCall4(function)
checkStackPointerAlignment(t4, 0xbad0c004)
if X86_64 or ARM64
call function
elsif X86_64_WIN
# On Win64, rcx, rdx, r8, and r9 are used for passing the first four parameters.
# We also need to make room on the stack for all four parameter registers.
# See http://msdn.microsoft.com/en-us/library/ms235286.aspx
subp 64, sp
call function
addp 64, sp
else
error
end
end
macro doVMEntry(makeCall)
functionPrologue()
pushCalleeSaves()
const entry = a0
const vm = a1
const protoCallFrame = a2
vmEntryRecord(cfr, sp)
checkStackPointerAlignment(t4, 0xbad0dc01)
storep vm, VMEntryRecord::m_vm[sp]
loadp VM::topCallFrame[vm], t4
storep t4, VMEntryRecord::m_prevTopCallFrame[sp]
loadp VM::topVMEntryFrame[vm], t4
storep t4, VMEntryRecord::m_prevTopVMEntryFrame[sp]
loadi ProtoCallFrame::paddedArgCount[protoCallFrame], t4
addp CallFrameHeaderSlots, t4, t4
lshiftp 3, t4
subp sp, t4, t3
# Ensure that we have enough additional stack capacity for the incoming args,
# and the frame for the JS code we're executing. We need to do this check
# before we start copying the args from the protoCallFrame below.
bpaeq t3, VM::m_jsStackLimit[vm], .stackHeightOK
if C_LOOP
move entry, t4
move vm, t5
cloopCallSlowPath _llint_stack_check_at_vm_entry, vm, t3
bpeq t0, 0, .stackCheckFailed
move t4, entry
move t5, vm
jmp .stackHeightOK
.stackCheckFailed:
move t4, entry
move t5, vm
end
move vm, a0
move protoCallFrame, a1
cCall2(_llint_throw_stack_overflow_error)
vmEntryRecord(cfr, t4)
loadp VMEntryRecord::m_vm[t4], vm
loadp VMEntryRecord::m_prevTopCallFrame[t4], extraTempReg
storep extraTempReg, VM::topCallFrame[vm]
loadp VMEntryRecord::m_prevTopVMEntryFrame[t4], extraTempReg
storep extraTempReg, VM::topVMEntryFrame[vm]
subp cfr, CalleeRegisterSaveSize, sp
popCalleeSaves()
functionEpilogue()
ret
.stackHeightOK:
move t3, sp
move 4, t3
.copyHeaderLoop:
subi 1, t3
loadq [protoCallFrame, t3, 8], extraTempReg
storeq extraTempReg, CodeBlock[sp, t3, 8]
btinz t3, .copyHeaderLoop
loadi PayloadOffset + ProtoCallFrame::argCountAndCodeOriginValue[protoCallFrame], t4
subi 1, t4
loadi ProtoCallFrame::paddedArgCount[protoCallFrame], extraTempReg
subi 1, extraTempReg
bieq t4, extraTempReg, .copyArgs
move ValueUndefined, t3
.fillExtraArgsLoop:
subi 1, extraTempReg
storeq t3, ThisArgumentOffset + 8[sp, extraTempReg, 8]
bineq t4, extraTempReg, .fillExtraArgsLoop
.copyArgs:
loadp ProtoCallFrame::args[protoCallFrame], t3
.copyArgsLoop:
btiz t4, .copyArgsDone
subi 1, t4
loadq [t3, t4, 8], extraTempReg
storeq extraTempReg, ThisArgumentOffset + 8[sp, t4, 8]
jmp .copyArgsLoop
.copyArgsDone:
if ARM64
move sp, t4
storep t4, VM::topCallFrame[vm]
else
storep sp, VM::topCallFrame[vm]
end
storep cfr, VM::topVMEntryFrame[vm]
checkStackPointerAlignment(extraTempReg, 0xbad0dc02)
makeCall(entry, t3)
# We may have just made a call into a JS function, so we can't rely on sp
# for anything but the fact that our own locals (ie the VMEntryRecord) are
# not below it. It also still has to be aligned, though.
checkStackPointerAlignment(t2, 0xbad0dc03)
vmEntryRecord(cfr, t4)
loadp VMEntryRecord::m_vm[t4], vm
loadp VMEntryRecord::m_prevTopCallFrame[t4], t2
storep t2, VM::topCallFrame[vm]
loadp VMEntryRecord::m_prevTopVMEntryFrame[t4], t2
storep t2, VM::topVMEntryFrame[vm]
subp cfr, CalleeRegisterSaveSize, sp
popCalleeSaves()
functionEpilogue()
ret
end
macro makeJavaScriptCall(entry, temp)
addp 16, sp
if C_LOOP
cloopCallJSFunction entry
else
call entry
end
subp 16, sp
end
macro makeHostFunctionCall(entry, temp)
move entry, temp
storep cfr, [sp]
move sp, a0
if C_LOOP
storep lr, 8[sp]
cloopCallNative temp
elsif X86_64_WIN
# We need to allocate 32 bytes on the stack for the shadow space.
subp 32, sp
call temp
addp 32, sp
else
call temp
end
end
_handleUncaughtException:
loadp Callee[cfr], t3
andp MarkedBlockMask, t3
loadp MarkedBlock::m_weakSet + WeakSet::m_vm[t3], t3
restoreCalleeSavesFromVMCalleeSavesBuffer(t3, t0)
loadp VM::callFrameForCatch[t3], cfr
storep 0, VM::callFrameForCatch[t3]
loadp CallerFrame[cfr], cfr
vmEntryRecord(cfr, t2)
loadp VMEntryRecord::m_vm[t2], t3
loadp VMEntryRecord::m_prevTopCallFrame[t2], extraTempReg
storep extraTempReg, VM::topCallFrame[t3]
loadp VMEntryRecord::m_prevTopVMEntryFrame[t2], extraTempReg
storep extraTempReg, VM::topVMEntryFrame[t3]
subp cfr, CalleeRegisterSaveSize, sp
popCalleeSaves()
functionEpilogue()
ret
macro prepareStateForCCall()
leap [PB, PC, 8], PC
end
macro restoreStateAfterCCall()
move r0, PC
subp PB, PC
rshiftp 3, PC
end
macro callSlowPath(slowPath)
prepareStateForCCall()
move cfr, a0
move PC, a1
cCall2(slowPath)
restoreStateAfterCCall()
end
macro traceOperand(fromWhere, operand)
prepareStateForCCall()
move fromWhere, a2
move operand, a3
move cfr, a0
move PC, a1
cCall4(_llint_trace_operand)
restoreStateAfterCCall()
end
macro traceValue(fromWhere, operand)
prepareStateForCCall()
move fromWhere, a2
move operand, a3
move cfr, a0
move PC, a1
cCall4(_llint_trace_value)
restoreStateAfterCCall()
end
# Call a slow path for call call opcodes.
macro callCallSlowPath(slowPath, action)
storei PC, ArgumentCount + TagOffset[cfr]
prepareStateForCCall()
move cfr, a0
move PC, a1
cCall2(slowPath)
action(r0, r1)
end
macro callWatchdogTimerHandler(throwHandler)
storei PC, ArgumentCount + TagOffset[cfr]
prepareStateForCCall()
move cfr, a0
move PC, a1
cCall2(_llint_slow_path_handle_watchdog_timer)
btpnz r0, throwHandler
loadi ArgumentCount + TagOffset[cfr], PC
end
macro checkSwitchToJITForLoop()
checkSwitchToJIT(
1,
macro()
storei PC, ArgumentCount + TagOffset[cfr]
prepareStateForCCall()
move cfr, a0
move PC, a1
cCall2(_llint_loop_osr)
btpz r0, .recover
move r1, sp
jmp r0
.recover:
loadi ArgumentCount + TagOffset[cfr], PC
end)
end
macro loadVariable(operand, value)
loadisFromInstruction(operand, value)
loadq [cfr, value, 8], value
end
# Index and value must be different registers. Index may be clobbered.
macro loadConstantOrVariable(index, value)
bpgteq index, FirstConstantRegisterIndex, .constant
loadq [cfr, index, 8], value
jmp .done
.constant:
loadp CodeBlock[cfr], value
loadp CodeBlock::m_constantRegisters + VectorBufferOffset[value], value
subp FirstConstantRegisterIndex, index
loadq [value, index, 8], value
.done:
end
macro loadConstantOrVariableInt32(index, value, slow)
loadConstantOrVariable(index, value)
bqb value, tagTypeNumber, slow
end
macro loadConstantOrVariableCell(index, value, slow)
loadConstantOrVariable(index, value)
btqnz value, tagMask, slow
end
macro writeBarrierOnOperand(cellOperand)
loadisFromInstruction(cellOperand, t1)
loadConstantOrVariableCell(t1, t2, .writeBarrierDone)
skipIfIsRememberedOrInEden(t2, t1, t3,
macro(cellState)
btbnz cellState, .writeBarrierDone
push PB, PC
move t2, a1 # t2 can be a0 (not on 64 bits, but better safe than sorry)
move cfr, a0
cCall2Void(_llint_write_barrier_slow)
pop PC, PB
end
)
.writeBarrierDone:
end
macro writeBarrierOnOperands(cellOperand, valueOperand)
loadisFromInstruction(valueOperand, t1)
loadConstantOrVariableCell(t1, t0, .writeBarrierDone)
btpz t0, .writeBarrierDone
writeBarrierOnOperand(cellOperand)
.writeBarrierDone:
end
macro writeBarrierOnGlobal(valueOperand, loadHelper)
loadisFromInstruction(valueOperand, t1)
loadConstantOrVariableCell(t1, t0, .writeBarrierDone)
btpz t0, .writeBarrierDone
loadHelper(t3)
skipIfIsRememberedOrInEden(t3, t1, t2,
macro(gcData)
btbnz gcData, .writeBarrierDone
push PB, PC
move cfr, a0
move t3, a1
cCall2Void(_llint_write_barrier_slow)
pop PC, PB
end
)
.writeBarrierDone:
end
macro writeBarrierOnGlobalObject(valueOperand)
writeBarrierOnGlobal(valueOperand,
macro(registerToStoreGlobal)
loadp CodeBlock[cfr], registerToStoreGlobal
loadp CodeBlock::m_globalObject[registerToStoreGlobal], registerToStoreGlobal
end)
end
macro writeBarrierOnGlobalLexicalEnvironment(valueOperand)
writeBarrierOnGlobal(valueOperand,
macro(registerToStoreGlobal)
loadp CodeBlock[cfr], registerToStoreGlobal
loadp CodeBlock::m_globalObject[registerToStoreGlobal], registerToStoreGlobal
loadp JSGlobalObject::m_globalLexicalEnvironment[registerToStoreGlobal], registerToStoreGlobal
end)
end
macro valueProfile(value, operand, scratch)
loadpFromInstruction(operand, scratch)
storeq value, ValueProfile::m_buckets[scratch]
end
macro structureIDToStructureWithScratch(structureIDThenStructure, scratch)
loadp CodeBlock[cfr], scratch
loadp CodeBlock::m_vm[scratch], scratch
loadp VM::heap + Heap::m_structureIDTable + StructureIDTable::m_table[scratch], scratch
loadp [scratch, structureIDThenStructure, 8], structureIDThenStructure
end
macro loadStructureWithScratch(cell, structure, scratch)
loadi JSCell::m_structureID[cell], structure
structureIDToStructureWithScratch(structure, scratch)
end
macro loadStructureAndClobberFirstArg(cell, structure)
loadi JSCell::m_structureID[cell], structure
loadp CodeBlock[cfr], cell
loadp CodeBlock::m_vm[cell], cell
loadp VM::heap + Heap::m_structureIDTable + StructureIDTable::m_table[cell], cell
loadp [cell, structure, 8], structure
end
macro storeStructureWithTypeInfo(cell, structure, scratch)
loadq Structure::m_blob + StructureIDBlob::u.doubleWord[structure], scratch
storeq scratch, JSCell::m_structureID[cell]
end
# Entrypoints into the interpreter.
# Expects that CodeBlock is in t1, which is what prologue() leaves behind.
macro functionArityCheck(doneLabel, slowPath)
loadi PayloadOffset + ArgumentCount[cfr], t0
biaeq t0, CodeBlock::m_numParameters[t1], doneLabel
prepareStateForCCall()
move cfr, a0
move PC, a1
cCall2(slowPath) # This slowPath has the protocol: r0 = 0 => no error, r0 != 0 => error
btiz r0, .noError
move r1, cfr # r1 contains caller frame
jmp _llint_throw_from_slow_path_trampoline
.noError:
loadi CommonSlowPaths::ArityCheckData::paddedStackSpace[r1], t1
btiz t1, .continue
loadi PayloadOffset + ArgumentCount[cfr], t2
addi CallFrameHeaderSlots, t2
// Check if there are some unaligned slots we can use
move t1, t3
andi StackAlignmentSlots - 1, t3
btiz t3, .noExtraSlot
move ValueUndefined, t0
.fillExtraSlots:
storeq t0, [cfr, t2, 8]
addi 1, t2
bsubinz 1, t3, .fillExtraSlots
andi ~(StackAlignmentSlots - 1), t1
btiz t1, .continue
.noExtraSlot:
// Move frame up t1 slots
negq t1
move cfr, t3
subp CalleeSaveSpaceAsVirtualRegisters * 8, t3
addi CalleeSaveSpaceAsVirtualRegisters, t2
.copyLoop:
loadq [t3], t0
storeq t0, [t3, t1, 8]
addp 8, t3
bsubinz 1, t2, .copyLoop
// Fill new slots with JSUndefined
move t1, t2
move ValueUndefined, t0
.fillLoop:
storeq t0, [t3, t1, 8]
addp 8, t3
baddinz 1, t2, .fillLoop
lshiftp 3, t1
addp t1, cfr
addp t1, sp
.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
macro branchIfException(label)
loadp Callee[cfr], t3
andp MarkedBlockMask, t3
loadp MarkedBlock::m_weakSet + WeakSet::m_vm[t3], t3
btqz VM::m_exception[t3], .noException
jmp label
.noException:
end
# Instruction implementations
_llint_op_enter:
traceExecution()
checkStackPointerAlignment(t2, 0xdead00e1)
loadp CodeBlock[cfr], t2 // t2<CodeBlock> = cfr.CodeBlock
loadi CodeBlock::m_numVars[t2], t2 // t2<size_t> = t2<CodeBlock>.m_numVars
subq CalleeSaveSpaceAsVirtualRegisters, t2
move cfr, t1
subq CalleeSaveSpaceAsVirtualRegisters * 8, t1
btiz t2, .opEnterDone
move ValueUndefined, t0
negi t2
sxi2q t2, t2
.opEnterLoop:
storeq t0, [t1, t2, 8]
addq 1, t2
btqnz t2, .opEnterLoop
.opEnterDone:
callSlowPath(_slow_path_enter)
dispatch(1)
_llint_op_get_scope:
traceExecution()
loadp Callee[cfr], t0
loadp JSCallee::m_scope[t0], t0
loadisFromInstruction(1, t1)
storeq t0, [cfr, t1, 8]
dispatch(2)
_llint_op_create_this:
traceExecution()
loadisFromInstruction(2, t0)
loadp [cfr, t0, 8], t0
loadp JSFunction::m_rareData[t0], t3
btpz t3, .opCreateThisSlow
loadp FunctionRareData::m_objectAllocationProfile + ObjectAllocationProfile::m_allocator[t3], t1
loadp FunctionRareData::m_objectAllocationProfile + ObjectAllocationProfile::m_structure[t3], t2
btpz t1, .opCreateThisSlow
loadpFromInstruction(4, t3)
bpeq t3, 1, .hasSeenMultipleCallee
bpneq t3, t0, .opCreateThisSlow
.hasSeenMultipleCallee:
allocateJSObject(t1, t2, t0, t3, .opCreateThisSlow)
loadisFromInstruction(1, t1)
storeq t0, [cfr, t1, 8]
dispatch(5)
.opCreateThisSlow:
callSlowPath(_slow_path_create_this)
dispatch(5)
_llint_op_to_this:
traceExecution()
loadisFromInstruction(1, t0)
loadq [cfr, t0, 8], t0
btqnz t0, tagMask, .opToThisSlow
bbneq JSCell::m_type[t0], FinalObjectType, .opToThisSlow
loadStructureWithScratch(t0, t1, t2)
loadpFromInstruction(2, t2)
bpneq t1, t2, .opToThisSlow
dispatch(4)
.opToThisSlow:
callSlowPath(_slow_path_to_this)
dispatch(4)
_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)
loadisFromInstruction(1, t1)
storeq t0, [cfr, t1, 8]
dispatch(4)
.opNewObjectSlow:
callSlowPath(_llint_slow_path_new_object)
dispatch(4)
_llint_op_check_tdz:
traceExecution()
loadisFromInstruction(1, t0)
loadConstantOrVariable(t0, t1)
bqneq t1, ValueEmpty, .opNotTDZ
callSlowPath(_slow_path_throw_tdz_error)
.opNotTDZ:
dispatch(2)
_llint_op_mov:
traceExecution()
loadisFromInstruction(2, t1)
loadisFromInstruction(1, t0)
loadConstantOrVariable(t1, t2)
storeq t2, [cfr, t0, 8]
dispatch(3)
_llint_op_not:
traceExecution()
loadisFromInstruction(2, t0)
loadisFromInstruction(1, t1)
loadConstantOrVariable(t0, t2)
xorq ValueFalse, t2
btqnz t2, ~1, .opNotSlow
xorq ValueTrue, t2
storeq t2, [cfr, t1, 8]
dispatch(3)
.opNotSlow:
callSlowPath(_slow_path_not)
dispatch(3)
macro equalityComparison(integerComparison, slowPath)
traceExecution()
loadisFromInstruction(3, t0)
loadisFromInstruction(2, t2)
loadisFromInstruction(1, t3)
loadConstantOrVariableInt32(t0, t1, .slow)
loadConstantOrVariableInt32(t2, t0, .slow)
integerComparison(t0, t1, t0)
orq ValueFalse, t0
storeq 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,
_slow_path_eq)
_llint_op_neq:
equalityComparison(
macro (left, right, result) cineq left, right, result end,
_slow_path_neq)
macro equalNullComparison()
loadisFromInstruction(2, t0)
loadq [cfr, t0, 8], t0
btqnz t0, tagMask, .immediate
btbnz JSCell::m_flags[t0], MasqueradesAsUndefined, .masqueradesAsUndefined
move 0, t0
jmp .done
.masqueradesAsUndefined:
loadStructureWithScratch(t0, t2, t1)
loadp CodeBlock[cfr], t0
loadp CodeBlock::m_globalObject[t0], t0
cpeq Structure::m_globalObject[t2], t0, t0
jmp .done
.immediate:
andq ~TagBitUndefined, t0
cqeq t0, ValueNull, t0
.done:
end
_llint_op_eq_null:
traceExecution()
equalNullComparison()
loadisFromInstruction(1, t1)
orq ValueFalse, t0
storeq t0, [cfr, t1, 8]
dispatch(3)
_llint_op_neq_null:
traceExecution()
equalNullComparison()
loadisFromInstruction(1, t1)
xorq ValueTrue, t0
storeq t0, [cfr, t1, 8]
dispatch(3)
macro strictEq(equalityOperation, slowPath)
traceExecution()
loadisFromInstruction(3, t0)
loadisFromInstruction(2, t2)
loadConstantOrVariable(t0, t1)
loadConstantOrVariable(t2, t0)
move t0, t2
orq t1, t2
btqz t2, tagMask, .slow
bqaeq t0, tagTypeNumber, .leftOK
btqnz t0, tagTypeNumber, .slow
.leftOK:
bqaeq t1, tagTypeNumber, .rightOK
btqnz t1, tagTypeNumber, .slow
.rightOK:
equalityOperation(t0, t1, t0)
loadisFromInstruction(1, t1)
orq ValueFalse, t0
storeq t0, [cfr, t1, 8]
dispatch(4)
.slow:
callSlowPath(slowPath)
dispatch(4)
end
_llint_op_stricteq:
strictEq(
macro (left, right, result) cqeq left, right, result end,
_slow_path_stricteq)
_llint_op_nstricteq:
strictEq(
macro (left, right, result) cqneq left, right, result end,
_slow_path_nstricteq)
macro preOp(arithmeticOperation, slowPath)
traceExecution()
loadisFromInstruction(1, t0)
loadq [cfr, t0, 8], t1
bqb t1, tagTypeNumber, .slow
arithmeticOperation(t1, .slow)
orq tagTypeNumber, t1
storeq t1, [cfr, t0, 8]
dispatch(2)
.slow:
callSlowPath(slowPath)
dispatch(2)
end
_llint_op_inc:
preOp(
macro (value, slow) baddio 1, value, slow end,
_slow_path_inc)
_llint_op_dec:
preOp(
macro (value, slow) bsubio 1, value, slow end,
_slow_path_dec)
_llint_op_to_number:
traceExecution()
loadisFromInstruction(2, t0)
loadisFromInstruction(1, t1)
loadConstantOrVariable(t0, t2)
bqaeq t2, tagTypeNumber, .opToNumberIsImmediate
btqz t2, tagTypeNumber, .opToNumberSlow
.opToNumberIsImmediate:
storeq t2, [cfr, t1, 8]
dispatch(3)
.opToNumberSlow:
callSlowPath(_slow_path_to_number)
dispatch(3)
_llint_op_to_string:
traceExecution()
loadisFromInstruction(2, t1)
loadisFromInstruction(1, t2)
loadConstantOrVariable(t1, t0)
btqnz t0, tagMask, .opToStringSlow
bbneq JSCell::m_type[t0], StringType, .opToStringSlow
.opToStringIsString:
storeq t0, [cfr, t2, 8]
dispatch(3)
.opToStringSlow:
callSlowPath(_slow_path_to_string)
dispatch(3)
_llint_op_negate:
traceExecution()
loadisFromInstruction(2, t0)
loadisFromInstruction(1, t1)
loadConstantOrVariable(t0, t2)
bqb t2, tagTypeNumber, .opNegateNotInt
btiz t2, 0x7fffffff, .opNegateSlow
negi t2
orq tagTypeNumber, t2
storeq t2, [cfr, t1, 8]
dispatch(3)
.opNegateNotInt:
btqz t2, tagTypeNumber, .opNegateSlow
xorq 0x8000000000000000, t2
storeq t2, [cfr, t1, 8]
dispatch(3)
.opNegateSlow:
callSlowPath(_slow_path_negate)
dispatch(3)
macro binaryOpCustomStore(integerOperationAndStore, doubleOperation, slowPath)
loadisFromInstruction(3, t0)
loadisFromInstruction(2, t2)
loadConstantOrVariable(t0, t1)
loadConstantOrVariable(t2, t0)
bqb t0, tagTypeNumber, .op1NotInt
bqb t1, tagTypeNumber, .op2NotInt
loadisFromInstruction(1, t2)
integerOperationAndStore(t1, t0, .slow, t2)
dispatch(5)
.op1NotInt:
# First operand is definitely not an int, the second operand could be anything.
btqz t0, tagTypeNumber, .slow
bqaeq t1, tagTypeNumber, .op1NotIntOp2Int
btqz t1, tagTypeNumber, .slow
addq tagTypeNumber, t1
fq2d t1, ft1
jmp .op1NotIntReady
.op1NotIntOp2Int:
ci2d t1, ft1
.op1NotIntReady:
loadisFromInstruction(1, t2)
addq tagTypeNumber, t0
fq2d t0, ft0
doubleOperation(ft1, ft0)
fd2q ft0, t0
subq tagTypeNumber, t0
storeq t0, [cfr, t2, 8]
dispatch(5)
.op2NotInt:
# First operand is definitely an int, the second is definitely not.
loadisFromInstruction(1, t2)
btqz t1, tagTypeNumber, .slow
ci2d t0, ft0
addq tagTypeNumber, t1
fq2d t1, ft1
doubleOperation(ft1, ft0)
fd2q ft0, t0
subq tagTypeNumber, t0
storeq 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)
orq tagTypeNumber, right
storeq 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,
_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:
orq tagTypeNumber, t3
storeq t3, [cfr, index, 8]
end,
macro (left, right) muld left, right end,
_slow_path_mul)
_llint_op_sub:
traceExecution()
binaryOp(
macro (left, right, slow) bsubio left, right, slow end,
macro (left, right) subd left, right end,
_slow_path_sub)
_llint_op_div:
traceExecution()
if X86_64 or X86_64_WIN
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
orq tagTypeNumber, t0
storeq t0, [cfr, index, 8]
end,
macro (left, right) divd left, right end,
_slow_path_div)
else
callSlowPath(_slow_path_div)
dispatch(5)
end
macro bitOp(operation, slowPath, advance)
loadisFromInstruction(3, t0)
loadisFromInstruction(2, t2)
loadisFromInstruction(1, t3)
loadConstantOrVariable(t0, t1)
loadConstantOrVariable(t2, t0)
bqb t0, tagTypeNumber, .slow
bqb t1, tagTypeNumber, .slow