FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
WebKit/Source/JavaScriptCore/jsc.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
/
jsc.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
4712 lines (3963 loc) · 177 KB
Breadcrumbs
WebKit
/
Source
/
JavaScriptCore
/
jsc.cpp
Copy path
File metadata and controls
4712 lines (3963 loc) · 177 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) 1999-2000 Harri Porten (porten@kde.org)
* Copyright (C) 2004-2025 Apple Inc. All rights reserved.
* Copyright (C) 2006 Bjoern Graf (bjoern.graf@gmail.com)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#
include
"
config.h
"
#
include
"
APICast.h
"
#
include
"
ArrayBuffer.h
"
#
include
"
AtomicsObject.h
"
#
include
"
BigIntConstructor.h
"
#
include
"
BytecodeCacheError.h
"
#
include
"
CodeBlock.h
"
#
include
"
CodeCache.h
"
#
include
"
CompilerTimingScope.h
"
#
include
"
Completion.h
"
#
include
"
ConfigFile.h
"
#
include
"
DeferTermination.h
"
#
include
"
DeferredWorkTimer.h
"
#
include
"
Disassembler.h
"
#
include
"
Exception.h
"
#
include
"
ExceptionHelpers.h
"
#
include
"
Fuzzilli.h
"
#
include
"
GlobalObjectMethodTable.h
"
#
include
"
HeapSnapshotBuilder.h
"
#
include
"
InitializeThreading.h
"
#
include
"
Interpreter.h
"
#
include
"
JIT.h
"
#
include
"
JITOperationList.h
"
#
include
"
JITSizeStatistics.h
"
#
include
"
JSArray.h
"
#
include
"
JSArrayBuffer.h
"
#
include
"
JSBasePrivate.h
"
#
include
"
JSBigInt.h
"
#
include
"
JSFinalizationRegistry.h
"
#
include
"
JSFunction.h
"
#
include
"
JSFunctionInlines.h
"
#
include
"
JSLock.h
"
#
include
"
JSNativeStdFunction.h
"
#
include
"
JSONObject.h
"
#
include
"
JSObjectInlines.h
"
#
include
"
JSPromise.h
"
#
include
"
JSSourceCode.h
"
#
include
"
JSString.h
"
#
include
"
JSTypedArrays.h
"
#
include
"
JSWebAssemblyInstance.h
"
#
include
"
JSWebAssemblyMemory.h
"
#
include
"
LLIntThunks.h
"
#
include
"
LinkBuffer.h
"
#
include
"
NativeCallee.h
"
#
include
"
ObjectConstructor.h
"
#
include
"
ParserError.h
"
#
include
"
ProfilerDatabase.h
"
#
include
"
ReleaseHeapAccessScope.h
"
#
include
"
SamplingProfiler.h
"
#
include
"
SideDataRepository.h
"
#
include
"
SimpleTypedArrayController.h
"
#
include
"
StackVisitor.h
"
#
include
"
StructureCreateInlines.h
"
#
include
"
SuperSampler.h
"
#
include
"
TestRunnerUtils.h
"
#
include
"
TopExceptionScope.h
"
#
include
"
TypedArrayInlines.h
"
#
include
"
VMInlines.h
"
#
include
"
VMManager.h
"
#
include
"
VMTrapsInlines.h
"
#
include
"
WasmCapabilities.h
"
#
include
"
WasmDebugServer.h
"
#
include
"
WasmFaultSignalHandler.h
"
#
include
"
WebAssemblyMemoryConstructor.h
"
#
include
<
span
>
#
include
<
stdio.h
>
#
include
<
stdlib.h
>
#
include
<
string.h
>
#
include
<
sys/stat.h
>
#
include
<
sys/types.h
>
#
include
<
type_traits
>
#
include
<
wtf/CPUTime.h
>
#
include
<
wtf/CommaPrinter.h
>
#
include
<
wtf/FastMalloc.h
>
#
include
<
wtf/FileHandle.h
>
#
include
<
wtf/FileSystem.h
>
#
include
<
wtf/MainThread.h
>
#
include
<
wtf/MemoryPressureHandler.h
>
#
include
<
wtf/MonotonicTime.h
>
#
include
<
wtf/ReducedResolutionSeconds.h
>
#
include
<
wtf/SafeStrerror.h
>
#
include
<
wtf/Scope.h
>
#
include
<
wtf/StringPrintStream.h
>
#
include
<
wtf/TZoneMallocInlines.h
>
#
include
<
wtf/URL.h
>
#
include
<
wtf/WTFProcess.h
>
#
include
<
wtf/WallTime.h
>
#
include
<
wtf/text/Base64.h
>
#
include
<
wtf/text/MakeString.h
>
#
include
<
wtf/text/StringBuilder.h
>
#
include
<
wtf/text/StringToIntegerConversion.h
>
#
include
<
wtf/threads/BinarySemaphore.h
>
#
include
<
wtf/threads/Signals.h
>
#
if
OS(WINDOWS)
#
include
<
direct.h
>
#
include
<
fcntl.h
>
#
include
<
io.h
>
#
else
#
include
<
unistd.h
>
#
endif
#
if
PLATFORM(COCOA)
#
include
<
crt_externs.h
>
#
include
<
wtf/OSObjectPtr.h
>
#
include
<
wtf/cocoa/CrashReporter.h
>
#
include
<
wtf/cocoa/RuntimeApplicationChecksCocoa.h
>
#
endif
#
if
PLATFORM(GTK)
#
include
<
locale.h
>
#
endif
#
if
HAVE(READLINE)
//
readline/history.h has a Function typedef which conflicts with the WTF::Function template from WTF/Forward.h
//
We #define it to something else to avoid this conflict.
#
define
Function
ReadlineFunction
#
include
<
readline/history.h
>
#
include
<
readline/readline.h
>
#
undef
Function
#
endif
#
if
OS(WINDOWS)
#
include
<
mmsystem.h
>
#
include
<
windows.h
>
#
include
<
wtf/win/WTFCRTDebug.h
>
#
endif
#
if
OS(DARWIN) && CPU(ARM_THUMB2)
#
include
<
arm/arch.h
>
#
include
<
fenv.h
>
#
endif
#
if
OS(DARWIN)
#
if
__has_include(<libproc.h>)
#
include
<
libproc.h
>
#
endif
#
endif
#
if
OS(DARWIN)
#
include
<
wtf/spi/darwin/ProcessMemoryFootprint.h
>
#
elif
OS(LINUX)
#
include
<
wtf/linux/ProcessMemoryFootprint.h
>
#
endif
WTF_ALLOW_UNSAFE_BUFFER_USAGE_BEGIN
#
if
OS(DARWIN) || OS(LINUX)
struct
MemoryFootprint
: ProcessMemoryFootprint {
MemoryFootprint
(
const
ProcessMemoryFootprint& src)
: ProcessMemoryFootprint(src)
{
}
};
#
else
struct
MemoryFootprint
{
uint64_t
current;
uint64_t
peak;
static
MemoryFootprint
now
()
{
return
{
0L
,
0L
};
}
static
void
resetPeak
()
{
}
};
#
endif
#
if
!defined(PATH_MAX)
#
define
PATH_MAX
4096
#
endif
using
namespace
JSC
;
namespace
{
#
define
EXIT_EXCEPTION
3
[[noreturn]]
static
void
jscExit
(
int
status)
{
#
if
ENABLE(DFG_JIT)
if
(
DFG::isCrashing
()) {
for
(;;) {
#
if
OS(WINDOWS)
Sleep
(
1000
);
#
else
pause
();
#
endif
}
}
#
endif
//
ENABLE(DFG_JIT)
exitProcess
(status);
}
static
unsigned
asyncTestPasses {
0
};
static
unsigned
asyncTestExpectedPasses {
0
};
}
static
RefPtr<Uint8Array>
fillBufferWithContentsOfFile
(
const
String& fileName);
class
CommandLine
;
class
GlobalObject
;
class
Workers
;
template
<
typename
Func>
int
runJSC
(
const
CommandLine&,
bool
isWorker,
const
Func&);
static
void
checkException
(GlobalObject*,
bool
isLastFile,
bool
hasException, JSValue,
const
CommandLine&,
bool
& success);
class
Message
:
public
ThreadSafeRefCounted
<Message> {
public:
#
if
ENABLE(WEBASSEMBLY)
struct
WasmMemory
{
RefPtr<SharedArrayBufferContents> contents;
Wasm::AddressType addressType;
};
using
Content = Variant<ArrayBufferContents, WasmMemory>;
#
else
using
Content = Variant<ArrayBufferContents>;
#
endif
Message
(Content&&,
int32_t
);
~Message
();
Content&&
NODELETE
releaseContents
() {
return
WTF::move
(m_contents); }
int32_t
NODELETE
index
()
const
{
return
m_index; }
private:
Content m_contents;
int32_t
m_index {
0
};
};
class
Worker
:
public
BasicRawSentinelNode
<Worker> {
public:
Worker
(Workers&,
bool
isMain);
~Worker
();
void
enqueue
(
const
AbstractLocker&, RefPtr<Message>);
RefPtr<Message>
dequeue
();
bool
NODELETE
isMain
()
const
{
return
m_isMain; }
static
Worker&
current
();
private:
static
ThreadSpecific<Worker*>&
currentWorker
();
Workers& m_workers;
Deque<RefPtr<Message>> m_messages;
const
bool
m_isMain;
};
class
Workers
{
WTF_MAKE_TZONE_ALLOCATED
(Workers);
WTF_MAKE_NONCOPYABLE
(Workers);
public:
Workers
();
~Workers
();
template
<
typename
Func>
void
broadcast
(
const
Func&);
void
report
(
const
String&);
String
tryGetReport
();
String
getReport
();
static
Workers&
singleton
();
private:
friend
class
Worker
;
Lock m_lock;
Condition m_condition;
SentinelLinkedList<Worker, BasicRawSentinelNode<Worker>> m_workers;
Deque<String> m_reports;
};
WTF_MAKE_TZONE_ALLOCATED_IMPL
(Workers);
static
JSC_DECLARE_HOST_FUNCTION
(functionAtob);
static
JSC_DECLARE_HOST_FUNCTION
(functionBtoa);
static
JSC_DECLARE_HOST_FUNCTION
(functionDisassembleBase64);
static
JSC_DECLARE_HOST_FUNCTION
(functionCreateGlobalObject);
static
JSC_DECLARE_HOST_FUNCTION
(functionCreateHeapBigInt);
#
if
USE(BIGINT32)
static
JSC_DECLARE_HOST_FUNCTION
(functionCreateBigInt32);
#
endif
static
JSC_DECLARE_HOST_FUNCTION
(functionUseBigInt32);
static
JSC_DECLARE_HOST_FUNCTION
(functionIsBigInt32);
static
JSC_DECLARE_HOST_FUNCTION
(functionIsHeapBigInt);
static
JSC_DECLARE_HOST_FUNCTION
(functionIs8BitString);
static
JSC_DECLARE_HOST_FUNCTION
(functionCreateNonRopeNonAtomString);
static
JSC_DECLARE_HOST_FUNCTION
(functionPrintStdOut);
static
JSC_DECLARE_HOST_FUNCTION
(functionPrintStdErr);
static
JSC_DECLARE_HOST_FUNCTION
(functionPrettyPrint);
static
JSC_DECLARE_HOST_FUNCTION
(functionDebug);
static
JSC_DECLARE_HOST_FUNCTION
(functionDescribe);
static
JSC_DECLARE_HOST_FUNCTION
(functionDescribeArray);
static
JSC_DECLARE_HOST_FUNCTION
(functionSleepSeconds);
static
JSC_DECLARE_HOST_FUNCTION
(functionJSCStack);
static
JSC_DECLARE_HOST_FUNCTION
(functionGCAndSweep);
static
JSC_DECLARE_HOST_FUNCTION
(functionFullGC);
static
JSC_DECLARE_HOST_FUNCTION
(functionEdenGC);
static
JSC_DECLARE_HOST_FUNCTION
(functionHeapSize);
static
JSC_DECLARE_HOST_FUNCTION
(functionMemoryUsageStatistics);
static
JSC_DECLARE_HOST_FUNCTION
(functionCreateMemoryFootprint);
static
JSC_DECLARE_HOST_FUNCTION
(functionResetMemoryPeak);
static
JSC_DECLARE_HOST_FUNCTION
(functionAddressOf);
static
JSC_DECLARE_HOST_FUNCTION
(functionVersion);
static
JSC_DECLARE_HOST_FUNCTION
(functionRun);
static
JSC_DECLARE_HOST_FUNCTION
(functionRunString);
static
JSC_DECLARE_HOST_FUNCTION
(functionLoad);
static
JSC_DECLARE_HOST_FUNCTION
(functionLoadString);
static
JSC_DECLARE_HOST_FUNCTION
(functionReadFile);
static
JSC_DECLARE_HOST_FUNCTION
(functionWriteFile);
static
JSC_DECLARE_HOST_FUNCTION
(functionCheckSyntax);
static
JSC_DECLARE_HOST_FUNCTION
(functionOpenFile);
static
JSC_DECLARE_HOST_FUNCTION
(functionReadline);
static
JSC_DECLARE_HOST_FUNCTION
(functionPreciseTime);
static
JSC_DECLARE_HOST_FUNCTION
(functionNeverInlineFunction);
static
JSC_DECLARE_HOST_FUNCTION
(functionNoDFG);
static
JSC_DECLARE_HOST_FUNCTION
(functionNoFTL);
static
JSC_DECLARE_HOST_FUNCTION
(functionNoOSRExitFuzzing);
static
JSC_DECLARE_HOST_FUNCTION
(functionOptimizeNextInvocation);
static
JSC_DECLARE_HOST_FUNCTION
(functionNumberOfDFGCompiles);
static
JSC_DECLARE_HOST_FUNCTION
(functionCallerIsBBQOrOMGCompiled);
static
JSC_DECLARE_HOST_FUNCTION
(functionJSCOptions);
static
JSC_DECLARE_HOST_FUNCTION
(functionReoptimizationRetryCount);
static
JSC_DECLARE_HOST_FUNCTION
(functionTransferArrayBuffer);
static
JSC_DECLARE_HOST_FUNCTION
(functionFailNextNewCodeBlock);
[[noreturn]]
static
JSC_DECLARE_HOST_FUNCTION
(functionQuit);
static
JSC_DECLARE_HOST_FUNCTION
(functionFalse);
static
JSC_DECLARE_HOST_FUNCTION
(functionUndefined1);
static
JSC_DECLARE_HOST_FUNCTION
(functionUndefined2);
static
JSC_DECLARE_HOST_FUNCTION
(functionIsInt32);
static
JSC_DECLARE_HOST_FUNCTION
(functionIsPureNaN);
static
JSC_DECLARE_HOST_FUNCTION
(functionEffectful42);
static
JSC_DECLARE_HOST_FUNCTION
(functionIdentity);
static
JSC_DECLARE_HOST_FUNCTION
(functionMakeMasquerader);
static
JSC_DECLARE_HOST_FUNCTION
(functionCallMasquerader);
static
JSC_DECLARE_HOST_FUNCTION
(functionHasCustomProperties);
static
JSC_DECLARE_HOST_FUNCTION
(functionDumpTypesForAllVariables);
static
JSC_DECLARE_HOST_FUNCTION
(functionDrainMicrotasks);
static
JSC_DECLARE_HOST_FUNCTION
(functionDumpBytecodeProfile);
static
JSC_DECLARE_HOST_FUNCTION
(functionSetTimeout);
static
JSC_DECLARE_HOST_FUNCTION
(functionReleaseWeakRefs);
static
JSC_DECLARE_HOST_FUNCTION
(functionFinalizationRegistryLiveCount);
static
JSC_DECLARE_HOST_FUNCTION
(functionFinalizationRegistryDeadCount);
static
JSC_DECLARE_HOST_FUNCTION
(functionIs32BitPlatform);
static
JSC_DECLARE_HOST_FUNCTION
(functionCheckModuleSyntax);
static
JSC_DECLARE_HOST_FUNCTION
(functionCheckScriptSyntax);
static
JSC_DECLARE_HOST_FUNCTION
(functionPlatformSupportsSamplingProfiler);
static
JSC_DECLARE_HOST_FUNCTION
(functionGenerateHeapSnapshot);
static
JSC_DECLARE_HOST_FUNCTION
(functionGenerateHeapSnapshotForGCDebugging);
static
JSC_DECLARE_HOST_FUNCTION
(functionResetSuperSamplerState);
static
JSC_DECLARE_HOST_FUNCTION
(functionEnsureArrayStorage);
static
JSC_DECLARE_HOST_FUNCTION
(functionCreateNoopNativeFunctionWithCapture);
#
if
ENABLE(SAMPLING_PROFILER)
static
JSC_DECLARE_HOST_FUNCTION
(functionStartSamplingProfiler);
static
JSC_DECLARE_HOST_FUNCTION
(functionSamplingProfilerStackTraces);
#
endif
static
JSC_DECLARE_HOST_FUNCTION
(functionMaxArguments);
static
JSC_DECLARE_HOST_FUNCTION
(functionAsyncTestStart);
static
JSC_DECLARE_HOST_FUNCTION
(functionAsyncTestPassed);
#
if
ENABLE(WEBASSEMBLY)
static
JSC_DECLARE_HOST_FUNCTION
(functionWebAssemblyMemoryMode);
static
JSC_DECLARE_HOST_FUNCTION
(functionCreateWebAssemblyMemoryWithMode);
#
endif
#
if
ENABLE(SAMPLING_FLAGS)
static
JSC_DECLARE_HOST_FUNCTION
(functionSetSamplingFlags);
static
JSC_DECLARE_HOST_FUNCTION
(functionClearSamplingFlags);
#
endif
static
JSC_DECLARE_HOST_FUNCTION
(functionGetRandomSeed);
static
JSC_DECLARE_HOST_FUNCTION
(functionSetRandomSeed);
static
JSC_DECLARE_HOST_FUNCTION
(functionIsRope);
static
JSC_DECLARE_HOST_FUNCTION
(functionCallerSourceOrigin);
static
JSC_DECLARE_HOST_FUNCTION
(functionDollarCreateRealm);
static
JSC_DECLARE_HOST_FUNCTION
(functionDollarEvalScript);
static
JSC_DECLARE_HOST_FUNCTION
(functionDollarGC);
static
JSC_DECLARE_HOST_FUNCTION
(functionDollarClearKeptObjects);
static
JSC_DECLARE_HOST_FUNCTION
(functionDollarGlobalObjectFor);
static
JSC_DECLARE_HOST_FUNCTION
(functionDollarIsRemoteFunction);
static
JSC_DECLARE_HOST_FUNCTION
(functionDollarAgentStart);
static
JSC_DECLARE_HOST_FUNCTION
(functionDollarAgentReceiveBroadcast);
static
JSC_DECLARE_HOST_FUNCTION
(functionDollarAgentReport);
static
JSC_DECLARE_HOST_FUNCTION
(functionDollarAgentSleep);
static
JSC_DECLARE_HOST_FUNCTION
(functionDollarAgentBroadcast);
static
JSC_DECLARE_HOST_FUNCTION
(functionDollarAgentGetReport);
static
JSC_DECLARE_HOST_FUNCTION
(functionDollarAgentLeaving);
static
JSC_DECLARE_HOST_FUNCTION
(functionDollarAgentMonotonicNow);
static
JSC_DECLARE_HOST_FUNCTION
(functionWaiterListSize);
static
JSC_DECLARE_HOST_FUNCTION
(functionWaitForReport);
static
JSC_DECLARE_HOST_FUNCTION
(functionHeapCapacity);
static
JSC_DECLARE_HOST_FUNCTION
(functionFlashHeapAccess);
static
JSC_DECLARE_HOST_FUNCTION
(functionDisableRichSourceInfo);
static
JSC_DECLARE_HOST_FUNCTION
(functionMallocInALoop);
static
JSC_DECLARE_HOST_FUNCTION
(functionTotalCompileTime);
static
JSC_DECLARE_HOST_FUNCTION
(functionSetUnhandledRejectionCallback);
static
JSC_DECLARE_HOST_FUNCTION
(functionAsDoubleNumber);
static
JSC_DECLARE_HOST_FUNCTION
(functionDropAllLocks);
static
JSC_DECLARE_HOST_FUNCTION
(functionPerformanceNow);
static
JSC_DECLARE_HOST_FUNCTION
(functionPerformanceMark);
static
JSC_DECLARE_HOST_FUNCTION
(functionPerformanceMeasure);
#
if
ENABLE(FUZZILLI)
static
JSC_DECLARE_HOST_FUNCTION
(functionFuzzilli);
#
endif
struct
Script
{
enum
class
StrictMode
{
Strict,
Sloppy
};
enum
class
ScriptType
{
Script,
Module
};
enum
class
CodeSource
{
File,
CommandLine,
#
if
ENABLE(FUZZILLI)
Reprl,
#
endif
};
StrictMode strictMode;
CodeSource codeSource;
ScriptType scriptType;
String argument;
Script
(StrictMode strictMode, CodeSource codeSource, ScriptType scriptType,
char
*argument)
: strictMode(strictMode)
, codeSource(codeSource)
, scriptType(scriptType)
, argument(String::fromLatin1(argument))
{
if
(strictMode == StrictMode::Strict)
ASSERT
(codeSource == CodeSource::File);
}
};
class
CommandLine
{
public:
CommandLine
(
int
argc,
char
** argv)
{
parseArguments
(argc, argv);
}
enum
CommandLineForWorkersTag { CommandLineForWorkers };
explicit
CommandLine
(CommandLineForWorkersTag);
Vector<Script> m_scripts;
Vector<String> m_arguments;
String m_profilerOutput;
String m_uncaughtExceptionName;
bool
m_interactive {
false
};
bool
m_module {
false
};
bool
m_exitCode {
false
};
bool
m_destroyVM {
false
};
bool
m_treatWatchdogExceptionAsSuccess {
false
};
bool
m_ignoreUncaughtExceptions {
false
};
bool
m_alwaysDumpUncaughtException {
false
};
bool
m_dumpMemoryFootprint {
false
};
bool
m_dumpLinkBufferStats {
false
};
bool
m_dumpSamplingProfilerData {
false
};
bool
m_inspectable {
false
};
bool
m_canBlockIsFalse {
false
};
bool
m_reprl {
false
};
//
Set to true to use Fuzzilli.
void
parseArguments
(
int
,
char
**,
int
start =
1
);
};
static
LazyNeverDestroyed<CommandLine> mainCommandLine;
static
const
char
interactivePrompt[] =
"
>>>
"
;
class
StopWatch
{
public:
void
start
();
void
stop
();
long
getElapsedMS
();
//
call stop() first
private:
MonotonicTime m_startTime;
MonotonicTime m_stopTime;
};
void
StopWatch::start
()
{
m_startTime =
MonotonicTime::now
();
}
void
StopWatch::stop
()
{
m_stopTime =
MonotonicTime::now
();
}
long
NODELETE
StopWatch::getElapsedMS
()
{
return
(m_stopTime - m_startTime).
millisecondsAs
<
long
>();
}
template
<
typename
Vector>
static
inline
String
stringFromUTF
(
const
Vector& utf8)
{
return
String::fromUTF8WithLatin1Fallback
(utf8.
span
());
}
static
JSC_DECLARE_CUSTOM_GETTER
(accessorMakeMasquerader);
static
JSC_DECLARE_CUSTOM_SETTER
(testCustomAccessorSetter);
static
JSC_DECLARE_CUSTOM_SETTER
(testCustomValueSetter);
JSC_DEFINE_CUSTOM_GETTER
(accessorMakeMasquerader, (JSGlobalObject* globalObject, EncodedJSValue, PropertyName))
{
VM
& vm = globalObject->
vm
();
return
JSValue::encode
(
InternalFunction::createFunctionThatMasqueradesAsUndefined
(vm, globalObject,
0
,
"
IsHTMLDDA
"
_s, functionCallMasquerader));
}
int
propertyFilterSideDataKey;
class
GlobalObject
final
: public JSGlobalObject {
public:
using
Base = JSGlobalObject;
static
constexpr
unsigned
StructureFlags = Base::StructureFlags | OverridesGetOwnPropertyNames;
static
GlobalObject*
create
(
VM
& vm, Structure* structure,
const
Vector<String>& arguments)
{
GlobalObject* object =
new
(NotNull, allocateCell<GlobalObject>(vm))
GlobalObject
(vm, structure);
object->
finishCreation
(vm, arguments);
return
object;
}
DECLARE_INFO
;
static
const
GlobalObjectMethodTable s_globalObjectMethodTable;
static
Structure*
createStructure
(
VM
& vm, JSValue prototype)
{
return
Structure::create
(vm,
nullptr
, prototype,
TypeInfo
(GlobalObjectType, StructureFlags),
info
());
}
static
RuntimeFlags
NODELETE
javaScriptRuntimeFlags
(
const
JSGlobalObject*) {
return
RuntimeFlags::createAllEnabled
(); }
static
void
getOwnPropertyNames
(JSObject* object, JSGlobalObject* globalObject, PropertyNameArrayBuilder& propertyNames, DontEnumPropertiesMode mode)
{
VM
& vm = globalObject->
vm
();
PropertyNameArrayBuilder
ownPropertyNames
(vm, propertyNames.
propertyNameMode
(), propertyNames.
privateSymbolMode
());
Base::getOwnPropertyNames
(object, globalObject, ownPropertyNames, mode);
auto
* thisObject = uncheckedDowncast<GlobalObject>(object);
auto
& filter = thisObject->
ensurePropertyFilter
();
for
(
auto
& propertyName : ownPropertyNames) {
if
(!filter.
contains
(propertyName.
impl
()))
propertyNames.
add
(propertyName);
}
}
private:
GlobalObject
(
VM
&, Structure*);
static
constexpr
unsigned
DontEnum =
0
| PropertyAttribute::DontEnum;
class
PropertyFilter
:
public
SideDataRepository
::SideData {
WTF_DEPRECATED_MAKE_FAST_ALLOCATED
(PropertyFilter);
public:
void
add
(UniquedStringImpl* uid)
{
auto
result = m_names.
add
(uid);
if
(result.
isNewEntry
)
m_strings.
append
(uid);
}
bool
contains
(UniquedStringImpl* name)
const
{
return
m_names.
contains
(name); }
const
UncheckedKeyHashSet<UniquedStringImpl*>&
NODELETE
names
()
const
{
return
m_names; }
private:
Vector<AtomString> m_strings;
//
To keep the UniqueStringImpls alive.
UncheckedKeyHashSet<UniquedStringImpl*> m_names;
};
void
finishCreation
(
VM
& vm,
const
Vector<String>& arguments)
{
//
This shouldn't actually throw in practice, it's a test object. That said, it creates
//
arrays and such that can generally throw.
auto
scope =
DECLARE_TOP_EXCEPTION_SCOPE
(vm);
auto
& filter =
ensurePropertyFilter
();
auto
addFunction = [&] (
VM
& vm, ASCIILiteral name, NativeFunction function,
unsigned
arguments,
unsigned
attributes =
static_cast
<
unsigned
>(PropertyAttribute::DontEnum)) {
addFunctionImpl
(filter, vm, name, function, arguments, attributes);
};
auto
addFunctionToObject = [&] (
VM
& vm, JSObject* owner, ASCIILiteral name, NativeFunction function,
unsigned
arguments,
unsigned
attributes =
static_cast
<
unsigned
>(PropertyAttribute::DontEnum)) {
addFunctionToObjectImpl
(filter, vm, owner, name, function, arguments, attributes);
};
auto
putDirect = [&] (
VM
& vm, PropertyName propertyName, JSValue value,
unsigned
attributes =
0
) ->
bool
{
return
putDirectImpl
(filter, vm, propertyName, value, attributes);
};
auto
putDirectWithoutTransition = [&] (
VM
& vm, PropertyName propertyName, JSValue value,
unsigned
attributes) {
putDirectWithoutTransitionImpl
(filter, vm, propertyName, value, attributes);
};
auto
putDirectNativeFunction = [&] (
VM
& vm, JSGlobalObject* globalObject,
const
PropertyName& propertyName,
unsigned
functionLength, NativeFunction nativeFunction, ImplementationVisibility implementationVisibility, Intrinsic intrinsic,
unsigned
attributes) ->
bool
{
return
putDirectNativeFunctionImpl
(filter, vm, globalObject, propertyName, functionLength, nativeFunction, implementationVisibility, intrinsic, attributes);
};
Base::finishCreation
(vm);
JSC_TO_STRING_TAG_WITHOUT_TRANSITION
();
//
Set loop counts based on enabled engine tiers. When concurrent JIT is off,
//
clamp to a small multiple of the top tier's warm-up threshold so eager
//
modes don't balloon stress-test runtime on the main thread.
auto
clampLoopCount = [](
uint32_t
defaultCount,
uint32_t
noCJITCap) {
return
Options::useConcurrentJIT
() ? defaultCount :
std::min
(defaultCount, noCJITCap);
};
unsigned
testLoopCount =
clampLoopCount
(
10000
,
Options::thresholdForFTLOptimizeAfterWarmUp
() *
3
);
if
(!
Options::useDFGJIT
())
testLoopCount =
clampLoopCount
(
1000
,
Options::thresholdForOptimizeAfterWarmUp
() *
3
);
if
(!
Options::useBaselineJIT
())
testLoopCount =
clampLoopCount
(
100
,
Options::thresholdForJITAfterWarmUp
() *
3
);
unsigned
wasmTestLoopCount =
clampLoopCount
(
10000
,
Options::thresholdForOMGOptimizeAfterWarmUp
() *
3
);
if
(!
Options::useOMGJIT
())
wasmTestLoopCount =
clampLoopCount
(
1000
,
Options::thresholdForBBQOptimizeAfterWarmUp
() *
3
);
if
(!
Options::useBBQJIT
())
wasmTestLoopCount =
100
;
putDirect
(vm,
Identifier::fromString
(vm,
"
testLoopCount
"
_s),
jsNumber
(testLoopCount), DontEnum);
putDirect
(vm,
Identifier::fromString
(vm,
"
wasmTestLoopCount
"
_s),
jsNumber
(wasmTestLoopCount), DontEnum);
addFunction
(vm,
"
atob
"
_s, functionAtob,
1
);
addFunction
(vm,
"
btoa
"
_s, functionBtoa,
1
);
addFunction
(vm,
"
disassembleBase64
"
_s, functionDisassembleBase64,
1
);
addFunction
(vm,
"
debug
"
_s, functionDebug,
1
);
addFunction
(vm,
"
describe
"
_s, functionDescribe,
1
);
addFunction
(vm,
"
describeArray
"
_s, functionDescribeArray,
1
);
addFunction
(vm,
"
print
"
_s, functionPrintStdOut,
1
);
addFunction
(vm,
"
printErr
"
_s, functionPrintStdErr,
1
);
addFunction
(vm,
"
prettyPrint
"
_s, functionPrettyPrint,
1
);
addFunction
(vm,
"
quit
"
_s, functionQuit,
0
);
addFunction
(vm,
"
gc
"
_s, functionGCAndSweep,
0
);
addFunction
(vm,
"
fullGC
"
_s, functionFullGC,
0
);
addFunction
(vm,
"
edenGC
"
_s, functionEdenGC,
0
);
addFunction
(vm,
"
gcHeapSize
"
_s, functionHeapSize,
0
);
addFunction
(vm,
"
memoryUsageStatistics
"
_s, functionMemoryUsageStatistics,
0
);
addFunction
(vm,
"
MemoryFootprint
"
_s, functionCreateMemoryFootprint,
0
);
addFunction
(vm,
"
resetMemoryPeak
"
_s, functionResetMemoryPeak,
0
);
addFunction
(vm,
"
addressOf
"
_s, functionAddressOf,
1
);
addFunction
(vm,
"
version
"
_s, functionVersion,
1
);
addFunction
(vm,
"
run
"
_s, functionRun,
1
);
addFunction
(vm,
"
runString
"
_s, functionRunString,
1
);
addFunction
(vm,
"
load
"
_s, functionLoad,
1
);
addFunction
(vm,
"
loadString
"
_s, functionLoadString,
1
);
addFunction
(vm,
"
readFile
"
_s, functionReadFile,
2
);
addFunction
(vm,
"
read
"
_s, functionReadFile,
2
);
addFunction
(vm,
"
writeFile
"
_s, functionWriteFile,
2
);
addFunction
(vm,
"
write
"
_s, functionWriteFile,
2
);
addFunction
(vm,
"
checkSyntax
"
_s, functionCheckSyntax,
1
);
addFunction
(vm,
"
sleepSeconds
"
_s, functionSleepSeconds,
1
);
addFunction
(vm,
"
jscStack
"
_s, functionJSCStack,
1
);
addFunction
(vm,
"
openFile
"
_s, functionOpenFile,
1
);
addFunction
(vm,
"
readline
"
_s, functionReadline,
0
);
addFunction
(vm,
"
preciseTime
"
_s, functionPreciseTime,
0
);
addFunction
(vm,
"
neverInlineFunction
"
_s, functionNeverInlineFunction,
1
);
addFunction
(vm,
"
noInline
"
_s, functionNeverInlineFunction,
1
);
addFunction
(vm,
"
noDFG
"
_s, functionNoDFG,
1
);
addFunction
(vm,
"
noFTL
"
_s, functionNoFTL,
1
);
addFunction
(vm,
"
noOSRExitFuzzing
"
_s, functionNoOSRExitFuzzing,
1
);
addFunction
(vm,
"
numberOfDFGCompiles
"
_s, functionNumberOfDFGCompiles,
1
);
addFunction
(vm,
"
callerIsBBQOrOMGCompiled
"
_s, functionCallerIsBBQOrOMGCompiled,
0
);
addFunction
(vm,
"
jscOptions
"
_s, functionJSCOptions,
0
);
addFunction
(vm,
"
optimizeNextInvocation
"
_s, functionOptimizeNextInvocation,
1
);
addFunction
(vm,
"
reoptimizationRetryCount
"
_s, functionReoptimizationRetryCount,
1
);
addFunction
(vm,
"
transferArrayBuffer
"
_s, functionTransferArrayBuffer,
1
);
addFunction
(vm,
"
failNextNewCodeBlock
"
_s, functionFailNextNewCodeBlock,
1
);
#
if
ENABLE(SAMPLING_FLAGS)
addFunction
(vm,
"
setSamplingFlags
"
_s, functionSetSamplingFlags,
1
);
addFunction
(vm,
"
clearSamplingFlags
"
_s, functionClearSamplingFlags,
1
);
#
endif
putDirectNativeFunction
(vm,
this
,
Identifier::fromString
(vm,
"
OSRExit
"
_s),
0
, functionUndefined1, ImplementationVisibility::Public, OSRExitIntrinsic, DontEnum);
putDirectNativeFunction
(vm,
this
,
Identifier::fromString
(vm,
"
isFinalTier
"
_s),
0
, functionFalse, ImplementationVisibility::Public, IsFinalTierIntrinsic, DontEnum);
putDirectNativeFunction
(vm,
this
,
Identifier::fromString
(vm,
"
predictInt32
"
_s),
0
, functionUndefined2, ImplementationVisibility::Public, SetInt32HeapPredictionIntrinsic, DontEnum);
putDirectNativeFunction
(vm,
this
,
Identifier::fromString
(vm,
"
isInt32
"
_s),
0
, functionIsInt32, ImplementationVisibility::Public, CheckInt32Intrinsic, DontEnum);
putDirectNativeFunction
(vm,
this
,
Identifier::fromString
(vm,
"
isPureNaN
"
_s),
0
, functionIsPureNaN, ImplementationVisibility::Public, CheckInt32Intrinsic, DontEnum);
putDirectNativeFunction
(vm,
this
,
Identifier::fromString
(vm,
"
fiatInt52
"
_s),
0
, functionIdentity, ImplementationVisibility::Public, FiatInt52Intrinsic, DontEnum);
addFunction
(vm,
"
effectful42
"
_s, functionEffectful42,
0
);
addFunction
(vm,
"
makeMasquerader
"
_s, functionMakeMasquerader,
0
);
addFunction
(vm,
"
hasCustomProperties
"
_s, functionHasCustomProperties,
0
);
addFunction
(vm,
"
createGlobalObject
"
_s, functionCreateGlobalObject,
0
);
addFunction
(vm,
"
createHeapBigInt
"
_s, functionCreateHeapBigInt,
1
);
#
if
USE(BIGINT32)
addFunction
(vm,
"
createBigInt32
"
_s, functionCreateBigInt32,
1
);
#
endif
addFunction
(vm,
"
useBigInt32
"
_s, functionUseBigInt32,
0
);
addFunction
(vm,
"
isBigInt32
"
_s, functionIsBigInt32,
1
);
addFunction
(vm,
"
isHeapBigInt
"
_s, functionIsHeapBigInt,
1
);
addFunction
(vm,
"
is8BitString
"
_s, functionIs8BitString,
1
);
addFunction
(vm,
"
createNonRopeNonAtomString
"
_s, functionCreateNonRopeNonAtomString,
1
);
addFunction
(vm,
"
dumpTypesForAllVariables
"
_s, functionDumpTypesForAllVariables ,
0
);
addFunction
(vm,
"
drainMicrotasks
"
_s, functionDrainMicrotasks,
0
);
addFunction
(vm,
"
setTimeout
"
_s, functionSetTimeout,
2
);
addFunction
(vm,
"
dumpBytecodeProfile
"
_s, functionDumpBytecodeProfile,
1
);
addFunction
(vm,
"
releaseWeakRefs
"
_s, functionReleaseWeakRefs,
0
);
addFunction
(vm,
"
finalizationRegistryLiveCount
"
_s, functionFinalizationRegistryLiveCount,
0
);
addFunction
(vm,
"
finalizationRegistryDeadCount
"
_s, functionFinalizationRegistryDeadCount,
0
);
addFunction
(vm,
"
getRandomSeed
"
_s, functionGetRandomSeed,
0
);
addFunction
(vm,
"
setRandomSeed
"
_s, functionSetRandomSeed,
1
);
addFunction
(vm,
"
isRope
"
_s, functionIsRope,
1
);
addFunction
(vm,
"
callerSourceOrigin
"
_s, functionCallerSourceOrigin,
0
);
addFunction
(vm,
"
is32BitPlatform
"
_s, functionIs32BitPlatform,
0
);
addFunction
(vm,
"
checkModuleSyntax
"
_s, functionCheckModuleSyntax,
1
);
addFunction
(vm,
"
checkScriptSyntax
"
_s, functionCheckScriptSyntax,
1
);
addFunction
(vm,
"
platformSupportsSamplingProfiler
"
_s, functionPlatformSupportsSamplingProfiler,
0
);
addFunction
(vm,
"
generateHeapSnapshot
"
_s, functionGenerateHeapSnapshot,
0
);
addFunction
(vm,
"
generateHeapSnapshotForGCDebugging
"
_s, functionGenerateHeapSnapshotForGCDebugging,
0
);
addFunction
(vm,
"
resetSuperSamplerState
"
_s, functionResetSuperSamplerState,
0
);
addFunction
(vm,
"
ensureArrayStorage
"
_s, functionEnsureArrayStorage,
0
);
addFunction
(vm,
"
createNoopNativeFunctionWithCapture
"
_s, functionCreateNoopNativeFunctionWithCapture,
1
);
#
if
ENABLE(SAMPLING_PROFILER)
addFunction
(vm,
"
startSamplingProfiler
"
_s, functionStartSamplingProfiler,
0
);
addFunction
(vm,
"
samplingProfilerStackTraces
"
_s, functionSamplingProfilerStackTraces,
0
);
#
endif
addFunction
(vm,
"
maxArguments
"
_s, functionMaxArguments,
0
);
addFunction
(vm,
"
asyncTestStart
"
_s, functionAsyncTestStart,
1
);
addFunction
(vm,
"
asyncTestPassed
"
_s, functionAsyncTestPassed,
1
);
#
if
ENABLE(WEBASSEMBLY)
addFunction
(vm,
"
WebAssemblyMemoryMode
"
_s, functionWebAssemblyMemoryMode,
1
);
addFunction
(vm,
"
createWebAssemblyMemoryWithMode
"
_s, functionCreateWebAssemblyMemoryWithMode,
2
);
#
endif
if
(!arguments.
isEmpty
()) {
JSArray* array =
constructEmptyArray
(
this
,
nullptr
);
scope.
assertNoException
();
for
(
size_t
i =
0
; i < arguments.
size
(); ++i) {
array->
putDirectIndex
(
this
, i,
jsString
(vm, arguments[i]));
scope.
assertNoException
();
}
putDirect
(vm,
Identifier::fromString
(vm,
"
arguments
"
_s), array, DontEnum);
}
putDirect
(vm,
Identifier::fromString
(vm,
"
console
"
_s),
jsUndefined
(), DontEnum);
Structure* plainObjectStructure =
JSFinalObject::createStructure
(vm,
this
,
objectPrototype
(),
0
);
JSObject* dollar =
JSFinalObject::create
(vm, plainObjectStructure);
putDirect
(vm,
Identifier::fromString
(vm,
"
$
"
_s), dollar, DontEnum);
putDirect
(vm,
Identifier::fromString
(vm,
"
$262
"
_s), dollar, DontEnum);
addFunctionToObject
(vm, dollar,
"
createRealm
"
_s, functionDollarCreateRealm,
0
,
static_cast
<
unsigned
>(PropertyAttribute::None));
addFunctionToObject
(vm, dollar,
"
detachArrayBuffer
"
_s, functionTransferArrayBuffer,
1
,
static_cast
<
unsigned
>(PropertyAttribute::None));
addFunctionToObject
(vm, dollar,
"
evalScript
"
_s, functionDollarEvalScript,
1
,
static_cast
<
unsigned
>(PropertyAttribute::None));
addFunctionToObject
(vm, dollar,
"
gc
"
_s, functionDollarGC,
0
,
static_cast
<
unsigned
>(PropertyAttribute::None));
addFunctionToObject
(vm, dollar,
"
clearKeptObjects
"
_s, functionDollarClearKeptObjects,
0
,
static_cast
<
unsigned
>(PropertyAttribute::None));
addFunctionToObject
(vm, dollar,
"
globalObjectFor
"
_s, functionDollarGlobalObjectFor,
1
,
static_cast
<
unsigned
>(PropertyAttribute::None));
addFunctionToObject
(vm, dollar,
"
isRemoteFunction
"
_s, functionDollarIsRemoteFunction,
1
,
static_cast
<
unsigned
>(PropertyAttribute::None));
dollar->
putDirect
(vm,
Identifier::fromString
(vm,
"
global
"
_s),
globalThis
());
dollar->
putDirectCustomAccessor
(vm,
Identifier::fromString
(vm,
"
IsHTMLDDA
"
_s),
CustomGetterSetter::create
(vm, accessorMakeMasquerader,
nullptr
),
static_cast
<
unsigned
>(PropertyAttribute::CustomValue)
);
JSObject* agent =
JSFinalObject::create
(vm, plainObjectStructure);
dollar->
putDirect
(vm,
Identifier::fromString
(vm,
"
agent
"
_s), agent);
//
The test262 INTERPRETING.md document says that some of these functions are just in the main
//
thread and some are in the other threads. We just put them in all threads.
addFunctionToObject
(vm, agent,
"
start
"
_s, functionDollarAgentStart,
1
);
addFunctionToObject
(vm, agent,
"
receiveBroadcast
"
_s, functionDollarAgentReceiveBroadcast,
1
);
addFunctionToObject
(vm, agent,
"
report
"
_s, functionDollarAgentReport,
1
);
addFunctionToObject
(vm, agent,
"
sleep
"
_s, functionDollarAgentSleep,
1
);
addFunctionToObject
(vm, agent,
"
broadcast
"
_s, functionDollarAgentBroadcast,
1
);
addFunctionToObject
(vm, agent,
"
getReport
"
_s, functionDollarAgentGetReport,
0
);
addFunctionToObject
(vm, agent,
"
leaving
"
_s, functionDollarAgentLeaving,
0
);
addFunctionToObject
(vm, agent,
"
monotonicNow
"
_s, functionDollarAgentMonotonicNow,
0
);
addFunction
(vm,
"
waiterListSize
"
_s, functionWaiterListSize,
2
);
addFunction
(vm,
"
waitForReport
"
_s, functionWaitForReport,
0
);
addFunction
(vm,
"
heapCapacity
"
_s, functionHeapCapacity,
0
);
addFunction
(vm,
"
flashHeapAccess
"
_s, functionFlashHeapAccess,
0
);
addFunction
(vm,
"
disableRichSourceInfo
"
_s, functionDisableRichSourceInfo,
0
);
addFunction
(vm,
"
mallocInALoop
"
_s, functionMallocInALoop,
0
);
addFunction
(vm,
"
totalCompileTime
"
_s, functionTotalCompileTime,
0
);
addFunction
(vm,
"
setUnhandledRejectionCallback
"
_s, functionSetUnhandledRejectionCallback,
1
);
addFunction
(vm,
"
asDoubleNumber
"
_s, functionAsDoubleNumber,
1
);
addFunction
(vm,
"
dropAllLocks
"
_s, functionDropAllLocks,
1
);
JSObject* performance =
JSFinalObject::create
(vm, plainObjectStructure);
putDirect
(vm,
Identifier::fromString
(vm,
"
performance
"
_s), performance, DontEnum);
addFunctionToObject
(vm, performance,
"
now
"
_s, functionPerformanceNow,
0
);
addFunctionToObject
(vm, performance,
"
mark
"
_s, functionPerformanceMark,
1
);
addFunctionToObject
(vm, performance,
"
measure
"
_s, functionPerformanceMeasure,
2
);
#
if
ENABLE(FUZZILLI)
addFunction
(vm,
"
fuzzilli
"
_s, functionFuzzilli,
2
);
#
endif
if
(
Options::exposeCustomSettersOnGlobalObjectForTesting
()) {
auto
putDirectCustomAccessor = [&] (
VM
& vm, PropertyName propertyName, JSValue value,
unsigned
attributes) ->
bool
{
return
putDirectCustomAccessorImpl
(filter, vm, propertyName, value, attributes);
};
{
CustomGetterSetter* custom =
CustomGetterSetter::create
(vm,
nullptr
, testCustomAccessorSetter);
Identifier identifier =
Identifier::fromString
(vm,
"
testCustomAccessorSetter
"
_s);
putDirectCustomAccessor
(vm, identifier, custom, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::CustomAccessor);
}
{
CustomGetterSetter* custom =
CustomGetterSetter::create
(vm,
nullptr
, testCustomValueSetter);
Identifier identifier =
Identifier::fromString
(vm,
"
testCustomValueSetter
"
_s);
putDirectCustomAccessor
(vm, identifier, custom, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::CustomValue);
}
}
if
(
Options::useDollarVM
()) {
//
$vm is added in JSGlobalObject but we also want it filtered out. Just add it to the filter here.
Identifier dollarVMIdentifier =
Identifier::fromString
(vm,
"
$vm
"
_s);
rememberDontEnumProperty
(filter, dollarVMIdentifier.
impl
(),
0
| PropertyAttribute::DontEnum);
}
#
if
PLATFORM(COCOA)
enableAllSDKAlignedBehaviors
();
#
endif
}
public:
static
bool
testCustomSetterImpl
(JSGlobalObject* lexicalGlobalObject, GlobalObject* thisObject, EncodedJSValue encodedValue, ASCIILiteral propertyName)
{
VM
& vm = lexicalGlobalObject->
vm
();
Identifier identifier =
Identifier::fromString
(vm, propertyName);
thisObject->
putDirect
(vm, identifier,
JSValue::decode
(encodedValue), DontEnum);
return
true
;
}
bool
putDirect
(
VM
& vm, PropertyName propertyName, JSValue value,
unsigned
attributes =
0
)
{
auto
& filter =
ensurePropertyFilter
();
return
putDirectImpl
(filter, vm, propertyName, value, attributes);
}
private:
PropertyFilter&
ensurePropertyFilter
()
{
return
vm
().
ensureSideData
<PropertyFilter>(&propertyFilterSideDataKey, [] () -> std::unique_ptr<PropertyFilter> {
return
makeUnique<PropertyFilter>();
});
}
void
rememberDontEnumProperty
(PropertyFilter& filter, UniquedStringImpl* uid,
unsigned
attributes)
{
static
constexpr
unsigned
DontEnum =
static_cast
<
unsigned
>(PropertyAttribute::DontEnum);
if
(attributes & DontEnum)
filter.
add
(uid);
}
void
addFunctionToObjectImpl
(PropertyFilter& filter,
VM
& vm, JSObject* owner, ASCIILiteral name, NativeFunction function,
unsigned
arguments,
unsigned
attributes =
static_cast
<
unsigned
>(PropertyAttribute::DontEnum))
{
Identifier identifier =
Identifier::fromString
(vm, name);
owner->
putDirect
(vm, identifier,
JSFunction::create
(vm,
this
, arguments, identifier.
string
(), function, ImplementationVisibility::Public), attributes);
//
addFunctionToObjectImpl is also used as a utility function for adding to other objects.
//
We only need to call rememberDontEnumProperty on GlobalObject properties.
if
(owner ==
this
)
rememberDontEnumProperty
(filter, identifier.
impl
(), attributes);
}
void
addFunctionImpl
(PropertyFilter& filter,
VM
& vm, ASCIILiteral name, NativeFunction function,
unsigned
arguments,
unsigned
attributes =
static_cast
<
unsigned
>(PropertyAttribute::DontEnum))
{
addFunctionToObjectImpl
(filter, vm,
this
, name, function, arguments, attributes);
}
bool
putDirectImpl
(PropertyFilter& filter,
VM
& vm, PropertyName propertyName, JSValue value,
unsigned
attributes =
0
)
{
rememberDontEnumProperty
(filter, propertyName.
uid
(), attributes);
return
Base::putDirect
(vm, propertyName, value, attributes);
}
void
putDirectWithoutTransition
(
VM
&, PropertyName, JSValue,
unsigned
) = delete;
void
putDirectWithoutTransitionImpl
(PropertyFilter& filter,
VM
& vm, PropertyName propertyName, JSValue value,
unsigned
attributes)
{
rememberDontEnumProperty
(filter, propertyName.
uid
(), attributes);
Base::putDirectWithoutTransition
(vm, propertyName, value, attributes);
}
bool
putDirectNativeFunction
(
VM
&, JSGlobalObject*,
const
PropertyName&,
unsigned
, NativeFunction, ImplementationVisibility, Intrinsic,
unsigned
) = delete;
bool
putDirectNativeFunctionImpl
(PropertyFilter& filter,
VM
& vm, JSGlobalObject* globalObject,
const
PropertyName& propertyName,
unsigned
functionLength, NativeFunction nativeFunction, ImplementationVisibility implementationVisibility, Intrinsic intrinsic,
unsigned
attributes)
{
rememberDontEnumProperty
(filter, propertyName.
uid
(), attributes);
return
Base::putDirectNativeFunction
(vm, globalObject, propertyName, functionLength, nativeFunction, implementationVisibility, intrinsic, attributes);
}
bool
putDirectCustomAccessorImpl
(PropertyFilter& filter,
VM
& vm, PropertyName propertyName, JSValue value,
unsigned
attributes)
{
rememberDontEnumProperty
(filter, propertyName.
uid
(), attributes);
return
Base::putDirectCustomAccessor
(vm, propertyName, value, attributes);
}
static
JSPromise*
moduleLoaderImportModule
(JSGlobalObject*, JSModuleLoader*, JSString*, RefPtr<ScriptFetchParameters>,
const
SourceOrigin&,
bool
deferred);
static
Identifier
moduleLoaderResolve
(JSGlobalObject*, JSModuleLoader*, JSValue, JSValue, RefPtr<ScriptFetcher>,
bool
useImportMap);
static
JSPromise*
moduleLoaderFetch
(JSGlobalObject*, JSModuleLoader*, JSValue, RefPtr<ScriptFetchParameters>, RefPtr<ScriptFetcher>);
static
JSObject*
moduleLoaderCreateImportMetaProperties
(JSGlobalObject*, JSModuleLoader*, JSValue, JSModuleRecord*, RefPtr<ScriptFetcher>);
#
if
ENABLE(FUZZILLI)
static
void
promiseRejectionTracker
(JSGlobalObject*, JSPromise*, JSPromiseRejectionOperation);
#
endif
static
void
reportUncaughtExceptionAtEventLoop
(JSGlobalObject*, Exception*);
};
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE
(GlobalObject, JSGlobalObject);
static
bool
supportsRichSourceInfo =
true
;
static
bool
NODELETE
shellSupportsRichSourceInfo
(
const
JSGlobalObject*)
{
return
supportsRichSourceInfo;
}
const
ClassInfo GlobalObject::s_info = {
"
global
"
_s, &JSGlobalObject::s_info,
nullptr
,
nullptr
,
CREATE_METHOD_TABLE
(GlobalObject) };
const
GlobalObjectMethodTable GlobalObject::s_globalObjectMethodTable = {
&shellSupportsRichSourceInfo,
&shouldInterruptScript,
&javaScriptRuntimeFlags,
&shouldInterruptScriptBeforeTimeout,
&moduleLoaderImportModule,
&moduleLoaderResolve,
&moduleLoaderFetch,
&moduleLoaderCreateImportMetaProperties,
nullptr
,
//
moduleLoaderEvaluate
&promiseRejectionTracker,
&reportUncaughtExceptionAtEventLoop,
¤tScriptExecutionOwner,
&scriptExecutionStatus,
&reportViolationForUnsafeEval,
nullptr
,
//
defaultLanguage
nullptr
,
//
compileStreaming
nullptr
,
//
instantinateStreaming
&deriveShadowRealmGlobalObject,
&codeForEval,
&canCompileStrings,
&trustedScriptStructure,
};
View remainder of file in raw view
Back
|
FazBrowse Home
|
New Git URL