FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
WebKit/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp at main · WebKit/WebKit · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
WebKit
/
WebKit
Public
Notifications
You must be signed in to change notification settings
Fork
2.1k
Star
10.1k
Code
Pull requests
2.6k
Actions
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
WebKit
/
Source
/
JavaScriptCore
/
llint
/
LLIntSlowPaths.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
2912 lines (2471 loc) · 115 KB
Breadcrumbs
WebKit
/
Source
/
JavaScriptCore
/
llint
/
LLIntSlowPaths.cpp
Copy path
File metadata and controls
2912 lines (2471 loc) · 115 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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-2025 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. ``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
* 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.
*/
#
include
"
config.h
"
#
include
"
LLIntSlowPaths.h
"
#
include
"
AbortReason.h
"
#
include
"
ArrayConstructor.h
"
#
include
"
BaselineJITPlan.h
"
#
include
"
BytecodeGenerator.h
"
#
include
"
BytecodeOperandsForCheckpoint.h
"
#
include
"
CallFrame.h
"
#
include
"
CheckpointOSRExitSideState.h
"
#
include
"
CodeBlockInlines.h
"
#
include
"
CommonSlowPathsInlines.h
"
#
include
"
Error.h
"
#
include
"
ErrorHandlingScope.h
"
#
include
"
Exception.h
"
#
include
"
ExceptionFuzz.h
"
#
include
"
FrameTracers.h
"
#
include
"
FunctionAllowlist.h
"
#
include
"
FunctionCodeBlock.h
"
#
include
"
GetterSetter.h
"
#
include
"
InterpreterInlines.h
"
#
include
"
JITExceptions.h
"
#
include
"
JITWorklist.h
"
#
include
"
JSAsyncFromSyncIterator.h
"
#
include
"
JSAsyncFunction.h
"
#
include
"
JSAsyncGenerator.h
"
#
include
"
JSAsyncGeneratorFunction.h
"
#
include
"
JSCInlines.h
"
#
include
"
JSCJSValue.h
"
#
include
"
JSGeneratorFunction.h
"
#
include
"
JSGlobalObjectFunctions.h
"
#
include
"
JSLexicalEnvironmentInlines.h
"
#
include
"
JSMicrotask.h
"
#
include
"
JSSentinel.h
"
#
include
"
JSString.h
"
#
include
"
LLIntCommon.h
"
#
include
"
LLIntData.h
"
#
include
"
LLIntEntrypoint.h
"
#
include
"
LLIntExceptions.h
"
#
include
"
LLIntPrototypeLoadAdaptiveStructureWatchpoint.h
"
#
include
"
LLIntThunks.h
"
#
include
"
MaxFrameExtentForSlowPathCall.h
"
#
include
"
ObjectConstructor.h
"
#
include
"
ObjectPropertyConditionSet.h
"
#
include
"
ProtoCallFrameInlines.h
"
#
include
"
RegExpObject.h
"
#
include
"
RepatchInlines.h
"
#
include
"
ShadowChicken.h
"
#
include
"
SuperSampler.h
"
#
include
"
SymbolTableInlines.h
"
#
include
"
VMInlines.h
"
#
include
"
VMTrapsInlines.h
"
#
include
<
wtf/NeverDestroyed.h
>
#
include
<
wtf/StringPrintStream.h
>
WTF_ALLOW_UNSAFE_BUFFER_USAGE_BEGIN
namespace
JSC
{
namespace
LLInt
{
#
define
LLINT_BEGIN_NO_SET_PC
() \
CodeBlock* codeBlock = callFrame->
codeBlock
(); \
JSGlobalObject* globalObject = codeBlock->
globalObject
(); \
VM
& vm = codeBlock->
vm
(); \
SlowPathFrameTracer
tracer
(vm, callFrame); \
dataLogLnIf
(
LLINT_TRACING
&& Options::traceLLIntSlowPath(),
"
Calling slow path
"
,
WTF_PRETTY_FUNCTION
); \
auto
throwScope =
DECLARE_THROW_SCOPE
(vm)
#
ifndef
NDEBUG
#
define
LLINT_SET_PC_FOR_STUBS
()
do
{ \
codeBlock->
bytecodeOffset
(pc); \
callFrame->
setCurrentVPC
(pc); \
}
while
(
false
)
#
else
#
define
LLINT_SET_PC_FOR_STUBS
()
do
{ \
callFrame->
setCurrentVPC
(pc); \
}
while
(
false
)
#
endif
#
define
LLINT_BEGIN
() \
LLINT_BEGIN_NO_SET_PC
(); \
LLINT_SET_PC_FOR_STUBS
()
static
inline
JSValue
NODELETE
getNonConstantOperand
(CallFrame* callFrame, VirtualRegister operand) {
return
callFrame->
uncheckedR
(operand).
jsValue
(); }
static
inline
JSValue
NODELETE
getOperand
(CallFrame* callFrame, VirtualRegister operand) {
return
callFrame->
r
(operand).
jsValue
(); }
#
define
LLINT_RETURN_TWO
(
first, second
)
do
{ \
return
encodeResult
(first, second); \
}
while
(
false
)
#
define
LLINT_END_IMPL
()
LLINT_RETURN_TWO
(pc,
nullptr
)
#
define
LLINT_THROW
(
exceptionToThrow
)
do
{ \
throwException
(globalObject, throwScope, exceptionToThrow); \
pc =
returnToThrow
(vm); \
LLINT_END_IMPL
(); \
}
while
(
false
)
#
define
LLINT_CHECK_EXCEPTION
()
do
{ \
doExceptionFuzzingIfEnabled
(globalObject, throwScope,
"
LLIntSlowPaths
"
, pc); \
if
(throwScope.
exception
())
[[unlikely]]
{ \
pc =
returnToThrow
(vm); \
LLINT_END_IMPL
(); \
} \
}
while
(
false
)
#
define
LLINT_END
()
do
{ \
LLINT_CHECK_EXCEPTION
(); \
LLINT_END_IMPL
(); \
}
while
(
false
)
#
define
JUMP_OFFSET
(
targetOffset
) \
((targetOffset) ? (targetOffset) : codeBlock->
outOfLineJumpOffset
(pc))
#
define
JUMP_TO
(
target
)
do
{ \
pc =
reinterpret_cast
<
const
JSInstruction*>(
reinterpret_cast
<
const
uint8_t
*>(pc) + (target)); \
}
while
(
false
)
#
define
LLINT_BRANCH
(
condition
)
do
{ \
bool
__b_condition = (condition); \
LLINT_CHECK_EXCEPTION
(); \
if
(__b_condition) \
JUMP_TO
(
JUMP_OFFSET
(bytecode.
m_targetLabel
)); \
else
\
JUMP_TO
(pc->
size
()); \
LLINT_END_IMPL
(); \
}
while
(
false
)
#
define
LLINT_RETURN
(
value
)
do
{ \
JSValue __r_returnValue = (value); \
LLINT_CHECK_EXCEPTION
(); \
callFrame->
uncheckedR
(bytecode.
m_dst
) = __r_returnValue; \
LLINT_END_IMPL
(); \
}
while
(
false
)
#
define
LLINT_RETURN_PROFILED
(
value
)
do
{ \
JSValue __rp_returnValue = (value); \
LLINT_CHECK_EXCEPTION
(); \
callFrame->
uncheckedR
(bytecode.
m_dst
) = __rp_returnValue; \
LLINT_PROFILE_VALUE
(__rp_returnValue); \
LLINT_END_IMPL
(); \
}
while
(
false
)
#
define
LLINT_PROFILE_VALUE
(
value
)
do
{ \
codeBlock->
valueProfileForOffset
(bytecode.
m_valueProfile
).
m_buckets
[
0
] =
JSValue::encode
(value); \
}
while
(
false
)
#
define
LLINT_CALL_END_IMPL
(
callFrame, callTarget, callTargetTag
) \
LLINT_RETURN_TWO
((retagCodePtr<callTargetTag, JSEntrySlowPathPtrTag>(callTarget)), (callFrame))
#
define
LLINT_CALL_THROW
(
globalObject, exceptionToThrow
)
do
{ \
JSGlobalObject* __ct_globalObject = (globalObject); \
throwException
(__ct_globalObject, throwScope, exceptionToThrow); \
LLINT_CALL_END_IMPL
(
nullptr
,
callToThrow
(vm).
code
().
taggedPtr
(), ExceptionHandlerPtrTag); \
}
while
(
false
)
#
define
LLINT_CALL_CHECK_EXCEPTION
(
globalObject
)
do
{ \
JSGlobalObject* __cce_globalObject = (globalObject); \
doExceptionFuzzingIfEnabled
(__cce_globalObject, throwScope,
"
LLIntSlowPaths/call
"
,
nullptr
); \
if
(throwScope.
exception
())
[[unlikely]]
\
LLINT_CALL_END_IMPL
(
nullptr
,
callToThrow
(vm).
code
().
taggedPtr
(), ExceptionHandlerPtrTag); \
}
while
(
false
)
#
define
LLINT_CALL_RETURN
(
globalObject, calleeFrame, callTarget, callTargetTag
)
do
{ \
JSGlobalObject* __cr_globalObject = (globalObject); \
CallFrame* __cr_calleeFrame = (calleeFrame); \
void
* __cr_callTarget = (callTarget); \
LLINT_CALL_CHECK_EXCEPTION
(__cr_globalObject); \
LLINT_CALL_END_IMPL
(__cr_calleeFrame, __cr_callTarget, callTargetTag); \
}
while
(
false
)
#
define
LLINT_RETURN_CALLEE_FRAME
(
calleeFrame
)
do
{ \
CallFrame* __rcf_calleeFrame = (calleeFrame); \
LLINT_RETURN_TWO
(pc, __rcf_calleeFrame); \
}
while
(
false
)
#
if
LLINT_TRACING
template
<
typename
... Types>
void
slowPathLog
(
const
Types&... values)
{
dataLogIf
(
Options::traceLLIntSlowPath
(), values...);
}
template
<
typename
... Types>
void
slowPathLn
(
const
Types&... values)
{
dataLogLnIf
(
Options::traceLLIntSlowPath
(), values...);
}
template
<
typename
... Types>
void
slowPathLogF
(
const
char
* format,
const
Types&... values)
{
ALLOW_NONLITERAL_FORMAT_BEGIN
IGNORE_WARNINGS_BEGIN
(
"
format-security
"
)
if
(
Options::traceLLIntSlowPath
())
dataLogF
(format, values...);
IGNORE_WARNINGS_END
ALLOW_NONLITERAL_FORMAT_END
}
#
else
//
not LLINT_TRACING
template
<
typename
... Types>
void
NODELETE
slowPathLog
(
const
Types&...) { }
template
<
typename
... Types>
void
slowPathLogLn
(
const
Types&...) { }
template
<
typename
... Types>
void
NODELETE
slowPathLogF
(
const
char
*,
const
Types&...) { }
#
endif
//
LLINT_TRACING
extern
"
C
"
UGPRPair
SYSV_ABI
llint_trace_operand
(CallFrame* callFrame,
const
JSInstruction* pc,
int
fromWhere,
int
operand)
{
if
(!
Options::traceLLIntExecution
())
LLINT_END_IMPL
();
LLINT_BEGIN
();
dataLogF
(
"
<%p> %p / %p: executing bc#%zu, op#%u: Trace(%d): %d
\n
"
,
&
Thread::currentSingleton
(),
callFrame->
codeBlock
(),
globalObject,
static_cast
<
intptr_t
>(callFrame->
codeBlock
()->
bytecodeOffset
(pc)),
pc->
opcodeID
(),
fromWhere,
operand);
LLINT_END
();
}
extern
"
C
"
UGPRPair
SYSV_ABI
llint_trace_value
(CallFrame* callFrame,
const
JSInstruction* pc,
int
fromWhere, VirtualRegister operand)
{
if
(!
Options::traceLLIntExecution
())
LLINT_END_IMPL
();
JSValue value =
getOperand
(callFrame, operand);
union
{
struct
{
uint32_t
tag;
uint32_t
payload;
} bits;
EncodedJSValue asValue;
} u;
u.
asValue
=
JSValue::encode
(value);
dataLogF
(
"
<%p> %p / %p: executing bc#%zu, op#%u: Trace(%d): %d: %08x:%08x: %s
\n
"
,
&
Thread::currentSingleton
(),
callFrame->
codeBlock
(),
callFrame,
static_cast
<
intptr_t
>(callFrame->
codeBlock
()->
bytecodeOffset
(pc)),
pc->
opcodeID
(),
fromWhere,
operand.
offset
(),
u.
bits
.
tag
,
u.
bits
.
payload
,
toCString
(value).
data
());
LLINT_END_IMPL
();
}
LLINT_SLOW_PATH_DECL
(trace_prologue)
{
if
(!
Options::traceLLIntExecution
())
LLINT_END_IMPL
();
CodeBlock* codeBlock = callFrame->
codeBlock
();
dataLogF
(
"
<%p> %p / %p: in prologue of
"
, &
Thread::currentSingleton
(), codeBlock, callFrame);
dataLog
(codeBlock,
"
\n
"
);
LLINT_END_IMPL
();
}
static
void
traceFunctionPrologue
(CallFrame* callFrame,
const
char
* comment, CodeSpecializationKind kind)
{
if
(!
Options::traceLLIntExecution
())
return
;
JSFunction* callee = uncheckedDowncast<JSFunction>(callFrame->
jsCallee
());
FunctionExecutable* executable = callee->
jsExecutable
();
CodeBlock* codeBlock = executable->
codeBlockFor
(kind);
dataLogF
(
"
<%p> %p / %p: in %s of
"
, &
Thread::currentSingleton
(), codeBlock, callFrame, comment);
dataLog
(codeBlock);
dataLogF
(
"
function %p, executable %p; numVars = %u, numParameters = %u, numCalleeLocals = %u, caller = %p.
\n
"
,
callee, executable, codeBlock->
numVars
(), codeBlock->
numParameters
(), codeBlock->
numCalleeLocals
(), callFrame->
callerFrame
());
}
LLINT_SLOW_PATH_DECL
(trace_prologue_function_for_call)
{
traceFunctionPrologue
(callFrame,
"
call prologue
"
, CodeSpecializationKind::CodeForCall);
LLINT_END_IMPL
();
}
LLINT_SLOW_PATH_DECL
(trace_prologue_function_for_construct)
{
traceFunctionPrologue
(callFrame,
"
construct prologue
"
, CodeSpecializationKind::CodeForConstruct);
LLINT_END_IMPL
();
}
LLINT_SLOW_PATH_DECL
(trace_arityCheck_for_call)
{
traceFunctionPrologue
(callFrame,
"
call arity check
"
, CodeSpecializationKind::CodeForCall);
LLINT_END_IMPL
();
}
LLINT_SLOW_PATH_DECL
(trace_arityCheck_for_construct)
{
traceFunctionPrologue
(callFrame,
"
construct arity check
"
, CodeSpecializationKind::CodeForConstruct);
LLINT_END_IMPL
();
}
LLINT_SLOW_PATH_DECL
(trace)
{
if
(!
Options::traceLLIntExecution
())
LLINT_END_IMPL
();
CodeBlock* codeBlock = callFrame->
codeBlock
();
OpcodeID opcodeID = pc->
opcodeID
();
SAFE_DATALOGF
(
"
<%p> %p / %p: executing bc#%zu, %s, pc = %p
\n
"
,
&
Thread::currentSingleton
(),
codeBlock,
callFrame,
static_cast
<
intptr_t
>(codeBlock->
bytecodeOffset
(pc)),
pc->
name
(),
pc);
if
(opcodeID == op_enter) {
dataLogF
(
"
Frame will eventually return to %p
\n
"
, callFrame->
returnPCForInspection
());
*std::bit_cast<
volatile
char
*>(callFrame->
returnPCForInspection
());
}
if
(opcodeID == op_ret) {
dataLogF
(
"
Will be returning to %p
\n
"
, callFrame->
returnPCForInspection
());
dataLogF
(
"
The new cfr will be %p
\n
"
, callFrame->
callerFrame
());
}
LLINT_END_IMPL
();
}
enum
EntryKind { Prologue, ArityCheck };
#
if
ENABLE(JIT)
static
FunctionAllowlist&
ensureGlobalJITAllowlist
()
{
static
LazyNeverDestroyed<FunctionAllowlist> baselineAllowlist;
static
std::once_flag initializeAllowlistFlag;
std::call_once
(initializeAllowlistFlag, [] {
const
char
* functionAllowlistFile =
Options::jitAllowlist
();
baselineAllowlist.
construct
(functionAllowlistFile);
});
return
baselineAllowlist;
}
static
inline
bool
shouldJIT
(CodeBlock* codeBlock)
{
if
(!
Options::bytecodeRangeToJITCompile
().
isInRange
(codeBlock->
instructionsSize
())
|| !
ensureGlobalJITAllowlist
().
contains
(codeBlock))
return
false
;
return
Options::useBaselineJIT
();
}
//
Returns true if we should try to OSR.
static
inline
bool
jitCompileAndSetHeuristics
(
VM
& vm, CodeBlock* codeBlock)
{
DeferGCForAWhile
deferGC
(vm);
//
My callers don't set top callframe, so we don't want to GC here at all.
ASSERT
(
Options::useJIT
());
if
(codeBlock->
jitType
() != JITType::BaselineJIT) {
if
(RefPtr<BaselineJITCode> baselineRef = codeBlock->
unlinkedCodeBlock
()->
m_unlinkedBaselineCode
) {
codeBlock->
setupWithUnlinkedBaselineCode
(baselineRef.
releaseNonNull
());
codeBlock->
ownerExecutable
()->
installCode
(codeBlock);
codeBlock->
jitNextInvocation
();
return
true
;
}
}
if
(!codeBlock->
checkIfJITThresholdReached
()) {
CODEBLOCK_LOG_EVENT
(codeBlock,
"
delayJITCompile
"
, (
"
threshold not reached, counter =
"
, codeBlock->
llintExecuteCounter
()));
dataLogLnIf
(
Options::verboseOSR
(),
"
JIT threshold should be lifted.
"
);
return
false
;
}
JITWorklist::State worklistState =
JITWorklist::ensureGlobalWorklist
().
completeAllReadyPlansForVM
(vm,
JITCompilationKey
(codeBlock->
unlinkedCodeBlock
(), JITCompilationMode::Baseline));
if
(codeBlock->
jitType
() == JITType::BaselineJIT) {
dataLogLnIf
(
Options::verboseOSR
(),
"
Code was already compiled.
"
);
codeBlock->
jitSoon
();
return
true
;
}
if
(worklistState == JITWorklist::NotKnown) {
Ref<BaselineJITPlan> plan =
adoptRef
(*
new
BaselineJITPlan
(codeBlock));
JITWorklist::ensureGlobalWorklist
().
enqueue
(
WTF::move
(plan));
return
codeBlock->
jitType
() == JITType::BaselineJIT;
}
return
false
;
}
static
UGPRPair
entryOSR
(CodeBlock* codeBlock,
const
char
*name, EntryKind kind)
{
dataLogLnIf
(
Options::verboseOSR
(),
*codeBlock,
"
: Entered
"
, name,
"
with executeCounter =
"
,
codeBlock->
llintExecuteCounter
());
if
(!
shouldJIT
(codeBlock)) {
codeBlock->
dontJITAnytimeSoon
();
LLINT_RETURN_TWO
(
nullptr
,
nullptr
);
}
VM
& vm = codeBlock->
vm
();
if
(!
jitCompileAndSetHeuristics
(vm, codeBlock))
LLINT_RETURN_TWO
(
nullptr
,
nullptr
);
CODEBLOCK_LOG_EVENT
(codeBlock,
"
OSR entry
"
, (
"
in prologue
"
));
if
(kind == Prologue)
LLINT_RETURN_TWO
(codeBlock->
jitCode
()->
executableAddress
(),
nullptr
);
ASSERT
(kind == ArityCheck);
LLINT_RETURN_TWO
(codeBlock->
jitCode
()->
addressForCall
(ArityCheckMode::MustCheckArity).
taggedPtr
(),
nullptr
);
}
#
else
//
ENABLE(JIT)
static
UGPRPair
entryOSR
(CodeBlock* codeBlock,
const
char
*, EntryKind)
{
codeBlock->
dontJITAnytimeSoon
();
LLINT_RETURN_TWO
(
nullptr
,
nullptr
);
}
#
endif
//
ENABLE(JIT)
LLINT_SLOW_PATH_DECL
(entry_osr)
{
UNUSED_PARAM
(pc);
return
entryOSR
(callFrame->
codeBlock
(),
"
entry_osr
"
, Prologue);
}
LLINT_SLOW_PATH_DECL
(entry_osr_function_for_call)
{
UNUSED_PARAM
(pc);
return
entryOSR
(uncheckedDowncast<JSFunction>(callFrame->
jsCallee
())->
jsExecutable
()->
codeBlockForCall
(),
"
entry_osr_function_for_call
"
, Prologue);
}
LLINT_SLOW_PATH_DECL
(entry_osr_function_for_construct)
{
UNUSED_PARAM
(pc);
return
entryOSR
(uncheckedDowncast<JSFunction>(callFrame->
jsCallee
())->
jsExecutable
()->
codeBlockForConstruct
(),
"
entry_osr_function_for_construct
"
, Prologue);
}
LLINT_SLOW_PATH_DECL
(entry_osr_function_for_call_arityCheck)
{
UNUSED_PARAM
(pc);
return
entryOSR
(uncheckedDowncast<JSFunction>(callFrame->
jsCallee
())->
jsExecutable
()->
codeBlockForCall
(),
"
entry_osr_function_for_call_arityCheck
"
, ArityCheck);
}
LLINT_SLOW_PATH_DECL
(entry_osr_function_for_construct_arityCheck)
{
UNUSED_PARAM
(pc);
return
entryOSR
(uncheckedDowncast<JSFunction>(callFrame->
jsCallee
())->
jsExecutable
()->
codeBlockForConstruct
(),
"
entry_osr_function_for_construct_arityCheck
"
, ArityCheck);
}
LLINT_SLOW_PATH_DECL
(loop_osr)
{
LLINT_BEGIN_NO_SET_PC
();
UNUSED_PARAM
(throwScope);
UNUSED_PARAM
(globalObject);
#
if
ENABLE(JIT)
dataLogLnIf
(
Options::verboseOSR
(),
*codeBlock,
"
: Entered loop_osr with executeCounter =
"
,
codeBlock->
llintExecuteCounter
());
if
(
Options::returnEarlyFromInfiniteLoopsForFuzzing
() && codeBlock->
loopHintsAreEligibleForFuzzingEarlyReturn
())
[[unlikely]]
{
uintptr_t
* ptr = vm.
getLoopHintExecutionCounter
(pc);
*ptr += codeBlock->
llintExecuteCounter
().
m_activeThreshold
;
if
(*ptr >=
Options::earlyReturnFromInfiniteLoopsLimit
())
LLINT_RETURN_TWO
(
LLInt::fuzzerReturnEarlyFromLoopHintEntrypoint
().
code
().
taggedPtr
(), callFrame->
topOfFrame
());
}
if
(!
shouldJIT
(codeBlock)) {
codeBlock->
dontJITAnytimeSoon
();
LLINT_RETURN_TWO
(
nullptr
,
nullptr
);
}
if
(!
jitCompileAndSetHeuristics
(vm, codeBlock))
LLINT_RETURN_TWO
(
nullptr
,
nullptr
);
auto
loopOSREntryBytecodeIndex =
BytecodeIndex
(codeBlock->
bytecodeOffset
(pc));
CODEBLOCK_LOG_EVENT
(codeBlock,
"
osrEntry
"
, (
"
at
"
, loopOSREntryBytecodeIndex));
RELEASE_ASSERT
(codeBlock->
jitType
() == JITType::BaselineJIT);
const
JITCodeMap& codeMap = codeBlock->
jitCodeMap
();
CodeLocationLabel<JSEntryPtrTag> codeLocation = codeMap.
find
(loopOSREntryBytecodeIndex);
ASSERT
(codeLocation);
void
* jumpTarget = codeLocation.
taggedPtr
();
ASSERT
(jumpTarget);
LLINT_RETURN_TWO
(jumpTarget, callFrame->
topOfFrame
());
#
else
//
ENABLE(JIT)
UNUSED_PARAM
(pc);
codeBlock->
dontJITAnytimeSoon
();
LLINT_RETURN_TWO
(
0
,
0
);
#
endif
//
ENABLE(JIT)
}
LLINT_SLOW_PATH_DECL
(replace)
{
LLINT_BEGIN_NO_SET_PC
();
UNUSED_PARAM
(throwScope);
UNUSED_PARAM
(globalObject);
#
if
ENABLE(JIT)
dataLogLnIf
(
Options::verboseOSR
(),
*codeBlock,
"
: Entered replace with executeCounter =
"
,
codeBlock->
llintExecuteCounter
());
if
(
shouldJIT
(codeBlock))
jitCompileAndSetHeuristics
(vm, codeBlock);
else
codeBlock->
dontJITAnytimeSoon
();
LLINT_END_IMPL
();
#
else
//
ENABLE(JIT)
codeBlock->
dontJITAnytimeSoon
();
LLINT_END_IMPL
();
#
endif
//
ENABLE(JIT)
}
UGPRPair
SYSV_ABI
llint_check_stack_and_vm_traps
(CallFrame* callFrame,
const
JSInstruction* pc,
void
* newTopOfStack)
{
//
It's ok to create the SlowPathFrameTracer here before we
//
convertToZombieFrame() because this function is always called
//
after the frame has been propulated with a proper CodeBlock and callee.
LLINT_BEGIN
();
if
(
Options::traceLLIntSlowPath
())
[[unlikely]]
{
slowPathLogF
(
"
Checking VMTraps and stack height with callFrame = %p.
\n
"
, callFrame);
slowPathLog
(
"
CodeBlock =
"
, codeBlock,
"
\n
"
);
if
(codeBlock) {
slowPathLogF
(
"
Num callee registers = %u.
\n
"
, codeBlock->
numCalleeLocals
());
slowPathLogF
(
"
Num vars = %u.
\n
"
, codeBlock->
numVars
());
}
slowPathLogF
(
"
Current OS stack end is at %p.
\n
"
, vm.
softStackLimit
());
#
if
ENABLE(C_LOOP)
slowPathLogF
(
"
Current C Loop stack end is at %p.
\n
"
, vm.
cloopStackLimit
());
#
endif
}
if
(vm.
traps
().
handleTrapsIfNeeded
()) {
if
(vm.
hasPendingTerminationException
()) {
throwScope.
release
();
callFrame->
convertToZombieFrame
(vm, codeBlock);
pc =
returnToThrow
(vm);
LLINT_RETURN_TWO
(pc, callFrame);
}
}
throwScope.
assertNoException
();
//
Redo stack check because we may really have gotten here due to an imminent StackOverflow.
bool
imminentOverflowDetected =
false
;
#
if
ENABLE(C_LOOP)
Register* newTopOfStackRegister =
reinterpret_cast
<Register*>(newTopOfStack);
if
(newTopOfStackRegister <
reinterpret_cast
<Register*>(callFrame)) {
if
(!vm.
ensureJSStackCapacityFor
(newTopOfStackRegister))
imminentOverflowDetected =
true
;
}
else
imminentOverflowDetected =
true
;
//
Stack underflow == overflow.
#
else
//
not C_LOOP case
void
* softStackLimit = vm.
softStackLimit
();
#
if
CPU(ADDRESS32)
//
With 32-bit addresses, there's a chance that we can underflow, and need this check.
//
The new stack pointer should only grow smaller. The only way it can be larger than
//
the callFrame is if subtracting the stack frame size resulted in an underflow.
if
(std::bit_cast<
uintptr_t
>(newTopOfStack) > std::bit_cast<
uintptr_t
>(callFrame))
imminentOverflowDetected =
true
;
#
endif
if
(newTopOfStack < softStackLimit)
imminentOverflowDetected =
true
;
#
endif
//
end of not C_LOOP case
//
If the stack check succeeds and we don't need to throw any errors, then
//
we'll return 0 instead. The prologue will check for a non-zero value
//
when determining whether to set the callFrame or not.
if
(!imminentOverflowDetected)
LLINT_RETURN_TWO
(pc,
0
);
//
Hence, if we get here, then we know a stack overflow is imminent. So, just
//
throw the StackOverflowError unconditionally.
callFrame->
convertToZombieFrame
(vm, codeBlock);
ErrorHandlingScope
errorScope
(vm);
throwStackOverflowError
(globalObject, throwScope);
pc =
returnToThrow
(vm);
LLINT_RETURN_TWO
(pc, callFrame);
}
extern
"
C
"
UGPRPair
SYSV_ABI
llint_default_call
(CallFrame* calleeFrame, CallLinkInfo* callLinkInfo)
{
JSCell* owner = callLinkInfo->
ownerForSlowPath
(calleeFrame);
VM
& vm = owner->
vm
();
NativeCallFrameTracer
tracer
(vm, calleeFrame);
sanitizeStackForVM
(vm);
auto
scope =
DECLARE_THROW_SCOPE
(vm);
calleeFrame->
setCodeBlock
(
nullptr
);
void
* callTarget =
linkFor
(vm, owner, calleeFrame, callLinkInfo);
ensureStillAliveHere
(owner);
if
(scope.
exception
())
[[unlikely]]
return
encodeResult
(callTarget, std::bit_cast<
void
*>(&vm));
return
encodeResult
(callTarget,
nullptr
);
}
extern
"
C
"
UGPRPair
SYSV_ABI
llint_virtual_call
(CallFrame* calleeFrame, CallLinkInfo* callLinkInfo)
{
JSCell* owner = callLinkInfo->
ownerForSlowPath
(calleeFrame);
VM
& vm = owner->
vm
();
NativeCallFrameTracer
tracer
(vm, calleeFrame);
sanitizeStackForVM
(vm);
auto
scope =
DECLARE_THROW_SCOPE
(vm);
JSCell* calleeAsFunctionCellIgnored;
calleeFrame->
setCodeBlock
(
nullptr
);
void
* callTarget =
virtualForWithFunction
(vm, owner, calleeFrame, callLinkInfo, calleeAsFunctionCellIgnored);
ensureStillAliveHere
(owner);
if
(scope.
exception
())
[[unlikely]]
return
encodeResult
(callTarget, std::bit_cast<
void
*>(&vm));
return
encodeResult
(callTarget,
nullptr
);
}
extern
"
C
"
UGPRPair
SYSV_ABI
llint_polymorphic_call
(CallFrame* calleeFrame, CallLinkInfo* callLinkInfo)
{
JSCell* owner = callLinkInfo->
ownerForSlowPath
(calleeFrame);
VM
& vm = owner->
vm
();
NativeCallFrameTracer
tracer
(vm, calleeFrame);
sanitizeStackForVM
(vm);
auto
scope =
DECLARE_THROW_SCOPE
(vm);
JSCell* calleeAsFunctionCell;
calleeFrame->
setCodeBlock
(
nullptr
);
void
* callTarget =
virtualForWithFunction
(vm, owner, calleeFrame, callLinkInfo, calleeAsFunctionCell);
if
(scope.
exception
())
[[unlikely]]
return
encodeResult
(callTarget, std::bit_cast<
void
*>(&vm));
//
A null cell means virtualForWithFunction did a host call that ran JS and may have freed *callLinkInfo; don't link.
if
(calleeAsFunctionCell)
[[likely]]
linkPolymorphicCall
(vm, owner, calleeFrame, *callLinkInfo,
CallVariant
(calleeAsFunctionCell));
ensureStillAliveHere
(owner);
if
(scope.
exception
())
[[unlikely]]
return
encodeResult
(callTarget, std::bit_cast<
void
*>(&vm));
return
encodeResult
(callTarget,
nullptr
);
}
LLINT_SLOW_PATH_DECL
(slow_path_new_object)
{
LLINT_BEGIN
();
auto
bytecode = pc->
as
<OpNewObject>();
auto
& metadata = bytecode.
metadata
(codeBlock);
LLINT_RETURN
(
constructEmptyObject
(vm, metadata.
m_objectAllocationProfile
.
structure
()));
}
LLINT_SLOW_PATH_DECL
(slow_path_new_array)
{
LLINT_BEGIN
();
auto
bytecode = pc->
as
<OpNewArray>();
auto
& metadata = bytecode.
metadata
(codeBlock);
LLINT_RETURN
(
constructArrayNegativeIndexed
(globalObject, &metadata.
m_arrayAllocationProfile
, std::bit_cast<JSValue*>(&callFrame->
uncheckedR
(bytecode.
m_argv
)), bytecode.
m_argc
));
}
LLINT_SLOW_PATH_DECL
(slow_path_new_array_with_size)
{
LLINT_BEGIN
();
auto
bytecode = pc->
as
<OpNewArrayWithSize>();
auto
& metadata = bytecode.
metadata
(codeBlock);
LLINT_RETURN
(
constructArrayWithSizeQuirk
(globalObject, &metadata.
m_arrayAllocationProfile
,
getOperand
(callFrame, bytecode.
m_length
)));
}
LLINT_SLOW_PATH_DECL
(slow_path_new_reg_exp)
{
LLINT_BEGIN
();
auto
bytecode = pc->
as
<OpNewRegExp>();
RegExp* regExp = uncheckedDowncast<RegExp>(
getOperand
(callFrame, bytecode.
m_regexp
));
static
constexpr
bool
areLegacyFeaturesEnabled =
true
;
LLINT_RETURN
(
RegExpObject::create
(vm, globalObject->
regExpStructure
(), regExp, areLegacyFeaturesEnabled));
}
LLINT_SLOW_PATH_DECL
(slow_path_create_lexical_environment)
{
LLINT_BEGIN
();
auto
bytecode = pc->
as
<OpCreateLexicalEnvironment>();
JSScope* currentScope = callFrame->
uncheckedR
(bytecode.
m_scope
).
Register
::scope
();
SymbolTable* symbolTable = uncheckedDowncast<SymbolTable>(
getOperand
(callFrame, bytecode.
m_symbolTable
));
JSValue initialValue =
getOperand
(callFrame, bytecode.
m_initialValue
);
ASSERT
(initialValue ==
jsUndefined
() || initialValue ==
jsTDZValue
());
JSScope* newScope =
JSLexicalEnvironment::create
(vm, globalObject, currentScope, symbolTable, initialValue);
LLINT_RETURN
(newScope);
}
LLINT_SLOW_PATH_DECL
(slow_path_create_direct_arguments)
{
LLINT_BEGIN
();
auto
bytecode = pc->
as
<OpCreateDirectArguments>();
LLINT_RETURN
(
DirectArguments::createByCopying
(globalObject, callFrame));
}
LLINT_SLOW_PATH_DECL
(slow_path_create_scoped_arguments)
{
LLINT_BEGIN
();
auto
bytecode = pc->
as
<OpCreateScopedArguments>();
JSLexicalEnvironment* scope = uncheckedDowncast<JSLexicalEnvironment>(
getOperand
(callFrame, bytecode.
m_scope
));
ScopedArgumentsTable* table = scope->
symbolTable
()->
arguments
();
LLINT_RETURN
(
ScopedArguments::createByCopying
(globalObject, callFrame, table, scope));
}
LLINT_SLOW_PATH_DECL
(slow_path_create_cloned_arguments)
{
LLINT_BEGIN
();
auto
bytecode = pc->
as
<OpCreateClonedArguments>();
auto
result =
ClonedArguments::createWithMachineFrame
(globalObject, callFrame, ArgumentsMode::Cloned);
EXCEPTION_ASSERT
(throwScope.
exception
() || result);
LLINT_RETURN
(result);
}
LLINT_SLOW_PATH_DECL
(slow_path_get_by_id_direct)
{
LLINT_BEGIN
();
auto
bytecode = pc->
as
<OpGetByIdDirect>();
const
Identifier& ident = codeBlock->
identifier
(bytecode.
m_property
);
JSValue baseValue =
getOperand
(callFrame, bytecode.
m_base
);
PropertySlot
slot
(baseValue, PropertySlot::PropertySlot::InternalMethodType::GetOwnProperty);
bool
found = baseValue.
getOwnPropertySlot
(globalObject, ident, slot);
LLINT_CHECK_EXCEPTION
();
JSValue result = found ? slot.
getValue
(globalObject, ident) :
jsUndefined
();
LLINT_CHECK_EXCEPTION
();
if
(
Options::useLLIntICs
() && slot.
isCacheable
() && !slot.
isUnset
()) {
auto
& metadata = bytecode.
metadata
(codeBlock);
{
StructureID oldStructureID = metadata.
m_structureID
;
if
(oldStructureID) {
Structure* a = oldStructureID.
decode
();
Structure* b = baseValue.
asCell
()->
structure
();
if
(
Structure::shouldConvertToPolyProto
(a, b)) {
ASSERT
(a->
rareData
()->
sharedPolyProtoWatchpoint
().
get
() == b->
rareData
()->
sharedPolyProtoWatchpoint
().
get
());
a->
rareData
()->
sharedPolyProtoWatchpoint
()->
invalidate
(vm,
StringFireDetail
(
"
Detected poly proto opportunity.
"
));
}
}
}
JSCell* baseCell = baseValue.
asCell
();
Structure* structure = baseCell->
structure
();
if
(slot.
isValue
()) {
//
Start out by clearing out the old cache.
metadata.
m_structureID
=
StructureID
();
metadata.
m_offset
=
0
;
if
(structure->
propertyAccessesAreCacheable
() && !structure->
needImpurePropertyWatchpoint
()) {
{
ConcurrentJSLocker
locker
(codeBlock->
m_lock
);
metadata.
m_structureID
= structure->
id
();
metadata.
m_offset
= slot.
cachedOffset
();
}
vm.
writeBarrier
(codeBlock);
}
}
}
LLINT_RETURN_PROFILED
(result);
}
LLINT_SLOW_PATH_DECL
(slow_path_get_by_id_with_this)
{
LLINT_BEGIN
();
auto
bytecode = pc->
as
<OpGetByIdWithThis>();
const
Identifier& ident = codeBlock->
identifier
(bytecode.
m_property
);
JSValue baseValue =
getOperand
(callFrame, bytecode.
m_base
);
JSValue thisVal =
getOperand
(callFrame, bytecode.
m_thisValue
);
PropertySlot
slot
(thisVal, PropertySlot::PropertySlot::InternalMethodType::Get);
JSValue result = baseValue.
get
(globalObject, ident, slot);
LLINT_RETURN_PROFILED
(result);
}
static
void
setupGetByIdPrototypeCache
(JSGlobalObject* globalObject,
VM
& vm, CodeBlock* codeBlock, BytecodeIndex bytecodeIndex, GetByIdModeMetadata& metadata, JSCell* baseCell, PropertySlot& slot,
const
Identifier& ident)
{
Structure* structure = baseCell->
structure
();
if
(structure->
typeInfo
().
prohibitsPropertyCaching
())
return
;
if
(structure->
needImpurePropertyWatchpoint
())
return
;
if
(structure->
isDictionary
()) {
if
(structure->
hasBeenFlattenedBefore
())
return
;
structure->
flattenDictionaryStructure
(vm, uncheckedDowncast<JSObject>(baseCell));
}
prepareChainForCaching
(globalObject, baseCell, ident.
impl
(), slot);
ObjectPropertyConditionSet conditions;
if
(slot.
isUnset
())
conditions =
generateConditionsForPropertyMiss
(vm, codeBlock, globalObject, structure, ident.
impl
());
else
conditions =
generateConditionsForPrototypePropertyHit
(vm, codeBlock, globalObject, structure, slot.
slotBase
(), ident.
impl
());
if
(!conditions.
isValid
())
return
;
PropertyOffset offset = invalidOffset;
CodeBlock::StructureWatchpointMap& watchpointMap = codeBlock->
llintGetByIdWatchpointMap
();
FixedVector<LLIntPrototypeLoadAdaptiveStructureWatchpoint>
watchpoints
(conditions.
size
());
unsigned
index =
0
;
for
(ObjectPropertyCondition condition : conditions) {
auto
& watchpoint = watchpoints[index++];
if
(!condition.
isWatchable
(PropertyCondition::MakeNoChanges))
return
;
if
(condition.
condition
().
kind
() == PropertyCondition::Presence)
offset = condition.
condition
().
offset
();
watchpoint.
initialize
(codeBlock, condition, bytecodeIndex);
watchpoint.
install
(vm);
}
ASSERT
((offset == invalidOffset) == slot.
isUnset
());
auto
result = watchpointMap.
add
(
std::make_tuple
(structure->
id
(), bytecodeIndex),
WTF::move
(watchpoints));
ASSERT_UNUSED
(result, result.
isNewEntry
);
{
ConcurrentJSLocker
locker
(codeBlock->
m_lock
);
if
(slot.
isUnset
())
metadata.
setUnsetMode
(structure);
else
{
ASSERT
(slot.
isValue
());
metadata.
setProtoLoadMode
(structure, offset, slot.
slotBase
());
}
}
vm.
writeBarrier
(codeBlock);
}
static
JSValue
performLLIntGetByID
(BytecodeIndex bytecodeIndex, CodeBlock* codeBlock, JSGlobalObject* globalObject, JSValue baseValue,
const
Identifier& ident, GetByIdModeMetadata& metadata)
{
VM
& vm = globalObject->
vm
();
auto
throwScope =
DECLARE_THROW_SCOPE
(vm);
PropertySlot
slot
(baseValue, PropertySlot::PropertySlot::InternalMethodType::Get);
JSValue result = baseValue.
get
<
true
>(globalObject, ident, slot);
RETURN_IF_EXCEPTION
(throwScope, { });
if
(
Options::useLLIntICs
()
&& baseValue.
isCell
()
&& slot.
isCacheable
()
&& !slot.
isUnset
()) {
{
StructureID oldStructureID;
switch
(metadata.
mode
) {
case
GetByIdMode::Default:
oldStructureID = metadata.
defaultMode
.
structureID
;
break
;
case
GetByIdMode::Unset:
oldStructureID = metadata.
unsetMode
.
structureID
;
break
;
case
GetByIdMode::ProtoLoad:
oldStructureID = metadata.
protoLoadMode
.
structureID
;
break
;
default
:
oldStructureID =
StructureID
();
}
if
(oldStructureID) {
Structure* a = oldStructureID.
decode
();
Structure* b = baseValue.
asCell
()->
structure
();
if
(
Structure::shouldConvertToPolyProto
(a, b)) {
ASSERT
(a->
rareData
()->
sharedPolyProtoWatchpoint
().
get
() == b->
rareData
()->
sharedPolyProtoWatchpoint
().
get
());
a->
rareData
()->
sharedPolyProtoWatchpoint
()->
invalidate
(vm,
StringFireDetail
(
"
Detected poly proto opportunity.
"
));
}
}
}
JSCell* baseCell = baseValue.
asCell
();
Structure* structure = baseCell->
structure
();
if
(slot.
isValue
() && slot.
slotBase
() == baseValue) {
ConcurrentJSLocker
locker
(codeBlock->
m_lock
);
//
Start out by clearing out the old cache.
metadata.
clearToDefaultModeWithoutCache
();
//
Prevent the prototype cache from ever happening.
metadata.
hitCountForLLIntCaching
=
0
;
if
(structure->
propertyAccessesAreCacheable
() && !structure->
needImpurePropertyWatchpoint
()) {
metadata.
defaultMode
.
structureID
= structure->
id
();
metadata.
defaultMode
.
cachedOffset
= slot.
cachedOffset
();
vm.
writeBarrier
(codeBlock);
}
}
else
if
(metadata.
hitCountForLLIntCaching
&& slot.
isValue
())
[[unlikely]]
{
ASSERT
(slot.
slotBase
() != baseValue);
if
(!(--metadata.
hitCountForLLIntCaching
))
setupGetByIdPrototypeCache
(globalObject, vm, codeBlock, bytecodeIndex, metadata, baseCell, slot, ident);
}
}
else
if
(
Options::useLLIntICs
() &&
isJSArray
(baseValue) && ident == vm.
propertyNames
->
length
)
metadata.
setArrayLengthMode
();
return
result;
}
LLINT_SLOW_PATH_DECL
(slow_path_get_by_id)
{
LLINT_BEGIN
();
auto
bytecode = pc->
as
<OpGetById>();
auto
& metadata = bytecode.
metadata
(codeBlock);
const
Identifier& ident = codeBlock->
identifier
(bytecode.
m_property
);
JSValue baseValue =
getOperand
(callFrame, bytecode.
m_base
);
JSValue result =
performLLIntGetByID
(codeBlock->
bytecodeIndex
(pc), codeBlock, globalObject, baseValue, ident, metadata.
m_modeMetadata
);
LLINT_RETURN_PROFILED
(result);
}
LLINT_SLOW_PATH_DECL
(slow_path_get_length)
{
LLINT_BEGIN
();
auto
bytecode = pc->
as
<OpGetLength>();
auto
& metadata = bytecode.
metadata
(codeBlock);
const
Identifier& ident = vm.
propertyNames
->
length
;
JSValue baseValue =
getOperand
(callFrame, bytecode.
m_base
);
if
(baseValue.
isCell
())
metadata.
m_arrayProfile
.
observeStructure
(baseValue.
asCell
()->
structure
());
JSValue result =
performLLIntGetByID
(codeBlock->
bytecodeIndex
(pc), codeBlock, globalObject, baseValue, ident, metadata.
m_modeMetadata
);
LLINT_RETURN_PROFILED
(result);
}
LLINT_SLOW_PATH_DECL
(slow_path_iterator_open_get_next)
{
LLINT_BEGIN
();
auto
bytecode = pc->
as
<OpIteratorOpen>();
auto
& metadata = bytecode.
metadata
(codeBlock);
JSValue iterator =
getOperand
(callFrame, bytecode.
m_iterator
);
Register& nextRegister = callFrame->
uncheckedR
(bytecode.
m_next
);
if
(!iterator.
isObject
())
LLINT_THROW
(
createTypeError
(globalObject,
"
Iterator result interface is not an object.
"
_s));
JSValue result =
performLLIntGetByID
(codeBlock->
bytecodeIndex
(pc).
withCheckpoint
(OpIteratorOpen::getNext), codeBlock, globalObject, iterator, vm.
propertyNames
->
next
, metadata.
m_modeMetadata
);
LLINT_CHECK_EXCEPTION
();
nextRegister = result;
codeBlock->
valueProfileForOffset
(bytecode.
m_nextValueProfile
).
m_buckets
[
0
] =
JSValue::encode
(result);
LLINT_END
();
}
LLINT_SLOW_PATH_DECL
(slow_path_iterator_next_get_done)
{
LLINT_BEGIN
();
auto
bytecode = pc->
as
<OpIteratorNext>();
auto
& metadata = bytecode.
metadata
(codeBlock);
//
We use m_value to hold the iterator return value since it's either not live past this bytecode or it's going to be filled later.
JSValue iteratorReturn =
getOperand
(callFrame, bytecode.
m_value
);
Register& doneRegister = callFrame->
uncheckedR
(bytecode.
m_done
);
if
(!iteratorReturn.
isObject
())
LLINT_THROW
(
createTypeError
(globalObject,
"
Iterator result interface is not an object.
"
_s));
JSValue result =
performLLIntGetByID
(codeBlock->
bytecodeIndex
(pc).
withCheckpoint
(OpIteratorNext::getDone), codeBlock, globalObject, iteratorReturn, vm.
propertyNames
->
done
, metadata.
m_doneModeMetadata
);
LLINT_CHECK_EXCEPTION
();
doneRegister = result;
codeBlock->
valueProfileForOffset
(bytecode.
m_doneValueProfile
).
m_buckets
[
0
] =
JSValue::encode
(result);
LLINT_END
();
}
LLINT_SLOW_PATH_DECL
(slow_path_iterator_next_get_value)
{
LLINT_BEGIN
();
auto
bytecode = pc->
as
<OpIteratorNext>();
auto
& metadata = bytecode.
metadata
(codeBlock);
//
We use m_value to hold the iterator return value tmp since it's either not live past this bytecode or it's going to be filled later.
Register& valueRegister = callFrame->
uncheckedR
(bytecode.
m_value
);
JSValue iteratorReturn = valueRegister.
jsValue
();
if
(callFrame->
uncheckedR
(bytecode.
m_done
).
jsValue
().
toBoolean
(globalObject))
LLINT_END
();
JSValue result =
performLLIntGetByID
(codeBlock->
bytecodeIndex
(pc).
withCheckpoint
(OpIteratorNext::getValue), codeBlock, globalObject, iteratorReturn, vm.
propertyNames
->
value
, metadata.
m_valueModeMetadata
);
LLINT_CHECK_EXCEPTION
();
valueRegister = result;
codeBlock->
valueProfileForOffset
(bytecode.
m_valueValueProfile
).
m_buckets
[
0
] =
JSValue::encode
(result);
View remainder of file in raw view
Back
|
FazBrowse Home
|
New Git URL