Commit acbc399e authored by sigbjornf@opera.com's avatar sigbjornf@opera.com

Oilpan: move ScriptLoader to the heap.

So as to be able to trace its PendingScript part object.

(Initially landed as r183909, relanded after r183984 fix.)

R=haraken
BUG=

Review URL: https://codereview.chromium.org/660233002

git-svn-id: svn://svn.chromium.org/blink/trunk@184013 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent ff7c8f86
...@@ -128,6 +128,6 @@ private: ...@@ -128,6 +128,6 @@ private:
RefPtr<ScriptStreamer> m_streamer; RefPtr<ScriptStreamer> m_streamer;
}; };
} } // namespace blink
#endif #endif // PendingScript_h
...@@ -78,6 +78,12 @@ ScriptLoader::~ScriptLoader() ...@@ -78,6 +78,12 @@ ScriptLoader::~ScriptLoader()
m_pendingScript.stopWatchingForLoad(this); m_pendingScript.stopWatchingForLoad(this);
} }
void ScriptLoader::trace(Visitor* visitor)
{
visitor->trace(m_element);
visitor->trace(m_pendingScript);
}
void ScriptLoader::didNotifySubtreeInsertionsToDocument() void ScriptLoader::didNotifySubtreeInsertionsToDocument()
{ {
if (!m_parserInserted) if (!m_parserInserted)
...@@ -372,7 +378,8 @@ void ScriptLoader::execute() ...@@ -372,7 +378,8 @@ void ScriptLoader::execute()
ASSERT(m_pendingScript.resource()); ASSERT(m_pendingScript.resource());
bool errorOccurred = false; bool errorOccurred = false;
ScriptSourceCode source = m_pendingScript.getSource(KURL(), errorOccurred); ScriptSourceCode source = m_pendingScript.getSource(KURL(), errorOccurred);
RefPtr<Element> element = m_pendingScript.releaseElementAndClear(); RefPtrWillBeRawPtr<Element> element = m_pendingScript.releaseElementAndClear();
ALLOW_UNUSED_LOCAL(element);
if (errorOccurred) { if (errorOccurred) {
dispatchErrorEvent(); dispatchErrorEvent();
} else if (!m_resource->wasCanceled()) { } else if (!m_resource->wasCanceled()) {
...@@ -455,4 +462,4 @@ ScriptLoader* toScriptLoaderIfPossible(Element* element) ...@@ -455,4 +462,4 @@ ScriptLoader* toScriptLoaderIfPossible(Element* element)
return 0; return 0;
} }
} } // namespace blink
...@@ -36,10 +36,15 @@ class ScriptLoaderClient; ...@@ -36,10 +36,15 @@ class ScriptLoaderClient;
class ScriptSourceCode; class ScriptSourceCode;
class ScriptLoader final : private ScriptResourceClient { class ScriptLoader final : public NoBaseWillBeGarbageCollectedFinalized<ScriptLoader>, private ScriptResourceClient {
public: public:
static PassOwnPtr<ScriptLoader> create(Element*, bool createdByParser, bool isEvaluated); static PassOwnPtrWillBeRawPtr<ScriptLoader> create(Element* element, bool createdByParser, bool isEvaluated)
{
return adoptPtrWillBeNoop(new ScriptLoader(element, createdByParser, isEvaluated));
}
virtual ~ScriptLoader(); virtual ~ScriptLoader();
virtual void trace(Visitor*);
Element* element() const { return m_element; } Element* element() const { return m_element; }
...@@ -91,10 +96,14 @@ private: ...@@ -91,10 +96,14 @@ private:
// ResourceClient // ResourceClient
virtual void notifyFinished(Resource*) override; virtual void notifyFinished(Resource*) override;
// FIXME: Oilpan: This should become a Member once ResourceClient is moved to the heap. RawPtrWillBeMember<Element> m_element;
Element* m_element;
ResourcePtr<ScriptResource> m_resource; ResourcePtr<ScriptResource> m_resource;
WTF::OrdinalNumber m_startLineNumber; WTF::OrdinalNumber m_startLineNumber;
String m_characterEncoding;
String m_fallbackCharacterEncoding;
PendingScript m_pendingScript;
bool m_parserInserted : 1; bool m_parserInserted : 1;
bool m_isExternalScript : 1; bool m_isExternalScript : 1;
bool m_alreadyStarted : 1; bool m_alreadyStarted : 1;
...@@ -104,20 +113,10 @@ private: ...@@ -104,20 +113,10 @@ private:
bool m_willExecuteWhenDocumentFinishedParsing : 1; bool m_willExecuteWhenDocumentFinishedParsing : 1;
bool m_forceAsync : 1; bool m_forceAsync : 1;
bool m_willExecuteInOrder : 1; bool m_willExecuteInOrder : 1;
String m_characterEncoding;
String m_fallbackCharacterEncoding;
PendingScript m_pendingScript;
}; };
ScriptLoader* toScriptLoaderIfPossible(Element*); ScriptLoader* toScriptLoaderIfPossible(Element*);
inline PassOwnPtr<ScriptLoader> ScriptLoader::create(Element* element, bool createdByParser, bool isEvaluated) } // namespace blink
{
return adoptPtr(new ScriptLoader(element, createdByParser, isEvaluated));
}
}
#endif #endif // ScriptLoader_h
...@@ -42,13 +42,15 @@ ScriptRunner::ScriptRunner(Document* document) ...@@ -42,13 +42,15 @@ ScriptRunner::ScriptRunner(Document* document)
ScriptRunner::~ScriptRunner() ScriptRunner::~ScriptRunner()
{ {
#if !ENABLE(OILPAN)
// Make sure that ScriptLoaders don't keep their PendingScripts alive. // Make sure that ScriptLoaders don't keep their PendingScripts alive.
for (size_t i = 0; i < m_scriptsToExecuteInOrder.size(); ++i) for (ScriptLoader* scriptLoader : m_scriptsToExecuteInOrder)
m_scriptsToExecuteInOrder[i]->detach(); scriptLoader->detach();
for (size_t i = 0; i < m_scriptsToExecuteSoon.size(); ++i) for (ScriptLoader* scriptLoader : m_scriptsToExecuteSoon)
m_scriptsToExecuteSoon[i]->detach(); scriptLoader->detach();
for (HashSet<ScriptLoader*>::iterator it = m_pendingAsyncScripts.begin(); it != m_pendingAsyncScripts.end(); ++it) for (ScriptLoader* scriptLoader : m_pendingAsyncScripts)
(*it)->detach(); scriptLoader->detach();
#endif
} }
void ScriptRunner::addPendingAsyncScript(ScriptLoader* scriptLoader) void ScriptRunner::addPendingAsyncScript(ScriptLoader* scriptLoader)
...@@ -131,7 +133,7 @@ void ScriptRunner::timerFired(Timer<ScriptRunner>* timer) ...@@ -131,7 +133,7 @@ void ScriptRunner::timerFired(Timer<ScriptRunner>* timer)
RefPtrWillBeRawPtr<Document> protect(m_document.get()); RefPtrWillBeRawPtr<Document> protect(m_document.get());
Vector<ScriptLoader*> scriptLoaders; WillBeHeapVector<RawPtrWillBeMember<ScriptLoader> > scriptLoaders;
scriptLoaders.swap(m_scriptsToExecuteSoon); scriptLoaders.swap(m_scriptsToExecuteSoon);
size_t numInOrderScriptsToExecute = 0; size_t numInOrderScriptsToExecute = 0;
......
...@@ -69,9 +69,10 @@ private: ...@@ -69,9 +69,10 @@ private:
void addPendingAsyncScript(ScriptLoader*); void addPendingAsyncScript(ScriptLoader*);
RawPtrWillBeMember<Document> m_document; RawPtrWillBeMember<Document> m_document;
Vector<ScriptLoader*> m_scriptsToExecuteInOrder; WillBeHeapVector<RawPtrWillBeMember<ScriptLoader> > m_scriptsToExecuteInOrder;
Vector<ScriptLoader*> m_scriptsToExecuteSoon; // http://www.whatwg.org/specs/web-apps/current-work/#set-of-scripts-that-will-execute-as-soon-as-possible // http://www.whatwg.org/specs/web-apps/current-work/#set-of-scripts-that-will-execute-as-soon-as-possible
HashSet<ScriptLoader*> m_pendingAsyncScripts; WillBeHeapVector<RawPtrWillBeMember<ScriptLoader> > m_scriptsToExecuteSoon;
WillBeHeapHashSet<RawPtrWillBeMember<ScriptLoader> > m_pendingAsyncScripts;
Timer<ScriptRunner> m_timer; Timer<ScriptRunner> m_timer;
}; };
......
...@@ -208,4 +208,10 @@ PassRefPtrWillBeRawPtr<Element> HTMLScriptElement::cloneElementWithoutAttributes ...@@ -208,4 +208,10 @@ PassRefPtrWillBeRawPtr<Element> HTMLScriptElement::cloneElementWithoutAttributes
return adoptRefWillBeNoop(new HTMLScriptElement(document(), false, m_loader->alreadyStarted())); return adoptRefWillBeNoop(new HTMLScriptElement(document(), false, m_loader->alreadyStarted()));
} }
void HTMLScriptElement::trace(Visitor* visitor)
{
visitor->trace(m_loader);
HTMLElement::trace(visitor);
}
} }
...@@ -46,6 +46,8 @@ public: ...@@ -46,6 +46,8 @@ public:
ScriptLoader* loader() const { return m_loader.get(); } ScriptLoader* loader() const { return m_loader.get(); }
virtual void trace(Visitor*) override;
private: private:
HTMLScriptElement(Document&, bool wasInsertedByParser, bool alreadyStarted); HTMLScriptElement(Document&, bool wasInsertedByParser, bool alreadyStarted);
...@@ -74,7 +76,7 @@ private: ...@@ -74,7 +76,7 @@ private:
virtual PassRefPtrWillBeRawPtr<Element> cloneElementWithoutAttributesAndChildren() override; virtual PassRefPtrWillBeRawPtr<Element> cloneElementWithoutAttributesAndChildren() override;
OwnPtr<ScriptLoader> m_loader; OwnPtrWillBeMember<ScriptLoader> m_loader;
}; };
} // namespace blink } // namespace blink
......
...@@ -178,4 +178,10 @@ bool SVGScriptElement::isAnimatableAttribute(const QualifiedName& name) const ...@@ -178,4 +178,10 @@ bool SVGScriptElement::isAnimatableAttribute(const QualifiedName& name) const
} }
#endif #endif
void SVGScriptElement::trace(Visitor* visitor)
{
visitor->trace(m_loader);
SVGElement::trace(visitor);
} }
} // namespace blink
...@@ -46,6 +46,8 @@ public: ...@@ -46,6 +46,8 @@ public:
virtual bool isAnimatableAttribute(const QualifiedName&) const override; virtual bool isAnimatableAttribute(const QualifiedName&) const override;
#endif #endif
virtual void trace(Visitor*) override;
private: private:
SVGScriptElement(Document&, bool wasInsertedByParser, bool alreadyStarted); SVGScriptElement(Document&, bool wasInsertedByParser, bool alreadyStarted);
virtual ~SVGScriptElement(); virtual ~SVGScriptElement();
...@@ -80,9 +82,8 @@ private: ...@@ -80,9 +82,8 @@ private:
virtual Timer<SVGElement>* svgLoadEventTimer() override { return &m_svgLoadEventTimer; } virtual Timer<SVGElement>* svgLoadEventTimer() override { return &m_svgLoadEventTimer; }
Timer<SVGElement> m_svgLoadEventTimer; Timer<SVGElement> m_svgLoadEventTimer;
OwnPtr<ScriptLoader> m_loader; OwnPtrWillBeMember<ScriptLoader> m_loader;
}; };
} // namespace blink } // namespace blink
......
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