1/*
2 * Copyright (C) 2008-2019 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of Apple Inc. ("Apple") nor the names of
14 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#pragma once
30
31#include "CallData.h"
32#include "CodeSpecializationKind.h"
33#include "CompleteSubspace.h"
34#include "ConcurrentJSLock.h"
35#include "ControlFlowProfiler.h"
36#include "DateInstanceCache.h"
37#include "DeleteAllCodeEffort.h"
38#include "ExceptionEventLocation.h"
39#include "ExecutableAllocator.h"
40#include "FunctionHasExecutedCache.h"
41#include "FuzzerAgent.h"
42#include "Heap.h"
43#include "Integrity.h"
44#include "Intrinsic.h"
45#include "IsoCellSet.h"
46#include "IsoSubspace.h"
47#include "JITThunks.h"
48#include "JSCJSValue.h"
49#include "JSLock.h"
50#include "MacroAssemblerCodeRef.h"
51#include "Microtask.h"
52#include "NumericStrings.h"
53#include "SmallStrings.h"
54#include "Strong.h"
55#include "StructureCache.h"
56#include "SubspaceAccess.h"
57#include "VMTraps.h"
58#include "WasmContext.h"
59#include "Watchpoint.h"
60#include <wtf/BumpPointerAllocator.h>
61#include <wtf/CheckedArithmetic.h>
62#include <wtf/DateMath.h>
63#include <wtf/Deque.h>
64#include <wtf/DoublyLinkedList.h>
65#include <wtf/Forward.h>
66#include <wtf/Gigacage.h>
67#include <wtf/HashMap.h>
68#include <wtf/HashSet.h>
69#include <wtf/SetForScope.h>
70#include <wtf/StackBounds.h>
71#include <wtf/StackPointer.h>
72#include <wtf/Stopwatch.h>
73#include <wtf/ThreadSafeRefCounted.h>
74#include <wtf/ThreadSpecific.h>
75#include <wtf/UniqueArray.h>
76#include <wtf/text/SymbolRegistry.h>
77#include <wtf/text/WTFString.h>
78#if ENABLE(REGEXP_TRACING)
79#include <wtf/ListHashSet.h>
80#endif
81
82#if ENABLE(EXCEPTION_SCOPE_VERIFICATION)
83#include <wtf/StackTrace.h>
84#endif
85
86// Enable the Objective-C API for platforms with a modern runtime. This has to match exactly what we
87// have in JSBase.h.
88#if !defined(JSC_OBJC_API_ENABLED)
89#if (defined(__clang__) && defined(__APPLE__) && (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE)))
90#define JSC_OBJC_API_ENABLED 1
91#else
92#define JSC_OBJC_API_ENABLED 0
93#endif
94#endif
95
96namespace WTF {
97class SimpleStats;
98} // namespace WTF
99using WTF::SimpleStats;
100
101namespace JSC {
102
103class BuiltinExecutables;
104class BytecodeIntrinsicRegistry;
105class CallFrame;
106class CodeBlock;
107class CodeCache;
108class CommonIdentifiers;
109class CompactVariableMap;
110class CustomGetterSetter;
111class DOMAttributeGetterSetter;
112class Exception;
113class ExceptionScope;
114class FastMallocAlignedMemoryAllocator;
115class GigacageAlignedMemoryAllocator;
116class HandleStack;
117class TypeProfiler;
118class TypeProfilerLog;
119class HasOwnPropertyCache;
120class HeapProfiler;
121class Identifier;
122class Interpreter;
123class JSCustomGetterSetterFunction;
124class JSDestructibleObjectHeapCellType;
125class JSGlobalObject;
126class JSObject;
127class JSPromise;
128class JSPropertyNameEnumerator;
129class JSRunLoopTimer;
130class JSStringHeapCellType;
131class JSWebAssemblyCodeBlockHeapCellType;
132class JSWebAssemblyInstance;
133class LLIntOffsetsExtractor;
134class NativeExecutable;
135class PromiseTimer;
136class RegExp;
137class RegExpCache;
138class Register;
139class RegisterAtOffsetList;
140#if ENABLE(SAMPLING_PROFILER)
141class SamplingProfiler;
142#endif
143class ShadowChicken;
144class ScriptExecutable;
145class SourceProvider;
146class SourceProviderCache;
147class StackFrame;
148class Structure;
149#if ENABLE(REGEXP_TRACING)
150class RegExp;
151#endif
152class Symbol;
153class TypedArrayController;
154class UnlinkedCodeBlock;
155class UnlinkedEvalCodeBlock;
156class UnlinkedFunctionExecutable;
157class UnlinkedProgramCodeBlock;
158class UnlinkedModuleProgramCodeBlock;
159class VirtualRegister;
160class VMEntryScope;
161class TopLevelGlobalObjectScope;
162class Watchdog;
163class Watchpoint;
164class WatchpointSet;
165class WebAssemblyFunctionHeapCellType;
166
167#if ENABLE(FTL_JIT)
168namespace FTL {
169class Thunks;
170}
171#endif // ENABLE(FTL_JIT)
172namespace Profiler {
173class Database;
174}
175namespace DOMJIT {
176class Signature;
177}
178
179struct EntryFrame;
180struct HashTable;
181struct Instruction;
182struct ValueProfile;
183
184struct LocalTimeOffsetCache {
185 LocalTimeOffsetCache()
186 : start(0.0)
187 , end(-1.0)
188 , increment(0.0)
189 {
190 }
191
192 void reset()
193 {
194 offset = LocalTimeOffset();
195 start = 0.0;
196 end = -1.0;
197 increment = 0.0;
198 }
199
200 LocalTimeOffset offset;
201 double start;
202 double end;
203 double increment;
204};
205
206class QueuedTask {
207 WTF_MAKE_NONCOPYABLE(QueuedTask);
208 WTF_MAKE_FAST_ALLOCATED;
209public:
210 void run();
211
212 QueuedTask(VM& vm, JSGlobalObject* globalObject, Ref<Microtask>&& microtask)
213 : m_globalObject(vm, globalObject)
214 , m_microtask(WTFMove(microtask))
215 {
216 }
217
218private:
219 Strong<JSGlobalObject> m_globalObject;
220 Ref<Microtask> m_microtask;
221};
222
223class ConservativeRoots;
224
225#if COMPILER(MSVC)
226#pragma warning(push)
227#pragma warning(disable: 4200) // Disable "zero-sized array in struct/union" warning
228#endif
229struct ScratchBuffer {
230 ScratchBuffer()
231 {
232 u.m_activeLength = 0;
233 }
234
235 static ScratchBuffer* create(size_t size)
236 {
237 ScratchBuffer* result = new (fastMalloc(ScratchBuffer::allocationSize(size))) ScratchBuffer;
238
239 return result;
240 }
241
242 static size_t allocationSize(Checked<size_t> bufferSize) { return (sizeof(ScratchBuffer) + bufferSize).unsafeGet(); }
243 void setActiveLength(size_t activeLength) { u.m_activeLength = activeLength; }
244 size_t activeLength() const { return u.m_activeLength; };
245 size_t* addressOfActiveLength() { return &u.m_activeLength; };
246 void* dataBuffer() { return m_buffer; }
247
248 union {
249 size_t m_activeLength;
250 double pad; // Make sure m_buffer is double aligned.
251 } u;
252#if CPU(MIPS) && (defined WTF_MIPS_ARCH_REV && WTF_MIPS_ARCH_REV == 2)
253 alignas(8) void* m_buffer[0];
254#else
255 void* m_buffer[0];
256#endif
257};
258#if COMPILER(MSVC)
259#pragma warning(pop)
260#endif
261
262class VM : public ThreadSafeRefCounted<VM>, public DoublyLinkedListNode<VM> {
263public:
264 // WebCore has a one-to-one mapping of threads to VMs;
265 // create() should only be called once
266 // on a thread, this is the 'default' VM (it uses the
267 // thread's default string uniquing table from Thread::current()).
268 // API contexts created using the new context group aware interface
269 // create APIContextGroup objects which require less locking of JSC
270 // than the old singleton APIShared VM created for use by
271 // the original API.
272 enum VMType { Default, APIContextGroup, APIShared };
273
274 struct ClientData {
275 JS_EXPORT_PRIVATE virtual ~ClientData() = 0;
276 };
277
278 bool isSharedInstance() { return vmType == APIShared; }
279 bool usingAPI() { return vmType != Default; }
280 JS_EXPORT_PRIVATE static bool sharedInstanceExists();
281 JS_EXPORT_PRIVATE static VM& sharedInstance();
282
283 JS_EXPORT_PRIVATE static Ref<VM> create(HeapType = SmallHeap);
284 static Ref<VM> createContextGroup(HeapType = SmallHeap);
285 JS_EXPORT_PRIVATE ~VM();
286
287 Watchdog& ensureWatchdog();
288 Watchdog* watchdog() { return m_watchdog.get(); }
289
290 HeapProfiler* heapProfiler() const { return m_heapProfiler.get(); }
291 JS_EXPORT_PRIVATE HeapProfiler& ensureHeapProfiler();
292
293#if ENABLE(SAMPLING_PROFILER)
294 SamplingProfiler* samplingProfiler() { return m_samplingProfiler.get(); }
295 JS_EXPORT_PRIVATE SamplingProfiler& ensureSamplingProfiler(RefPtr<Stopwatch>&&);
296#endif
297
298 FuzzerAgent* fuzzerAgent() const { return m_fuzzerAgent.get(); }
299 void setFuzzerAgent(std::unique_ptr<FuzzerAgent>&& fuzzerAgent)
300 {
301 m_fuzzerAgent = WTFMove(fuzzerAgent);
302 }
303
304 static unsigned numberOfIDs() { return s_numberOfIDs.load(); }
305 unsigned id() const { return m_id; }
306 bool isEntered() const { return !!entryScope; }
307
308 inline CallFrame* topJSCallFrame() const;
309
310 // Global object in which execution began.
311 JS_EXPORT_PRIVATE JSGlobalObject* deprecatedVMEntryGlobalObject(JSGlobalObject*) const;
312
313 WeakRandom& random() { return m_random; }
314 Integrity::Random& integrityRandom() { return m_integrityRandom; }
315
316private:
317 unsigned nextID();
318
319 static Atomic<unsigned> s_numberOfIDs;
320
321 unsigned m_id;
322 RefPtr<JSLock> m_apiLock;
323#if USE(CF)
324 // These need to be initialized before heap below.
325 RetainPtr<CFRunLoopRef> m_runLoop;
326#endif
327
328 WeakRandom m_random;
329 Integrity::Random m_integrityRandom;
330
331public:
332 Heap heap;
333
334 std::unique_ptr<FastMallocAlignedMemoryAllocator> fastMallocAllocator;
335 std::unique_ptr<GigacageAlignedMemoryAllocator> primitiveGigacageAllocator;
336 std::unique_ptr<GigacageAlignedMemoryAllocator> jsValueGigacageAllocator;
337
338 std::unique_ptr<HeapCellType> auxiliaryHeapCellType;
339 std::unique_ptr<HeapCellType> immutableButterflyHeapCellType;
340 std::unique_ptr<HeapCellType> cellHeapCellType;
341 std::unique_ptr<HeapCellType> destructibleCellHeapCellType;
342 std::unique_ptr<JSStringHeapCellType> stringHeapCellType;
343 std::unique_ptr<JSDestructibleObjectHeapCellType> destructibleObjectHeapCellType;
344#if ENABLE(WEBASSEMBLY)
345 std::unique_ptr<JSWebAssemblyCodeBlockHeapCellType> webAssemblyCodeBlockHeapCellType;
346 std::unique_ptr<WebAssemblyFunctionHeapCellType> webAssemblyFunctionHeapCellType;
347#endif
348
349 CompleteSubspace primitiveGigacageAuxiliarySpace; // Typed arrays, strings, bitvectors, etc go here.
350 CompleteSubspace jsValueGigacageAuxiliarySpace; // Butterflies, arrays of JSValues, etc go here.
351 CompleteSubspace immutableButterflyJSValueGigacageAuxiliarySpace; // JSImmutableButterfly goes here.
352
353 // We make cross-cutting assumptions about typed arrays being in the primitive Gigacage and butterflies
354 // being in the JSValue gigacage. For some types, it's super obvious where they should go, and so we
355 // can hardcode that fact. But sometimes it's not clear, so we abstract it by having a Gigacage::Kind
356 // constant somewhere.
357 // FIXME: Maybe it would be better if everyone abstracted this?
358 // https://bugs.webkit.org/show_bug.cgi?id=175248
359 ALWAYS_INLINE CompleteSubspace& gigacageAuxiliarySpace(Gigacage::Kind kind)
360 {
361 switch (kind) {
362 case Gigacage::Primitive:
363 return primitiveGigacageAuxiliarySpace;
364 case Gigacage::JSValue:
365 return jsValueGigacageAuxiliarySpace;
366 case Gigacage::NumberOfKinds:
367 break;
368 }
369 RELEASE_ASSERT_NOT_REACHED();
370 return primitiveGigacageAuxiliarySpace;
371 }
372
373 // Whenever possible, use subspaceFor<CellType>(vm) to get one of these subspaces.
374 CompleteSubspace cellSpace;
375 CompleteSubspace variableSizedCellSpace; // FIXME: This space is problematic because we have things in here like DirectArguments and ScopedArguments; those should be split into JSValueOOB cells and JSValueStrict auxiliaries. https://bugs.webkit.org/show_bug.cgi?id=182858
376 CompleteSubspace destructibleCellSpace;
377 CompleteSubspace destructibleObjectSpace;
378
379 IsoSubspace bigIntSpace;
380 IsoSubspace executableToCodeBlockEdgeSpace;
381 IsoSubspace functionSpace;
382 IsoSubspace getterSetterSpace;
383 IsoSubspace internalFunctionSpace;
384 IsoSubspace nativeExecutableSpace;
385 IsoSubspace propertyTableSpace;
386 IsoSubspace ropeStringSpace;
387 IsoSubspace scopedArgumentsSpace;
388 IsoSubspace sparseArrayValueMapSpace;
389 IsoSubspace stringSpace;
390 IsoSubspace structureRareDataSpace;
391 IsoSubspace structureSpace;
392 IsoSubspace symbolTableSpace;
393
394#define DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(name) \
395 template<SubspaceAccess mode> \
396 IsoSubspace* name() \
397 { \
398 if (m_##name || mode == SubspaceAccess::Concurrently) \
399 return m_##name.get(); \
400 return name##Slow(); \
401 } \
402 JS_EXPORT_PRIVATE IsoSubspace* name##Slow(); \
403 std::unique_ptr<IsoSubspace> m_##name;
404
405
406#if JSC_OBJC_API_ENABLED
407 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(objCCallbackFunctionSpace)
408#endif
409 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(boundFunctionSpace)
410 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(callbackFunctionSpace)
411 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(customGetterSetterFunctionSpace)
412 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(errorInstanceSpace)
413 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(functionRareDataSpace)
414 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(nativeStdFunctionSpace)
415 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(proxyObjectSpace)
416 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(proxyRevokeSpace)
417 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(symbolSpace)
418 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(unlinkedEvalCodeBlockSpace)
419 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(unlinkedFunctionCodeBlockSpace)
420 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(unlinkedModuleProgramCodeBlockSpace)
421 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(unlinkedProgramCodeBlockSpace)
422 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(weakObjectRefSpace)
423 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(weakSetSpace)
424 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(weakMapSpace)
425#if ENABLE(WEBASSEMBLY)
426 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(webAssemblyCodeBlockSpace)
427 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(webAssemblyFunctionSpace)
428 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(webAssemblyMemorySpace)
429 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(webAssemblyWrapperFunctionSpace)
430#endif
431
432#undef DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER
433
434 IsoCellSet executableToCodeBlockEdgesWithConstraints;
435 IsoCellSet executableToCodeBlockEdgesWithFinalizers;
436
437#define DYNAMIC_SPACE_AND_SET_DEFINE_MEMBER(name) \
438 template<SubspaceAccess mode> \
439 IsoSubspace* name() \
440 { \
441 if (auto* spaceAndSet = m_##name.get()) \
442 return &spaceAndSet->space; \
443 if (mode == SubspaceAccess::Concurrently) \
444 return nullptr; \
445 return name##Slow(); \
446 } \
447 IsoSubspace* name##Slow(); \
448 std::unique_ptr<SpaceAndSet> m_##name;
449
450 struct SpaceAndSet {
451 WTF_MAKE_STRUCT_FAST_ALLOCATED;
452
453 IsoSubspace space;
454 IsoCellSet set;
455
456 template<typename... Arguments>
457 SpaceAndSet(Arguments&&... arguments)
458 : space(std::forward<Arguments>(arguments)...)
459 , set(space)
460 {
461 }
462
463 static IsoCellSet& setFor(Subspace& space)
464 {
465 return *bitwise_cast<IsoCellSet*>(
466 bitwise_cast<char*>(&space) -
467 OBJECT_OFFSETOF(SpaceAndSet, space) +
468 OBJECT_OFFSETOF(SpaceAndSet, set));
469 }
470 };
471
472 SpaceAndSet codeBlockSpace;
473
474 template<typename Func>
475 void forEachCodeBlockSpace(const Func& func)
476 {
477 // This should not include webAssemblyCodeBlockSpace because this is about subsclasses of
478 // JSC::CodeBlock.
479 func(codeBlockSpace);
480 }
481
482 DYNAMIC_SPACE_AND_SET_DEFINE_MEMBER(evalExecutableSpace)
483 DYNAMIC_SPACE_AND_SET_DEFINE_MEMBER(moduleProgramExecutableSpace)
484 SpaceAndSet functionExecutableSpace;
485 SpaceAndSet programExecutableSpace;
486
487 template<typename Func>
488 void forEachScriptExecutableSpace(const Func& func)
489 {
490 if (m_evalExecutableSpace)
491 func(*m_evalExecutableSpace);
492 func(functionExecutableSpace);
493 if (m_moduleProgramExecutableSpace)
494 func(*m_moduleProgramExecutableSpace);
495 func(programExecutableSpace);
496 }
497
498 SpaceAndSet unlinkedFunctionExecutableSpace;
499
500#undef DYNAMIC_SPACE_AND_SET_DEFINE_MEMBER
501
502 VMType vmType;
503 ClientData* clientData;
504 EntryFrame* topEntryFrame { nullptr };
505 // NOTE: When throwing an exception while rolling back the call frame, this may be equal to
506 // topEntryFrame.
507 // FIXME: This should be a void*, because it might not point to a CallFrame.
508 // https://bugs.webkit.org/show_bug.cgi?id=160441
509 CallFrame* topCallFrame { nullptr };
510#if ENABLE(WEBASSEMBLY)
511 Wasm::Context wasmContext;
512#endif
513 Strong<Structure> structureStructure;
514 Strong<Structure> structureRareDataStructure;
515 Strong<Structure> terminatedExecutionErrorStructure;
516 Strong<Structure> stringStructure;
517 Strong<Structure> propertyNameEnumeratorStructure;
518 Strong<Structure> getterSetterStructure;
519 Strong<Structure> customGetterSetterStructure;
520 Strong<Structure> domAttributeGetterSetterStructure;
521 Strong<Structure> scopedArgumentsTableStructure;
522 Strong<Structure> apiWrapperStructure;
523 Strong<Structure> nativeExecutableStructure;
524 Strong<Structure> evalExecutableStructure;
525 Strong<Structure> programExecutableStructure;
526 Strong<Structure> functionExecutableStructure;
527#if ENABLE(WEBASSEMBLY)
528 Strong<Structure> webAssemblyCodeBlockStructure;
529#endif
530 Strong<Structure> moduleProgramExecutableStructure;
531 Strong<Structure> regExpStructure;
532 Strong<Structure> symbolStructure;
533 Strong<Structure> symbolTableStructure;
534 Strong<Structure> fixedArrayStructure;
535 Strong<Structure> immutableButterflyStructures[NumberOfCopyOnWriteIndexingModes];
536 Strong<Structure> sourceCodeStructure;
537 Strong<Structure> scriptFetcherStructure;
538 Strong<Structure> scriptFetchParametersStructure;
539 Strong<Structure> structureChainStructure;
540 Strong<Structure> sparseArrayValueMapStructure;
541 Strong<Structure> templateObjectDescriptorStructure;
542 Strong<Structure> arrayBufferNeuteringWatchpointStructure;
543 Strong<Structure> unlinkedFunctionExecutableStructure;
544 Strong<Structure> unlinkedProgramCodeBlockStructure;
545 Strong<Structure> unlinkedEvalCodeBlockStructure;
546 Strong<Structure> unlinkedFunctionCodeBlockStructure;
547 Strong<Structure> unlinkedModuleProgramCodeBlockStructure;
548 Strong<Structure> propertyTableStructure;
549 Strong<Structure> functionRareDataStructure;
550 Strong<Structure> exceptionStructure;
551 Strong<Structure> nativeStdFunctionCellStructure;
552 Strong<Structure> programCodeBlockStructure;
553 Strong<Structure> moduleProgramCodeBlockStructure;
554 Strong<Structure> evalCodeBlockStructure;
555 Strong<Structure> functionCodeBlockStructure;
556 Strong<Structure> hashMapBucketSetStructure;
557 Strong<Structure> hashMapBucketMapStructure;
558 Strong<Structure> bigIntStructure;
559 Strong<Structure> executableToCodeBlockEdgeStructure;
560
561 Strong<Structure> m_setIteratorStructure;
562 Strong<Structure> m_mapIteratorStructure;
563
564 Strong<JSPropertyNameEnumerator> m_emptyPropertyNameEnumerator;
565
566 Strong<JSCell> m_sentinelSetBucket;
567 Strong<JSCell> m_sentinelMapBucket;
568
569 Ref<PromiseTimer> promiseTimer;
570
571 JSCell* currentlyDestructingCallbackObject;
572 const ClassInfo* currentlyDestructingCallbackObjectClassInfo { nullptr };
573
574 AtomStringTable* m_atomStringTable;
575 WTF::SymbolRegistry m_symbolRegistry;
576 CommonIdentifiers* propertyNames;
577 const ArgList* emptyList;
578 SmallStrings smallStrings;
579 NumericStrings numericStrings;
580 DateInstanceCache dateInstanceCache;
581 std::unique_ptr<SimpleStats> machineCodeBytesPerBytecodeWordForBaselineJIT;
582 WeakGCMap<std::pair<CustomGetterSetter*, int>, JSCustomGetterSetterFunction> customGetterSetterFunctionMap;
583 WeakGCMap<StringImpl*, JSString, PtrHash<StringImpl*>> stringCache;
584 Strong<JSString> lastCachedString;
585
586 AtomStringTable* atomStringTable() const { return m_atomStringTable; }
587 WTF::SymbolRegistry& symbolRegistry() { return m_symbolRegistry; }
588
589 Strong<JSBigInt> bigIntConstantOne;
590
591 Structure* setIteratorStructure()
592 {
593 if (LIKELY(m_setIteratorStructure))
594 return m_setIteratorStructure.get();
595 return setIteratorStructureSlow();
596 }
597
598 Structure* mapIteratorStructure()
599 {
600 if (LIKELY(m_mapIteratorStructure))
601 return m_mapIteratorStructure.get();
602 return mapIteratorStructureSlow();
603 }
604
605 JSCell* sentinelSetBucket()
606 {
607 if (LIKELY(m_sentinelSetBucket))
608 return m_sentinelSetBucket.get();
609 return sentinelSetBucketSlow();
610 }
611
612 JSCell* sentinelMapBucket()
613 {
614 if (LIKELY(m_sentinelMapBucket))
615 return m_sentinelMapBucket.get();
616 return sentinelMapBucketSlow();
617 }
618
619 JSPropertyNameEnumerator* emptyPropertyNameEnumerator()
620 {
621 if (LIKELY(m_emptyPropertyNameEnumerator))
622 return m_emptyPropertyNameEnumerator.get();
623 return emptyPropertyNameEnumeratorSlow();
624 }
625
626 WeakGCMap<SymbolImpl*, Symbol, PtrHash<SymbolImpl*>> symbolImplToSymbolMap;
627
628 enum class DeletePropertyMode {
629 // Default behaviour of deleteProperty, matching the spec.
630 Default,
631 // This setting causes deleteProperty to force deletion of all
632 // properties including those that are non-configurable (DontDelete).
633 IgnoreConfigurable
634 };
635
636 DeletePropertyMode deletePropertyMode()
637 {
638 return m_deletePropertyMode;
639 }
640
641 class DeletePropertyModeScope {
642 public:
643 DeletePropertyModeScope(VM& vm, DeletePropertyMode mode)
644 : m_vm(vm)
645 , m_previousMode(vm.m_deletePropertyMode)
646 {
647 m_vm.m_deletePropertyMode = mode;
648 }
649
650 ~DeletePropertyModeScope()
651 {
652 m_vm.m_deletePropertyMode = m_previousMode;
653 }
654
655 private:
656 VM& m_vm;
657 DeletePropertyMode m_previousMode;
658 };
659
660 static JS_EXPORT_PRIVATE bool canUseAssembler();
661 static bool isInMiniMode()
662 {
663 return !canUseJIT() || Options::forceMiniVMMode();
664 }
665
666 static bool useUnlinkedCodeBlockJettisoning()
667 {
668 return Options::useUnlinkedCodeBlockJettisoning() || isInMiniMode();
669 }
670
671 static void computeCanUseJIT();
672 ALWAYS_INLINE static bool canUseJIT()
673 {
674#if ENABLE(JIT)
675#if !ASSERT_DISABLED
676 RELEASE_ASSERT(s_canUseJITIsSet);
677#endif
678 return s_canUseJIT;
679#else
680 return false;
681#endif
682 }
683
684 SourceProviderCache* addSourceProviderCache(SourceProvider*);
685 void clearSourceProviderCaches();
686
687 StructureCache structureCache;
688
689 typedef HashMap<RefPtr<SourceProvider>, RefPtr<SourceProviderCache>> SourceProviderCacheMap;
690 SourceProviderCacheMap sourceProviderCacheMap;
691 Interpreter* interpreter;
692#if ENABLE(JIT)
693 std::unique_ptr<JITThunks> jitStubs;
694 MacroAssemblerCodeRef<JITThunkPtrTag> getCTIStub(ThunkGenerator generator)
695 {
696 return jitStubs->ctiStub(*this, generator);
697 }
698
699#endif // ENABLE(JIT)
700#if ENABLE(FTL_JIT)
701 std::unique_ptr<FTL::Thunks> ftlThunks;
702#endif
703 NativeExecutable* getHostFunction(NativeFunction, NativeFunction constructor, const String& name);
704 NativeExecutable* getHostFunction(NativeFunction, Intrinsic, NativeFunction constructor, const DOMJIT::Signature*, const String& name);
705
706 MacroAssemblerCodePtr<JSEntryPtrTag> getCTIInternalFunctionTrampolineFor(CodeSpecializationKind);
707
708 static ptrdiff_t exceptionOffset()
709 {
710 return OBJECT_OFFSETOF(VM, m_exception);
711 }
712
713 static ptrdiff_t callFrameForCatchOffset()
714 {
715 return OBJECT_OFFSETOF(VM, callFrameForCatch);
716 }
717
718 static ptrdiff_t topEntryFrameOffset()
719 {
720 return OBJECT_OFFSETOF(VM, topEntryFrame);
721 }
722
723 static ptrdiff_t offsetOfHeapBarrierThreshold()
724 {
725 return OBJECT_OFFSETOF(VM, heap) + OBJECT_OFFSETOF(Heap, m_barrierThreshold);
726 }
727
728 static ptrdiff_t offsetOfHeapMutatorShouldBeFenced()
729 {
730 return OBJECT_OFFSETOF(VM, heap) + OBJECT_OFFSETOF(Heap, m_mutatorShouldBeFenced);
731 }
732
733 void restorePreviousException(Exception* exception) { setException(exception); }
734
735 void clearLastException() { m_lastException = nullptr; }
736
737 CallFrame** addressOfCallFrameForCatch() { return &callFrameForCatch; }
738
739 JSCell** addressOfException() { return reinterpret_cast<JSCell**>(&m_exception); }
740
741 Exception* lastException() const { return m_lastException; }
742 JSCell** addressOfLastException() { return reinterpret_cast<JSCell**>(&m_lastException); }
743
744 // This should only be used for test or assertion code that wants to inspect
745 // the pending exception without interfering with Throw/CatchScopes.
746 Exception* exceptionForInspection() const { return m_exception; }
747
748 void setFailNextNewCodeBlock() { m_failNextNewCodeBlock = true; }
749 bool getAndClearFailNextNewCodeBlock()
750 {
751 bool result = m_failNextNewCodeBlock;
752 m_failNextNewCodeBlock = false;
753 return result;
754 }
755
756 ALWAYS_INLINE Structure* getStructure(StructureID id)
757 {
758 return heap.structureIDTable().get(decontaminate(id));
759 }
760
761 void* stackPointerAtVMEntry() const { return m_stackPointerAtVMEntry; }
762 void setStackPointerAtVMEntry(void*);
763
764 size_t softReservedZoneSize() const { return m_currentSoftReservedZoneSize; }
765 size_t updateSoftReservedZoneSize(size_t softReservedZoneSize);
766
767 static size_t committedStackByteCount();
768 inline bool ensureStackCapacityFor(Register* newTopOfStack);
769
770 void* stackLimit() { return m_stackLimit; }
771 void* softStackLimit() { return m_softStackLimit; }
772 void** addressOfSoftStackLimit() { return &m_softStackLimit; }
773#if ENABLE(C_LOOP)
774 void* cloopStackLimit() { return m_cloopStackLimit; }
775 void setCLoopStackLimit(void* limit) { m_cloopStackLimit = limit; }
776 JS_EXPORT_PRIVATE void* currentCLoopStackPointer() const;
777#endif
778
779 inline bool isSafeToRecurseSoft() const;
780 bool isSafeToRecurse() const
781 {
782 return isSafeToRecurse(m_stackLimit);
783 }
784
785 void** addressOfLastStackTop() { return &m_lastStackTop; }
786 void* lastStackTop() { return m_lastStackTop; }
787 void setLastStackTop(void*);
788
789 void firePrimitiveGigacageEnabledIfNecessary()
790 {
791 if (m_needToFirePrimitiveGigacageEnabled) {
792 m_needToFirePrimitiveGigacageEnabled = false;
793 m_primitiveGigacageEnabled.fireAll(*this, "Primitive gigacage disabled asynchronously");
794 }
795 }
796
797 JSValue hostCallReturnValue;
798 unsigned varargsLength;
799 CallFrame* newCallFrameReturnValue;
800 CallFrame* callFrameForCatch;
801 void* targetMachinePCForThrow;
802 const Instruction* targetInterpreterPCForThrow;
803 uint32_t osrExitIndex;
804 void* osrExitJumpDestination;
805 bool isExecutingInRegExpJIT { false };
806
807 // The threading protocol here is as follows:
808 // - You can call scratchBufferForSize from any thread.
809 // - You can only set the ScratchBuffer's activeLength from the main thread.
810 // - You can only write to entries in the ScratchBuffer from the main thread.
811 ScratchBuffer* scratchBufferForSize(size_t size);
812 void clearScratchBuffers();
813
814 EncodedJSValue* exceptionFuzzingBuffer(size_t size)
815 {
816 ASSERT(Options::useExceptionFuzz());
817 if (!m_exceptionFuzzBuffer)
818 m_exceptionFuzzBuffer = MallocPtr<EncodedJSValue>::malloc(size);
819 return m_exceptionFuzzBuffer.get();
820 }
821
822 void gatherScratchBufferRoots(ConservativeRoots&);
823
824 VMEntryScope* entryScope;
825
826 JSObject* stringRecursionCheckFirstObject { nullptr };
827 HashSet<JSObject*> stringRecursionCheckVisitedObjects;
828
829 LocalTimeOffsetCache utcTimeOffsetCache;
830 LocalTimeOffsetCache localTimeOffsetCache;
831
832 String cachedDateString;
833 double cachedDateStringValue;
834
835 std::unique_ptr<Profiler::Database> m_perBytecodeProfiler;
836 RefPtr<TypedArrayController> m_typedArrayController;
837 RegExpCache* m_regExpCache;
838 BumpPointerAllocator m_regExpAllocator;
839 ConcurrentJSLock m_regExpAllocatorLock;
840
841#if ENABLE(YARR_JIT_ALL_PARENS_EXPRESSIONS)
842 static constexpr size_t patternContextBufferSize = 8192; // Space allocated to save nested parenthesis context
843 UniqueArray<char> m_regExpPatternContexBuffer;
844 Lock m_regExpPatternContextLock;
845 char* acquireRegExpPatternContexBuffer();
846 void releaseRegExpPatternContexBuffer();
847#else
848 static constexpr size_t patternContextBufferSize = 0; // Space allocated to save nested parenthesis context
849#endif
850
851 Ref<CompactVariableMap> m_compactVariableMap;
852
853 std::unique_ptr<HasOwnPropertyCache> m_hasOwnPropertyCache;
854 ALWAYS_INLINE HasOwnPropertyCache* hasOwnPropertyCache() { return m_hasOwnPropertyCache.get(); }
855 HasOwnPropertyCache* ensureHasOwnPropertyCache();
856
857#if ENABLE(REGEXP_TRACING)
858 typedef ListHashSet<RegExp*> RTTraceList;
859 RTTraceList* m_rtTraceList;
860#endif
861
862 JS_EXPORT_PRIVATE void resetDateCache();
863
864 RegExpCache* regExpCache() { return m_regExpCache; }
865#if ENABLE(REGEXP_TRACING)
866 void addRegExpToTrace(RegExp*);
867#endif
868 JS_EXPORT_PRIVATE void dumpRegExpTrace();
869
870 bool isCollectorBusyOnCurrentThread() { return heap.isCurrentThreadBusy(); }
871
872#if ENABLE(GC_VALIDATION)
873 bool isInitializingObject() const;
874 void setInitializingObjectClass(const ClassInfo*);
875#endif
876
877 bool currentThreadIsHoldingAPILock() const { return m_apiLock->currentThreadIsHoldingLock(); }
878
879 JSLock& apiLock() { return *m_apiLock; }
880 CodeCache* codeCache() { return m_codeCache.get(); }
881
882 JS_EXPORT_PRIVATE void whenIdle(Function<void()>&&);
883
884 JS_EXPORT_PRIVATE void deleteAllCode(DeleteAllCodeEffort);
885 JS_EXPORT_PRIVATE void deleteAllLinkedCode(DeleteAllCodeEffort);
886
887 void shrinkFootprintWhenIdle();
888
889 WatchpointSet* ensureWatchpointSetForImpureProperty(const Identifier&);
890 void registerWatchpointForImpureProperty(const Identifier&, Watchpoint*);
891
892 // FIXME: Use AtomString once it got merged with Identifier.
893 JS_EXPORT_PRIVATE void addImpureProperty(const String&);
894
895 InlineWatchpointSet& primitiveGigacageEnabled() { return m_primitiveGigacageEnabled; }
896
897 BuiltinExecutables* builtinExecutables() { return m_builtinExecutables.get(); }
898
899 bool enableTypeProfiler();
900 bool disableTypeProfiler();
901 TypeProfilerLog* typeProfilerLog() { return m_typeProfilerLog.get(); }
902 TypeProfiler* typeProfiler() { return m_typeProfiler.get(); }
903 JS_EXPORT_PRIVATE void dumpTypeProfilerData();
904
905 FunctionHasExecutedCache* functionHasExecutedCache() { return &m_functionHasExecutedCache; }
906
907 ControlFlowProfiler* controlFlowProfiler() { return m_controlFlowProfiler.get(); }
908 bool enableControlFlowProfiler();
909 bool disableControlFlowProfiler();
910
911 void queueMicrotask(JSGlobalObject&, Ref<Microtask>&&);
912 JS_EXPORT_PRIVATE void drainMicrotasks();
913 void setOnEachMicrotaskTick(WTF::Function<void(VM&)>&& func) { m_onEachMicrotaskTick = WTFMove(func); }
914 void finalizeSynchronousJSExecution() { ASSERT(currentThreadIsHoldingAPILock()); m_currentWeakRefVersion++; }
915 uintptr_t currentWeakRefVersion() const { return m_currentWeakRefVersion; }
916
917 void setGlobalConstRedeclarationShouldThrow(bool globalConstRedeclarationThrow) { m_globalConstRedeclarationShouldThrow = globalConstRedeclarationThrow; }
918 ALWAYS_INLINE bool globalConstRedeclarationShouldThrow() const { return m_globalConstRedeclarationShouldThrow; }
919
920 void setShouldBuildPCToCodeOriginMapping() { m_shouldBuildPCToCodeOriginMapping = true; }
921 bool shouldBuilderPCToCodeOriginMapping() const { return m_shouldBuildPCToCodeOriginMapping; }
922
923 BytecodeIntrinsicRegistry& bytecodeIntrinsicRegistry() { return *m_bytecodeIntrinsicRegistry; }
924
925 ShadowChicken* shadowChicken() { return m_shadowChicken.get(); }
926 void ensureShadowChicken();
927
928 template<typename Func>
929 void logEvent(CodeBlock*, const char* summary, const Func& func);
930
931 Optional<RefPtr<Thread>> ownerThread() const { return m_apiLock->ownerThread(); }
932
933 VMTraps& traps() { return m_traps; }
934
935 void handleTraps(JSGlobalObject* globalObject, CallFrame* callFrame, VMTraps::Mask mask = VMTraps::Mask::allEventTypes()) { m_traps.handleTraps(globalObject, callFrame, mask); }
936
937 bool needTrapHandling() { return m_traps.needTrapHandling(); }
938 bool needTrapHandling(VMTraps::Mask mask) { return m_traps.needTrapHandling(mask); }
939 void* needTrapHandlingAddress() { return m_traps.needTrapHandlingAddress(); }
940
941 void notifyNeedDebuggerBreak() { m_traps.fireTrap(VMTraps::NeedDebuggerBreak); }
942 void notifyNeedTermination() { m_traps.fireTrap(VMTraps::NeedTermination); }
943 void notifyNeedWatchdogCheck() { m_traps.fireTrap(VMTraps::NeedWatchdogCheck); }
944
945 void promiseRejected(JSPromise*);
946
947#if ENABLE(EXCEPTION_SCOPE_VERIFICATION)
948 StackTrace* nativeStackTraceOfLastThrow() const { return m_nativeStackTraceOfLastThrow.get(); }
949 Thread* throwingThread() const { return m_throwingThread.get(); }
950 bool needExceptionCheck() const { return m_needExceptionCheck; }
951#endif
952
953#if USE(CF)
954 CFRunLoopRef runLoop() const { return m_runLoop.get(); }
955 JS_EXPORT_PRIVATE void setRunLoop(CFRunLoopRef);
956#endif // USE(CF)
957
958 static void setCrashOnVMCreation(bool);
959
960 class DeferExceptionScope {
961 public:
962 DeferExceptionScope(VM& vm)
963 : m_savedException(vm.m_exception, nullptr)
964 , m_savedLastException(vm.m_lastException, nullptr)
965 {
966 }
967
968 private:
969 SetForScope<Exception*> m_savedException;
970 SetForScope<Exception*> m_savedLastException;
971 };
972
973private:
974 friend class LLIntOffsetsExtractor;
975
976 VM(VMType, HeapType);
977 static VM*& sharedInstanceInternal();
978 void createNativeThunk();
979
980 JS_EXPORT_PRIVATE Structure* setIteratorStructureSlow();
981 JS_EXPORT_PRIVATE Structure* mapIteratorStructureSlow();
982 JSCell* sentinelSetBucketSlow();
983 JSCell* sentinelMapBucketSlow();
984 JSPropertyNameEnumerator* emptyPropertyNameEnumeratorSlow();
985
986 void updateStackLimits();
987
988 bool isSafeToRecurse(void* stackLimit) const
989 {
990 void* curr = currentStackPointer();
991 return curr >= stackLimit;
992 }
993
994 void setException(Exception* exception)
995 {
996 m_exception = exception;
997 m_lastException = exception;
998 }
999 Exception* exception() const
1000 {
1001#if ENABLE(EXCEPTION_SCOPE_VERIFICATION)
1002 m_needExceptionCheck = false;
1003#endif
1004 return m_exception;
1005 }
1006 void clearException()
1007 {
1008#if ENABLE(EXCEPTION_SCOPE_VERIFICATION)
1009 m_needExceptionCheck = false;
1010 m_nativeStackTraceOfLastThrow = nullptr;
1011 m_throwingThread = nullptr;
1012#endif
1013 m_exception = nullptr;
1014 }
1015
1016#if ENABLE(C_LOOP)
1017 bool ensureStackCapacityForCLoop(Register* newTopOfStack);
1018 bool isSafeToRecurseSoftCLoop() const;
1019#endif // ENABLE(C_LOOP)
1020
1021 JS_EXPORT_PRIVATE Exception* throwException(JSGlobalObject*, Exception*);
1022 JS_EXPORT_PRIVATE Exception* throwException(JSGlobalObject*, JSValue);
1023 JS_EXPORT_PRIVATE Exception* throwException(JSGlobalObject*, JSObject*);
1024
1025#if ENABLE(EXCEPTION_SCOPE_VERIFICATION)
1026 void verifyExceptionCheckNeedIsSatisfied(unsigned depth, ExceptionEventLocation&);
1027#endif
1028
1029 static void primitiveGigacageDisabledCallback(void*);
1030 void primitiveGigacageDisabled();
1031
1032 void callPromiseRejectionCallback(Strong<JSPromise>&);
1033 void didExhaustMicrotaskQueue();
1034
1035#if ENABLE(GC_VALIDATION)
1036 const ClassInfo* m_initializingObjectClass;
1037#endif
1038
1039 void* m_stackPointerAtVMEntry;
1040 size_t m_currentSoftReservedZoneSize;
1041 void* m_stackLimit { nullptr };
1042 void* m_softStackLimit { nullptr };
1043#if ENABLE(C_LOOP)
1044 void* m_cloopStackLimit { nullptr };
1045#endif
1046 void* m_lastStackTop { nullptr };
1047
1048 Exception* m_exception { nullptr };
1049 Exception* m_lastException { nullptr };
1050#if ENABLE(EXCEPTION_SCOPE_VERIFICATION)
1051 ExceptionScope* m_topExceptionScope { nullptr };
1052 ExceptionEventLocation m_simulatedThrowPointLocation;
1053 unsigned m_simulatedThrowPointRecursionDepth { 0 };
1054 mutable bool m_needExceptionCheck { false };
1055 std::unique_ptr<StackTrace> m_nativeStackTraceOfLastThrow;
1056 std::unique_ptr<StackTrace> m_nativeStackTraceOfLastSimulatedThrow;
1057 RefPtr<Thread> m_throwingThread;
1058#endif
1059
1060 bool m_failNextNewCodeBlock { false };
1061 DeletePropertyMode m_deletePropertyMode { DeletePropertyMode::Default };
1062 bool m_globalConstRedeclarationShouldThrow { true };
1063 bool m_shouldBuildPCToCodeOriginMapping { false };
1064 std::unique_ptr<CodeCache> m_codeCache;
1065 std::unique_ptr<BuiltinExecutables> m_builtinExecutables;
1066 HashMap<String, RefPtr<WatchpointSet>> m_impurePropertyWatchpointSets;
1067 std::unique_ptr<TypeProfiler> m_typeProfiler;
1068 std::unique_ptr<TypeProfilerLog> m_typeProfilerLog;
1069 unsigned m_typeProfilerEnabledCount;
1070 bool m_needToFirePrimitiveGigacageEnabled { false };
1071 Lock m_scratchBufferLock;
1072 Vector<ScratchBuffer*> m_scratchBuffers;
1073 size_t m_sizeOfLastScratchBuffer { 0 };
1074 InlineWatchpointSet m_primitiveGigacageEnabled;
1075 FunctionHasExecutedCache m_functionHasExecutedCache;
1076 std::unique_ptr<ControlFlowProfiler> m_controlFlowProfiler;
1077 unsigned m_controlFlowProfilerEnabledCount;
1078 Deque<std::unique_ptr<QueuedTask>> m_microtaskQueue;
1079 MallocPtr<EncodedJSValue> m_exceptionFuzzBuffer;
1080 VMTraps m_traps;
1081 RefPtr<Watchdog> m_watchdog;
1082 std::unique_ptr<HeapProfiler> m_heapProfiler;
1083#if ENABLE(SAMPLING_PROFILER)
1084 RefPtr<SamplingProfiler> m_samplingProfiler;
1085#endif
1086 std::unique_ptr<FuzzerAgent> m_fuzzerAgent;
1087 std::unique_ptr<ShadowChicken> m_shadowChicken;
1088 std::unique_ptr<BytecodeIntrinsicRegistry> m_bytecodeIntrinsicRegistry;
1089
1090 // FIXME: We should remove handled promises from this list at GC flip. <https://webkit.org/b/201005>
1091 Vector<Strong<JSPromise>> m_aboutToBeNotifiedRejectedPromises;
1092
1093 WTF::Function<void(VM&)> m_onEachMicrotaskTick;
1094 uintptr_t m_currentWeakRefVersion { 0 };
1095
1096#if ENABLE(JIT)
1097#if !ASSERT_DISABLED
1098 JS_EXPORT_PRIVATE static bool s_canUseJITIsSet;
1099#endif
1100 JS_EXPORT_PRIVATE static bool s_canUseJIT;
1101#endif
1102
1103 VM* m_prev; // Required by DoublyLinkedListNode.
1104 VM* m_next; // Required by DoublyLinkedListNode.
1105
1106 // Friends for exception checking purpose only.
1107 friend class Heap;
1108 friend class CatchScope;
1109 friend class ExceptionScope;
1110 friend class JSDollarVMHelper;
1111 friend class ThrowScope;
1112 friend class VMTraps;
1113 friend class WTF::DoublyLinkedListNode<VM>;
1114};
1115
1116#if ENABLE(GC_VALIDATION)
1117inline bool VM::isInitializingObject() const
1118{
1119 return !!m_initializingObjectClass;
1120}
1121
1122inline void VM::setInitializingObjectClass(const ClassInfo* initializingObjectClass)
1123{
1124 m_initializingObjectClass = initializingObjectClass;
1125}
1126#endif
1127
1128inline Heap* WeakSet::heap() const
1129{
1130 return &m_vm->heap;
1131}
1132
1133#if !ENABLE(C_LOOP)
1134extern "C" void sanitizeStackForVMImpl(VM*);
1135#endif
1136
1137JS_EXPORT_PRIVATE void sanitizeStackForVM(VM&);
1138void logSanitizeStack(VM&);
1139
1140} // namespace JSC
1141