| OLD | NEW |
| 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 Loading... |
| 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 // Do not cache for small scripts, even if caching is available. | 283 if (cacheOptions == V8CacheOptionsNone) |
| 284 if (cacheOptions == V8CacheOptionsNone || code->Length() < minimalCodeLength
) | |
| 285 return bind(compileWithoutOptions, V8CompileHistogram::Cacheable); | 284 return bind(compileWithoutOptions, V8CompileHistogram::Cacheable); |
| 286 | 285 |
| 287 // The cacheOptions will guide our strategy: | 286 // The cacheOptions will guide our strategy: |
| 288 // FIXME: Clean up code caching options. crbug.com/455187. | 287 // FIXME: Clean up code caching options. crbug.com/455187. |
| 289 switch (cacheOptions) { | 288 switch (cacheOptions) { |
| 290 case V8CacheOptionsDefault: | 289 case V8CacheOptionsDefault: |
| 291 case V8CacheOptionsParseMemory: | 290 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 } |
| 292 // Use parser-cache; in-memory only. | 295 // Use parser-cache; in-memory only. |
| 293 return bind(compileAndConsumeOrProduce, cacheHandler, cacheTag(CacheTagP
arser, cacheHandler), v8::ScriptCompiler::kConsumeParserCache, v8::ScriptCompile
r::kProduceParserCache, false, CachedMetadataHandler::CacheLocally); | 296 return bind(compileAndConsumeOrProduce, cacheHandler, cacheTag(CacheTagP
arser, cacheHandler), v8::ScriptCompiler::kConsumeParserCache, v8::ScriptCompile
r::kProduceParserCache, false, CachedMetadataHandler::CacheLocally); |
| 294 break; | 297 break; |
| 295 | 298 |
| 296 case V8CacheOptionsParse: | 299 case V8CacheOptionsParse: |
| 297 // Use parser-cache. | 300 // Use parser-cache. |
| 298 return bind(compileAndConsumeOrProduce, cacheHandler, cacheTag(CacheTagP
arser, cacheHandler), v8::ScriptCompiler::kConsumeParserCache, v8::ScriptCompile
r::kProduceParserCache, false, CachedMetadataHandler::SendToPlatform); | 301 return bind(compileAndConsumeOrProduce, cacheHandler, cacheTag(CacheTagP
arser, cacheHandler), v8::ScriptCompiler::kConsumeParserCache, v8::ScriptCompile
r::kProduceParserCache, false, CachedMetadataHandler::SendToPlatform); |
| 299 break; | 302 break; |
| 300 | 303 |
| 301 case V8CacheOptionsHeuristicsDefault: | 304 case V8CacheOptionsHeuristicsDefault: |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 { | 506 { |
| 504 return cacheTag(CacheTagParser, cacheHandler); | 507 return cacheTag(CacheTagParser, cacheHandler); |
| 505 } | 508 } |
| 506 | 509 |
| 507 unsigned V8ScriptRunner::tagForCodeCache(CachedMetadataHandler* cacheHandler) | 510 unsigned V8ScriptRunner::tagForCodeCache(CachedMetadataHandler* cacheHandler) |
| 508 { | 511 { |
| 509 return cacheTag(CacheTagCode, cacheHandler); | 512 return cacheTag(CacheTagCode, cacheHandler); |
| 510 } | 513 } |
| 511 | 514 |
| 512 } // namespace blink | 515 } // namespace blink |
| OLD | NEW |