]>
Commit | Line | Data |
---|---|---|
9dae56ea | 1 | /* |
ba379fdc | 2 | * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. |
9dae56ea A |
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 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. | |
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 | #ifndef JSGlobalData_h | |
30 | #define JSGlobalData_h | |
31 | ||
9dae56ea | 32 | #include "Collector.h" |
f9bf01c6 | 33 | #include "DateInstanceCache.h" |
9dae56ea | 34 | #include "ExecutableAllocator.h" |
ba379fdc | 35 | #include "JITStubs.h" |
9dae56ea | 36 | #include "JSValue.h" |
f9bf01c6 A |
37 | #include "MarkStack.h" |
38 | #include "NumericStrings.h" | |
ba379fdc A |
39 | #include "SmallStrings.h" |
40 | #include "TimeoutChecker.h" | |
f9bf01c6 | 41 | #include "WeakRandom.h" |
ba379fdc A |
42 | #include <wtf/Forward.h> |
43 | #include <wtf/HashMap.h> | |
44 | #include <wtf/RefCounted.h> | |
9dae56ea A |
45 | |
46 | struct OpaqueJSClass; | |
47 | struct OpaqueJSClassContextData; | |
48 | ||
49 | namespace JSC { | |
50 | ||
f9bf01c6 | 51 | class CodeBlock; |
9dae56ea | 52 | class CommonIdentifiers; |
9dae56ea | 53 | class IdentifierTable; |
9dae56ea A |
54 | class Interpreter; |
55 | class JSGlobalObject; | |
56 | class JSObject; | |
57 | class Lexer; | |
58 | class Parser; | |
ba379fdc | 59 | class Stringifier; |
9dae56ea A |
60 | class Structure; |
61 | class UString; | |
ba379fdc | 62 | |
9dae56ea | 63 | struct HashTable; |
f9bf01c6 A |
64 | struct Instruction; |
65 | ||
66 | struct DSTOffsetCache { | |
67 | DSTOffsetCache() | |
68 | { | |
69 | reset(); | |
70 | } | |
71 | ||
72 | void reset() | |
73 | { | |
74 | offset = 0.0; | |
75 | start = 0.0; | |
76 | end = -1.0; | |
77 | increment = 0.0; | |
78 | } | |
79 | ||
80 | double offset; | |
81 | double start; | |
82 | double end; | |
83 | double increment; | |
84 | }; | |
9dae56ea A |
85 | |
86 | class JSGlobalData : public RefCounted<JSGlobalData> { | |
87 | public: | |
ba379fdc A |
88 | struct ClientData { |
89 | virtual ~ClientData() = 0; | |
90 | }; | |
91 | ||
9dae56ea A |
92 | static bool sharedInstanceExists(); |
93 | static JSGlobalData& sharedInstance(); | |
94 | ||
f9bf01c6 | 95 | static PassRefPtr<JSGlobalData> create(); |
9dae56ea | 96 | static PassRefPtr<JSGlobalData> createLeaked(); |
f9bf01c6 | 97 | static PassRefPtr<JSGlobalData> createNonDefault(); |
9dae56ea A |
98 | ~JSGlobalData(); |
99 | ||
100 | #if ENABLE(JSC_MULTIPLE_THREADS) | |
101 | // Will start tracking threads that use the heap, which is resource-heavy. | |
102 | void makeUsableFromMultipleThreads() { heap.makeUsableFromMultipleThreads(); } | |
103 | #endif | |
104 | ||
ba379fdc A |
105 | bool isSharedInstance; |
106 | ClientData* clientData; | |
9dae56ea A |
107 | |
108 | const HashTable* arrayTable; | |
109 | const HashTable* dateTable; | |
ba379fdc | 110 | const HashTable* jsonTable; |
9dae56ea A |
111 | const HashTable* mathTable; |
112 | const HashTable* numberTable; | |
113 | const HashTable* regExpTable; | |
114 | const HashTable* regExpConstructorTable; | |
115 | const HashTable* stringTable; | |
116 | ||
117 | RefPtr<Structure> activationStructure; | |
118 | RefPtr<Structure> interruptedExecutionErrorStructure; | |
119 | RefPtr<Structure> staticScopeStructure; | |
120 | RefPtr<Structure> stringStructure; | |
121 | RefPtr<Structure> notAnObjectErrorStubStructure; | |
122 | RefPtr<Structure> notAnObjectStructure; | |
f9bf01c6 A |
123 | RefPtr<Structure> propertyNameIteratorStructure; |
124 | RefPtr<Structure> getterSetterStructure; | |
125 | RefPtr<Structure> apiWrapperStructure; | |
126 | RefPtr<Structure> dummyMarkableCellStructure; | |
127 | ||
ba379fdc | 128 | #if USE(JSVALUE32) |
9dae56ea A |
129 | RefPtr<Structure> numberStructure; |
130 | #endif | |
131 | ||
f9bf01c6 A |
132 | static void storeVPtrs(); |
133 | static JS_EXPORTDATA void* jsArrayVPtr; | |
134 | static JS_EXPORTDATA void* jsByteArrayVPtr; | |
135 | static JS_EXPORTDATA void* jsStringVPtr; | |
136 | static JS_EXPORTDATA void* jsFunctionVPtr; | |
ba379fdc | 137 | |
9dae56ea A |
138 | IdentifierTable* identifierTable; |
139 | CommonIdentifiers* propertyNames; | |
ba379fdc | 140 | 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. |
9dae56ea | 141 | SmallStrings smallStrings; |
f9bf01c6 A |
142 | NumericStrings numericStrings; |
143 | DateInstanceCache dateInstanceCache; | |
144 | ||
ba379fdc A |
145 | #if ENABLE(ASSEMBLER) |
146 | ExecutableAllocator executableAllocator; | |
147 | #endif | |
9dae56ea A |
148 | |
149 | Lexer* lexer; | |
150 | Parser* parser; | |
ba379fdc A |
151 | Interpreter* interpreter; |
152 | #if ENABLE(JIT) | |
153 | JITThunks jitStubs; | |
154 | #endif | |
155 | TimeoutChecker timeoutChecker; | |
156 | Heap heap; | |
9dae56ea | 157 | |
ba379fdc A |
158 | JSValue exception; |
159 | #if ENABLE(JIT) | |
160 | ReturnAddressPtr exceptionLocation; | |
161 | #endif | |
9dae56ea | 162 | |
ba379fdc A |
163 | const Vector<Instruction>& numericCompareFunction(ExecState*); |
164 | Vector<Instruction> lazyNumericCompareFunction; | |
165 | bool initializingLazyNumericCompareFunction; | |
9dae56ea | 166 | |
ba379fdc | 167 | HashMap<OpaqueJSClass*, OpaqueJSClassContextData*> opaqueJSClassData; |
9dae56ea | 168 | |
ba379fdc A |
169 | JSGlobalObject* head; |
170 | JSGlobalObject* dynamicGlobalObject; | |
9dae56ea A |
171 | |
172 | HashSet<JSObject*> arrayVisitedElements; | |
173 | ||
f9bf01c6 | 174 | CodeBlock* functionCodeBlockBeingReparsed; |
ba379fdc | 175 | Stringifier* firstStringifierToMark; |
9dae56ea | 176 | |
f9bf01c6 A |
177 | MarkStack markStack; |
178 | ||
179 | double cachedUTCOffset; | |
180 | DSTOffsetCache dstOffsetCache; | |
181 | ||
182 | UString cachedDateString; | |
183 | double cachedDateStringValue; | |
184 | ||
185 | WeakRandom weakRandom; | |
186 | ||
187 | #ifndef NDEBUG | |
188 | bool mainThreadOnly; | |
189 | #endif | |
190 | ||
191 | void resetDateCache(); | |
192 | ||
193 | void startSampling(); | |
194 | void stopSampling(); | |
195 | void dumpSampleData(ExecState* exec); | |
9dae56ea | 196 | private: |
f9bf01c6 | 197 | JSGlobalData(bool isShared); |
9dae56ea | 198 | static JSGlobalData*& sharedInstanceInternal(); |
ba379fdc | 199 | void createNativeThunk(); |
9dae56ea | 200 | }; |
f9bf01c6 | 201 | |
ba379fdc | 202 | } // namespace JSC |
9dae56ea | 203 | |
ba379fdc | 204 | #endif // JSGlobalData_h |