source: webkit/trunk/JavaScriptCore/kjs/JSGlobalData.cpp@ 36755

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

JavaScriptCore:

2008-09-21 Maciej Stachowiak <[email protected]>

Reviewed by Darin.


  • JavaScriptCore.exp:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • VM/CTI.cpp: (JSC::CTI::privateCompileMainPass): (JSC::CTI::privateCompilePutByIdTransition):
  • VM/Machine.cpp: (JSC::jsIsObjectType): (JSC::Machine::Machine):
  • kjs/AllInOneFile.cpp:
  • kjs/JSCell.h: (JSC::JSCell::isObject): (JSC::JSCell::isString):
  • kjs/JSGlobalData.cpp: (JSC::JSGlobalData::JSGlobalData):
  • kjs/JSGlobalObject.cpp: (JSC::JSGlobalObject::reset):
  • kjs/JSGlobalObject.h: (JSC::StructureID::prototypeForLookup):
  • kjs/JSNumberCell.h: (JSC::JSNumberCell::createStructureID):
  • kjs/JSObject.cpp: (JSC::JSObject::createInheritorID):
  • kjs/JSObject.h: (JSC::JSObject::createStructureID):
  • kjs/JSString.h: (JSC::JSString::createStructureID):
  • kjs/NativeErrorConstructor.cpp: (JSC::NativeErrorConstructor::NativeErrorConstructor):
  • kjs/RegExpConstructor.cpp:
  • kjs/RegExpMatchesArray.h: Added. (JSC::RegExpMatchesArray::getOwnPropertySlot): (JSC::RegExpMatchesArray::put): (JSC::RegExpMatchesArray::deleteProperty): (JSC::RegExpMatchesArray::getPropertyNames):
  • kjs/StructureID.cpp: (JSC::StructureID::StructureID): (JSC::StructureID::addPropertyTransition): (JSC::StructureID::toDictionaryTransition): (JSC::StructureID::changePrototypeTransition): (JSC::StructureID::getterSetterTransition):
  • kjs/StructureID.h: (JSC::StructureID::create): (JSC::StructureID::typeInfo):
  • kjs/TypeInfo.h: Added. (JSC::TypeInfo::TypeInfo): (JSC::TypeInfo::type):

WebCore:

2008-09-21 Maciej Stachowiak <[email protected]>

Reviewed by Darin.


  • bindings/js/JSAudioConstructor.cpp: (WebCore::JSAudioConstructor::JSAudioConstructor):
  • bindings/js/JSCSSStyleDeclarationCustom.cpp: (WebCore::JSCSSStyleDeclaration::nameGetter):
  • bindings/js/JSDOMBinding.cpp: (WebCore::createDOMStructure):
  • bindings/js/JSDOMBinding.h: (WebCore::getDOMStructure):
  • bindings/js/JSDOMWindowShell.cpp: (WebCore::JSDOMWindowShell::JSDOMWindowShell): (WebCore::JSDOMWindowShell::setWindow):
  • bindings/js/JSEventTargetNode.cpp: (WebCore::JSEventTargetNode::createPrototype):
  • bindings/js/JSHTMLOptionElementConstructor.cpp: (WebCore::JSHTMLOptionElementConstructor::JSHTMLOptionElementConstructor):
  • bindings/js/JSImageConstructor.cpp: (WebCore::JSImageConstructor::JSImageConstructor):
  • bindings/js/JSXMLHttpRequestConstructor.cpp: (WebCore::JSXMLHttpRequestConstructor::JSXMLHttpRequestConstructor):
  • bindings/js/JSXSLTProcessorConstructor.cpp: (WebCore::JSXSLTProcessorConstructor::JSXSLTProcessorConstructor):
  • bindings/scripts/CodeGeneratorJS.pm:
  • Property svn:eol-style set to native
File size: 4.9 KB
Line 
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#include "config.h"
30#include "JSGlobalData.h"
31
32#include "ArgList.h"
33#include "CommonIdentifiers.h"
34#include "JSClassRef.h"
35#include "JSLock.h"
36#include "Machine.h"
37#include "Parser.h"
38#include "collector.h"
39#include "lexer.h"
40#include "lookup.h"
41#include "nodes.h"
42
43#if ENABLE(JSC_MULTIPLE_THREADS)
44#include <wtf/Threading.h>
45#endif
46
47using namespace WTF;
48
49namespace JSC {
50
51extern const HashTable arrayTable;
52extern const HashTable dateTable;
53extern const HashTable mathTable;
54extern const HashTable numberTable;
55extern const HashTable regExpTable;
56extern const HashTable regExpConstructorTable;
57extern const HashTable stringTable;
58
59JSGlobalData::JSGlobalData(bool isShared)
60 : machine(new Machine)
61 , heap(new Heap(this))
62#if ENABLE(JSC_MULTIPLE_THREADS)
63 , arrayTable(new HashTable(JSC::arrayTable))
64 , dateTable(new HashTable(JSC::dateTable))
65 , mathTable(new HashTable(JSC::mathTable))
66 , numberTable(new HashTable(JSC::numberTable))
67 , regExpTable(new HashTable(JSC::regExpTable))
68 , regExpConstructorTable(new HashTable(JSC::regExpConstructorTable))
69 , stringTable(new HashTable(JSC::stringTable))
70#else
71 , arrayTable(&JSC::arrayTable)
72 , dateTable(&JSC::dateTable)
73 , mathTable(&JSC::mathTable)
74 , numberTable(&JSC::numberTable)
75 , regExpTable(&JSC::regExpTable)
76 , regExpConstructorTable(&JSC::regExpConstructorTable)
77 , stringTable(&JSC::stringTable)
78#endif
79 , nullProtoStructureID(JSObject::createStructureID(jsNull()))
80 , stringStructureID(JSString::createStructureID(jsNull()))
81 , numberStructureID(JSNumberCell::createStructureID(jsNull()))
82 , identifierTable(createIdentifierTable())
83 , propertyNames(new CommonIdentifiers(this))
84 , emptyList(new ArgList)
85 , opaqueJSClassData(new HashMap<OpaqueJSClass*, OpaqueJSClassContextData*>)
86 , newParserObjects(0)
87 , parserObjectExtraRefCounts(0)
88 , lexer(new Lexer(this))
89 , parser(new Parser)
90 , head(0)
91 , isSharedInstance(isShared)
92{
93}
94
95JSGlobalData::~JSGlobalData()
96{
97 delete heap;
98 delete machine;
99#ifndef NDEBUG
100 // Zeroing out to make the behavior more predictable when someone attempts to use a deleted instance.
101 heap = 0;
102 machine = 0;
103#endif
104
105#if ENABLE(JSC_MULTIPLE_THREADS)
106 arrayTable->deleteTable();
107 dateTable->deleteTable();
108 mathTable->deleteTable();
109 numberTable->deleteTable();
110 regExpTable->deleteTable();
111 regExpConstructorTable->deleteTable();
112 stringTable->deleteTable();
113 delete arrayTable;
114 delete dateTable;
115 delete mathTable;
116 delete numberTable;
117 delete regExpTable;
118 delete regExpConstructorTable;
119 delete stringTable;
120#endif
121
122 delete parser;
123 delete lexer;
124
125 deleteAllValues(*opaqueJSClassData);
126 delete opaqueJSClassData;
127
128 delete emptyList;
129
130 delete propertyNames;
131 deleteIdentifierTable(identifierTable);
132
133 delete newParserObjects;
134 delete parserObjectExtraRefCounts;
135}
136
137PassRefPtr<JSGlobalData> JSGlobalData::create()
138{
139 return adoptRef(new JSGlobalData);
140}
141
142bool JSGlobalData::sharedInstanceExists()
143{
144 return sharedInstanceInternal();
145}
146
147JSGlobalData& JSGlobalData::sharedInstance()
148{
149 JSGlobalData*& instance = sharedInstanceInternal();
150 if (!instance)
151 instance = new JSGlobalData(true);
152 return *instance;
153}
154
155JSGlobalData*& JSGlobalData::sharedInstanceInternal()
156{
157 ASSERT(JSLock::currentThreadIsHoldingLock());
158 static JSGlobalData* sharedInstance;
159 return sharedInstance;
160}
161
162}
Note: See TracBrowser for help on using the repository browser.