2 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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 Computer, 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.
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.
29 #ifndef JSGlobalData_h
30 #define JSGlobalData_h
32 #include "Collector.h"
33 #include "DateInstanceCache.h"
34 #include "ExecutableAllocator.h"
37 #include "MarkStack.h"
38 #include "NumericStrings.h"
39 #include "SmallStrings.h"
40 #include "TimeoutChecker.h"
41 #include "WeakRandom.h"
42 #include <wtf/Forward.h>
43 #include <wtf/HashMap.h>
44 #include <wtf/RefCounted.h>
47 struct OpaqueJSClassContextData
;
52 class CommonIdentifiers
;
53 class IdentifierTable
;
67 struct DSTOffsetCache
{
87 class JSGlobalData
: public RefCounted
<JSGlobalData
> {
90 virtual ~ClientData() = 0;
93 static bool sharedInstanceExists();
94 static JSGlobalData
& sharedInstance();
96 static PassRefPtr
<JSGlobalData
> create(bool isShared
= false);
97 static PassRefPtr
<JSGlobalData
> createLeaked();
100 #if ENABLE(JSC_MULTIPLE_THREADS)
101 // Will start tracking threads that use the heap, which is resource-heavy.
102 void makeUsableFromMultipleThreads() { heap
.makeUsableFromMultipleThreads(); }
105 bool isSharedInstance
;
106 ClientData
* clientData
;
108 const HashTable
* arrayTable
;
109 const HashTable
* dateTable
;
110 const HashTable
* jsonTable
;
111 const HashTable
* mathTable
;
112 const HashTable
* numberTable
;
113 const HashTable
* regExpTable
;
114 const HashTable
* regExpConstructorTable
;
115 const HashTable
* stringTable
;
117 RefPtr
<Structure
> activationStructure
;
118 RefPtr
<Structure
> interruptedExecutionErrorStructure
;
119 RefPtr
<Structure
> staticScopeStructure
;
120 RefPtr
<Structure
> stringStructure
;
121 RefPtr
<Structure
> notAnObjectErrorStubStructure
;
122 RefPtr
<Structure
> notAnObjectStructure
;
123 RefPtr
<Structure
> propertyNameIteratorStructure
;
124 RefPtr
<Structure
> getterSetterStructure
;
125 RefPtr
<Structure
> apiWrapperStructure
;
126 RefPtr
<Structure
> dummyMarkableCellStructure
;
129 RefPtr
<Structure
> numberStructure
;
133 void* jsByteArrayVPtr
;
135 void* jsFunctionVPtr
;
137 IdentifierTable
* identifierTable
;
138 CommonIdentifiers
* propertyNames
;
139 const MarkedArgumentBuffer
* emptyList
; // Lists are supposed to be allocated on the stack to have their elements properly marked, which is not the case here - but this list has nothing to mark.
140 SmallStrings smallStrings
;
141 NumericStrings numericStrings
;
142 DateInstanceCache dateInstanceCache
;
144 #if ENABLE(ASSEMBLER)
145 ExecutableAllocator executableAllocator
;
150 Interpreter
* interpreter
;
154 TimeoutChecker timeoutChecker
;
159 ReturnAddressPtr exceptionLocation
;
162 const Vector
<Instruction
>& numericCompareFunction(ExecState
*);
163 Vector
<Instruction
> lazyNumericCompareFunction
;
164 bool initializingLazyNumericCompareFunction
;
166 HashMap
<OpaqueJSClass
*, OpaqueJSClassContextData
*> opaqueJSClassData
;
168 JSGlobalObject
* head
;
169 JSGlobalObject
* dynamicGlobalObject
;
171 HashSet
<JSObject
*> arrayVisitedElements
;
173 CodeBlock
* functionCodeBlockBeingReparsed
;
174 Stringifier
* firstStringifierToMark
;
178 double cachedUTCOffset
;
179 DSTOffsetCache dstOffsetCache
;
181 UString cachedDateString
;
182 double cachedDateStringValue
;
184 WeakRandom weakRandom
;
190 void resetDateCache();
192 void startSampling();
194 void dumpSampleData(ExecState
* exec
);
196 JSGlobalData(bool isShared
, const VPtrSet
&);
197 static JSGlobalData
*& sharedInstanceInternal();
198 void createNativeThunk();
203 #endif // JSGlobalData_h