Commit 5c465b09 authored by darin@apple.com's avatar darin@apple.com

JavaScriptCore:

2008-10-18  Darin Adler  <darin@apple.com>

        Reviewed by Oliver Hunt.

        - next step of https://bugs.webkit.org/show_bug.cgi?id=21732
          improve performance by eliminating JSValue as a base class for JSCell

        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@apple.com>

        Reviewed by Oliver Hunt.

        - next step of https://bugs.webkit.org/show_bug.cgi?id=21732
          improve performance by eliminating JSValue as a base class for JSCell

        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@apple.com>

        Reviewed by Oliver Hunt.

        - next step of https://bugs.webkit.org/show_bug.cgi?id=21732
          improve performance by eliminating JSValue as a base class for JSCell

        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@apple.com>

        Reviewed by Oliver Hunt.

        - next step of https://bugs.webkit.org/show_bug.cgi?id=21732
          improve performance by eliminating JSValue as a base class for JSCell

        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.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@37705 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 50ba3892
......@@ -50,7 +50,7 @@ inline JSC::ExecState* toJS(JSGlobalContextRef c)
inline JSC::JSValuePtr toJS(JSValueRef v)
{
return reinterpret_cast<JSC::JSValuePtr>(const_cast<OpaqueJSValue*>(v));
return reinterpret_cast<JSC::JSValue*>(const_cast<OpaqueJSValue*>(v));
}
inline JSC::JSObject* toJS(JSObjectRef o)
......
2008-10-18 Darin Adler <darin@apple.com>
Reviewed by Oliver Hunt.
- next step of https://bugs.webkit.org/show_bug.cgi?id=21732
improve performance by eliminating JSValue as a base class for JSCell
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.
2008-10-18 Darin Adler <darin@apple.com>
- fix non-all-in-one build
......
......@@ -3098,7 +3098,7 @@ void CTI::unlinkCall(StructureStubInfo* structureStubInfo)
// When the JSFunction is deleted the pointer embedded in the instruction stream will no longer be valid
// (and, if a new JSFunction happened to be constructed at the same location, we could get a false positive
// match). Reset the check so it no longer matches.
reinterpret_cast<void**>(structureStubInfo->hotPathBegin)[-1] = JSImmediate::impossibleValue();
reinterpret_cast<void**>(structureStubInfo->hotPathBegin)[-1] = asPointer(JSImmediate::impossibleValue());
}
void CTI::linkCall(CodeBlock* callerCodeBlock, JSFunction* callee, CodeBlock* calleeCodeBlock, void* ctiCode, void* returnAddress, int callerArgCount)
......
......@@ -53,11 +53,11 @@
#define ARG_setCallFrame(newCallFrame) (ARGS[CTI_ARGS_callFrame] = (newCallFrame))
#define ARG_src1 static_cast<JSValuePtr>(ARGS[1])
#define ARG_src2 static_cast<JSValuePtr>(ARGS[2])
#define ARG_src3 static_cast<JSValuePtr>(ARGS[3])
#define ARG_src4 static_cast<JSValuePtr>(ARGS[4])
#define ARG_src5 static_cast<JSValuePtr>(ARGS[5])
#define ARG_src1 static_cast<JSValue*>(ARGS[1])
#define ARG_src2 static_cast<JSValue*>(ARGS[2])
#define ARG_src3 static_cast<JSValue*>(ARGS[3])
#define ARG_src4 static_cast<JSValue*>(ARGS[4])
#define ARG_src5 static_cast<JSValue*>(ARGS[5])
#define ARG_id1 static_cast<Identifier*>(ARGS[1])
#define ARG_id2 static_cast<Identifier*>(ARGS[2])
#define ARG_id3 static_cast<Identifier*>(ARGS[3])
......
......@@ -39,7 +39,7 @@ namespace JSC {
DebuggerCallFrame(CallFrame* callFrame)
: m_callFrame(callFrame)
, m_exception(0)
, m_exception(noValue())
{
}
......
......@@ -60,7 +60,7 @@ extern const HashTable stringTable;
JSGlobalData::JSGlobalData(bool isShared)
: machine(new Machine)
, exception(0)
, exception(noValue())
, arrayTable(new HashTable(JSC::arrayTable))
, dateTable(new HashTable(JSC::dateTable))
, mathTable(new HashTable(JSC::mathTable))
......
......@@ -36,9 +36,9 @@ JSObject* JSImmediate::toObject(JSValuePtr v, ExecState* exec)
{
ASSERT(isImmediate(v));
if (isNumber(v))
return constructNumberFromImmediateNumber(exec, const_cast<JSValuePtr>(v));
return constructNumberFromImmediateNumber(exec, v);
if (isBoolean(v))
return constructBooleanFromImmediateBoolean(exec, const_cast<JSValuePtr>(v));
return constructBooleanFromImmediateBoolean(exec, v);
JSNotAnObjectErrorStub* exception = createNotAnObjectErrorStub(exec, v->isNull());
exec->setException(exception);
......
......@@ -43,7 +43,7 @@ namespace JSC {
inline JSWrapperObject::JSWrapperObject(PassRefPtr<StructureID> structure)
: JSObject(structure)
, m_internalValue(0)
, m_internalValue(noValue())
{
}
......
2008-10-18 Darin Adler <darin@apple.com>
Reviewed by Oliver Hunt.
- next step of https://bugs.webkit.org/show_bug.cgi?id=21732
improve performance by eliminating JSValue as a base class for JSCell
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.
2008-10-18 Darin Adler <darin@apple.com>
Reviewed by Cameron Zwarich.
......
......@@ -75,7 +75,7 @@ void JSUserObject::SetProperty(CFStringRef propertyName, JSUserObject* value)
static JSValuePtr nativeCallFunction(ExecState* exec, JSObject* functionObject, JSValuePtr thisValue, const ArgList& args)
{
return static_cast<UserObjectImp*>(functionObject)->callAsFunction(exec, static_cast<JSObject*>(thisValue), args);
return static_cast<UserObjectImp*>(functionObject)->callAsFunction(exec, asObject(thisValue), args);
}
CallType JSUserObject::getCallData(CallData& callData)
......
......@@ -43,7 +43,7 @@ struct ObjectImpList {
CFTypeRef data;
};
static CFTypeRef KJSValueToCFTypeInternal(JSValue *inValue, ExecState *exec, ObjectImpList* inImps);
static CFTypeRef KJSValueToCFTypeInternal(JSValuePtr inValue, ExecState *exec, ObjectImpList* inImps);
//--------------------------------------------------------------------------
......@@ -100,12 +100,12 @@ CFStringRef IdentifierToCFString(const Identifier& inIdentifier)
//--------------------------------------------------------------------------
// KJSValueToJSObject
//--------------------------------------------------------------------------
JSUserObject* KJSValueToJSObject(JSValue *inValue, ExecState *exec)
JSUserObject* KJSValueToJSObject(JSValuePtr inValue, ExecState *exec)
{
JSUserObject* result = 0;
if (inValue->isObject(&UserObjectImp::info)) {
UserObjectImp* userObjectImp = static_cast<UserObjectImp *>(inValue);
UserObjectImp* userObjectImp = static_cast<UserObjectImp *>(asObject(inValue));
result = userObjectImp->GetJSUserObject();
if (result)
result->Retain();
......@@ -126,11 +126,11 @@ JSUserObject* KJSValueToJSObject(JSValue *inValue, ExecState *exec)
//--------------------------------------------------------------------------
// JSObjectKJSValue
//--------------------------------------------------------------------------
JSValue *JSObjectKJSValue(JSUserObject* ptr)
JSValuePtr JSObjectKJSValue(JSUserObject* ptr)
{
JSLock lock(true);
JSValue *result = jsUndefined();
JSValuePtr result = jsUndefined();
if (ptr)
{
bool handled = false;
......@@ -196,7 +196,7 @@ JSValue *JSObjectKJSValue(JSUserObject* ptr)
// KJSValueToCFTypeInternal
//--------------------------------------------------------------------------
// Caller is responsible for releasing the returned CFTypeRef
CFTypeRef KJSValueToCFTypeInternal(JSValue *inValue, ExecState *exec, ObjectImpList* inImps)
CFTypeRef KJSValueToCFTypeInternal(JSValuePtr inValue, ExecState *exec, ObjectImpList* inImps)
{
if (!inValue)
return 0;
......@@ -238,7 +238,7 @@ CFTypeRef KJSValueToCFTypeInternal(JSValue *inValue, ExecState *exec, ObjectImpL
if (inValue->isObject())
{
if (inValue->isObject(&UserObjectImp::info)) {
UserObjectImp* userObjectImp = static_cast<UserObjectImp *>(inValue);
UserObjectImp* userObjectImp = static_cast<UserObjectImp *>(asObject(inValue));
JSUserObject* ptr = userObjectImp->GetJSUserObject();
if (ptr)
{
......@@ -358,7 +358,7 @@ CFTypeRef KJSValueToCFTypeInternal(JSValue *inValue, ExecState *exec, ObjectImpL
return 0;
}
CFTypeRef KJSValueToCFType(JSValue *inValue, ExecState *exec)
CFTypeRef KJSValueToCFType(JSValuePtr inValue, ExecState *exec)
{
return KJSValueToCFTypeInternal(inValue, exec, 0);
}
......
......@@ -54,9 +54,9 @@ UString CFStringToUString(CFStringRef inCFString);
CFStringRef UStringToCFString(const UString& inUString);
Identifier CFStringToIdentifier(CFStringRef inCFString, ExecState*);
CFStringRef IdentifierToCFString(const Identifier& inIdentifier);
JSUserObject *KJSValueToJSObject(JSValue *inValue, ExecState *exec);
CFTypeRef KJSValueToCFType(JSValue *inValue, ExecState *exec);
JSValue *JSObjectKJSValue(JSUserObject* ptr);
JSUserObject *KJSValueToJSObject(JSValuePtr inValue, ExecState *exec);
CFTypeRef KJSValueToCFType(JSValuePtr inValue, ExecState *exec);
JSValuePtr JSObjectKJSValue(JSUserObject* ptr);
CFTypeRef GetCFNull(void);
inline CFTypeRef RetainCFType(CFTypeRef x) { if (x) x = CFRetain(x); return x; }
......
......@@ -56,9 +56,9 @@ CallType UserObjectImp::getCallData(CallData& callData)
return fJSUserObject ? fJSUserObject->getCallData(callData) : CallTypeNone;
}
JSValue *UserObjectImp::callAsFunction(ExecState *exec, JSObject *thisObj, const ArgList &args)
JSValuePtr UserObjectImp::callAsFunction(ExecState *exec, JSObject *thisObj, const ArgList &args)
{
JSValue *result = jsUndefined();
JSValuePtr result = jsUndefined();
JSUserObject* jsThisObj = KJSValueToJSObject(thisObj, exec);
if (jsThisObj) {
CFIndex argCount = args.size();
......@@ -114,14 +114,14 @@ void UserObjectImp::getPropertyNames(ExecState *exec, PropertyNameArray& propert
JSValuePtr UserObjectImp::userObjectGetter(ExecState*, const Identifier& propertyName, const PropertySlot& slot)
{
UserObjectImp *thisObj = static_cast<UserObjectImp *>(slot.slotBase());
UserObjectImp *thisObj = static_cast<UserObjectImp *>(asObject(slot.slotBase()));
// getOwnPropertySlot should have guarded against a null fJSUserObject.
assert(thisObj->fJSUserObject);
CFStringRef cfPropName = IdentifierToCFString(propertyName);
JSUserObject *jsResult = thisObj->fJSUserObject->CopyProperty(cfPropName);
ReleaseCFType(cfPropName);
JSValue *result = JSObjectKJSValue(jsResult);
JSValuePtr result = JSObjectKJSValue(jsResult);
jsResult->Release();
return result;
......@@ -140,7 +140,7 @@ bool UserObjectImp::getOwnPropertySlot(ExecState *exec, const Identifier& proper
jsResult->Release();
return true;
} else {
JSValue *kjsValue = toPrimitive(exec);
JSValuePtr kjsValue = toPrimitive(exec);
if (!kjsValue->isUndefinedOrNull()) {
JSObject *kjsObject = kjsValue->toObject(exec);
if (kjsObject->getPropertySlot(exec, propertyName, slot))
......@@ -150,7 +150,7 @@ bool UserObjectImp::getOwnPropertySlot(ExecState *exec, const Identifier& proper
return JSObject::getOwnPropertySlot(exec, propertyName, slot);
}
void UserObjectImp::put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr)
void UserObjectImp::put(ExecState *exec, const Identifier &propertyName, JSValuePtr value, int attr)
{
if (!fJSUserObject)
return;
......@@ -169,9 +169,9 @@ JSUserObject* UserObjectImp::GetJSUserObject() const
return fJSUserObject;
}
JSValue *UserObjectImp::toPrimitive(ExecState *exec, JSType) const
JSValuePtr UserObjectImp::toPrimitive(ExecState *exec, JSType) const
{
JSValue *result = jsUndefined();
JSValuePtr result = jsUndefined();
JSUserObject* jsObjPtr = KJSValueToJSObject(toObject(exec), exec);
CFTypeRef cfValue = jsObjPtr ? jsObjPtr->CopyCFValue() : 0;
if (cfValue) {
......
......@@ -47,9 +47,9 @@ public:
virtual void getPropertyNames(ExecState*, PropertyNameArray&);
virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const ArgList &args);
virtual JSValuePtr callAsFunction(ExecState *exec, JSObject *thisObj, const ArgList &args);
virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
virtual void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None);
virtual void put(ExecState *exec, const Identifier &propertyName, JSValuePtr value, int attr = None);
JSValuePtr toPrimitive(ExecState*, JSType preferredType = UnspecifiedType) const;
virtual bool toBoolean(ExecState *exec) const;
......
2008-10-18 Darin Adler <darin@apple.com>
Reviewed by Oliver Hunt.
- next step of https://bugs.webkit.org/show_bug.cgi?id=21732
improve performance by eliminating JSValue as a base class for JSCell
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.
2008-10-19 Dan Bernstein <mitz@apple.com>
Reviewed by Timothy Hatcher.
......
......@@ -42,7 +42,7 @@ const ClassInfo JSAudioConstructor::s_info = { "AudioConstructor", 0, 0, 0 };
JSAudioConstructor::JSAudioConstructor(ExecState* exec, Document* document)
: DOMObject(JSAudioConstructor::createStructureID(exec->lexicalGlobalObject()->objectPrototype()))
, m_document(static_cast<JSDocument*>(toJS(exec, document)))
, m_document(static_cast<JSDocument*>(asObject(toJS(exec, document))))
{
putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly|DontDelete|DontEnum);
}
......@@ -56,7 +56,7 @@ static JSObject* constructAudio(ExecState* exec, JSObject* constructor, const Ar
audio->setSrc(args.at(exec, 0)->toString(exec));
audio->scheduleLoad();
}
return static_cast<JSObject*>(toJS(exec, audio.release()));
return asObject(toJS(exec, audio.release()));
}
ConstructType JSAudioConstructor::getConstructData(ConstructData& constructData)
......
......@@ -129,7 +129,7 @@ bool JSCSSStyleDeclaration::canGetItemsForName(ExecState*, CSSStyleDeclaration*,
// but you should also be able to enumerate them.
JSValuePtr JSCSSStyleDeclaration::nameGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
JSCSSStyleDeclaration* thisObj = static_cast<JSCSSStyleDeclaration*>(slot.slotBase());
JSCSSStyleDeclaration* thisObj = static_cast<JSCSSStyleDeclaration*>(asObject(slot.slotBase()));
// Set up pixelOrPos boolean to handle the fact that
// pixelTop returns "CSS Top" as number value in unit pixels
......
......@@ -52,10 +52,10 @@ static JSValuePtr toJS(ExecState* exec, CanvasStyle* style)
static PassRefPtr<CanvasStyle> toHTMLCanvasStyle(ExecState* exec, JSValuePtr value)
{
if (value->isString())
return CanvasStyle::create(static_cast<JSString*>(value)->value());
return CanvasStyle::create(asString(value)->value());
if (!value->isObject())
return 0;
JSObject* object = static_cast<JSObject*>(value);
JSObject* object = asObject(value);
if (object->inherits(&JSCanvasGradient::s_info))
return CanvasStyle::create(static_cast<JSCanvasGradient*>(object)->impl());
if (object->inherits(&JSCanvasPattern::s_info))
......@@ -96,13 +96,13 @@ JSValuePtr JSCanvasRenderingContext2D::setFillColor(ExecState* exec, const ArgLi
switch (args.size()) {
case 1:
if (args.at(exec, 0)->isString())
context->setFillColor(static_cast<JSString*>(args.at(exec, 0))->value());
context->setFillColor(asString(args.at(exec, 0))->value());
else
context->setFillColor(args.at(exec, 0)->toFloat(exec));
break;
case 2:
if (args.at(exec, 0)->isString())
context->setFillColor(static_cast<JSString*>(args.at(exec, 0))->value(), args.at(exec, 1)->toFloat(exec));
context->setFillColor(asString(args.at(exec, 0))->value(), args.at(exec, 1)->toFloat(exec));
else
context->setFillColor(args.at(exec, 0)->toFloat(exec), args.at(exec, 1)->toFloat(exec));
break;
......@@ -133,13 +133,13 @@ JSValuePtr JSCanvasRenderingContext2D::setStrokeColor(ExecState* exec, const Arg
switch (args.size()) {
case 1:
if (args.at(exec, 0)->isString())
context->setStrokeColor(static_cast<JSString*>(args.at(exec, 0))->value());
context->setStrokeColor(asString(args.at(exec, 0))->value());
else
context->setStrokeColor(args.at(exec, 0)->toFloat(exec));
break;
case 2:
if (args.at(exec, 0)->isString())
context->setStrokeColor(static_cast<JSString*>(args.at(exec, 0))->value(), args.at(exec, 1)->toFloat(exec));
context->setStrokeColor(asString(args.at(exec, 0))->value(), args.at(exec, 1)->toFloat(exec));
else
context->setStrokeColor(args.at(exec, 0)->toFloat(exec), args.at(exec, 1)->toFloat(exec));
break;
......@@ -185,11 +185,11 @@ JSValuePtr JSCanvasRenderingContext2D::drawImage(ExecState* exec, const ArgList&
JSValuePtr value = args.at(exec, 0);
if (!value->isObject())
return throwError(exec, TypeError);
JSObject* o = static_cast<JSObject*>(value);
JSObject* o = asObject(value);
ExceptionCode ec = 0;
if (o->inherits(&JSHTMLImageElement::s_info)) {
HTMLImageElement* imgElt = static_cast<HTMLImageElement*>(static_cast<JSHTMLElement*>(args.at(exec, 0))->impl());
HTMLImageElement* imgElt = static_cast<HTMLImageElement*>(static_cast<JSHTMLElement*>(o)->impl());
switch (args.size()) {
case 3:
context->drawImage(imgElt, args.at(exec, 1)->toFloat(exec), args.at(exec, 2)->toFloat(exec));
......@@ -210,7 +210,7 @@ JSValuePtr JSCanvasRenderingContext2D::drawImage(ExecState* exec, const ArgList&
return throwError(exec, SyntaxError);
}
} else if (o->inherits(&JSHTMLCanvasElement::s_info)) {
HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(static_cast<JSHTMLElement*>(args.at(exec, 0))->impl());
HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(static_cast<JSHTMLElement*>(o)->impl());
switch (args.size()) {
case 3:
context->drawImage(canvas, args.at(exec, 1)->toFloat(exec), args.at(exec, 2)->toFloat(exec));
......@@ -232,7 +232,6 @@ JSValuePtr JSCanvasRenderingContext2D::drawImage(ExecState* exec, const ArgList&
}
} else {
setDOMException(exec, TYPE_MISMATCH_ERR);
return 0;
}
return jsUndefined();
......@@ -245,11 +244,11 @@ JSValuePtr JSCanvasRenderingContext2D::drawImageFromRect(ExecState* exec, const
JSValuePtr value = args.at(exec, 0);
if (!value->isObject())
return throwError(exec, TypeError);
JSObject* o = static_cast<JSObject*>(value);
JSObject* o = asObject(value);
if (!o->inherits(&JSHTMLImageElement::s_info))
return throwError(exec, TypeError);
context->drawImageFromRect(static_cast<HTMLImageElement*>(static_cast<JSHTMLElement*>(args.at(exec, 0))->impl()),
context->drawImageFromRect(static_cast<HTMLImageElement*>(static_cast<JSHTMLElement*>(o)->impl()),
args.at(exec, 1)->toFloat(exec), args.at(exec, 2)->toFloat(exec),
args.at(exec, 3)->toFloat(exec), args.at(exec, 4)->toFloat(exec),
args.at(exec, 5)->toFloat(exec), args.at(exec, 6)->toFloat(exec),
......@@ -270,7 +269,7 @@ JSValuePtr JSCanvasRenderingContext2D::setShadow(ExecState* exec, const ArgList&
case 4:
if (args.at(exec, 3)->isString())
context->setShadow(args.at(exec, 0)->toFloat(exec), args.at(exec, 1)->toFloat(exec),
args.at(exec, 2)->toFloat(exec), static_cast<JSString*>(args.at(exec, 3))->value());
args.at(exec, 2)->toFloat(exec), asString(args.at(exec, 3))->value());
else
context->setShadow(args.at(exec, 0)->toFloat(exec), args.at(exec, 1)->toFloat(exec),
args.at(exec, 2)->toFloat(exec), args.at(exec, 3)->toFloat(exec));
......