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

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

Revert r44521 as it causes regressions on windows for some reason.

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