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

Last change on this file since 37747 was 37705, checked in by Darin Adler, 17 years ago

JavaScriptCore:

2008-10-18 Darin Adler <Darin Adler>

Reviewed by Oliver Hunt.

Tweak a little more to get closer to where we can make JSValuePtr a class.

  • API/APICast.h: (toJS): Change back to JSValue* here, since we're converting the pointer type.
  • VM/CTI.cpp: (JSC::CTI::unlinkCall): Call asPointer.
  • VM/CTI.h: Cast to JSValue* here, since it's a pointer cast.
  • kjs/DebuggerCallFrame.h: (JSC::DebuggerCallFrame::DebuggerCallFrame): Call noValue.
  • kjs/JSGlobalData.cpp: (JSC::JSGlobalData::JSGlobalData): Call noValue.
  • kjs/JSImmediate.cpp: (JSC::JSImmediate::toObject): Remove unneeded const_cast.
  • kjs/JSWrapperObject.h: (JSC::JSWrapperObject::JSWrapperObject): Call noValue.

JavaScriptGlue:

2008-10-18 Darin Adler <Darin Adler>

Reviewed by Oliver Hunt.

Tweak a little more to get closer to where we can make JSValuePtr a class.

  • JSObject.cpp: (nativeCallFunction): Call asObject.
  • JSUtils.cpp: (KJSValueToJSObject): Use JSValuePtr and asObject. (JSObjectKJSValue): Ditto. (KJSValueToCFTypeInternal): Ditto. (KJSValueToCFType): Ditto.
  • JSUtils.h: Ditto.
  • UserObjectImp.cpp: (UserObjectImp::callAsFunction): Use JSValuePtr and asObject. (UserObjectImp::userObjectGetter): Ditto. (UserObjectImp::getOwnPropertySlot): Ditto. (UserObjectImp::put): Ditto. (UserObjectImp::toPrimitive): Ditto.
  • UserObjectImp.h: Ditto.

WebCore:

2008-10-18 Darin Adler <Darin Adler>

Reviewed by Oliver Hunt.

Tweak a little more to get closer to where we can make JSValuePtr a class.

  • bindings/js/JSAudioConstructor.cpp: (WebCore::JSAudioConstructor::JSAudioConstructor): Use asObject. (WebCore::constructAudio): Ditto.
  • bindings/js/JSCSSStyleDeclarationCustom.cpp: (WebCore::JSCSSStyleDeclaration::nameGetter): Ditto.
  • bindings/js/JSCanvasRenderingContext2DCustom.cpp: (WebCore::toHTMLCanvasStyle): Use asString and asObject. (WebCore::JSCanvasRenderingContext2D::setFillColor): Ditto. (WebCore::JSCanvasRenderingContext2D::setStrokeColor): Ditto. (WebCore::JSCanvasRenderingContext2D::drawImage): Ditto. (WebCore::JSCanvasRenderingContext2D::drawImageFromRect): Ditto. (WebCore::JSCanvasRenderingContext2D::setShadow): Ditto. (WebCore::JSCanvasRenderingContext2D::createPattern): Ditto.
  • bindings/js/JSCustomSQLTransactionErrorCallback.cpp: (WebCore::JSCustomSQLTransactionErrorCallback::handleEvent): Use JSValuePtr.
  • bindings/js/JSDOMBinding.cpp: (WebCore::setDOMException): Use noValue.
  • bindings/js/JSDOMBinding.h: (WebCore::getDOMPrototype): Use asObject.
  • bindings/js/JSDOMWindowBase.cpp: (WebCore::showModalDialog): Use noValue. (jsDOMWindowBaseEvent): Use asObject. (jsDOMWindowBaseImage): Ditto. (jsDOMWindowBaseMessageChannel): Ditto. (jsDOMWindowBaseOption): Ditto. (jsDOMWindowBaseXMLHttpRequest): Ditto. (jsDOMWindowBaseAudio): Ditto. (jsDOMWindowBaseXSLTProcessor): Ditto. (WebCore::JSDOMWindowBase::childFrameGetter): Ditto. (WebCore::JSDOMWindowBase::indexGetter): Ditto. (WebCore::JSDOMWindowBase::namedItemGetter): Ditto. (WebCore::JSDOMWindowBase::getOwnPropertySlot): Ditto. (WebCore::JSDOMWindowBase::findJSEventListener): Ditto. (WebCore::JSDOMWindowBase::findOrCreateJSEventListener): Ditto. (WebCore::JSDOMWindowBase::findJSUnprotectedEventListener): Ditto. (WebCore::JSDOMWindowBase::findOrCreateJSUnprotectedEventListener): Ditto. (windowProtoFuncOpen): Use noValue. (WebCore::toJSDOMWindow): Use asObject.
  • bindings/js/JSDOMWindowCustom.cpp: (WebCore::setTimeoutOrInterval): Use asString. (WebCore::toDOMWindow): Use asObject.
  • bindings/js/JSEventListener.cpp: (WebCore::JSAbstractEventListener::handleEvent): Use noValue. (WebCore::JSLazyEventListener::parseCode): Use asObject.
  • bindings/js/JSHTMLCollectionCustom.cpp: (WebCore::JSHTMLCollection::nameGetter): Use asObject.
  • bindings/js/JSHTMLDocumentCustom.cpp: (WebCore::JSHTMLDocument::nameGetter): Ditto.
  • bindings/js/JSHTMLElementCustom.cpp: (WebCore::JSHTMLElement::pushEventHandlerScope): Ditto.
  • bindings/js/JSHTMLFormElementCustom.cpp: (WebCore::JSHTMLFormElement::nameGetter): Ditto.
  • bindings/js/JSHTMLFrameSetElementCustom.cpp: (WebCore::JSHTMLFrameSetElement::nameGetter): Ditto.
  • bindings/js/JSHTMLOptionElementConstructor.cpp: (WebCore::JSHTMLOptionElementConstructor::JSHTMLOptionElementConstructor): Ditto. (WebCore::constructHTMLOptionElement): Ditto.
  • bindings/js/JSHTMLOptionsCollectionCustom.cpp: (WebCore::JSHTMLOptionsCollection::remove): Ditto.
  • bindings/js/JSImageConstructor.cpp: (WebCore::JSImageConstructor::JSImageConstructor): Ditto. (WebCore::constructImage): Ditto.
  • bindings/js/JSInspectedObjectWrapper.cpp: (WebCore::JSInspectedObjectWrapper::wrap): Ditto.
  • bindings/js/JSInspectorCallbackWrapper.cpp: (WebCore::JSInspectorCallbackWrapper::wrap): Ditto.
  • bindings/js/JSJavaScriptCallFrameCustom.cpp: (WebCore::JSJavaScriptCallFrame::evaluate): Use noValue.
  • bindings/js/JSMessageChannelConstructor.cpp: (WebCore::JSMessageChannelConstructor::JSMessageChannelConstructor): Use asObject. (WebCore::JSMessageChannelConstructor::construct): Ditto.
  • bindings/js/JSMimeTypeArrayCustom.cpp: (WebCore::JSMimeTypeArray::nameGetter): Ditto.
  • bindings/js/JSNamedNodeMapCustom.cpp: (WebCore::JSNamedNodeMap::nameGetter): Ditto.
  • bindings/js/JSNamedNodesCollection.cpp: (WebCore::JSNamedNodesCollection::lengthGetter): Ditto. (WebCore::JSNamedNodesCollection::indexGetter): Ditto.
  • bindings/js/JSNodeFilterCustom.cpp: (WebCore::toNodeFilter): Ditto.
  • bindings/js/JSNodeListCustom.cpp: (WebCore::JSNodeList::nameGetter): Ditto.
  • bindings/js/JSPluginArrayCustom.cpp: (WebCore::JSPluginArray::nameGetter): Ditto.
  • bindings/js/JSPluginCustom.cpp: (WebCore::JSPlugin::nameGetter): Ditto.
  • bindings/js/JSPluginElementFunctions.cpp: (WebCore::runtimeObjectGetter): Ditto. (WebCore::runtimeObjectPropertyGetter): Ditto.
  • bindings/js/JSQuarantinedObjectWrapper.cpp: (WebCore::JSQuarantinedObjectWrapper::asWrapper): Ditto. (WebCore::JSQuarantinedObjectWrapper::getOwnPropertySlot): Ditto. (WebCore::JSQuarantinedObjectWrapper::construct): Ditto.
  • bindings/js/JSRGBColor.cpp: (jsRGBColorRed): Ditto. (jsRGBColorGreen): Ditto. (jsRGBColorBlue): Ditto.
  • bindings/js/JSSQLResultSetRowListCustom.cpp: (WebCore::JSSQLResultSetRowList::item): Use noValue.
  • bindings/js/JSStorageCustom.cpp: (WebCore::JSStorage::nameGetter): Use asObject. (WebCore::JSStorage::deleteProperty): Ditto. (WebCore::JSStorage::customPut): Ditto.
  • bindings/js/JSStyleSheetListCustom.cpp: (WebCore::JSStyleSheetList::nameGetter): Ditto.
  • bindings/js/JSXMLHttpRequestConstructor.cpp: (WebCore::JSXMLHttpRequestConstructor::JSXMLHttpRequestConstructor): Ditto.
  • bindings/js/JSXSLTProcessorCustom.cpp: (WebCore::JSXSLTProcessor::importStylesheet): Ditto. (WebCore::JSXSLTProcessor::transformToFragment): Ditto. (WebCore::JSXSLTProcessor::transformToDocument): Ditto.
  • bindings/js/ScriptController.cpp: (WebCore::ScriptController::evaluate): Use noValue.
  • bindings/objc/DOMInternal.mm: (-[WebScriptObject _initializeScriptDOMNodeImp]): Ditto.
  • bindings/objc/WebScriptObject.mm: (-[WebScriptObject evaluateWebScript:]): Use JSValuePtr. (-[WebScriptObject valueForKey:]): Ditto. (-[WebScriptObject webScriptValueAtIndex:]): Ditto. (+[WebScriptObject _convertValueToObjcValue:originRootObject:rootObject:]): Use asObject and asString.
  • bindings/scripts/CodeGeneratorJS.pm: Use asObject.
  • bridge/c/c_instance.h: Use JSValuePtr.
  • bridge/c/c_runtime.cpp: (JSC::Bindings::CField::setValueToInstance): Ditto.
  • bridge/c/c_utility.cpp: (JSC::Bindings::convertValueToNPVariant): Use asObject.
  • bridge/jni/jni_instance.cpp: (JavaInstance::booleanValue): Use JSValuePtr. (JavaInstance::invokeMethod): Ditto. And noValue.
  • bridge/jni/jni_jsobject.mm: (JavaJSObject::getSlot): Ditto. (JavaJSObject::convertValueToJObject): Ditto.
  • bridge/jni/jni_runtime.cpp: (JavaField::dispatchValueFromInstance): Ditto. (JavaField::valueFromInstance): Ditto. (JavaField::dispatchSetValueToInstance): Ditto. (JavaField::setValueToInstance): Ditto. (JavaArray::setValueAt): Ditto. (JavaArray::valueAt): Ditto.
  • bridge/jni/jni_runtime.h: Ditto.
  • bridge/jni/jni_utility.cpp: (JSC::Bindings::convertArrayInstanceToJavaArray): Take a JSArray* instead of a JSValue*. (JSC::Bindings::convertValueToJValue): Use asObject and asArray.
  • bridge/objc/objc_class.h: Use JSValuePtr.
  • bridge/objc/objc_instance.h: Ditto.
  • bridge/objc/objc_runtime.h: Ditto.
  • bridge/objc/objc_runtime.mm: (JSC::Bindings::callObjCFallbackObject): Use asObject.
  • bridge/objc/objc_utility.h: Use JSValuePtr.
  • bridge/objc/objc_utility.mm: (JSC::Bindings::convertValueToObjcValue): Use JSValuePtr and asObject. (JSC::Bindings::convertObjcValueToValue): Use jsUndefined() instead of 0.
  • bridge/runtime.cpp: (JSC::Bindings::Instance::getValueOfField): Use JSValuePtr. (JSC::Bindings::Instance::setValueOfField): Ditto.
  • bridge/runtime_array.cpp: (JSC::RuntimeArray::lengthGetter): Use JSValuePtr and asObject. (JSC::RuntimeArray::indexGetter): Ditto.
  • bridge/runtime_array.h: Ditto.
  • bridge/runtime_method.cpp: (JSC::RuntimeMethod::lengthGetter): Ditto. (JSC::callRuntimeMethod): Ditto.
  • bridge/runtime_object.cpp: (JSC::RuntimeObjectImp::fallbackObjectGetter): Ditto. (JSC::RuntimeObjectImp::fieldGetter): Ditto. (JSC::RuntimeObjectImp::methodGetter): Ditto.
  • loader/FrameLoader.cpp: (WebCore::FrameLoader::executeScript): Use noValue.
  • page/Console.cpp: (WebCore::Console::trace): Use asInternalFunction.

WebKit/mac:

2008-10-18 Darin Adler <Darin Adler>

Reviewed by Oliver Hunt.

Tweak a little more to get closer to where we can make JSValuePtr a class.

  • WebView/WebScriptDebugDelegate.mm: (-[WebScriptCallFrame _convertValueToObjcValue:]): Use JSValuePtr. (-[WebScriptCallFrame exception]): Ditto. (-[WebScriptCallFrame evaluateWebScript:]): Ditto. And noValue.
  • WebView/WebScriptDebugger.mm: (WebScriptDebugger::WebScriptDebugger): Use new DebuggerCallFrame constructor that doesn't require explicitly passing an exception.
  • WebView/WebView.mm: (aeDescFromJSValue): Use JSValuePtr. (-[WebView aeDescByEvaluatingJavaScriptFromString:]): Ditto.
  • Property svn:eol-style set to native
File size: 5.1 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 "JSActivation.h"
35#include "JSClassRef.h"
36#include "JSLock.h"
37#include "JSStaticScopeObject.h"
38#include "Machine.h"
39#include "Parser.h"
40#include "collector.h"
41#include "lexer.h"
42#include "lookup.h"
43#include "nodes.h"
44
45#if ENABLE(JSC_MULTIPLE_THREADS)
46#include <wtf/Threading.h>
47#endif
48
49using namespace WTF;
50
51namespace JSC {
52
53extern const HashTable arrayTable;
54extern const HashTable dateTable;
55extern const HashTable mathTable;
56extern const HashTable numberTable;
57extern const HashTable regExpTable;
58extern const HashTable regExpConstructorTable;
59extern const HashTable stringTable;
60
61JSGlobalData::JSGlobalData(bool isShared)
62 : machine(new Machine)
63 , exception(noValue())
64 , arrayTable(new HashTable(JSC::arrayTable))
65 , dateTable(new HashTable(JSC::dateTable))
66 , mathTable(new HashTable(JSC::mathTable))
67 , numberTable(new HashTable(JSC::numberTable))
68 , regExpTable(new HashTable(JSC::regExpTable))
69 , regExpConstructorTable(new HashTable(JSC::regExpConstructorTable))
70 , stringTable(new HashTable(JSC::stringTable))
71 , nullProtoStructureID(JSObject::createStructureID(jsNull()))
72 , activationStructureID(JSActivation::createStructureID(jsNull()))
73 , staticScopeStructureID(JSStaticScopeObject::createStructureID(jsNull()))
74 , stringStructureID(JSString::createStructureID(jsNull()))
75 , numberStructureID(JSNumberCell::createStructureID(jsNull()))
76 , identifierTable(createIdentifierTable())
77 , propertyNames(new CommonIdentifiers(this))
78 , emptyList(new ArgList)
79 , newParserObjects(0)
80 , parserObjectExtraRefCounts(0)
81 , lexer(new Lexer(this))
82 , parser(new Parser)
83 , head(0)
84 , dynamicGlobalObject(0)
85 , isSharedInstance(isShared)
86 , clientData(0)
87 , heap(this)
88{
89}
90
91JSGlobalData::~JSGlobalData()
92{
93 // By the time this is destroyed, heap.destroy() must already have been called.
94
95 delete machine;
96#ifndef NDEBUG
97 // Zeroing out to make the behavior more predictable when someone attempts to use a deleted instance.
98 machine = 0;
99#endif
100
101 arrayTable->deleteTable();
102 dateTable->deleteTable();
103 mathTable->deleteTable();
104 numberTable->deleteTable();
105 regExpTable->deleteTable();
106 regExpConstructorTable->deleteTable();
107 stringTable->deleteTable();
108 delete arrayTable;
109 delete dateTable;
110 delete mathTable;
111 delete numberTable;
112 delete regExpTable;
113 delete regExpConstructorTable;
114 delete stringTable;
115
116 delete parser;
117 delete lexer;
118
119 deleteAllValues(opaqueJSClassData);
120
121 delete emptyList;
122
123 delete propertyNames;
124 deleteIdentifierTable(identifierTable);
125
126 delete newParserObjects;
127 delete parserObjectExtraRefCounts;
128
129 delete clientData;
130}
131
132PassRefPtr<JSGlobalData> JSGlobalData::create()
133{
134 return adoptRef(new JSGlobalData);
135}
136
137PassRefPtr<JSGlobalData> JSGlobalData::createLeaked()
138{
139#ifndef NDEBUG
140 StructureID::startIgnoringLeaks();
141 RefPtr<JSGlobalData> data = create();
142 StructureID::stopIgnoringLeaks();
143 return data.release();
144#else
145 return create();
146#endif
147}
148
149bool JSGlobalData::sharedInstanceExists()
150{
151 return sharedInstanceInternal();
152}
153
154JSGlobalData& JSGlobalData::sharedInstance()
155{
156 JSGlobalData*& instance = sharedInstanceInternal();
157 if (!instance)
158 instance = new JSGlobalData(true);
159 return *instance;
160}
161
162JSGlobalData*& JSGlobalData::sharedInstanceInternal()
163{
164 ASSERT(JSLock::currentThreadIsHoldingLock());
165 static JSGlobalData* sharedInstance;
166 return sharedInstance;
167}
168
169JSGlobalData::ClientData::~ClientData()
170{
171}
172
173}
Note: See TracBrowser for help on using the repository browser.