Commit 4292302b authored by andersca@apple.com's avatar andersca@apple.com

2008-05-26 Anders Carlsson <andersca@apple.com>

        Reviewed by Sam.

        This patch does two things:
        
        * It adds a toJSNewlyCreated function for creating JS wrappers for nodes where we know
        that the node doesn't have a wrapper. This avoids a hash lookup.
        
        * It adds toJSNewlyCreated methods for JSElement and JSText. 
        
        All in all this is a 4.3% speedup on Acid 3 test 26.
        
        * WebCore.vcproj/WebCore.vcproj:
        * WebCore.xcodeproj/project.pbxproj:
        * bindings/js/JSElementCustom.cpp:
        (WebCore::toJSNewlyCreated):
        * bindings/js/JSNodeCustom.cpp:
        (WebCore::createWrapper):
        (WebCore::toJSNewlyCreated):
        (WebCore::toJS):
        * bindings/js/JSTextCustom.cpp: Added.
        (WebCore::toJSNewlyCreated):
        * bindings/scripts/CodeGeneratorJS.pm:
        * dom/Document.idl:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@34141 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9656ab16
2008-05-26 Anders Carlsson <andersca@apple.com>
Reviewed by Sam.
This patch does two things:
* It adds a toJSNewlyCreated function for creating JS wrappers for nodes where we know
that the node doesn't have a wrapper. This avoids a hash lookup.
* It adds toJSNewlyCreated methods for JSElement and JSText.
All in all this is a 4.3% speedup on Acid 3 test 26.
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSElementCustom.cpp:
(WebCore::toJSNewlyCreated):
* bindings/js/JSNodeCustom.cpp:
(WebCore::createWrapper):
(WebCore::toJSNewlyCreated):
(WebCore::toJS):
* bindings/js/JSTextCustom.cpp: Added.
(WebCore::toJSNewlyCreated):
* bindings/scripts/CodeGeneratorJS.pm:
* dom/Document.idl:
2008-05-26 Sam Weinig <sam@webkit.org>
Reviewed by Anders Carlsson.
Inline the getOwnPropertySlot for JSNode, JSEventTargetNode, JSElement,
and JSDocument for a 1-2% speedup on Acide 3 test 26.
and JSDocument for a 1-2% speedup on Acid 3 test 26.
* bindings/js/JSEventTargetNode.cpp:
* bindings/js/JSEventTargetNode.h:
......@@ -13886,6 +13886,10 @@
RelativePath="..\bindings\js\JSSVGTransformListCustom.cpp"
>
</File>
<File
RelativePath="..\bindings\js\JSTextCustom.cpp"
>
</File>
<File
RelativePath="..\bindings\js\JSTreeWalkerCustom.cpp"
>
......
......@@ -92,6 +92,7 @@
1A2A68240B5BEDE70002A480 /* ProgressTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2A68220B5BEDE70002A480 /* ProgressTracker.h */; settings = {ATTRIBUTES = (Private, ); }; };
1A2AAC580DC2A3B100A20D9A /* ApplicationCacheStorage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2AAC560DC2A3B100A20D9A /* ApplicationCacheStorage.cpp */; };
1A2AAC590DC2A3B100A20D9A /* ApplicationCacheStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2AAC570DC2A3B100A20D9A /* ApplicationCacheStorage.h */; settings = {ATTRIBUTES = (Private, ); }; };
1A2C40AB0DEB55AA005AF19E /* JSTextCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2C40AA0DEB55AA005AF19E /* JSTextCustom.cpp */; };
1A2D753D0DE47FAB00F0A648 /* IconFetcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2D753B0DE47FAB00F0A648 /* IconFetcher.h */; settings = {ATTRIBUTES = (Private, ); }; };
1A2D753E0DE47FAB00F0A648 /* IconFetcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2D753C0DE47FAB00F0A648 /* IconFetcher.cpp */; };
1A2E6E590CC55213004A2062 /* SQLValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2E6E570CC55213004A2062 /* SQLValue.cpp */; };
......@@ -4548,6 +4549,7 @@
1A2A68220B5BEDE70002A480 /* ProgressTracker.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ProgressTracker.h; sourceTree = "<group>"; };
1A2AAC560DC2A3B100A20D9A /* ApplicationCacheStorage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ApplicationCacheStorage.cpp; sourceTree = "<group>"; };
1A2AAC570DC2A3B100A20D9A /* ApplicationCacheStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplicationCacheStorage.h; sourceTree = "<group>"; };
1A2C40AA0DEB55AA005AF19E /* JSTextCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTextCustom.cpp; sourceTree = "<group>"; };
1A2D753B0DE47FAB00F0A648 /* IconFetcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IconFetcher.h; sourceTree = "<group>"; };
1A2D753C0DE47FAB00F0A648 /* IconFetcher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IconFetcher.cpp; sourceTree = "<group>"; };
1A2E6E570CC55213004A2062 /* SQLValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SQLValue.cpp; path = sql/SQLValue.cpp; sourceTree = "<group>"; };
......@@ -12311,6 +12313,7 @@
B297BC6F0B3C14CF0045A590 /* JSSVGPathSegListCustom.cpp */,
516BB7910CE91E6800512F79 /* JSSVGPointListCustom.cpp */,
B2D3FC890C2212CB00CF3618 /* JSSVGTransformListCustom.cpp */,
1A2C40AA0DEB55AA005AF19E /* JSTextCustom.cpp */,
516BB7920CE91E6800512F79 /* JSTreeWalkerCustom.cpp */,
BC348BBD0DB7F531004ABAB9 /* JSXMLHttpRequestCustom.cpp */,
BCEFE1E40DCA5F3300739219 /* JSXSLTProcessorCustom.cpp */,
......@@ -16862,6 +16865,7 @@
1A7FA6490DDA3CBA0028F8A5 /* NetworkStateNotifierMac.cpp in Sources */,
1A2D753E0DE47FAB00F0A648 /* IconFetcher.cpp in Sources */,
E1A302C10DE8376900C52F2C /* StringBuilder.cpp in Sources */,
1A2C40AB0DEB55AA005AF19E /* JSTextCustom.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -35,6 +35,12 @@
#include "HTMLFrameElementBase.h"
#include "HTMLNames.h"
#include "JSAttr.h"
#include "JSHTMLElementWrapperFactory.h"
#if ENABLE(SVG)
#include "JSSVGElementWrapperFactory.h"
#include "SVGElement.h"
#endif
using namespace KJS;
......@@ -119,4 +125,29 @@ JSValue* JSElement::setAttributeNodeNS(ExecState* exec, const List& args)
return result;
}
JSValue* toJSNewlyCreated(ExecState* exec, Element* element)
{
if (!element)
return jsNull();
ASSERT(!ScriptInterpreter::getDOMNodeForDocument(element->document(), element));
Document* doc = element->document();
JSNode* ret = 0;
if (element->isHTMLElement())
ret = createJSHTMLWrapper(exec, static_cast<HTMLElement*>(element));
#if ENABLE(SVG)
else if (element->isSVGElement())
ret = createJSSVGWrapper(exec, static_cast<SVGElement*>(element));
#endif
else
ret = new JSElement(JSElementPrototype::self(exec), element);
ScriptInterpreter::putDOMNodeForDocument(doc, element, ret);
return ret;
}
} // namespace WebCore
......@@ -161,16 +161,14 @@ void JSNode::mark()
ASSERT(marked());
}
JSValue* toJS(ExecState* exec, Node* node)
static ALWAYS_INLINE JSValue* createWrapper(ExecState* exec, Node* node)
{
if (!node)
return jsNull();
ASSERT(node);
ASSERT(!ScriptInterpreter::getDOMNodeForDocument(node->document(), node));
Document* doc = node->document();
JSNode* ret = ScriptInterpreter::getDOMNodeForDocument(doc, node);
if (ret)
return ret;
JSNode* ret = 0;
switch (node->nodeType()) {
case Node::ELEMENT_NODE:
if (node->isHTMLElement())
......@@ -221,7 +219,28 @@ JSValue* toJS(ExecState* exec, Node* node)
ScriptInterpreter::putDOMNodeForDocument(doc, node, ret);
return ret;
return ret;
}
JSValue* toJSNewlyCreated(ExecState* exec, Node* node)
{
if (!node)
return jsNull();
return createWrapper(exec, node);
}
JSValue* toJS(ExecState* exec, Node* node)
{
if (!node)
return jsNull();
Document* doc = node->document();
JSNode* ret = ScriptInterpreter::getDOMNodeForDocument(doc, node);
if (ret)
return ret;
return createWrapper(exec, node);
}
} // namespace WebCore
/*
* Copyright (C) 2008 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "JSText.h"
#include "Text.h"
using namespace KJS;
namespace WebCore {
JSValue* toJSNewlyCreated(ExecState* exec, Text* text)
{
if (!text)
return jsNull();
JSNode* ret = new JSText(JSTextPrototype::self(exec), text);
ScriptInterpreter::putDOMNodeForDocument(text->document(), text, ret);
return ret;
}
} // namespace WebCore
......@@ -144,7 +144,7 @@ sub UsesManualToJSImplementation
{
my $type = shift;
return 1 if $type eq "Node" or $type eq "Document" or $type eq "HTMLCollection" or $type eq "SVGPathSeg" or $type eq "StyleSheet" or $type eq "CSSRule" or $type eq "CSSValue" or $type eq "Event" or $type eq "CanvasPixelArray";
return 1 if $type eq "Node" or $type eq "Document" or $type eq "HTMLCollection" or $type eq "SVGPathSeg" or $type eq "StyleSheet" or $type eq "CSSRule" or $type eq "CSSValue" or $type eq "Event" or $type eq "CanvasPixelArray" or $type eq "Element" or $type eq "Text";
return 0;
}
......@@ -615,6 +615,11 @@ sub GenerateHeader
} else {
push(@headerContent, "$implClassName* to${interfaceName}(KJS::JSValue*);\n");
}
if ($interfaceName eq "Node" or $interfaceName eq "Element" or $interfaceName eq "Text") {
push(@headerContent, "KJS::JSValue* toJSNewlyCreated(KJS::ExecState*, Node*);\n");
}
}
push(@headerContent, "\n");
......@@ -1627,6 +1632,10 @@ sub NativeToJSValue
}
}
if ($signature->extendedAttributes->{"ReturnsNew"}) {
return "toJSNewlyCreated(exec, WTF::getPtr($value))";
}
return "toJS(exec, WTF::getPtr($value))";
}
......
......@@ -34,32 +34,32 @@ module core {
readonly attribute DOMImplementation implementation;
readonly attribute Element documentElement;
Element createElement(in [ConvertNullToNullString] DOMString tagName)
[ReturnsNew] Element createElement(in [ConvertNullToNullString] DOMString tagName)
raises (DOMException);
DocumentFragment createDocumentFragment();
Text createTextNode(in DOMString data);
Comment createComment(in DOMString data);
CDATASection createCDATASection(in DOMString data)
[ReturnsNew] Text createTextNode(in DOMString data);
[ReturnsNew] Comment createComment(in DOMString data);
[ReturnsNew] CDATASection createCDATASection(in DOMString data)
raises(DOMException);
[OldStyleObjC] ProcessingInstruction createProcessingInstruction(in DOMString target,
in DOMString data)
[OldStyleObjC, ReturnsNew] ProcessingInstruction createProcessingInstruction(in DOMString target,
in DOMString data)
raises (DOMException);
Attr createAttribute(in DOMString name)
[ReturnsNew] Attr createAttribute(in DOMString name)
raises (DOMException);
EntityReference createEntityReference(in DOMString name)
[ReturnsNew] EntityReference createEntityReference(in DOMString name)
raises(DOMException);
NodeList getElementsByTagName(in DOMString tagname);
// Introduced in DOM Level 2:
[OldStyleObjC] Node importNode(in Node importedNode,
in boolean deep)
[OldStyleObjC, ReturnsNew] Node importNode(in Node importedNode,
in boolean deep)
raises (DOMException);
[OldStyleObjC] Element createElementNS(in [ConvertNullToNullString] DOMString namespaceURI,
in [ConvertNullToNullString] DOMString qualifiedName)
[OldStyleObjC, ReturnsNew] Element createElementNS(in [ConvertNullToNullString] DOMString namespaceURI,
in [ConvertNullToNullString] DOMString qualifiedName)
raises (DOMException);
[OldStyleObjC] Attr createAttributeNS(in [ConvertNullToNullString] DOMString namespaceURI,
in [ConvertNullToNullString] DOMString qualifiedName)
[OldStyleObjC, ReturnsNew] Attr createAttributeNS(in [ConvertNullToNullString] DOMString namespaceURI,
in [ConvertNullToNullString] DOMString qualifiedName)
raises (DOMException);
[OldStyleObjC] NodeList getElementsByTagNameNS(in [ConvertNullToNullString] DOMString namespaceURI,
in DOMString localName);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment