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

Side by Side Diff: Source/bindings/core/v8/V8ScriptRunner.cpp

Issue 988303003: Do not cache resource metadata if the source code size is small. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 // Select a compile function from any of the above, mainly depending on 273 // Select a compile function from any of the above, mainly depending on
274 // cacheOptions. 274 // cacheOptions.
275 PassOwnPtr<CompileFn> selectCompileFunction(V8CacheOptions cacheOptions, CachedM etadataHandler* cacheHandler, v8::Handle<v8::String> code) 275 PassOwnPtr<CompileFn> selectCompileFunction(V8CacheOptions cacheOptions, CachedM etadataHandler* cacheHandler, v8::Handle<v8::String> code)
276 { 276 {
277 static const int minimalCodeLength = 1024; 277 static const int minimalCodeLength = 1024;
278 278
279 if (!cacheHandler) 279 if (!cacheHandler)
280 // Caching is not available in this case. 280 // Caching is not available in this case.
281 return bind(compileWithoutOptions, V8CompileHistogram::Noncacheable); 281 return bind(compileWithoutOptions, V8CompileHistogram::Noncacheable);
282 282
283 if (cacheOptions == V8CacheOptionsNone) 283 // Do not cache for small scripts, even if caching is available.
falken 2015/03/10 00:54:05 This comment kind of just repeats the code. It'd b
284 if (cacheOptions == V8CacheOptionsNone || code->Length() < minimalCodeLength )
284 return bind(compileWithoutOptions, V8CompileHistogram::Cacheable); 285 return bind(compileWithoutOptions, V8CompileHistogram::Cacheable);
285 286
286 // The cacheOptions will guide our strategy: 287 // The cacheOptions will guide our strategy:
287 // FIXME: Clean up code caching options. crbug.com/455187. 288 // FIXME: Clean up code caching options. crbug.com/455187.
288 switch (cacheOptions) { 289 switch (cacheOptions) {
289 case V8CacheOptionsDefault: 290 case V8CacheOptionsDefault:
290 case V8CacheOptionsParseMemory: 291 case V8CacheOptionsParseMemory:
291 if (code->Length() < minimalCodeLength) {
292 // Do not cache for small scripts, though caching is available.
293 return bind(compileWithoutOptions, V8CompileHistogram::Cacheable);
294 }
295 // Use parser-cache; in-memory only. 292 // Use parser-cache; in-memory only.
296 return bind(compileAndConsumeOrProduce, cacheHandler, cacheTag(CacheTagP arser, cacheHandler), v8::ScriptCompiler::kConsumeParserCache, v8::ScriptCompile r::kProduceParserCache, false, CachedMetadataHandler::CacheLocally); 293 return bind(compileAndConsumeOrProduce, cacheHandler, cacheTag(CacheTagP arser, cacheHandler), v8::ScriptCompiler::kConsumeParserCache, v8::ScriptCompile r::kProduceParserCache, false, CachedMetadataHandler::CacheLocally);
297 break; 294 break;
298 295
299 case V8CacheOptionsParse: 296 case V8CacheOptionsParse:
300 // Use parser-cache. 297 // Use parser-cache.
301 return bind(compileAndConsumeOrProduce, cacheHandler, cacheTag(CacheTagP arser, cacheHandler), v8::ScriptCompiler::kConsumeParserCache, v8::ScriptCompile r::kProduceParserCache, false, CachedMetadataHandler::SendToPlatform); 298 return bind(compileAndConsumeOrProduce, cacheHandler, cacheTag(CacheTagP arser, cacheHandler), v8::ScriptCompiler::kConsumeParserCache, v8::ScriptCompile r::kProduceParserCache, false, CachedMetadataHandler::SendToPlatform);
302 break; 299 break;
303 300
304 case V8CacheOptionsHeuristicsDefault: 301 case V8CacheOptionsHeuristicsDefault:
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 { 503 {
507 return cacheTag(CacheTagParser, cacheHandler); 504 return cacheTag(CacheTagParser, cacheHandler);
508 } 505 }
509 506
510 unsigned V8ScriptRunner::tagForCodeCache(CachedMetadataHandler* cacheHandler) 507 unsigned V8ScriptRunner::tagForCodeCache(CachedMetadataHandler* cacheHandler)
511 { 508 {
512 return cacheTag(CacheTagCode, cacheHandler); 509 return cacheTag(CacheTagCode, cacheHandler);
513 } 510 }
514 511
515 } // namespace blink 512 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698