-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
JSGlobalObject.h
1239 lines (1046 loc) · 59.8 KB
/
JSGlobalObject.h
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) 2007 Eric Seidel <eric@webkit.org>
* Copyright (C) 2007-2021 Apple Inc. All rights reserved.
*
* 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.
*
*/
#pragma once
#include "ArrayAllocationProfile.h"
#include "ArrayBufferSharingMode.h"
#include "BigIntPrototype.h"
#include "BooleanPrototype.h"
#include "ErrorType.h"
#include "ExceptionHelpers.h"
#include "GetVM.h"
#include "InternalFunction.h"
#include "JSArray.h"
#include "JSClassRef.h"
#include "JSGlobalLexicalEnvironment.h"
#include "JSPromise.h"
#include "JSSegmentedVariableObject.h"
#include "JSWeakObjectMapRefInternal.h"
#include "LazyClassStructure.h"
#include "LazyProperty.h"
#include "NumberPrototype.h"
#include "ParserModes.h"
#include "RegExpGlobalData.h"
#include "RuntimeFlags.h"
#include "StringPrototype.h"
#include "SymbolPrototype.h"
#include "VM.h"
#include "Watchpoint.h"
#include "WeakGCSet.h"
#include <JavaScriptCore/JSBase.h>
#include <array>
#include <wtf/FixedVector.h>
#include <wtf/HashSet.h>
#include <wtf/RetainPtr.h>
#include <wtf/WeakPtr.h>
struct OpaqueJSClass;
struct OpaqueJSClassContextData;
OBJC_CLASS JSWrapperMap;
namespace Inspector {
class JSGlobalObjectInspectorController;
}
namespace JSC {
class ArrayConstructor;
class ArrayPrototype;
class ArrayIteratorPrototype;
class AsyncIteratorPrototype;
class AsyncFunctionPrototype;
class AsyncGeneratorPrototype;
class AsyncGeneratorFunctionPrototype;
class BooleanPrototype;
class ConsoleClient;
class Debugger;
class ErrorConstructor;
class ErrorPrototype;
class EvalCodeBlock;
class EvalExecutable;
class FunctionConstructor;
class FunctionPrototype;
class GeneratorPrototype;
class GeneratorFunctionPrototype;
class GetterSetter;
class GlobalCodeBlock;
class IndirectEvalExecutable;
class InputCursor;
class IntlObject;
class IntlCollator;
class JSArrayBuffer;
class JSArrayBufferPrototype;
class JSCallee;
class JSCustomGetterFunction;
class JSCustomSetterFunction;
class JSGlobalObjectDebuggable;
class JSInternalPromise;
class JSModuleLoader;
class JSModuleRecord;
class JSPromise;
class JSPromiseConstructor;
class JSPromisePrototype;
class JSSharedArrayBuffer;
class JSSharedArrayBufferPrototype;
class JSTypedArrayViewConstructor;
class JSTypedArrayViewPrototype;
class DirectEvalExecutable;
class LLIntOffsetsExtractor;
class MapIteratorPrototype;
class MapPrototype;
class Microtask;
class ModuleLoader;
class ModuleProgramExecutable;
class NativeErrorConstructorBase;
class NullGetterFunction;
class NullSetterFunction;
class ObjectConstructor;
class ProgramCodeBlock;
class ProgramExecutable;
class RegExpConstructor;
class RegExpPrototype;
class SetIteratorPrototype;
class SetPrototype;
class SourceCode;
class SourceOrigin;
class UnlinkedModuleProgramCodeBlock;
class VariableEnvironment;
struct ActivationStackNode;
struct HashTable;
enum class LinkTimeConstant : int32_t;
#ifdef JSC_GLIB_API_ENABLED
class WrapperMap;
#endif
template<typename Watchpoint> class ObjectPropertyChangeAdaptiveWatchpoint;
constexpr bool typeExposedByDefault = true;
#define DEFINE_STANDARD_BUILTIN(macro, upperName, lowerName) macro(upperName, lowerName, lowerName, JS ## upperName, upperName, object, typeExposedByDefault)
#define FOR_EACH_SIMPLE_BUILTIN_TYPE_WITH_CONSTRUCTOR(macro) \
macro(String, string, stringObject, StringObject, String, object, typeExposedByDefault) \
macro(JSPromise, promise, promise, JSPromise, Promise, object, typeExposedByDefault) \
macro(BigInt, bigInt, bigIntObject, BigIntObject, BigInt, object, typeExposedByDefault) \
macro(WeakObjectRef, weakObjectRef, weakObjectRef, JSWeakObjectRef, WeakRef, object, Options::useWeakRefs()) \
macro(FinalizationRegistry, finalizationRegistry, finalizationRegistry, JSFinalizationRegistry, FinalizationRegistry, object, Options::useWeakRefs()) \
#define FOR_EACH_BUILTIN_DERIVED_ITERATOR_TYPE(macro) \
macro(StringIterator, stringIterator, stringIterator, JSStringIterator, StringIterator, iterator, typeExposedByDefault) \
#define FOR_EACH_SIMPLE_BUILTIN_TYPE(macro) \
FOR_EACH_SIMPLE_BUILTIN_TYPE_WITH_CONSTRUCTOR(macro) \
macro(JSInternalPromise, internalPromise, internalPromise, JSInternalPromise, InternalPromise, object, typeExposedByDefault) \
#define FOR_EACH_LAZY_BUILTIN_TYPE_WITH_DECLARATION(macro) \
macro(Boolean, boolean, booleanObject, BooleanObject, Boolean, object, typeExposedByDefault) \
macro(Date, date, date, DateInstance, Date, object, typeExposedByDefault) \
macro(Error, error, error, ErrorInstance, Error, object, typeExposedByDefault) \
macro(Map, map, map, JSMap, Map, object, typeExposedByDefault) \
macro(Number, number, numberObject, NumberObject, Number, object, typeExposedByDefault) \
macro(Set, set, set, JSSet, Set, object, typeExposedByDefault) \
macro(Symbol, symbol, symbolObject, SymbolObject, Symbol, object, typeExposedByDefault) \
DEFINE_STANDARD_BUILTIN(macro, WeakMap, weakMap) \
DEFINE_STANDARD_BUILTIN(macro, WeakSet, weakSet) \
#define FOR_EACH_LAZY_BUILTIN_TYPE(macro) \
FOR_EACH_LAZY_BUILTIN_TYPE_WITH_DECLARATION(macro) \
macro(JSArrayBuffer, arrayBuffer, arrayBuffer, JSArrayBuffer, ArrayBuffer, object, typeExposedByDefault) \
#if ENABLE(WEBASSEMBLY)
#define FOR_EACH_WEBASSEMBLY_CONSTRUCTOR_TYPE(macro) \
macro(WebAssemblyCompileError, webAssemblyCompileError, webAssemblyCompileError, ErrorInstance, CompileError, error, typeExposedByDefault) \
macro(WebAssemblyGlobal, webAssemblyGlobal, webAssemblyGlobal, JSWebAssemblyGlobal, Global, object, typeExposedByDefault) \
macro(WebAssemblyInstance, webAssemblyInstance, webAssemblyInstance, JSWebAssemblyInstance, Instance, object, typeExposedByDefault) \
macro(WebAssemblyLinkError, webAssemblyLinkError, webAssemblyLinkError, ErrorInstance, LinkError, error, typeExposedByDefault) \
macro(WebAssemblyMemory, webAssemblyMemory, webAssemblyMemory, JSWebAssemblyMemory, Memory, object, typeExposedByDefault) \
macro(WebAssemblyModule, webAssemblyModule, webAssemblyModule, JSWebAssemblyModule, Module, object, typeExposedByDefault) \
macro(WebAssemblyRuntimeError, webAssemblyRuntimeError, webAssemblyRuntimeError, ErrorInstance, RuntimeError, error, typeExposedByDefault) \
macro(WebAssemblyTable, webAssemblyTable, webAssemblyTable, JSWebAssemblyTable, Table, object, typeExposedByDefault)
#else
#define FOR_EACH_WEBASSEMBLY_CONSTRUCTOR_TYPE(macro)
#endif // ENABLE(WEBASSEMBLY)
#define DECLARE_SIMPLE_BUILTIN_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase, featureFlag) \
class JS ## capitalName; \
class capitalName ## Prototype; \
class capitalName ## Constructor;
class IteratorPrototype;
FOR_EACH_SIMPLE_BUILTIN_TYPE(DECLARE_SIMPLE_BUILTIN_TYPE)
FOR_EACH_LAZY_BUILTIN_TYPE_WITH_DECLARATION(DECLARE_SIMPLE_BUILTIN_TYPE)
FOR_EACH_BUILTIN_DERIVED_ITERATOR_TYPE(DECLARE_SIMPLE_BUILTIN_TYPE)
FOR_EACH_WEBASSEMBLY_CONSTRUCTOR_TYPE(DECLARE_SIMPLE_BUILTIN_TYPE)
#undef DECLARE_SIMPLE_BUILTIN_TYPE
enum class JSPromiseRejectionOperation : unsigned {
Reject, // When a promise is rejected without any handlers.
Handle, // When a handler is added to a rejected promise for the first time.
};
enum class ScriptExecutionStatus {
Running,
Suspended,
Stopped,
};
struct GlobalObjectMethodTable {
typedef bool (*SupportsRichSourceInfoFunctionPtr)(const JSGlobalObject*);
SupportsRichSourceInfoFunctionPtr supportsRichSourceInfo;
typedef bool (*ShouldInterruptScriptFunctionPtr)(const JSGlobalObject*);
ShouldInterruptScriptFunctionPtr shouldInterruptScript;
typedef RuntimeFlags (*JavaScriptRuntimeFlagsFunctionPtr)(const JSGlobalObject*);
JavaScriptRuntimeFlagsFunctionPtr javaScriptRuntimeFlags;
typedef void (*QueueTaskToEventLoopFunctionPtr)(JSGlobalObject&, Ref<Microtask>&&);
QueueTaskToEventLoopFunctionPtr queueTaskToEventLoop;
typedef bool (*ShouldInterruptScriptBeforeTimeoutPtr)(const JSGlobalObject*);
ShouldInterruptScriptBeforeTimeoutPtr shouldInterruptScriptBeforeTimeout;
typedef JSInternalPromise* (*ModuleLoaderImportModulePtr)(JSGlobalObject*, JSModuleLoader*, JSString*, JSValue, const SourceOrigin&);
ModuleLoaderImportModulePtr moduleLoaderImportModule;
typedef Identifier (*ModuleLoaderResolvePtr)(JSGlobalObject*, JSModuleLoader*, JSValue, JSValue, JSValue);
ModuleLoaderResolvePtr moduleLoaderResolve;
typedef JSInternalPromise* (*ModuleLoaderFetchPtr)(JSGlobalObject*, JSModuleLoader*, JSValue, JSValue, JSValue);
ModuleLoaderFetchPtr moduleLoaderFetch;
typedef JSObject* (*ModuleLoaderCreateImportMetaPropertiesPtr)(JSGlobalObject*, JSModuleLoader*, JSValue, JSModuleRecord*, JSValue);
ModuleLoaderCreateImportMetaPropertiesPtr moduleLoaderCreateImportMetaProperties;
typedef JSValue (*ModuleLoaderEvaluatePtr)(JSGlobalObject*, JSModuleLoader*, JSValue key, JSValue moduleRecordValue, JSValue scriptFetcher, JSValue awaitedValue, JSValue resumeMode);
ModuleLoaderEvaluatePtr moduleLoaderEvaluate;
typedef void (*PromiseRejectionTrackerPtr)(JSGlobalObject*, JSPromise*, JSPromiseRejectionOperation);
PromiseRejectionTrackerPtr promiseRejectionTracker;
typedef void (*ReportUncaughtExceptionAtEventLoopPtr)(JSGlobalObject*, Exception*);
ReportUncaughtExceptionAtEventLoopPtr reportUncaughtExceptionAtEventLoop;
// For most contexts this is just the global object. For JSDOMWindow, however, this is the JSDocument.
typedef JSObject* (*CurrentScriptExecutionOwnerPtr)(JSGlobalObject*);
CurrentScriptExecutionOwnerPtr currentScriptExecutionOwner;
typedef ScriptExecutionStatus (*ScriptExecutionStatusPtr)(JSGlobalObject*, JSObject* scriptExecutionOwner);
ScriptExecutionStatusPtr scriptExecutionStatus;
typedef String (*DefaultLanguageFunctionPtr)();
DefaultLanguageFunctionPtr defaultLanguage;
typedef JSPromise* (*CompileStreamingPtr)(JSGlobalObject*, JSValue);
CompileStreamingPtr compileStreaming;
typedef JSPromise* (*InstantiateStreamingPtr)(JSGlobalObject*, JSValue, JSObject*);
InstantiateStreamingPtr instantiateStreaming;
};
class JSGlobalObject : public JSSegmentedVariableObject {
private:
typedef HashSet<RefPtr<OpaqueJSWeakObjectMap>> WeakMapSet;
typedef HashMap<OpaqueJSClass*, std::unique_ptr<OpaqueJSClassContextData>> OpaqueJSClassDataMap;
struct JSGlobalObjectRareData {
WTF_MAKE_FAST_ALLOCATED;
public:
JSGlobalObjectRareData()
: profileGroup(0)
{
}
WeakMapSet weakMaps;
unsigned profileGroup;
OpaqueJSClassDataMap opaqueJSClassData;
};
// m_vm must be a pointer (instead of a reference) because the JSCLLIntOffsetsExtractor
// cannot handle it being a reference.
VM* m_vm;
// Our hashtable code-generator tries to access these properties, so we make them public.
// However, we'd like it better if they could be protected.
public:
template<typename T> using Initializer = typename LazyProperty<JSGlobalObject, T>::Initializer;
Register m_deprecatedCallFrameForDebugger[CallFrame::headerSizeInRegisters];
WriteBarrier<JSObject> m_globalThis;
WriteBarrier<JSGlobalLexicalEnvironment> m_globalLexicalEnvironment;
WriteBarrier<JSScope> m_globalScopeExtension;
WriteBarrier<JSCallee> m_globalCallee;
WriteBarrier<JSCallee> m_stackOverflowFrameCallee;
LazyClassStructure m_evalErrorStructure;
LazyClassStructure m_rangeErrorStructure;
LazyClassStructure m_referenceErrorStructure;
LazyClassStructure m_syntaxErrorStructure;
LazyClassStructure m_typeErrorStructure;
LazyClassStructure m_URIErrorStructure;
LazyClassStructure m_aggregateErrorStructure;
WriteBarrier<ObjectConstructor> m_objectConstructor;
WriteBarrier<ArrayConstructor> m_arrayConstructor;
WriteBarrier<RegExpConstructor> m_regExpConstructor;
WriteBarrier<FunctionConstructor> m_functionConstructor;
WriteBarrier<JSPromiseConstructor> m_promiseConstructor;
WriteBarrier<JSInternalPromiseConstructor> m_internalPromiseConstructor;
LazyProperty<JSGlobalObject, IntlCollator> m_defaultCollator;
LazyProperty<JSGlobalObject, Structure> m_collatorStructure;
LazyProperty<JSGlobalObject, Structure> m_displayNamesStructure;
LazyProperty<JSGlobalObject, Structure> m_listFormatStructure;
LazyProperty<JSGlobalObject, Structure> m_localeStructure;
LazyProperty<JSGlobalObject, Structure> m_pluralRulesStructure;
LazyProperty<JSGlobalObject, Structure> m_relativeTimeFormatStructure;
LazyProperty<JSGlobalObject, Structure> m_segmentIteratorStructure;
LazyProperty<JSGlobalObject, Structure> m_segmenterStructure;
LazyProperty<JSGlobalObject, Structure> m_segmentsStructure;
LazyClassStructure m_dateTimeFormatStructure;
LazyClassStructure m_numberFormatStructure;
WriteBarrier<NullGetterFunction> m_nullGetterFunction;
WriteBarrier<NullSetterFunction> m_nullSetterFunction;
WriteBarrier<NullSetterFunction> m_nullSetterStrictFunction;
LazyProperty<JSGlobalObject, JSFunction> m_parseIntFunction;
LazyProperty<JSGlobalObject, JSFunction> m_parseFloatFunction;
LazyProperty<JSGlobalObject, JSFunction> m_objectProtoToStringFunction;
LazyProperty<JSGlobalObject, JSFunction> m_arrayProtoToStringFunction;
LazyProperty<JSGlobalObject, JSFunction> m_arrayProtoValuesFunction;
LazyProperty<JSGlobalObject, JSFunction> m_evalFunction;
LazyProperty<JSGlobalObject, JSFunction> m_iteratorProtocolFunction;
LazyProperty<JSGlobalObject, JSFunction> m_promiseResolveFunction;
LazyProperty<JSGlobalObject, JSFunction> m_numberProtoToStringFunction;
WriteBarrier<JSFunction> m_objectProtoValueOfFunction;
WriteBarrier<JSFunction> m_functionProtoHasInstanceSymbolFunction;
LazyProperty<JSGlobalObject, GetterSetter> m_throwTypeErrorGetterSetter;
WriteBarrier<JSObject> m_regExpProtoSymbolReplace;
WriteBarrier<GetterSetter> m_throwTypeErrorArgumentsCalleeAndCallerGetterSetter;
LazyProperty<JSGlobalObject, JSModuleLoader> m_moduleLoader;
WriteBarrier<ObjectPrototype> m_objectPrototype;
WriteBarrier<FunctionPrototype> m_functionPrototype;
WriteBarrier<ArrayPrototype> m_arrayPrototype;
WriteBarrier<RegExpPrototype> m_regExpPrototype;
WriteBarrier<IteratorPrototype> m_iteratorPrototype;
WriteBarrier<AsyncIteratorPrototype> m_asyncIteratorPrototype;
WriteBarrier<GeneratorFunctionPrototype> m_generatorFunctionPrototype;
WriteBarrier<GeneratorPrototype> m_generatorPrototype;
WriteBarrier<AsyncGeneratorPrototype> m_asyncGeneratorPrototype;
WriteBarrier<ArrayIteratorPrototype> m_arrayIteratorPrototype;
WriteBarrier<MapIteratorPrototype> m_mapIteratorPrototype;
WriteBarrier<SetIteratorPrototype> m_setIteratorPrototype;
LazyProperty<JSGlobalObject, Structure> m_debuggerScopeStructure;
LazyProperty<JSGlobalObject, Structure> m_withScopeStructure;
LazyProperty<JSGlobalObject, Structure> m_strictEvalActivationStructure;
WriteBarrier<Structure> m_lexicalEnvironmentStructure;
LazyProperty<JSGlobalObject, Structure> m_moduleEnvironmentStructure;
WriteBarrier<Structure> m_directArgumentsStructure;
WriteBarrier<Structure> m_scopedArgumentsStructure;
WriteBarrier<Structure> m_clonedArgumentsStructure;
WriteBarrier<Structure> m_objectStructureForObjectConstructor;
// Lists the actual structures used for having these particular indexing shapes.
WriteBarrier<Structure> m_originalArrayStructureForIndexingShape[NumberOfArrayIndexingModes];
// Lists the structures we should use during allocation for these particular indexing shapes.
// These structures will differ from the originals list above when we are having a bad time.
WriteBarrier<Structure> m_arrayStructureForIndexingShapeDuringAllocation[NumberOfArrayIndexingModes];
LazyProperty<JSGlobalObject, Structure> m_callbackConstructorStructure;
LazyProperty<JSGlobalObject, Structure> m_callbackFunctionStructure;
LazyProperty<JSGlobalObject, Structure> m_callbackObjectStructure;
#if JSC_OBJC_API_ENABLED
LazyProperty<JSGlobalObject, Structure> m_objcCallbackFunctionStructure;
LazyProperty<JSGlobalObject, Structure> m_objcWrapperObjectStructure;
#endif
#ifdef JSC_GLIB_API_ENABLED
LazyProperty<JSGlobalObject, Structure> m_glibCallbackFunctionStructure;
LazyProperty<JSGlobalObject, Structure> m_glibWrapperObjectStructure;
#endif
WriteBarrier<Structure> m_nullPrototypeObjectStructure;
WriteBarrier<Structure> m_calleeStructure;
WriteBarrier<Structure> m_hostFunctionStructure;
struct FunctionStructures {
WriteBarrier<Structure> arrowFunctionStructure;
WriteBarrier<Structure> sloppyFunctionStructure;
WriteBarrier<Structure> strictFunctionStructure;
};
FunctionStructures m_builtinFunctions;
FunctionStructures m_ordinaryFunctions;
LazyProperty<JSGlobalObject, Structure> m_boundFunctionStructure;
LazyProperty<JSGlobalObject, Structure> m_customGetterFunctionStructure;
LazyProperty<JSGlobalObject, Structure> m_customSetterFunctionStructure;
LazyProperty<JSGlobalObject, Structure> m_nativeStdFunctionStructure;
PropertyOffset m_functionNameOffset;
WriteBarrier<Structure> m_regExpStructure;
WriteBarrier<AsyncFunctionPrototype> m_asyncFunctionPrototype;
WriteBarrier<AsyncGeneratorFunctionPrototype> m_asyncGeneratorFunctionPrototype;
WriteBarrier<Structure> m_asyncFunctionStructure;
WriteBarrier<Structure> m_asyncGeneratorFunctionStructure;
WriteBarrier<Structure> m_generatorFunctionStructure;
WriteBarrier<Structure> m_generatorStructure;
WriteBarrier<Structure> m_asyncGeneratorStructure;
WriteBarrier<Structure> m_arrayIteratorStructure;
WriteBarrier<Structure> m_mapIteratorStructure;
WriteBarrier<Structure> m_setIteratorStructure;
LazyProperty<JSGlobalObject, Structure> m_iteratorResultObjectStructure;
LazyProperty<JSGlobalObject, Structure> m_dataPropertyDescriptorObjectStructure;
LazyProperty<JSGlobalObject, Structure> m_accessorPropertyDescriptorObjectStructure;
WriteBarrier<Structure> m_regExpMatchesArrayStructure;
WriteBarrier<Structure> m_regExpMatchesArrayWithIndicesStructure;
WriteBarrier<Structure> m_regExpMatchesIndicesArrayStructure;
LazyProperty<JSGlobalObject, Structure> m_moduleRecordStructure;
LazyProperty<JSGlobalObject, Structure> m_moduleNamespaceObjectStructure;
LazyProperty<JSGlobalObject, Structure> m_proxyObjectStructure;
LazyProperty<JSGlobalObject, Structure> m_callableProxyObjectStructure;
LazyProperty<JSGlobalObject, Structure> m_proxyRevokeStructure;
LazyClassStructure m_sharedArrayBufferStructure;
#define DEFINE_STORAGE_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase, featureFlag) \
WriteBarrier<capitalName ## Prototype> m_ ## lowerName ## Prototype; \
WriteBarrier<Structure> m_ ## properName ## Structure;
#define DEFINE_STORAGE_FOR_LAZY_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase, featureFlag) \
LazyClassStructure m_ ## properName ## Structure;
FOR_EACH_SIMPLE_BUILTIN_TYPE(DEFINE_STORAGE_FOR_SIMPLE_TYPE)
FOR_EACH_BUILTIN_DERIVED_ITERATOR_TYPE(DEFINE_STORAGE_FOR_SIMPLE_TYPE)
#if ENABLE(WEBASSEMBLY)
LazyProperty<JSGlobalObject, Structure> m_webAssemblyModuleRecordStructure;
LazyProperty<JSGlobalObject, Structure> m_webAssemblyFunctionStructure;
LazyProperty<JSGlobalObject, Structure> m_jsToWasmICCalleeStructure;
LazyProperty<JSGlobalObject, Structure> m_webAssemblyWrapperFunctionStructure;
FOR_EACH_WEBASSEMBLY_CONSTRUCTOR_TYPE(DEFINE_STORAGE_FOR_LAZY_TYPE)
#endif // ENABLE(WEBASSEMBLY)
FOR_EACH_LAZY_BUILTIN_TYPE(DEFINE_STORAGE_FOR_LAZY_TYPE)
#undef DEFINE_STORAGE_FOR_SIMPLE_TYPE
#undef DEFINE_STORAGE_FOR_LAZY_TYPE
WriteBarrier<GetterSetter> m_speciesGetterSetter;
LazyProperty<JSGlobalObject, JSTypedArrayViewPrototype> m_typedArrayProto;
LazyProperty<JSGlobalObject, JSTypedArrayViewConstructor> m_typedArraySuperConstructor;
#define DECLARE_TYPED_ARRAY_TYPE_STRUCTURE(name) LazyClassStructure m_typedArray ## name;
FOR_EACH_TYPED_ARRAY_TYPE(DECLARE_TYPED_ARRAY_TYPE_STRUCTURE)
#undef DECLARE_TYPED_ARRAY_TYPE_STRUCTURE
FixedVector<LazyProperty<JSGlobalObject, JSCell>> m_linkTimeConstants;
String m_name;
Strong<JSObject> m_unhandledRejectionCallback;
Debugger* m_debugger;
#if ENABLE(REMOTE_INSPECTOR)
std::unique_ptr<Inspector::JSGlobalObjectInspectorController> m_inspectorController;
std::unique_ptr<JSGlobalObjectDebuggable> m_inspectorDebuggable;
#endif
RefPtr<WatchpointSet> m_masqueradesAsUndefinedWatchpoint;
RefPtr<WatchpointSet> m_havingABadTimeWatchpoint;
RefPtr<WatchpointSet> m_varInjectionWatchpoint;
RefPtr<WatchpointSet> m_varReadOnlyWatchpoint;
std::unique_ptr<JSGlobalObjectRareData> m_rareData;
WeakRandom m_weakRandom;
RegExpGlobalData m_regExpGlobalData;
// If this hasn't been invalidated, it means the array iterator protocol
// is not observable to user code yet.
InlineWatchpointSet m_arrayIteratorProtocolWatchpointSet;
InlineWatchpointSet m_mapIteratorProtocolWatchpointSet;
InlineWatchpointSet m_setIteratorProtocolWatchpointSet;
InlineWatchpointSet m_stringIteratorProtocolWatchpointSet;
InlineWatchpointSet m_mapSetWatchpointSet;
InlineWatchpointSet m_setAddWatchpointSet;
InlineWatchpointSet m_arraySpeciesWatchpointSet { ClearWatchpoint };
InlineWatchpointSet m_arrayJoinWatchpointSet;
InlineWatchpointSet m_numberToStringWatchpointSet;
InlineWatchpointSet m_arrayBufferSpeciesWatchpointSet { ClearWatchpoint };
InlineWatchpointSet m_sharedArrayBufferSpeciesWatchpointSet { ClearWatchpoint };
std::unique_ptr<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>> m_arrayConstructorSpeciesWatchpoint;
std::unique_ptr<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>> m_arrayPrototypeConstructorWatchpoint;
std::unique_ptr<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>> m_arrayPrototypeSymbolIteratorWatchpoint;
std::unique_ptr<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>> m_arrayPrototypeJoinWatchpoint;
std::unique_ptr<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>> m_arrayIteratorPrototypeNext;
std::unique_ptr<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>> m_mapPrototypeSymbolIteratorWatchpoint;
std::unique_ptr<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>> m_mapIteratorPrototypeNextWatchpoint;
std::unique_ptr<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>> m_setPrototypeSymbolIteratorWatchpoint;
std::unique_ptr<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>> m_setIteratorPrototypeNextWatchpoint;
std::unique_ptr<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>> m_stringPrototypeSymbolIteratorWatchpoint;
std::unique_ptr<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>> m_stringIteratorPrototypeNextWatchpoint;
std::unique_ptr<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>> m_mapPrototypeSetWatchpoint;
std::unique_ptr<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>> m_setPrototypeAddWatchpoint;
std::unique_ptr<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>> m_numberPrototypeToStringWatchpoint;
std::unique_ptr<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>> m_arrayBufferConstructorSpeciesWatchpoints[2];
std::unique_ptr<ObjectPropertyChangeAdaptiveWatchpoint<InlineWatchpointSet>> m_arrayBufferPrototypeConstructorWatchpoints[2];
public:
JSCallee* stackOverflowFrameCallee() const { return m_stackOverflowFrameCallee.get(); }
InlineWatchpointSet& arrayIteratorProtocolWatchpointSet() { return m_arrayIteratorProtocolWatchpointSet; }
InlineWatchpointSet& mapIteratorProtocolWatchpointSet() { return m_mapIteratorProtocolWatchpointSet; }
InlineWatchpointSet& setIteratorProtocolWatchpointSet() { return m_setIteratorProtocolWatchpointSet; }
InlineWatchpointSet& stringIteratorProtocolWatchpointSet() { return m_stringIteratorProtocolWatchpointSet; }
InlineWatchpointSet& mapSetWatchpointSet() { return m_mapSetWatchpointSet; }
InlineWatchpointSet& setAddWatchpointSet() { return m_setAddWatchpointSet; }
InlineWatchpointSet& arraySpeciesWatchpointSet() { return m_arraySpeciesWatchpointSet; }
InlineWatchpointSet& arrayJoinWatchpointSet() { return m_arrayJoinWatchpointSet; }
InlineWatchpointSet& numberToStringWatchpointSet()
{
RELEASE_ASSERT(Options::useJIT());
return m_numberToStringWatchpointSet;
}
InlineWatchpointSet& arrayBufferSpeciesWatchpointSet(ArrayBufferSharingMode sharingMode)
{
switch (sharingMode) {
case ArrayBufferSharingMode::Default:
return m_arrayBufferSpeciesWatchpointSet;
case ArrayBufferSharingMode::Shared:
return m_sharedArrayBufferSpeciesWatchpointSet;
}
RELEASE_ASSERT_NOT_REACHED();
return m_arrayBufferSpeciesWatchpointSet;
}
bool isArrayPrototypeIteratorProtocolFastAndNonObservable();
bool isMapPrototypeIteratorProtocolFastAndNonObservable();
bool isSetPrototypeIteratorProtocolFastAndNonObservable();
bool isStringPrototypeIteratorProtocolFastAndNonObservable();
bool isMapPrototypeSetFastAndNonObservable();
bool isSetPrototypeAddFastAndNonObservable();
#if ENABLE(DFG_JIT)
using ReferencedGlobalPropertyWatchpointSets = HashMap<RefPtr<UniquedStringImpl>, Ref<WatchpointSet>, IdentifierRepHash>;
ReferencedGlobalPropertyWatchpointSets m_referencedGlobalPropertyWatchpointSets;
ConcurrentJSLock m_referencedGlobalPropertyWatchpointSetsLock;
#endif
bool m_evalEnabled { true };
bool m_webAssemblyEnabled { true };
unsigned m_globalLexicalBindingEpoch { 1 };
String m_evalDisabledErrorMessage;
String m_webAssemblyDisabledErrorMessage;
RuntimeFlags m_runtimeFlags;
WeakPtr<ConsoleClient> m_consoleClient;
Optional<unsigned> m_stackTraceLimit;
template<typename T>
struct WeakCustomGetterOrSetterHash {
static unsigned hash(const Weak<T>&);
static bool equal(const Weak<T>&, const Weak<T>&);
static unsigned hash(const PropertyName&, typename T::CustomFunctionPointer);
static constexpr bool safeToCompareToEmptyOrDeleted = false;
};
WeakGCSet<JSCustomGetterFunction, WeakCustomGetterOrSetterHash<JSCustomGetterFunction>> m_customGetterFunctionSet;
WeakGCSet<JSCustomSetterFunction, WeakCustomGetterOrSetterHash<JSCustomSetterFunction>> m_customSetterFunctionSet;
WeakGCSet<JSCustomGetterFunction, WeakCustomGetterOrSetterHash<JSCustomGetterFunction>>& customGetterFunctionSet() { return m_customGetterFunctionSet; }
WeakGCSet<JSCustomSetterFunction, WeakCustomGetterOrSetterHash<JSCustomSetterFunction>>& customSetterFunctionSet() { return m_customSetterFunctionSet; }
#if ASSERT_ENABLED
const JSGlobalObject* m_globalObjectAtDebuggerEntry { nullptr };
#endif
static JS_EXPORT_PRIVATE const GlobalObjectMethodTable s_globalObjectMethodTable;
const GlobalObjectMethodTable* m_globalObjectMethodTable;
void createRareDataIfNeeded()
{
if (m_rareData)
return;
m_rareData = makeUnique<JSGlobalObjectRareData>();
}
public:
using Base = JSSegmentedVariableObject;
static constexpr unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable | OverridesGetOwnPropertySlot | OverridesPut | IsImmutablePrototypeExoticObject;
static constexpr bool needsDestruction = true;
template<typename CellType, SubspaceAccess mode>
static IsoSubspace* subspaceFor(VM& vm)
{
return vm.globalObjectSpace<mode>();
}
JS_EXPORT_PRIVATE static JSGlobalObject* create(VM&, Structure*);
DECLARE_EXPORT_INFO;
bool hasDebugger() const;
bool hasInteractiveDebugger() const;
const RuntimeFlags& runtimeFlags() const { return m_runtimeFlags; }
#if ENABLE(DFG_JIT)
WatchpointSet* getReferencedPropertyWatchpointSet(UniquedStringImpl*);
WatchpointSet& ensureReferencedPropertyWatchpointSet(UniquedStringImpl*);
#endif
Optional<unsigned> stackTraceLimit() const { return m_stackTraceLimit; }
void setStackTraceLimit(Optional<unsigned> value) { m_stackTraceLimit = value; }
protected:
JS_EXPORT_PRIVATE explicit JSGlobalObject(VM&, Structure*, const GlobalObjectMethodTable* = nullptr);
JS_EXPORT_PRIVATE void finishCreation(VM&);
JS_EXPORT_PRIVATE void finishCreation(VM&, JSObject*);
void addGlobalVar(const Identifier&);
public:
JS_EXPORT_PRIVATE ~JSGlobalObject();
JS_EXPORT_PRIVATE static void destroy(JSCell*);
DECLARE_VISIT_CHILDREN_WITH_MODIFIER(JS_EXPORT_PRIVATE);
JS_EXPORT_PRIVATE static bool getOwnPropertySlot(JSObject*, JSGlobalObject*, PropertyName, PropertySlot&);
JS_EXPORT_PRIVATE static bool put(JSCell*, JSGlobalObject*, PropertyName, JSValue, PutPropertySlot&);
JS_EXPORT_PRIVATE static bool defineOwnProperty(JSObject*, JSGlobalObject*, PropertyName, const PropertyDescriptor&, bool shouldThrow);
void addVar(JSGlobalObject* globalObject, const Identifier& propertyName)
{
if (!hasOwnProperty(globalObject, propertyName))
addGlobalVar(propertyName);
}
void addFunction(JSGlobalObject*, const Identifier&);
JSScope* globalScope() { return m_globalLexicalEnvironment.get(); }
JSGlobalLexicalEnvironment* globalLexicalEnvironment() { return m_globalLexicalEnvironment.get(); }
JSScope* globalScopeExtension() { return m_globalScopeExtension.get(); }
void setGlobalScopeExtension(JSScope*);
void clearGlobalScopeExtension();
JSCallee* globalCallee() { return m_globalCallee.get(); }
// The following accessors return pristine values, even if a script
// replaces the global object's associated property.
GetterSetter* speciesGetterSetter() const { return m_speciesGetterSetter.get(); }
ArrayConstructor* arrayConstructor() const { return m_arrayConstructor.get(); }
RegExpConstructor* regExpConstructor() const { return m_regExpConstructor.get(); }
ObjectConstructor* objectConstructor() const { return m_objectConstructor.get(); }
FunctionConstructor* functionConstructor() const { return m_functionConstructor.get(); }
JSPromiseConstructor* promiseConstructor() const { return m_promiseConstructor.get(); }
JSInternalPromiseConstructor* internalPromiseConstructor() const { return m_internalPromiseConstructor.get(); }
IntlCollator* defaultCollator() const { return m_defaultCollator.get(this); }
NullGetterFunction* nullGetterFunction() const { return m_nullGetterFunction.get(); }
NullSetterFunction* nullSetterFunction() const { return m_nullSetterFunction.get(); }
NullSetterFunction* nullSetterStrictFunction() const { return m_nullSetterStrictFunction.get(); }
JSFunction* parseIntFunction() const { return m_parseIntFunction.get(this); }
JSFunction* parseFloatFunction() const { return m_parseFloatFunction.get(this); }
JSFunction* evalFunction() const { return m_evalFunction.get(this); }
JSFunction* throwTypeErrorFunction() const;
JSFunction* objectProtoToStringFunction() const { return m_objectProtoToStringFunction.get(this); }
JSFunction* arrayProtoToStringFunction() const { return m_arrayProtoToStringFunction.get(this); }
JSFunction* arrayProtoValuesFunction() const { return m_arrayProtoValuesFunction.get(this); }
JSFunction* arrayProtoValuesFunctionConcurrently() const { return m_arrayProtoValuesFunction.getConcurrently(); }
JSFunction* iteratorProtocolFunction() const { return m_iteratorProtocolFunction.get(this); }
JSFunction* newPromiseCapabilityFunction() const;
JSFunction* promiseResolveFunction() const { return m_promiseResolveFunction.get(this); }
JSFunction* resolvePromiseFunction() const;
JSFunction* rejectPromiseFunction() const;
JSFunction* promiseProtoThenFunction() const;
JSFunction* objectProtoValueOfFunction() const { return m_objectProtoValueOfFunction.get(); }
JSFunction* numberProtoToStringFunction() const { return m_numberProtoToStringFunction.getInitializedOnMainThread(this); }
JSFunction* functionProtoHasInstanceSymbolFunction() const { return m_functionProtoHasInstanceSymbolFunction.get(); }
JSFunction* regExpProtoExecFunction() const;
JSObject* regExpProtoSymbolReplaceFunction() const { return m_regExpProtoSymbolReplace.get(); }
GetterSetter* regExpProtoGlobalGetter() const;
GetterSetter* regExpProtoUnicodeGetter() const;
GetterSetter* throwTypeErrorArgumentsCalleeAndCallerGetterSetter()
{
return m_throwTypeErrorArgumentsCalleeAndCallerGetterSetter.get();
}
JSModuleLoader* moduleLoader() const { return m_moduleLoader.get(this); }
ObjectPrototype* objectPrototype() const { return m_objectPrototype.get(); }
FunctionPrototype* functionPrototype() const { return m_functionPrototype.get(); }
ArrayPrototype* arrayPrototype() const { return m_arrayPrototype.get(); }
JSObject* booleanPrototype() const { return m_booleanObjectStructure.prototypeInitializedOnMainThread(this); }
StringPrototype* stringPrototype() const { return m_stringPrototype.get(); }
JSObject* numberPrototype() const { return m_numberObjectStructure.prototypeInitializedOnMainThread(this); }
BigIntPrototype* bigIntPrototype() const { return m_bigIntPrototype.get(); }
JSObject* datePrototype() const { return m_dateStructure.prototype(this); }
JSObject* symbolPrototype() const { return m_symbolObjectStructure.prototypeInitializedOnMainThread(this); }
RegExpPrototype* regExpPrototype() const { return m_regExpPrototype.get(); }
JSObject* errorPrototype() const { return m_errorStructure.prototype(this); }
IteratorPrototype* iteratorPrototype() const { return m_iteratorPrototype.get(); }
AsyncIteratorPrototype* asyncIteratorPrototype() const { return m_asyncIteratorPrototype.get(); }
GeneratorFunctionPrototype* generatorFunctionPrototype() const { return m_generatorFunctionPrototype.get(); }
GeneratorPrototype* generatorPrototype() const { return m_generatorPrototype.get(); }
AsyncFunctionPrototype* asyncFunctionPrototype() const { return m_asyncFunctionPrototype.get(); }
ArrayIteratorPrototype* arrayIteratorPrototype() const { return m_arrayIteratorPrototype.get(); }
MapIteratorPrototype* mapIteratorPrototype() const { return m_mapIteratorPrototype.get(); }
SetIteratorPrototype* setIteratorPrototype() const { return m_setIteratorPrototype.get(); }
JSObject* mapPrototype() const { return m_mapStructure.prototype(this); }
// Workaround for the name conflict between JSCell::setPrototype.
JSObject* jsSetPrototype() const { return m_setStructure.prototype(this); }
JSPromisePrototype* promisePrototype() const { return m_promisePrototype.get(); }
AsyncGeneratorPrototype* asyncGeneratorPrototype() const { return m_asyncGeneratorPrototype.get(); }
AsyncGeneratorFunctionPrototype* asyncGeneratorFunctionPrototype() const { return m_asyncGeneratorFunctionPrototype.get(); }
Structure* debuggerScopeStructure() const { return m_debuggerScopeStructure.get(this); }
Structure* withScopeStructure() const { return m_withScopeStructure.get(this); }
Structure* strictEvalActivationStructure() const { return m_strictEvalActivationStructure.get(this); }
Structure* activationStructure() const { return m_lexicalEnvironmentStructure.get(); }
Structure* moduleEnvironmentStructure() const { return m_moduleEnvironmentStructure.get(this); }
Structure* directArgumentsStructure() const { return m_directArgumentsStructure.get(); }
Structure* scopedArgumentsStructure() const { return m_scopedArgumentsStructure.get(); }
Structure* clonedArgumentsStructure() const { return m_clonedArgumentsStructure.get(); }
Structure* objectStructureForObjectConstructor() const { return m_objectStructureForObjectConstructor.get(); }
Structure* originalArrayStructureForIndexingType(IndexingType indexingType) const
{
ASSERT(indexingType & IsArray);
return m_originalArrayStructureForIndexingShape[arrayIndexFromIndexingType(indexingType)].get();
}
Structure* arrayStructureForIndexingTypeDuringAllocation(IndexingType indexingType) const
{
ASSERT(indexingType & IsArray);
return m_arrayStructureForIndexingShapeDuringAllocation[arrayIndexFromIndexingType(indexingType)].get();
}
Structure* arrayStructureForIndexingTypeDuringAllocation(JSGlobalObject* globalObject, IndexingType indexingType, JSValue newTarget) const;
Structure* arrayStructureForProfileDuringAllocation(JSGlobalObject* globalObject, ArrayAllocationProfile* profile, JSValue newTarget) const
{
return arrayStructureForIndexingTypeDuringAllocation(globalObject, ArrayAllocationProfile::selectIndexingTypeFor(profile), newTarget);
}
bool isOriginalArrayStructure(Structure* structure)
{
return originalArrayStructureForIndexingType(structure->indexingMode() | IsArray) == structure;
}
Structure* booleanObjectStructure() const { return m_booleanObjectStructure.get(this); }
Structure* callbackConstructorStructure() const { return m_callbackConstructorStructure.get(this); }
Structure* callbackFunctionStructure() const { return m_callbackFunctionStructure.get(this); }
Structure* callbackObjectStructure() const { return m_callbackObjectStructure.get(this); }
#if JSC_OBJC_API_ENABLED
Structure* objcCallbackFunctionStructure() const { return m_objcCallbackFunctionStructure.get(this); }
Structure* objcWrapperObjectStructure() const { return m_objcWrapperObjectStructure.get(this); }
#endif
#ifdef JSC_GLIB_API_ENABLED
Structure* glibCallbackFunctionStructure() const { return m_glibCallbackFunctionStructure.get(this); }
Structure* glibWrapperObjectStructure() const { return m_glibWrapperObjectStructure.get(this); }
#endif
Structure* dateStructure() const { return m_dateStructure.get(this); }
Structure* symbolObjectStructure() const { return m_symbolObjectStructure.get(this); }
Structure* nullPrototypeObjectStructure() const { return m_nullPrototypeObjectStructure.get(); }
Structure* errorStructure() const { return m_errorStructure.get(this); }
Structure* errorStructure(ErrorType errorType) const
{
switch (errorType) {
case ErrorType::Error:
return errorStructure();
case ErrorType::EvalError:
return m_evalErrorStructure.get(this);
case ErrorType::RangeError:
return m_rangeErrorStructure.get(this);
case ErrorType::ReferenceError:
return m_referenceErrorStructure.get(this);
case ErrorType::SyntaxError:
return m_syntaxErrorStructure.get(this);
case ErrorType::TypeError:
return m_typeErrorStructure.get(this);
case ErrorType::URIError:
return m_URIErrorStructure.get(this);
case ErrorType::AggregateError:
return m_aggregateErrorStructure.get(this);
}
ASSERT_NOT_REACHED();
return nullptr;
}
template<ErrorType errorType> Structure* errorStructureWithErrorType() const { return errorStructure(errorType); }
Structure* calleeStructure() const { return m_calleeStructure.get(); }
Structure* hostFunctionStructure() const { return m_hostFunctionStructure.get(); }
Structure* arrowFunctionStructure(bool isBuiltin) const
{
if (isBuiltin)
return m_builtinFunctions.arrowFunctionStructure.get();
return m_ordinaryFunctions.arrowFunctionStructure.get();
}
Structure* sloppyFunctionStructure(bool isBuiltin) const
{
if (isBuiltin)
return m_builtinFunctions.sloppyFunctionStructure.get();
return m_ordinaryFunctions.sloppyFunctionStructure.get();
}
Structure* strictFunctionStructure(bool isBuiltin) const
{
if (isBuiltin)
return m_builtinFunctions.strictFunctionStructure.get();
return m_ordinaryFunctions.strictFunctionStructure.get();
}
Structure* boundFunctionStructure() const { return m_boundFunctionStructure.get(this); }
Structure* customGetterFunctionStructure() const { return m_customGetterFunctionStructure.get(this); }
Structure* customSetterFunctionStructure() const { return m_customSetterFunctionStructure.get(this); }
Structure* nativeStdFunctionStructure() const { return m_nativeStdFunctionStructure.get(this); }
PropertyOffset functionNameOffset() const { return m_functionNameOffset; }
Structure* numberObjectStructure() const { return m_numberObjectStructure.get(this); }
Structure* regExpStructure() const { return m_regExpStructure.get(); }
Structure* generatorStructure() const { return m_generatorStructure.get(); }
Structure* asyncGeneratorStructure() const { return m_asyncGeneratorStructure.get(); }
Structure* generatorFunctionStructure() const { return m_generatorFunctionStructure.get(); }
Structure* asyncFunctionStructure() const { return m_asyncFunctionStructure.get(); }
Structure* asyncGeneratorFunctionStructure() const { return m_asyncGeneratorFunctionStructure.get(); }
Structure* arrayIteratorStructure() const { return m_arrayIteratorStructure.get(); }
Structure* mapIteratorStructure() const { return m_mapIteratorStructure.get(); }
Structure* setIteratorStructure() const { return m_setIteratorStructure.get(); }
Structure* stringObjectStructure() const { return m_stringObjectStructure.get(); }
Structure* iteratorResultObjectStructure() const { return m_iteratorResultObjectStructure.get(this); }
Structure* dataPropertyDescriptorObjectStructure() const { return m_dataPropertyDescriptorObjectStructure.get(this); }
Structure* accessorPropertyDescriptorObjectStructure() const { return m_accessorPropertyDescriptorObjectStructure.get(this); }
Structure* regExpMatchesArrayStructure() const { return m_regExpMatchesArrayStructure.get(); }
Structure* regExpMatchesArrayWithIndicesStructure() const { return m_regExpMatchesArrayWithIndicesStructure.get(); }
Structure* regExpMatchesIndicesArrayStructure() const { return m_regExpMatchesIndicesArrayStructure.get(); }
Structure* moduleRecordStructure() const { return m_moduleRecordStructure.get(this); }
Structure* moduleNamespaceObjectStructure() const { return m_moduleNamespaceObjectStructure.get(this); }
Structure* proxyObjectStructure() const { return m_proxyObjectStructure.get(this); }
Structure* callableProxyObjectStructure() const { return m_callableProxyObjectStructure.get(this); }
Structure* proxyRevokeStructure() const { return m_proxyRevokeStructure.get(this); }
Structure* restParameterStructure() const { return arrayStructureForIndexingTypeDuringAllocation(ArrayWithContiguous); }
Structure* originalRestParameterStructure() const { return originalArrayStructureForIndexingType(ArrayWithContiguous); }
#if ENABLE(WEBASSEMBLY)
Structure* webAssemblyModuleRecordStructure() const { return m_webAssemblyModuleRecordStructure.get(this); }
Structure* webAssemblyFunctionStructure() const { return m_webAssemblyFunctionStructure.get(this); }
Structure* jsToWasmICCalleeStructure() const { return m_jsToWasmICCalleeStructure.get(this); }
Structure* webAssemblyWrapperFunctionStructure() const { return m_webAssemblyWrapperFunctionStructure.get(this); }
#endif // ENABLE(WEBASSEMBLY)
Structure* collatorStructure() { return m_collatorStructure.get(this); }
Structure* dateTimeFormatStructure() { return m_dateTimeFormatStructure.get(this); }
Structure* displayNamesStructure() { return m_displayNamesStructure.get(this); }
Structure* listFormatStructure() { return m_listFormatStructure.get(this); }
Structure* numberFormatStructure() { return m_numberFormatStructure.get(this); }
Structure* localeStructure() { return m_localeStructure.get(this); }
Structure* pluralRulesStructure() { return m_pluralRulesStructure.get(this); }
Structure* relativeTimeFormatStructure() { return m_relativeTimeFormatStructure.get(this); }
Structure* segmentIteratorStructure() { return m_segmentIteratorStructure.get(this); }
Structure* segmenterStructure() { return m_segmenterStructure.get(this); }
Structure* segmentsStructure() { return m_segmentsStructure.get(this); }
JSObject* dateTimeFormatConstructor() { return m_dateTimeFormatStructure.constructor(this); }
JSObject* dateTimeFormatPrototype() { return m_dateTimeFormatStructure.prototype(this); }
JSObject* numberFormatConstructor() { return m_numberFormatStructure.constructor(this); }
JSObject* numberFormatPrototype() { return m_numberFormatStructure.prototype(this); }
JS_EXPORT_PRIVATE void setRemoteDebuggingEnabled(bool);
JS_EXPORT_PRIVATE bool remoteDebuggingEnabled() const;
void setIsITML();
RegExpGlobalData& regExpGlobalData() { return m_regExpGlobalData; }
static ptrdiff_t regExpGlobalDataOffset() { return OBJECT_OFFSETOF(JSGlobalObject, m_regExpGlobalData); }
static ptrdiff_t offsetOfVM() { return OBJECT_OFFSETOF(JSGlobalObject, m_vm); }
#if ENABLE(REMOTE_INSPECTOR)
Inspector::JSGlobalObjectInspectorController& inspectorController() const { return *m_inspectorController.get(); }
JSGlobalObjectDebuggable& inspectorDebuggable() { return *m_inspectorDebuggable.get(); }
#endif
void bumpGlobalLexicalBindingEpoch(VM&);
unsigned globalLexicalBindingEpoch() const { return m_globalLexicalBindingEpoch; }
static ptrdiff_t globalLexicalBindingEpochOffset() { return OBJECT_OFFSETOF(JSGlobalObject, m_globalLexicalBindingEpoch); }
unsigned* addressOfGlobalLexicalBindingEpoch() { return &m_globalLexicalBindingEpoch; }
JS_EXPORT_PRIVATE void setConsoleClient(WeakPtr<ConsoleClient>&&);
WeakPtr<ConsoleClient> consoleClient() const { return m_consoleClient; }
void setName(const String&);
const String& name() const { return m_name; }
void setUnhandledRejectionCallback(VM& vm, JSObject* function) { m_unhandledRejectionCallback.set(vm, function); }
JSObject* unhandledRejectionCallback() const { return m_unhandledRejectionCallback.get(); }
static void reportUncaughtExceptionAtEventLoop(JSGlobalObject*, Exception*);
static JSObject* currentScriptExecutionOwner(JSGlobalObject* global) { return global; }
static ScriptExecutionStatus scriptExecutionStatus(JSGlobalObject*, JSObject*) { return ScriptExecutionStatus::Running; }
JSObject* arrayBufferPrototype(ArrayBufferSharingMode sharingMode) const
{
switch (sharingMode) {
case ArrayBufferSharingMode::Default:
return m_arrayBufferStructure.prototype(this);
case ArrayBufferSharingMode::Shared:
return m_sharedArrayBufferStructure.prototype(this);
}
RELEASE_ASSERT_NOT_REACHED();
return nullptr;
}
Structure* arrayBufferStructure(ArrayBufferSharingMode sharingMode) const
{
switch (sharingMode) {
case ArrayBufferSharingMode::Default:
return m_arrayBufferStructure.get(this);
case ArrayBufferSharingMode::Shared:
return m_sharedArrayBufferStructure.get(this);
}
RELEASE_ASSERT_NOT_REACHED();
return nullptr;
}
template<ArrayBufferSharingMode sharingMode> Structure* arrayBufferStructureWithSharingMode() const { return arrayBufferStructure(sharingMode); }
JSObject* arrayBufferConstructor(ArrayBufferSharingMode sharingMode) const
{
switch (sharingMode) {
case ArrayBufferSharingMode::Default:
return m_arrayBufferStructure.constructor(this);
case ArrayBufferSharingMode::Shared:
return m_sharedArrayBufferStructure.constructor(this);
}
RELEASE_ASSERT_NOT_REACHED();
return nullptr;
}
#define DEFINE_ACCESSORS_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase, featureFlag) \
Structure* properName ## Structure() { return m_ ## properName ## Structure.get(); }
FOR_EACH_SIMPLE_BUILTIN_TYPE(DEFINE_ACCESSORS_FOR_SIMPLE_TYPE)
FOR_EACH_BUILTIN_DERIVED_ITERATOR_TYPE(DEFINE_ACCESSORS_FOR_SIMPLE_TYPE)
#undef DEFINE_ACCESSORS_FOR_SIMPLE_TYPE
#define DEFINE_ACCESSORS_FOR_LAZY_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase, featureFlag) \
Structure* properName ## Structure() { return m_ ## properName ## Structure.get(this); } \
JSObject* properName ## Constructor() { return m_ ## properName ## Structure.constructor(this); }
FOR_EACH_LAZY_BUILTIN_TYPE(DEFINE_ACCESSORS_FOR_LAZY_TYPE)
FOR_EACH_WEBASSEMBLY_CONSTRUCTOR_TYPE(DEFINE_ACCESSORS_FOR_LAZY_TYPE)
#undef DEFINE_ACCESSORS_FOR_LAZY_TYPE
LazyClassStructure& lazyTypedArrayStructure(TypedArrayType type)
{
switch (type) {
case NotTypedArray:
RELEASE_ASSERT_NOT_REACHED();
return m_typedArrayInt8;
#define TYPED_ARRAY_TYPE_CASE(name) case Type ## name: return m_typedArray ## name;
FOR_EACH_TYPED_ARRAY_TYPE(TYPED_ARRAY_TYPE_CASE)
#undef TYPED_ARRAY_TYPE_CASE
}
RELEASE_ASSERT_NOT_REACHED();
return m_typedArrayInt8;
}
const LazyClassStructure& lazyTypedArrayStructure(TypedArrayType type) const
{
return const_cast<const LazyClassStructure&>(const_cast<JSGlobalObject*>(this)->lazyTypedArrayStructure(type));
}
Structure* typedArrayStructure(TypedArrayType type) const
{
return lazyTypedArrayStructure(type).get(this);
}
Structure* typedArrayStructureConcurrently(TypedArrayType type) const
{
return lazyTypedArrayStructure(type).getConcurrently();
}
bool isOriginalTypedArrayStructure(Structure* structure)
{
TypedArrayType type = structure->classInfo()->typedArrayStorageType;
if (type == NotTypedArray)
return false;
return typedArrayStructureConcurrently(type) == structure;
}
template<TypedArrayType type> Structure* typedArrayStructureWithTypedArrayType() const { return typedArrayStructure(type); }
JSObject* typedArrayConstructor(TypedArrayType type) const
{
return lazyTypedArrayStructure(type).constructor(this);