1 | /*
|
---|
2 | * Copyright (C) 2008 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 <wtf/Forward.h>
|
---|
33 | #include <wtf/HashMap.h>
|
---|
34 | #include <wtf/RefCounted.h>
|
---|
35 | #include "collector.h"
|
---|
36 | #include "SmallStrings.h"
|
---|
37 |
|
---|
38 | struct OpaqueJSClass;
|
---|
39 | struct OpaqueJSClassContextData;
|
---|
40 |
|
---|
41 | namespace JSC {
|
---|
42 |
|
---|
43 | class ArgList;
|
---|
44 | class CommonIdentifiers;
|
---|
45 | class Heap;
|
---|
46 | class IdentifierTable;
|
---|
47 | class JSGlobalObject;
|
---|
48 | class JSObject;
|
---|
49 | class Lexer;
|
---|
50 | class Machine;
|
---|
51 | class Parser;
|
---|
52 | class ParserRefCounted;
|
---|
53 | class StructureID;
|
---|
54 | class UString;
|
---|
55 | struct HashTable;
|
---|
56 |
|
---|
57 | class JSGlobalData : public RefCounted<JSGlobalData> {
|
---|
58 | public:
|
---|
59 | static bool sharedInstanceExists();
|
---|
60 | static JSGlobalData& sharedInstance();
|
---|
61 |
|
---|
62 | static PassRefPtr<JSGlobalData> create();
|
---|
63 | static PassRefPtr<JSGlobalData> createLeaked();
|
---|
64 | ~JSGlobalData();
|
---|
65 |
|
---|
66 | Machine* machine;
|
---|
67 |
|
---|
68 | JSValuePtr exception;
|
---|
69 | #if ENABLE(CTI)
|
---|
70 | void* throwReturnAddress;
|
---|
71 | #endif
|
---|
72 |
|
---|
73 | const HashTable* arrayTable;
|
---|
74 | const HashTable* dateTable;
|
---|
75 | const HashTable* mathTable;
|
---|
76 | const HashTable* numberTable;
|
---|
77 | const HashTable* regExpTable;
|
---|
78 | const HashTable* regExpConstructorTable;
|
---|
79 | const HashTable* stringTable;
|
---|
80 |
|
---|
81 | RefPtr<StructureID> nullProtoStructureID;
|
---|
82 | RefPtr<StructureID> activationStructureID;
|
---|
83 | RefPtr<StructureID> staticScopeStructureID;
|
---|
84 | RefPtr<StructureID> stringStructureID;
|
---|
85 | RefPtr<StructureID> numberStructureID;
|
---|
86 |
|
---|
87 | IdentifierTable* identifierTable;
|
---|
88 | CommonIdentifiers* propertyNames;
|
---|
89 | 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.
|
---|
90 |
|
---|
91 | SmallStrings smallStrings;
|
---|
92 |
|
---|
93 | HashMap<OpaqueJSClass*, OpaqueJSClassContextData*> opaqueJSClassData;
|
---|
94 |
|
---|
95 | HashSet<ParserRefCounted*>* newParserObjects;
|
---|
96 | HashCountedSet<ParserRefCounted*>* parserObjectExtraRefCounts;
|
---|
97 |
|
---|
98 | Lexer* lexer;
|
---|
99 | Parser* parser;
|
---|
100 |
|
---|
101 | JSGlobalObject* head;
|
---|
102 | JSGlobalObject* dynamicGlobalObject;
|
---|
103 |
|
---|
104 | bool isSharedInstance;
|
---|
105 |
|
---|
106 | struct ClientData {
|
---|
107 | virtual ~ClientData() = 0;
|
---|
108 | };
|
---|
109 |
|
---|
110 | ClientData* clientData;
|
---|
111 |
|
---|
112 | HashSet<JSObject*> arrayVisitedElements;
|
---|
113 |
|
---|
114 | Heap heap;
|
---|
115 |
|
---|
116 | private:
|
---|
117 | JSGlobalData(bool isShared = false);
|
---|
118 |
|
---|
119 | static JSGlobalData*& sharedInstanceInternal();
|
---|
120 | };
|
---|
121 |
|
---|
122 | }
|
---|
123 |
|
---|
124 | #endif
|
---|