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 "ExecutableAllocator.h"
36
#include "MarkStack.h"
37
#include "NumericStrings.h"
38
#include "SmallStrings.h"
39
#include "TimeoutChecker.h"
40
#include <wtf/Forward.h>
41
#include <wtf/HashMap.h>
42
#include <wtf/RefCounted.h>
45
struct OpaqueJSClassContextData;
50
class CommonIdentifiers;
51
class IdentifierTable;
65
class JSGlobalData : public RefCounted<JSGlobalData> {
68
virtual ~ClientData() = 0;
69
#ifdef QT_BUILD_SCRIPT_LIB
70
virtual void mark(MarkStack&) {}
74
static bool sharedInstanceExists();
75
static JSGlobalData& sharedInstance();
77
static PassRefPtr<JSGlobalData> create(bool isShared = false);
78
static PassRefPtr<JSGlobalData> createLeaked();
81
#if ENABLE(JSC_MULTIPLE_THREADS)
82
// Will start tracking threads that use the heap, which is resource-heavy.
83
void makeUsableFromMultipleThreads() { heap.makeUsableFromMultipleThreads(); }
86
bool isSharedInstance;
87
ClientData* clientData;
89
const HashTable* arrayTable;
90
const HashTable* dateTable;
91
const HashTable* jsonTable;
92
const HashTable* mathTable;
93
const HashTable* numberTable;
94
const HashTable* regExpTable;
95
const HashTable* regExpConstructorTable;
96
const HashTable* stringTable;
98
RefPtr<Structure> activationStructure;
99
RefPtr<Structure> interruptedExecutionErrorStructure;
100
RefPtr<Structure> staticScopeStructure;
101
RefPtr<Structure> stringStructure;
102
RefPtr<Structure> notAnObjectErrorStubStructure;
103
RefPtr<Structure> notAnObjectStructure;
104
RefPtr<Structure> propertyNameIteratorStructure;
105
RefPtr<Structure> getterSetterStructure;
106
RefPtr<Structure> apiWrapperStructure;
109
RefPtr<Structure> numberStructure;
113
void* jsByteArrayVPtr;
115
void* jsFunctionVPtr;
117
IdentifierTable* identifierTable;
118
CommonIdentifiers* propertyNames;
119
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.
120
SmallStrings smallStrings;
121
NumericStrings numericStrings;
123
#if ENABLE(ASSEMBLER)
124
ExecutableAllocator executableAllocator;
129
Interpreter* interpreter;
133
TimeoutChecker* timeoutChecker;
138
ReturnAddressPtr exceptionLocation;
141
const Vector<Instruction>& numericCompareFunction(ExecState*);
142
Vector<Instruction> lazyNumericCompareFunction;
143
bool initializingLazyNumericCompareFunction;
145
HashMap<OpaqueJSClass*, OpaqueJSClassContextData*> opaqueJSClassData;
147
JSGlobalObject* head;
148
JSGlobalObject* dynamicGlobalObject;
150
HashSet<JSObject*> arrayVisitedElements;
152
CodeBlock* functionCodeBlockBeingReparsed;
153
Stringifier* firstStringifierToMark;
162
JSGlobalData(bool isShared, const VPtrSet&);
163
static JSGlobalData*& sharedInstanceInternal();
164
void createNativeThunk();
169
#endif // JSGlobalData_h