source: webkit/trunk/JavaScriptCore/runtime/JSGlobalData.h@ 48788

Last change on this file since 48788 was 48315, checked in by [email protected], 16 years ago

Reviewed by Geoff Garen.

https://bugs.webkit.org/show_bug.cgi?id=29207
Add checks for using WebCore JS context on secondary threads

  • Property svn:eol-style set to native
File size: 5.3 KB
Line 
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 "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>
43
44struct OpaqueJSClass;
45struct OpaqueJSClassContextData;
46
47namespace JSC {
48
49 class CodeBlock;
50 class CommonIdentifiers;
51 class IdentifierTable;
52 class Interpreter;
53 class JSGlobalObject;
54 class JSObject;
55 class Lexer;
56 class Parser;
57 class Stringifier;
58 class Structure;
59 class UString;
60
61 struct HashTable;
62 struct Instruction;
63 struct VPtrSet;
64
65 class JSGlobalData : public RefCounted<JSGlobalData> {
66 public:
67 struct ClientData {
68 virtual ~ClientData() = 0;
69 };
70
71 static bool sharedInstanceExists();
72 static JSGlobalData& sharedInstance();
73
74 static PassRefPtr<JSGlobalData> create(bool isShared = false);
75 static PassRefPtr<JSGlobalData> createLeaked();
76 ~JSGlobalData();
77
78#if ENABLE(JSC_MULTIPLE_THREADS)
79 // Will start tracking threads that use the heap, which is resource-heavy.
80 void makeUsableFromMultipleThreads() { heap.makeUsableFromMultipleThreads(); }
81#endif
82
83 bool isSharedInstance;
84 ClientData* clientData;
85
86 const HashTable* arrayTable;
87 const HashTable* dateTable;
88 const HashTable* jsonTable;
89 const HashTable* mathTable;
90 const HashTable* numberTable;
91 const HashTable* regExpTable;
92 const HashTable* regExpConstructorTable;
93 const HashTable* stringTable;
94
95 RefPtr<Structure> activationStructure;
96 RefPtr<Structure> interruptedExecutionErrorStructure;
97 RefPtr<Structure> staticScopeStructure;
98 RefPtr<Structure> stringStructure;
99 RefPtr<Structure> notAnObjectErrorStubStructure;
100 RefPtr<Structure> notAnObjectStructure;
101 RefPtr<Structure> propertyNameIteratorStructure;
102 RefPtr<Structure> getterSetterStructure;
103 RefPtr<Structure> apiWrapperStructure;
104
105#if USE(JSVALUE32)
106 RefPtr<Structure> numberStructure;
107#endif
108
109 void* jsArrayVPtr;
110 void* jsByteArrayVPtr;
111 void* jsStringVPtr;
112 void* jsFunctionVPtr;
113
114 IdentifierTable* identifierTable;
115 CommonIdentifiers* propertyNames;
116 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.
117 SmallStrings smallStrings;
118 NumericStrings numericStrings;
119
120#if ENABLE(ASSEMBLER)
121 ExecutableAllocator executableAllocator;
122#endif
123
124 Lexer* lexer;
125 Parser* parser;
126 Interpreter* interpreter;
127#if ENABLE(JIT)
128 JITThunks jitStubs;
129#endif
130 TimeoutChecker timeoutChecker;
131 Heap heap;
132
133 JSValue exception;
134#if ENABLE(JIT)
135 ReturnAddressPtr exceptionLocation;
136#endif
137
138 const Vector<Instruction>& numericCompareFunction(ExecState*);
139 Vector<Instruction> lazyNumericCompareFunction;
140 bool initializingLazyNumericCompareFunction;
141
142 HashMap<OpaqueJSClass*, OpaqueJSClassContextData*> opaqueJSClassData;
143
144 JSGlobalObject* head;
145 JSGlobalObject* dynamicGlobalObject;
146
147 HashSet<JSObject*> arrayVisitedElements;
148
149 CodeBlock* functionCodeBlockBeingReparsed;
150 Stringifier* firstStringifierToMark;
151
152 MarkStack markStack;
153
154#ifndef NDEBUG
155 bool mainThreadOnly;
156#endif
157
158 private:
159 JSGlobalData(bool isShared, const VPtrSet&);
160 static JSGlobalData*& sharedInstanceInternal();
161 void createNativeThunk();
162 };
163
164} // namespace JSC
165
166#endif // JSGlobalData_h
Note: See TracBrowser for help on using the repository browser.