Commit dcc2048c authored by ggaren@apple.com's avatar ggaren@apple.com

JavaScriptCore:

2008-07-08  Geoffrey Garen  <ggaren@apple.com>

        Reviewed by Oliver Hunt.
        
        Added support for checking if an object has custom properties in its
        property map. WebCore uses this to optimize marking DOM wrappers.

WebCore:

2008-07-08  Geoffrey Garen  <ggaren@apple.com>

        Reviewed by Oliver Hunt.
        
        Only artificially mark JS DOM wrappers if they have custom properties.
        
        21X speedup on http://nerget.com/jstests/dom-mandelbrot.html.
        
        No, that is not a typo.

        * bindings/js/JSDOMBinding.cpp:
        (WebCore::ScriptInterpreter::markDOMNodesForDocument):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@35068 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent be3a861c
2008-07-08 Geoffrey Garen <ggaren@apple.com>
Reviewed by Oliver Hunt.
Added support for checking if an object has custom properties in its
property map. WebCore uses this to optimize marking DOM wrappers.
2008-07-08 Simon Hausmann <hausmann@webkit.org>
Prospective Gtk/Wx build fixes, add ProfileGenerator.cpp to the build.
......@@ -306,6 +306,7 @@ namespace KJS {
void putDirect(const Identifier& propertyName, JSValue* value, unsigned attr = 0);
void putDirect(ExecState*, const Identifier& propertyName, int value, unsigned attr = 0);
void removeDirect(const Identifier& propertyName);
bool hasCustomProperties() { return !m_propertyMap.isEmpty(); }
// convenience to add a function property under the function's own built-in name
void putDirectFunction(InternalFunction*, unsigned attr = 0);
......
......@@ -37,6 +37,7 @@ namespace KJS {
~PropertyMap();
void clear();
bool isEmpty() { return !m_usingTable & !m_singleEntryKey; }
void put(const Identifier& propertyName, JSValue*, unsigned attributes, bool checkReadOnly = false);
void remove(const Identifier& propertyName);
......
2008-07-08 Geoffrey Garen <ggaren@apple.com>
Reviewed by Oliver Hunt.
Only artificially mark JS DOM wrappers if they have custom properties.
21X speedup on http://nerget.com/jstests/dom-mandelbrot.html.
No, that is not a typo.
* bindings/js/JSDOMBinding.cpp:
(WebCore::ScriptInterpreter::markDOMNodesForDocument):
2008-07-08 Kevin Watters <kevinwatters@gmail.com>
Reviewed by Kevin Ollivier.
......@@ -176,20 +176,29 @@ void ScriptInterpreter::forgetAllDOMNodesForDocument(Document* document)
void ScriptInterpreter::markDOMNodesForDocument(Document* doc)
{
// If a node's JS wrapper holds custom properties, those properties must
// persist every time the node is fetched from the DOM. So, we keep JS
// wrappers like that from being garbage collected.
JSWrapperCache& nodeDict = doc->wrapperCache();
JSWrapperCache::iterator nodeEnd = nodeDict.end();
for (JSWrapperCache::iterator nodeIt = nodeDict.begin(); nodeIt != nodeEnd; ++nodeIt) {
JSNode* jsNode = nodeIt->second;
WebCore::Node* node = jsNode->impl();
// don't mark wrappers for nodes that are no longer in the
// document - they should not be saved if the node is not
// otherwise reachable from JS.
// However, image elements that aren't in the document are also
// marked, if they are not done loading yet.
if (!jsNode->marked() && (node->inDocument() || (node->hasTagName(imgTag) &&
!static_cast<HTMLImageElement*>(node)->haveFiredLoadEvent())))
jsNode->mark();
if (jsNode->marked())
continue;
// No need to preserve a wrapper that has no custom properties or is no
// longer fetchable through the DOM.
if (!jsNode->hasCustomProperties() || !node->inDocument())
//... unless the wrapper wraps a loading image, since the "new Image"
// syntax allows an orphan image wrapper to be the last reference
// to a loading image, whose load event might have important side-effects.
if (!node->hasTagName(imgTag) || static_cast<HTMLImageElement*>(node)->haveFiredLoadEvent())
continue;
jsNode->mark();
}
}
......
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