2 * Copyright (C) 2008 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 <wtf/Forward.h>
33 #include <wtf/HashMap.h>
34 #include <wtf/RefCounted.h>
35 #include "Collector.h"
36 #include "ExecutableAllocator.h"
37 #include "SmallStrings.h"
41 struct OpaqueJSClassContextData;
46 class CommonIdentifiers;
48 class IdentifierTable;
54 class ParserRefCounted;
60 class JSGlobalData : public RefCounted<JSGlobalData> {
62 static bool sharedInstanceExists();
63 static JSGlobalData& sharedInstance();
65 static PassRefPtr<JSGlobalData> create();
66 static PassRefPtr<JSGlobalData> createLeaked();
69 #if ENABLE(JSC_MULTIPLE_THREADS)
70 // Will start tracking threads that use the heap, which is resource-heavy.
71 void makeUsableFromMultipleThreads() { heap.makeUsableFromMultipleThreads(); }
74 Interpreter* interpreter;
78 void* exceptionLocation;
81 const HashTable* arrayTable;
82 const HashTable* dateTable;
83 const HashTable* mathTable;
84 const HashTable* numberTable;
85 const HashTable* regExpTable;
86 const HashTable* regExpConstructorTable;
87 const HashTable* stringTable;
89 RefPtr<Structure> activationStructure;
90 RefPtr<Structure> interruptedExecutionErrorStructure;
91 RefPtr<Structure> staticScopeStructure;
92 RefPtr<Structure> stringStructure;
93 RefPtr<Structure> notAnObjectErrorStubStructure;
94 RefPtr<Structure> notAnObjectStructure;
95 RefPtr<Structure> numberStructure;
97 IdentifierTable* identifierTable;
98 CommonIdentifiers* propertyNames;
99 const ArgList* 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.
101 SmallStrings smallStrings;
103 HashMap<OpaqueJSClass*, OpaqueJSClassContextData*> opaqueJSClassData;
105 HashSet<ParserRefCounted*>* newParserObjects;
106 HashCountedSet<ParserRefCounted*>* parserObjectExtraRefCounts;
111 JSGlobalObject* head;
112 JSGlobalObject* dynamicGlobalObject;
114 bool isSharedInstance;
117 virtual ~ClientData() = 0;
120 ClientData* clientData;
122 HashSet<JSObject*> arrayVisitedElements;
124 ScopeNode* scopeNodeBeingReparsed;
127 #if ENABLE(ASSEMBLER)
128 PassRefPtr<ExecutablePool> poolForSize(size_t n) { return m_executableAllocator.poolForSize(n); }
131 JSGlobalData(bool isShared = false);
132 #if ENABLE(ASSEMBLER)
133 ExecutableAllocator m_executableAllocator;
136 static JSGlobalData*& sharedInstanceInternal();