Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Unified Diff: Source/bindings/core/v8/V8ScriptRunner.cpp

Issue 549533002: Follow-on to "Restore in-memory parser cache for V8 compile" (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/bindings/core/v8/V8ScriptRunnerTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/core/v8/V8ScriptRunner.cpp
diff --git a/Source/bindings/core/v8/V8ScriptRunner.cpp b/Source/bindings/core/v8/V8ScriptRunner.cpp
index 57c9d3db84a61b00b6992c697165ea6d1fbe17fc..32720d4325a05379e3f3e3594eee9f38d3d62152 100644
--- a/Source/bindings/core/v8/V8ScriptRunner.cpp
+++ b/Source/bindings/core/v8/V8ScriptRunner.cpp
@@ -62,7 +62,7 @@ v8::Local<v8::Value> throwStackOverflowExceptionIfNeeded(v8::Isolate* isolate)
return result;
}
-v8::Local<v8::Script> compileAndProduceCache(v8::Handle<v8::String> code, v8::ScriptOrigin origin, ScriptResource* resource, v8::Isolate* isolate, v8::ScriptCompiler::CompileOptions options, unsigned cacheTag, Resource::MetadataCacheType cacheType)
+v8::Local<v8::Script> compileAndProduceCache(v8::Isolate* isolate, v8::Handle<v8::String> code, v8::ScriptOrigin origin, ScriptResource* resource, v8::ScriptCompiler::CompileOptions options, unsigned cacheTag, Resource::MetadataCacheType cacheType)
{
v8::ScriptCompiler::Source source(code, origin);
v8::Local<v8::Script> script = v8::ScriptCompiler::Compile(isolate, &source, options);
@@ -78,7 +78,7 @@ v8::Local<v8::Script> compileAndProduceCache(v8::Handle<v8::String> code, v8::Sc
return script;
}
-v8::Local<v8::Script> compileAndConsumeCache(v8::Handle<v8::String> code, v8::ScriptOrigin origin, ScriptResource* resource, v8::Isolate* isolate, v8::ScriptCompiler::CompileOptions options, unsigned cacheTag)
+v8::Local<v8::Script> compileAndConsumeCache(v8::Isolate* isolate, v8::Handle<v8::String> code, v8::ScriptOrigin origin, ScriptResource* resource, v8::ScriptCompiler::CompileOptions options, unsigned cacheTag)
{
// Consume existing cache data:
CachedMetadata* cachedMetadata = resource->cachedMetadata(cacheTag);
@@ -90,6 +90,16 @@ v8::Local<v8::Script> compileAndConsumeCache(v8::Handle<v8::String> code, v8::Sc
return v8::ScriptCompiler::Compile(isolate, &source, options);
}
+unsigned tagForParserCache()
+{
+ return StringHash::hash(v8::V8::GetVersion()) * 2;
+}
+
+unsigned tagForCodeCache()
+{
+ return StringHash::hash(v8::V8::GetVersion()) * 2 + 1;
+}
+
} // namespace
v8::Local<v8::Script> V8ScriptRunner::compileScript(const ScriptSourceCode& source, v8::Isolate* isolate, AccessControlStatus corsStatus, V8CacheOptions cacheOptions)
@@ -118,26 +128,26 @@ v8::Local<v8::Script> V8ScriptRunner::compileScript(v8::Handle<v8::String> code,
} else {
switch (cacheOptions) {
case V8CacheOptionsParse:
- cacheTag = StringHash::hash(v8::V8::GetVersion()) * 2;
+ cacheTag = tagForParserCache();
script = resource->cachedMetadata(cacheTag)
- ? compileAndConsumeCache(code, origin, resource, isolate, v8::ScriptCompiler::kConsumeParserCache, cacheTag)
- : compileAndProduceCache(code, origin, resource, isolate, v8::ScriptCompiler::kProduceParserCache, cacheTag, Resource::SendToPlatform);
+ ? compileAndConsumeCache(isolate, code, origin, resource, v8::ScriptCompiler::kConsumeParserCache, cacheTag)
+ : compileAndProduceCache(isolate, code, origin, resource, v8::ScriptCompiler::kProduceParserCache, cacheTag, Resource::SendToPlatform);
break;
case V8CacheOptionsCode:
- cacheTag = StringHash::hash(v8::V8::GetVersion()) * 2 + 1;
+ cacheTag = tagForCodeCache();
script = resource->cachedMetadata(cacheTag)
- ? compileAndConsumeCache(code, origin, resource, isolate, v8::ScriptCompiler::kConsumeCodeCache, cacheTag)
- : compileAndProduceCache(code, origin, resource, isolate, v8::ScriptCompiler::kProduceCodeCache, cacheTag, Resource::SendToPlatform);
+ ? compileAndConsumeCache(isolate, code, origin, resource, v8::ScriptCompiler::kConsumeCodeCache, cacheTag)
+ : compileAndProduceCache(isolate, code, origin, resource, v8::ScriptCompiler::kProduceCodeCache, cacheTag, Resource::SendToPlatform);
break;
case V8CacheOptionsOff:
// Previous behaviour was to always generate an in-memory parser
// cache. We emulate this here.
- // TODO(vogelheim): Determine whether this should get its own
- // setting, so we can also have a true 'off'.
- cacheTag = StringHash::hash(v8::V8::GetVersion()) * 2;
+ // FIXME: Determine whether this should get its own setting, so we
+ // can also have a true 'off'.
+ cacheTag = tagForParserCache();
script = resource->cachedMetadata(cacheTag)
- ? compileAndConsumeCache(code, origin, resource, isolate, v8::ScriptCompiler::kConsumeParserCache, cacheTag)
- : compileAndProduceCache(code, origin, resource, isolate, v8::ScriptCompiler::kProduceParserCache, cacheTag, Resource::CacheLocally);
+ ? compileAndConsumeCache(isolate, code, origin, resource, v8::ScriptCompiler::kConsumeParserCache, cacheTag)
+ : compileAndProduceCache(isolate, code, origin, resource, v8::ScriptCompiler::kProduceParserCache, cacheTag, Resource::CacheLocally);
break;
}
}
« no previous file with comments | « no previous file | Source/bindings/core/v8/V8ScriptRunnerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698