| 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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 cacheHandler->clearCachedMetadata(cacheType); | 241 cacheHandler->clearCachedMetadata(cacheType); |
| 242 cacheHandler->setCachedMetadata(cacheTag(CacheTagParser, cacheHandler),
reinterpret_cast<const char*>(newCachedData->data), newCachedData->length, cache
Type); | 242 cacheHandler->setCachedMetadata(cacheTag(CacheTagParser, cacheHandler),
reinterpret_cast<const char*>(newCachedData->data), newCachedData->length, cache
Type); |
| 243 break; | 243 break; |
| 244 } | 244 } |
| 245 | 245 |
| 246 case V8CacheOptionsDefault: | 246 case V8CacheOptionsDefault: |
| 247 case V8CacheOptionsCode: | 247 case V8CacheOptionsCode: |
| 248 V8ScriptRunner::setCacheTimeStamp(cacheHandler); | 248 V8ScriptRunner::setCacheTimeStamp(cacheHandler); |
| 249 break; | 249 break; |
| 250 | 250 |
| 251 case V8CacheOptionsAlways: |
| 252 // Currently V8CacheOptionsAlways doesn't support streaming. |
| 253 ASSERT_NOT_REACHED(); |
| 251 case V8CacheOptionsNone: | 254 case V8CacheOptionsNone: |
| 252 break; | 255 break; |
| 253 } | 256 } |
| 254 return script; | 257 return script; |
| 255 } | 258 } |
| 256 | 259 |
| 257 typedef Function<v8::MaybeLocal<v8::Script>(v8::Isolate*, v8::Local<v8::String>,
v8::ScriptOrigin)> CompileFn; | 260 typedef Function<v8::MaybeLocal<v8::Script>(v8::Isolate*, v8::Local<v8::String>,
v8::ScriptOrigin)> CompileFn; |
| 258 | 261 |
| 259 // A notation convenience: WTF::bind<...> needs to be given the right argument | 262 // A notation convenience: WTF::bind<...> needs to be given the right argument |
| 260 // types. We have an awful lot of bind calls below, all with the same types, so | 263 // types. We have an awful lot of bind calls below, all with the same types, so |
| (...skipping 27 matching lines...) Expand all Loading... |
| 288 return bind(compileWithoutOptions, V8CompileHistogram::Cacheable); | 291 return bind(compileWithoutOptions, V8CompileHistogram::Cacheable); |
| 289 | 292 |
| 290 // The cacheOptions will guide our strategy: | 293 // The cacheOptions will guide our strategy: |
| 291 switch (cacheOptions) { | 294 switch (cacheOptions) { |
| 292 case V8CacheOptionsParse: | 295 case V8CacheOptionsParse: |
| 293 // Use parser-cache; in-memory only. | 296 // Use parser-cache; in-memory only. |
| 294 return bind(compileAndConsumeOrProduce, cacheHandler, cacheTag(CacheTagP
arser, cacheHandler), v8::ScriptCompiler::kConsumeParserCache, v8::ScriptCompile
r::kProduceParserCache, CachedMetadataHandler::CacheLocally); | 297 return bind(compileAndConsumeOrProduce, cacheHandler, cacheTag(CacheTagP
arser, cacheHandler), v8::ScriptCompiler::kConsumeParserCache, v8::ScriptCompile
r::kProduceParserCache, CachedMetadataHandler::CacheLocally); |
| 295 break; | 298 break; |
| 296 | 299 |
| 297 case V8CacheOptionsDefault: | 300 case V8CacheOptionsDefault: |
| 298 case V8CacheOptionsCode: { | 301 case V8CacheOptionsCode: |
| 302 case V8CacheOptionsAlways: { |
| 299 // Use code caching for recently seen resources. | 303 // Use code caching for recently seen resources. |
| 300 // Use compression depending on the cache option. | 304 // Use compression depending on the cache option. |
| 301 unsigned codeCacheTag = cacheTag(CacheTagCode, cacheHandler); | 305 unsigned codeCacheTag = cacheTag(CacheTagCode, cacheHandler); |
| 302 CachedMetadata* codeCache = cacheHandler->cachedMetadata(codeCacheTag); | 306 CachedMetadata* codeCache = cacheHandler->cachedMetadata(codeCacheTag); |
| 303 if (codeCache) | 307 if (codeCache) |
| 304 return bind(compileAndConsumeCache, cacheHandler, codeCacheTag, v8::
ScriptCompiler::kConsumeCodeCache); | 308 return bind(compileAndConsumeCache, cacheHandler, codeCacheTag, v8::
ScriptCompiler::kConsumeCodeCache); |
| 305 if (!isResourceHotForCaching(cacheHandler, hotHours)) { | 309 if (cacheOptions != V8CacheOptionsAlways && !isResourceHotForCaching(cac
heHandler, hotHours)) { |
| 306 V8ScriptRunner::setCacheTimeStamp(cacheHandler); | 310 V8ScriptRunner::setCacheTimeStamp(cacheHandler); |
| 307 return bind(compileWithoutOptions, V8CompileHistogram::Cacheable); | 311 return bind(compileWithoutOptions, V8CompileHistogram::Cacheable); |
| 308 } | 312 } |
| 309 return bind(compileAndProduceCache, cacheHandler, codeCacheTag, v8::Scri
ptCompiler::kProduceCodeCache, CachedMetadataHandler::SendToPlatform); | 313 return bind(compileAndProduceCache, cacheHandler, codeCacheTag, v8::Scri
ptCompiler::kProduceCodeCache, CachedMetadataHandler::SendToPlatform); |
| 310 break; | 314 break; |
| 311 } | 315 } |
| 312 | 316 |
| 313 case V8CacheOptionsNone: | 317 case V8CacheOptionsNone: |
| 314 // Shouldn't happen, as this is handled above. | 318 // Shouldn't happen, as this is handled above. |
| 315 // Case is here so that compiler can check all cases are handled. | 319 // Case is here so that compiler can check all cases are handled. |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 // Store a timestamp to the cache as hint. | 527 // Store a timestamp to the cache as hint. |
| 524 void V8ScriptRunner::setCacheTimeStamp(CachedMetadataHandler* cacheHandler) | 528 void V8ScriptRunner::setCacheTimeStamp(CachedMetadataHandler* cacheHandler) |
| 525 { | 529 { |
| 526 double now = WTF::currentTime(); | 530 double now = WTF::currentTime(); |
| 527 unsigned tag = cacheTag(CacheTagTimeStamp, cacheHandler); | 531 unsigned tag = cacheTag(CacheTagTimeStamp, cacheHandler); |
| 528 cacheHandler->clearCachedMetadata(CachedMetadataHandler::CacheLocally); | 532 cacheHandler->clearCachedMetadata(CachedMetadataHandler::CacheLocally); |
| 529 cacheHandler->setCachedMetadata(tag, reinterpret_cast<char*>(&now), sizeof(n
ow), CachedMetadataHandler::SendToPlatform); | 533 cacheHandler->setCachedMetadata(tag, reinterpret_cast<char*>(&now), sizeof(n
ow), CachedMetadataHandler::SendToPlatform); |
| 530 } | 534 } |
| 531 | 535 |
| 532 } // namespace blink | 536 } // namespace blink |
| OLD | NEW |