]> git.saurik.com Git - apple/javascriptcore.git/blob - runtime/JSGlobalData.h
JavaScriptCore-554.1.tar.gz
[apple/javascriptcore.git] / runtime / JSGlobalData.h
1 /*
2 * Copyright (C) 2008, 2009 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 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
32 #include "Collector.h"
33 #include "ExecutableAllocator.h"
34 #include "JITStubs.h"
35 #include "JSValue.h"
36 #include "SmallStrings.h"
37 #include "TimeoutChecker.h"
38 #include <wtf/Forward.h>
39 #include <wtf/HashMap.h>
40 #include <wtf/RefCounted.h>
41
42 struct OpaqueJSClass;
43 struct OpaqueJSClassContextData;
44
45 namespace JSC {
46
47 class CommonIdentifiers;
48 class FunctionBodyNode;
49 class IdentifierTable;
50 class Instruction;
51 class Interpreter;
52 class JSGlobalObject;
53 class JSObject;
54 class Lexer;
55 class Parser;
56 class ScopeNode;
57 class Stringifier;
58 class Structure;
59 class UString;
60
61 struct HashTable;
62 struct VPtrSet;
63
64 class JSGlobalData : public RefCounted<JSGlobalData> {
65 public:
66 struct ClientData {
67 virtual ~ClientData() = 0;
68 };
69
70 static bool sharedInstanceExists();
71 static JSGlobalData& sharedInstance();
72
73 static PassRefPtr<JSGlobalData> create(bool isShared = false);
74 static PassRefPtr<JSGlobalData> createLeaked();
75 ~JSGlobalData();
76
77 #if ENABLE(JSC_MULTIPLE_THREADS)
78 // Will start tracking threads that use the heap, which is resource-heavy.
79 void makeUsableFromMultipleThreads() { heap.makeUsableFromMultipleThreads(); }
80 #endif
81
82 bool isSharedInstance;
83 ClientData* clientData;
84
85 const HashTable* arrayTable;
86 const HashTable* dateTable;
87 const HashTable* jsonTable;
88 const HashTable* mathTable;
89 const HashTable* numberTable;
90 const HashTable* regExpTable;
91 const HashTable* regExpConstructorTable;
92 const HashTable* stringTable;
93
94 RefPtr<Structure> activationStructure;
95 RefPtr<Structure> interruptedExecutionErrorStructure;
96 RefPtr<Structure> staticScopeStructure;
97 RefPtr<Structure> stringStructure;
98 RefPtr<Structure> notAnObjectErrorStubStructure;
99 RefPtr<Structure> notAnObjectStructure;
100 #if USE(JSVALUE32)
101 RefPtr<Structure> numberStructure;
102 #endif
103
104 void* jsArrayVPtr;
105 void* jsByteArrayVPtr;
106 void* jsStringVPtr;
107 void* jsFunctionVPtr;
108
109 IdentifierTable* identifierTable;
110 CommonIdentifiers* propertyNames;
111 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.
112 SmallStrings smallStrings;
113
114 #if ENABLE(ASSEMBLER)
115 ExecutableAllocator executableAllocator;
116 #endif
117
118 Lexer* lexer;
119 Parser* parser;
120 Interpreter* interpreter;
121 #if ENABLE(JIT)
122 JITThunks jitStubs;
123 #endif
124 TimeoutChecker timeoutChecker;
125 Heap heap;
126
127 JSValue exception;
128 #if ENABLE(JIT)
129 ReturnAddressPtr exceptionLocation;
130 #endif
131
132 const Vector<Instruction>& numericCompareFunction(ExecState*);
133 Vector<Instruction> lazyNumericCompareFunction;
134 bool initializingLazyNumericCompareFunction;
135
136 HashMap<OpaqueJSClass*, OpaqueJSClassContextData*> opaqueJSClassData;
137
138 JSGlobalObject* head;
139 JSGlobalObject* dynamicGlobalObject;
140
141 HashSet<JSObject*> arrayVisitedElements;
142
143 ScopeNode* scopeNodeBeingReparsed;
144 Stringifier* firstStringifierToMark;
145
146 private:
147 JSGlobalData(bool isShared, const VPtrSet&);
148 static JSGlobalData*& sharedInstanceInternal();
149 void createNativeThunk();
150 };
151
152 } // namespace JSC
153
154 #endif // JSGlobalData_h