WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-38661-20100527131041.patch (text/plain), 6.79 KB, created by
Tony Gentilcore
on 2010-05-27 13:10:43 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Tony Gentilcore
Created:
2010-05-27 13:10:43 PDT
Size:
6.79 KB
patch
obsolete
>diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog >index 6c96452b065f04e119183e0b73b28164e464609c..812e18a521f9260e1a29b4d15e0aa4206a579510 100644 >--- a/WebCore/ChangeLog >+++ b/WebCore/ChangeLog >@@ -1,3 +1,27 @@ >+2010-05-27 Tony Gentilcore <tonyg@chromium.org> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Persist V8's ScriptData to the memory cache. >+ https://bugs.webkit.org/show_bug.cgi?id=38661 >+ >+ This stores V8's ScriptData in the memory cache and also causes the >+ network platform layer to be notified of the available cacheable >+ metadata. >+ >+ Chromium's morejs benchmark shows a 3-4% improvement on fast hardware. >+ >+ No new tests because no new functionality. >+ >+ * bindings/v8/ScriptSourceCode.h: >+ (WebCore::ScriptSourceCode::ScriptSourceCode): >+ (WebCore::ScriptSourceCode::cachedScript): >+ * bindings/v8/V8Proxy.cpp: >+ (WebCore::V8Proxy::compileScript): >+ (WebCore::V8Proxy::precompileScript): >+ (WebCore::V8Proxy::evaluate): >+ * bindings/v8/V8Proxy.h: >+ > 2010-05-27 Yury Semikhatsky <yurys@chromium.org> > > Reviewed by Pavel Feldman. >diff --git a/WebCore/bindings/v8/ScriptSourceCode.h b/WebCore/bindings/v8/ScriptSourceCode.h >index 5c16168e41f06b4261de4a970de6de1a564c7262..dbc9d5e6fc6007fcfdd66024db07826c66263b5b 100644 >--- a/WebCore/bindings/v8/ScriptSourceCode.h >+++ b/WebCore/bindings/v8/ScriptSourceCode.h >@@ -31,6 +31,7 @@ > #ifndef ScriptSourceCode_h > #define ScriptSourceCode_h > >+#include "CachedResourceHandle.h" > #include "CachedScript.h" > #include "KURL.h" > #include "PlatformString.h" >@@ -41,6 +42,7 @@ class ScriptSourceCode { > public: > ScriptSourceCode(const String& source, const KURL& url = KURL(), int startLine = 1) > : m_source(source) >+ , m_cachedScript(0) > , m_url(url) > , m_startLine(startLine) > { >@@ -50,6 +52,7 @@ public: > // Not sure if that matters. > ScriptSourceCode(CachedScript* cs) > : m_source(cs->script()) >+ , m_cachedScript(cs) > , m_url(ParsedURLString, cs->url()) > , m_startLine(1) > { >@@ -58,11 +61,13 @@ public: > bool isEmpty() const { return m_source.isEmpty(); } > > const String& source() const { return m_source; } >+ CachedScript* cachedScript() const { return m_cachedScript.get(); } > const KURL& url() const { return m_url; } > int startLine() const { return m_startLine; } > > private: > String m_source; >+ CachedResourceHandle<CachedScript> m_cachedScript; > KURL m_url; > int m_startLine; > }; >diff --git a/WebCore/bindings/v8/V8Proxy.cpp b/WebCore/bindings/v8/V8Proxy.cpp >index d7ef6f678d1699aada3c3f61a6d342fd93dd9b0a..3c6dd3a2649003cebd5266c372ce901cc8ab76f4 100644 >--- a/WebCore/bindings/v8/V8Proxy.cpp >+++ b/WebCore/bindings/v8/V8Proxy.cpp >@@ -31,6 +31,7 @@ > #include "config.h" > #include "V8Proxy.h" > >+#include "CachedMetadata.h" > #include "CSSMutableStyleDeclaration.h" > #include "DateExtension.h" > #include "DocumentLoader.h" >@@ -70,6 +71,7 @@ > #include <v8.h> > #include <wtf/Assertions.h> > #include <wtf/OwnArrayPtr.h> >+#include <wtf/OwnPtr.h> > #include <wtf/StdLibExtras.h> > #include <wtf/StringExtras.h> > #include <wtf/UnusedParam.h> >@@ -233,13 +235,13 @@ V8Proxy::~V8Proxy() > windowShell()->destroyGlobal(); > } > >-v8::Handle<v8::Script> V8Proxy::compileScript(v8::Handle<v8::String> code, const String& fileName, int baseLine) >+v8::Handle<v8::Script> V8Proxy::compileScript(v8::Handle<v8::String> code, const String& fileName, int baseLine, v8::ScriptData* scriptData) > { > const uint16_t* fileNameString = fromWebCoreString(fileName); > v8::Handle<v8::String> name = v8::String::New(fileNameString, fileName.length()); > v8::Handle<v8::Integer> line = v8::Integer::New(baseLine); > v8::ScriptOrigin origin(name, line); >- v8::Handle<v8::Script> script = v8::Script::Compile(code, &origin); >+ v8::Handle<v8::Script> script = v8::Script::Compile(code, &origin, scriptData); > return script; > } > >@@ -338,6 +340,28 @@ bool V8Proxy::setInjectedScriptContextDebugId(v8::Handle<v8::Context> targetCont > return true; > } > >+PassOwnPtr<v8::ScriptData> V8Proxy::precompileScript(const ScriptSourceCode& sourceCode) >+{ >+ static const unsigned dataTypeID = 0xECC13BD7; >+ >+ // If there is no CachedScript, don't bother precompiling because there is >+ // no where to cache it. >+ CachedScript* cachedScript = sourceCode.cachedScript(); >+ if (!cachedScript) >+ return 0; >+ >+ // If there is cached data, use it. >+ CachedMetadata* cachedMetadata = cachedScript->cachedMetadata(dataTypeID); >+ if (cachedMetadata) >+ return v8::ScriptData::New(cachedMetadata->data(), cachedMetadata->size()); >+ >+ // There is no cached data, so generate and cache it. >+ v8::ScriptData* scriptData = v8::ScriptData::PreCompile(sourceCode.source().utf8().data(), sourceCode.source().utf8().length()); >+ cachedScript->setCachedMetadata(dataTypeID, scriptData->Data(), scriptData->Length()); >+ >+ return scriptData; >+} >+ > v8::Local<v8::Value> V8Proxy::evaluate(const ScriptSourceCode& source, Node* node) > { > ASSERT(v8::Context::InContext()); >@@ -363,10 +387,11 @@ v8::Local<v8::Value> V8Proxy::evaluate(const ScriptSourceCode& source, Node* nod > #if PLATFORM(CHROMIUM) > PlatformBridge::traceEventBegin("v8.compile", node, ""); > #endif >+ OwnPtr<v8::ScriptData> scriptData = precompileScript(source); > > // NOTE: For compatibility with WebCore, ScriptSourceCode's line starts at > // 1, whereas v8 starts at 0. >- v8::Handle<v8::Script> script = compileScript(code, source.url(), source.startLine() - 1); >+ v8::Handle<v8::Script> script = compileScript(code, source.url(), source.startLine() - 1, scriptData.get()); > #if PLATFORM(CHROMIUM) > PlatformBridge::traceEventEnd("v8.compile", node, ""); > >diff --git a/WebCore/bindings/v8/V8Proxy.h b/WebCore/bindings/v8/V8Proxy.h >index 098d956e2c620d7154c62e2ee6d4a5332a30c204..d6ba1aca7c1013bd8da9e4e21dcf3d22e32d1f56 100644 >--- a/WebCore/bindings/v8/V8Proxy.h >+++ b/WebCore/bindings/v8/V8Proxy.h >@@ -285,7 +285,7 @@ namespace WebCore { > > static v8::Handle<v8::Value> checkNewLegal(const v8::Arguments&); > >- static v8::Handle<v8::Script> compileScript(v8::Handle<v8::String> code, const String& fileName, int baseLine); >+ static v8::Handle<v8::Script> compileScript(v8::Handle<v8::String> code, const String& fileName, int baseLine, v8::ScriptData* scriptData = 0); > > // If the exception code is different from zero, a DOM exception is > // schedule to be thrown. >@@ -337,6 +337,8 @@ namespace WebCore { > > void resetIsolatedWorlds(); > >+ PassOwnPtr<v8::ScriptData> precompileScript(const ScriptSourceCode& sourceCode); >+ > // Returns false when we're out of memory in V8. > bool setInjectedScriptContextDebugId(v8::Handle<v8::Context> targetContext); >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 38661
:
55260
|
57269
|
57348
|
57664
|
57795
|
58694
|
58809
|
59121