Changeset 60684 in webkit
- Timestamp:
- Jun 4, 2010 9:59:23 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r60683 r60684 1 2010-06-04 Tony Gentilcore <tonyg@chromium.org> 2 3 Reviewed by Adam Barth. 4 5 Persist V8's ScriptData to the memory cache. 6 https://bugs.webkit.org/show_bug.cgi?id=38661 7 8 This stores V8's ScriptData in the memory cache and also causes the 9 network platform layer to be notified of the available cacheable 10 metadata. 11 12 Chromium's morejs benchmark shows a 3-4% improvement on fast hardware. 13 14 No new tests because no new functionality. 15 16 * bindings/v8/ScriptSourceCode.h: 17 (WebCore::ScriptSourceCode::ScriptSourceCode): 18 (WebCore::ScriptSourceCode::cachedScript): 19 * bindings/v8/V8Proxy.cpp: 20 (WebCore::V8Proxy::compileScript): 21 (WebCore::V8Proxy::precompileScript): 22 (WebCore::V8Proxy::evaluate): 23 * bindings/v8/V8Proxy.h: 24 1 25 2010-06-04 Tony Gentilcore <tonyg@chromium.org> 2 26 -
trunk/WebCore/bindings/v8/ScriptSourceCode.h
r47912 r60684 32 32 #define ScriptSourceCode_h 33 33 34 #include "CachedResourceHandle.h" 34 35 #include "CachedScript.h" 35 36 #include "KURL.h" … … 42 43 ScriptSourceCode(const String& source, const KURL& url = KURL(), int startLine = 1) 43 44 : m_source(source) 45 , m_cachedScript(0) 44 46 , m_url(url) 45 47 , m_startLine(startLine) … … 51 53 ScriptSourceCode(CachedScript* cs) 52 54 : m_source(cs->script()) 55 , m_cachedScript(cs) 53 56 , m_url(ParsedURLString, cs->url()) 54 57 , m_startLine(1) … … 59 62 60 63 const String& source() const { return m_source; } 64 CachedScript* cachedScript() const { return m_cachedScript.get(); } 61 65 const KURL& url() const { return m_url; } 62 66 int startLine() const { return m_startLine; } … … 64 68 private: 65 69 String m_source; 70 CachedResourceHandle<CachedScript> m_cachedScript; 66 71 KURL m_url; 67 72 int m_startLine; -
trunk/WebCore/bindings/v8/V8Proxy.cpp
r58345 r60684 32 32 #include "V8Proxy.h" 33 33 34 #include "CachedMetadata.h" 34 35 #include "CSSMutableStyleDeclaration.h" 35 36 #include "DateExtension.h" … … 71 72 #include <wtf/Assertions.h> 72 73 #include <wtf/OwnArrayPtr.h> 74 #include <wtf/OwnPtr.h> 73 75 #include <wtf/StdLibExtras.h> 74 76 #include <wtf/StringExtras.h> … … 234 236 } 235 237 236 v8::Handle<v8::Script> V8Proxy::compileScript(v8::Handle<v8::String> code, const String& fileName, int baseLine )238 v8::Handle<v8::Script> V8Proxy::compileScript(v8::Handle<v8::String> code, const String& fileName, int baseLine, v8::ScriptData* scriptData) 237 239 { 238 240 const uint16_t* fileNameString = fromWebCoreString(fileName); … … 240 242 v8::Handle<v8::Integer> line = v8::Integer::New(baseLine); 241 243 v8::ScriptOrigin origin(name, line); 242 v8::Handle<v8::Script> script = v8::Script::Compile(code, &origin );244 v8::Handle<v8::Script> script = v8::Script::Compile(code, &origin, scriptData); 243 245 return script; 244 246 } … … 339 341 } 340 342 343 PassOwnPtr<v8::ScriptData> V8Proxy::precompileScript(const ScriptSourceCode& source) 344 { 345 // A pseudo-randomly chosen ID used to store and retrieve V8 ScriptData from 346 // the CachedScript. If the format changes, this ID should be changed too. 347 static const unsigned dataTypeID = 0xECC13BD7; 348 349 // Very small scripts are not worth the effort to preparse. 350 static const unsigned minPreparseLength = 1024; 351 352 CachedScript* cachedScript = source.cachedScript(); 353 if (!cachedScript) 354 return 0; 355 356 CachedMetadata* cachedMetadata = cachedScript->cachedMetadata(dataTypeID); 357 if (cachedMetadata) 358 return v8::ScriptData::New(cachedMetadata->data(), cachedMetadata->size()); 359 360 const CString& utf8Source = source.source().utf8(); 361 if (utf8Source.length() < minPreparseLength) 362 return 0; 363 364 v8::ScriptData* scriptData = v8::ScriptData::PreCompile(utf8Source.data(), utf8Source.length()); 365 cachedScript->setCachedMetadata(dataTypeID, scriptData->Data(), scriptData->Length()); 366 367 return scriptData; 368 } 369 341 370 v8::Local<v8::Value> V8Proxy::evaluate(const ScriptSourceCode& source, Node* node) 342 371 { … … 364 393 PlatformBridge::traceEventBegin("v8.compile", node, ""); 365 394 #endif 395 OwnPtr<v8::ScriptData> scriptData = precompileScript(source); 366 396 367 397 // NOTE: For compatibility with WebCore, ScriptSourceCode's line starts at 368 398 // 1, whereas v8 starts at 0. 369 v8::Handle<v8::Script> script = compileScript(code, source.url(), source.startLine() - 1 );399 v8::Handle<v8::Script> script = compileScript(code, source.url(), source.startLine() - 1, scriptData.get()); 370 400 #if PLATFORM(CHROMIUM) 371 401 PlatformBridge::traceEventEnd("v8.compile", node, ""); -
trunk/WebCore/bindings/v8/V8Proxy.h
r58919 r60684 286 286 static v8::Handle<v8::Value> checkNewLegal(const v8::Arguments&); 287 287 288 static v8::Handle<v8::Script> compileScript(v8::Handle<v8::String> code, const String& fileName, int baseLine );288 static v8::Handle<v8::Script> compileScript(v8::Handle<v8::String> code, const String& fileName, int baseLine, v8::ScriptData* scriptData = 0); 289 289 290 290 // If the exception code is different from zero, a DOM exception is … … 338 338 void resetIsolatedWorlds(); 339 339 340 PassOwnPtr<v8::ScriptData> precompileScript(const ScriptSourceCode& source); 341 340 342 // Returns false when we're out of memory in V8. 341 343 bool setInjectedScriptContextDebugId(v8::Handle<v8::Context> targetContext);
Note: See TracChangeset
for help on using the changeset viewer.