| 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 21 matching lines...) Expand all Loading... |
| 32 #include "bindings/core/v8/V8GCController.h" | 32 #include "bindings/core/v8/V8GCController.h" |
| 33 #include "bindings/core/v8/V8RecursionScope.h" | 33 #include "bindings/core/v8/V8RecursionScope.h" |
| 34 #include "bindings/core/v8/V8ThrowException.h" | 34 #include "bindings/core/v8/V8ThrowException.h" |
| 35 #include "core/dom/ExecutionContext.h" | 35 #include "core/dom/ExecutionContext.h" |
| 36 #include "core/fetch/CachedMetadata.h" | 36 #include "core/fetch/CachedMetadata.h" |
| 37 #include "core/fetch/ScriptResource.h" | 37 #include "core/fetch/ScriptResource.h" |
| 38 #include "core/inspector/InspectorTraceEvents.h" | 38 #include "core/inspector/InspectorTraceEvents.h" |
| 39 #include "platform/ScriptForbiddenScope.h" | 39 #include "platform/ScriptForbiddenScope.h" |
| 40 #include "platform/TraceEvent.h" | 40 #include "platform/TraceEvent.h" |
| 41 #include "public/platform/Platform.h" | 41 #include "public/platform/Platform.h" |
| 42 #include "third_party/snappy/src/snappy.h" | |
| 43 #include "wtf/CurrentTime.h" | 42 #include "wtf/CurrentTime.h" |
| 44 | 43 |
| 45 #if defined(WTF_OS_WIN) | 44 #if defined(WTF_OS_WIN) |
| 46 #include <malloc.h> | 45 #include <malloc.h> |
| 47 #else | 46 #else |
| 48 #include <alloca.h> | 47 #include <alloca.h> |
| 49 #endif | 48 #endif |
| 50 | 49 |
| 51 namespace blink { | 50 namespace blink { |
| 52 | 51 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 108 |
| 110 // Compile a script without any caching or compile options. | 109 // Compile a script without any caching or compile options. |
| 111 v8::MaybeLocal<v8::Script> compileWithoutOptions(V8CompileHistogram::Cacheabilit
y cacheability, v8::Isolate* isolate, v8::Local<v8::String> code, v8::ScriptOrig
in origin) | 110 v8::MaybeLocal<v8::Script> compileWithoutOptions(V8CompileHistogram::Cacheabilit
y cacheability, v8::Isolate* isolate, v8::Local<v8::String> code, v8::ScriptOrig
in origin) |
| 112 { | 111 { |
| 113 V8CompileHistogram histogramScope(cacheability); | 112 V8CompileHistogram histogramScope(cacheability); |
| 114 v8::ScriptCompiler::Source source(code, origin); | 113 v8::ScriptCompiler::Source source(code, origin); |
| 115 return v8::ScriptCompiler::Compile(isolate->GetCurrentContext(), &source, v8
::ScriptCompiler::kNoCompileOptions); | 114 return v8::ScriptCompiler::Compile(isolate->GetCurrentContext(), &source, v8
::ScriptCompiler::kNoCompileOptions); |
| 116 } | 115 } |
| 117 | 116 |
| 118 // Compile a script, and consume a V8 cache that was generated previously. | 117 // Compile a script, and consume a V8 cache that was generated previously. |
| 119 v8::MaybeLocal<v8::Script> compileAndConsumeCache(CachedMetadataHandler* cacheHa
ndler, unsigned tag, v8::ScriptCompiler::CompileOptions compileOptions, bool com
pressed, v8::Isolate* isolate, v8::Local<v8::String> code, v8::ScriptOrigin orig
in) | 118 v8::MaybeLocal<v8::Script> compileAndConsumeCache(CachedMetadataHandler* cacheHa
ndler, unsigned tag, v8::ScriptCompiler::CompileOptions compileOptions, v8::Isol
ate* isolate, v8::Local<v8::String> code, v8::ScriptOrigin origin) |
| 120 { | 119 { |
| 121 V8CompileHistogram histogramScope(V8CompileHistogram::Cacheable); | 120 V8CompileHistogram histogramScope(V8CompileHistogram::Cacheable); |
| 122 CachedMetadata* cachedMetadata = cacheHandler->cachedMetadata(tag); | 121 CachedMetadata* cachedMetadata = cacheHandler->cachedMetadata(tag); |
| 123 const char* data = cachedMetadata->data(); | 122 const char* data = cachedMetadata->data(); |
| 124 int length = cachedMetadata->size(); | 123 int length = cachedMetadata->size(); |
| 125 std::string uncompressedOutput; | 124 v8::ScriptCompiler::CachedData* cachedData = new v8::ScriptCompiler::CachedD
ata( |
| 126 bool invalidCache = false; | 125 reinterpret_cast<const uint8_t*>(data), length, v8::ScriptCompiler::Cach
edData::BufferNotOwned); |
| 127 if (compressed) { | 126 v8::ScriptCompiler::Source source(code, origin, cachedData); |
| 128 if (snappy::Uncompress(data, length, &uncompressedOutput)) { | 127 v8::MaybeLocal<v8::Script> script = v8::ScriptCompiler::Compile(isolate->Get
CurrentContext(), &source, compileOptions); |
| 129 data = uncompressedOutput.data(); | 128 if (cachedData->rejected) |
| 130 length = uncompressedOutput.length(); | |
| 131 } else { | |
| 132 invalidCache = true; | |
| 133 } | |
| 134 } | |
| 135 v8::MaybeLocal<v8::Script> script; | |
| 136 if (invalidCache) { | |
| 137 v8::ScriptCompiler::Source source(code, origin); | |
| 138 script = v8::ScriptCompiler::Compile(isolate->GetCurrentContext(), &sour
ce, v8::ScriptCompiler::kNoCompileOptions); | |
| 139 } else { | |
| 140 v8::ScriptCompiler::CachedData* cachedData = new v8::ScriptCompiler::Cac
hedData( | |
| 141 reinterpret_cast<const uint8_t*>(data), length, v8::ScriptCompiler::
CachedData::BufferNotOwned); | |
| 142 v8::ScriptCompiler::Source source(code, origin, cachedData); | |
| 143 script = v8::ScriptCompiler::Compile(isolate->GetCurrentContext(), &sour
ce, compileOptions); | |
| 144 invalidCache = cachedData->rejected; | |
| 145 } | |
| 146 if (invalidCache) | |
| 147 cacheHandler->clearCachedMetadata(CachedMetadataHandler::SendToPlatform)
; | 129 cacheHandler->clearCachedMetadata(CachedMetadataHandler::SendToPlatform)
; |
| 148 return script; | 130 return script; |
| 149 } | 131 } |
| 150 | 132 |
| 151 // Compile a script, and produce a V8 cache for future use. | 133 // Compile a script, and produce a V8 cache for future use. |
| 152 v8::MaybeLocal<v8::Script> compileAndProduceCache(CachedMetadataHandler* cacheHa
ndler, unsigned tag, v8::ScriptCompiler::CompileOptions compileOptions, bool com
pressed, CachedMetadataHandler::CacheType cacheType, v8::Isolate* isolate, v8::L
ocal<v8::String> code, v8::ScriptOrigin origin) | 134 v8::MaybeLocal<v8::Script> compileAndProduceCache(CachedMetadataHandler* cacheHa
ndler, unsigned tag, v8::ScriptCompiler::CompileOptions compileOptions, CachedMe
tadataHandler::CacheType cacheType, v8::Isolate* isolate, v8::Local<v8::String>
code, v8::ScriptOrigin origin) |
| 153 { | 135 { |
| 154 V8CompileHistogram histogramScope(V8CompileHistogram::Cacheable); | 136 V8CompileHistogram histogramScope(V8CompileHistogram::Cacheable); |
| 155 v8::ScriptCompiler::Source source(code, origin); | 137 v8::ScriptCompiler::Source source(code, origin); |
| 156 v8::MaybeLocal<v8::Script> script = v8::ScriptCompiler::Compile(isolate->Get
CurrentContext(), &source, compileOptions); | 138 v8::MaybeLocal<v8::Script> script = v8::ScriptCompiler::Compile(isolate->Get
CurrentContext(), &source, compileOptions); |
| 157 const v8::ScriptCompiler::CachedData* cachedData = source.GetCachedData(); | 139 const v8::ScriptCompiler::CachedData* cachedData = source.GetCachedData(); |
| 158 if (cachedData) { | 140 if (cachedData) { |
| 159 const char* data = reinterpret_cast<const char*>(cachedData->data); | 141 const char* data = reinterpret_cast<const char*>(cachedData->data); |
| 160 int length = cachedData->length; | 142 int length = cachedData->length; |
| 161 std::string compressedOutput; | |
| 162 if (compressed) { | |
| 163 snappy::Compress(data, length, &compressedOutput); | |
| 164 data = compressedOutput.data(); | |
| 165 length = compressedOutput.length(); | |
| 166 } | |
| 167 if (length > 1024) { | 143 if (length > 1024) { |
| 168 // Omit histogram samples for small cache data to avoid outliers. | 144 // Omit histogram samples for small cache data to avoid outliers. |
| 169 int cacheSizeRatio = static_cast<int>(100.0 * length / code->Length(
)); | 145 int cacheSizeRatio = static_cast<int>(100.0 * length / code->Length(
)); |
| 170 Platform::current()->histogramCustomCounts("V8.CodeCacheSizeRatio",
cacheSizeRatio, 0, 10000, 50); | 146 Platform::current()->histogramCustomCounts("V8.CodeCacheSizeRatio",
cacheSizeRatio, 0, 10000, 50); |
| 171 } | 147 } |
| 172 cacheHandler->clearCachedMetadata(CachedMetadataHandler::CacheLocally); | 148 cacheHandler->clearCachedMetadata(CachedMetadataHandler::CacheLocally); |
| 173 cacheHandler->setCachedMetadata(tag, data, length, cacheType); | 149 cacheHandler->setCachedMetadata(tag, data, length, cacheType); |
| 174 } | 150 } |
| 175 return script; | 151 return script; |
| 176 } | 152 } |
| 177 | 153 |
| 178 // Compile a script, and consume or produce a V8 Cache, depending on whether the | 154 // Compile a script, and consume or produce a V8 Cache, depending on whether the |
| 179 // given resource already has cached data available. | 155 // given resource already has cached data available. |
| 180 v8::MaybeLocal<v8::Script> compileAndConsumeOrProduce(CachedMetadataHandler* cac
heHandler, unsigned tag, v8::ScriptCompiler::CompileOptions consumeOptions, v8::
ScriptCompiler::CompileOptions produceOptions, bool compressed, CachedMetadataHa
ndler::CacheType cacheType, v8::Isolate* isolate, v8::Local<v8::String> code, v8
::ScriptOrigin origin) | 156 v8::MaybeLocal<v8::Script> compileAndConsumeOrProduce(CachedMetadataHandler* cac
heHandler, unsigned tag, v8::ScriptCompiler::CompileOptions consumeOptions, v8::
ScriptCompiler::CompileOptions produceOptions, CachedMetadataHandler::CacheType
cacheType, v8::Isolate* isolate, v8::Local<v8::String> code, v8::ScriptOrigin or
igin) |
| 181 { | 157 { |
| 182 return cacheHandler->cachedMetadata(tag) | 158 return cacheHandler->cachedMetadata(tag) |
| 183 ? compileAndConsumeCache(cacheHandler, tag, consumeOptions, compressed,
isolate, code, origin) | 159 ? compileAndConsumeCache(cacheHandler, tag, consumeOptions, isolate, cod
e, origin) |
| 184 : compileAndProduceCache(cacheHandler, tag, produceOptions, compressed,
cacheType, isolate, code, origin); | 160 : compileAndProduceCache(cacheHandler, tag, produceOptions, cacheType, i
solate, code, origin); |
| 185 } | 161 } |
| 186 | 162 |
| 187 enum CacheTagKind { | 163 enum CacheTagKind { |
| 188 CacheTagParser = 0, | 164 CacheTagParser = 0, |
| 189 CacheTagCode = 1, | 165 CacheTagCode = 1, |
| 190 CacheTagCodeCompressed = 2, | |
| 191 CacheTagTimeStamp = 3, | 166 CacheTagTimeStamp = 3, |
| 192 CacheTagLast | 167 CacheTagLast |
| 193 }; | 168 }; |
| 194 | 169 |
| 195 static const int kCacheTagKindSize = 2; | 170 static const int kCacheTagKindSize = 2; |
| 196 | 171 |
| 197 unsigned cacheTag(CacheTagKind kind, CachedMetadataHandler* cacheHandler) | 172 unsigned cacheTag(CacheTagKind kind, CachedMetadataHandler* cacheHandler) |
| 198 { | 173 { |
| 199 static_assert((1 << kCacheTagKindSize) >= CacheTagLast, "CacheTagLast must b
e large enough"); | 174 static_assert((1 << kCacheTagKindSize) >= CacheTagLast, "CacheTagLast must b
e large enough"); |
| 200 | 175 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 V8CompileHistogram histogramScope(V8CompileHistogram::Noncacheable); | 214 V8CompileHistogram histogramScope(V8CompileHistogram::Noncacheable); |
| 240 v8::MaybeLocal<v8::Script> script = v8::ScriptCompiler::Compile(isolate->Get
CurrentContext(), streamer->source(), code, origin); | 215 v8::MaybeLocal<v8::Script> script = v8::ScriptCompiler::Compile(isolate->Get
CurrentContext(), streamer->source(), code, origin); |
| 241 | 216 |
| 242 if (!cacheHandler) | 217 if (!cacheHandler) |
| 243 return script; | 218 return script; |
| 244 | 219 |
| 245 // If the non-streaming compiler uses the parser cache, retrieve and store | 220 // If the non-streaming compiler uses the parser cache, retrieve and store |
| 246 // the cache data. If the code cache uses time stamp as heuristic, set that | 221 // the cache data. If the code cache uses time stamp as heuristic, set that |
| 247 // time stamp. | 222 // time stamp. |
| 248 switch (cacheOptions) { | 223 switch (cacheOptions) { |
| 249 case V8CacheOptionsParseMemory: | |
| 250 case V8CacheOptionsParse: { | 224 case V8CacheOptionsParse: { |
| 251 const v8::ScriptCompiler::CachedData* newCachedData = streamer->source()
->GetCachedData(); | 225 const v8::ScriptCompiler::CachedData* newCachedData = streamer->source()
->GetCachedData(); |
| 252 if (!newCachedData) | 226 if (!newCachedData) |
| 253 break; | 227 break; |
| 254 CachedMetadataHandler::CacheType cacheType = (cacheOptions == V8CacheOpt
ionsParse) ? CachedMetadataHandler::SendToPlatform : CachedMetadataHandler::Cach
eLocally; | 228 CachedMetadataHandler::CacheType cacheType = (cacheOptions == V8CacheOpt
ionsParse) ? CachedMetadataHandler::SendToPlatform : CachedMetadataHandler::Cach
eLocally; |
| 255 cacheHandler->clearCachedMetadata(cacheType); | 229 cacheHandler->clearCachedMetadata(cacheType); |
| 256 cacheHandler->setCachedMetadata(cacheTag(CacheTagParser, cacheHandler),
reinterpret_cast<const char*>(newCachedData->data), newCachedData->length, cache
Type); | 230 cacheHandler->setCachedMetadata(cacheTag(CacheTagParser, cacheHandler),
reinterpret_cast<const char*>(newCachedData->data), newCachedData->length, cache
Type); |
| 257 break; | 231 break; |
| 258 } | 232 } |
| 259 | 233 |
| 260 case V8CacheOptionsDefault: | 234 case V8CacheOptionsDefault: |
| 261 case V8CacheOptionsHeuristics: | 235 case V8CacheOptionsCode: |
| 262 case V8CacheOptionsHeuristicsMobile: | |
| 263 case V8CacheOptionsRecent: | |
| 264 case V8CacheOptionsRecentSmall: | |
| 265 setCacheTimeStamp(cacheHandler); | 236 setCacheTimeStamp(cacheHandler); |
| 266 break; | 237 break; |
| 267 | 238 |
| 268 default: | 239 case V8CacheOptionsNone: |
| 269 break; | 240 break; |
| 270 } | 241 } |
| 271 return script; | 242 return script; |
| 272 } | 243 } |
| 273 | 244 |
| 274 typedef Function<v8::MaybeLocal<v8::Script>(v8::Isolate*, v8::Local<v8::String>,
v8::ScriptOrigin)> CompileFn; | 245 typedef Function<v8::MaybeLocal<v8::Script>(v8::Isolate*, v8::Local<v8::String>,
v8::ScriptOrigin)> CompileFn; |
| 275 | 246 |
| 276 // A notation convenience: WTF::bind<...> needs to be given the right argument | 247 // A notation convenience: WTF::bind<...> needs to be given the right argument |
| 277 // types. We have an awful lot of bind calls below, all with the same types, so | 248 // types. We have an awful lot of bind calls below, all with the same types, so |
| 278 // this local bind lets WTF::bind to all the work, but 'knows' the right | 249 // this local bind lets WTF::bind to all the work, but 'knows' the right |
| 279 // parameter types. | 250 // parameter types. |
| 280 // This version isn't quite as smart as the real WTF::bind, though, so you | 251 // This version isn't quite as smart as the real WTF::bind, though, so you |
| 281 // sometimes may still have to call the original. | 252 // sometimes may still have to call the original. |
| 282 template<typename... A> | 253 template<typename... A> |
| 283 PassOwnPtr<CompileFn> bind(const A&... args) | 254 PassOwnPtr<CompileFn> bind(const A&... args) |
| 284 { | 255 { |
| 285 return WTF::bind<v8::Isolate*, v8::Local<v8::String>, v8::ScriptOrigin>(args
...); | 256 return WTF::bind<v8::Isolate*, v8::Local<v8::String>, v8::ScriptOrigin>(args
...); |
| 286 } | 257 } |
| 287 | 258 |
| 288 // Select a compile function from any of the above, mainly depending on | 259 // Select a compile function from any of the above, mainly depending on |
| 289 // cacheOptions. | 260 // cacheOptions. |
| 290 PassOwnPtr<CompileFn> selectCompileFunction(V8CacheOptions cacheOptions, CachedM
etadataHandler* cacheHandler, v8::Local<v8::String> code) | 261 PassOwnPtr<CompileFn> selectCompileFunction(V8CacheOptions cacheOptions, CachedM
etadataHandler* cacheHandler, v8::Local<v8::String> code) |
| 291 { | 262 { |
| 292 static const int minimalCodeLength = 1024; | 263 static const int minimalCodeLength = 1024; |
| 264 static const int hotHours = 72; |
| 293 | 265 |
| 294 if (!cacheHandler) | 266 if (!cacheHandler) |
| 295 // Caching is not available in this case. | 267 // Caching is not available in this case. |
| 296 return bind(compileWithoutOptions, V8CompileHistogram::Noncacheable); | 268 return bind(compileWithoutOptions, V8CompileHistogram::Noncacheable); |
| 297 | 269 |
| 298 if (cacheOptions == V8CacheOptionsNone) | 270 if (cacheOptions == V8CacheOptionsNone) |
| 299 return bind(compileWithoutOptions, V8CompileHistogram::Cacheable); | 271 return bind(compileWithoutOptions, V8CompileHistogram::Cacheable); |
| 300 | 272 |
| 301 // Caching is not worthwhile for small scripts. Do not use caching | 273 // Caching is not worthwhile for small scripts. Do not use caching |
| 302 // unless explicitly expected, indicated by the cache option. | 274 // unless explicitly expected, indicated by the cache option. |
| 303 if (code->Length() < minimalCodeLength && cacheOptions != V8CacheOptionsPars
e && cacheOptions != V8CacheOptionsCode) | 275 if (code->Length() < minimalCodeLength) |
| 304 return bind(compileWithoutOptions, V8CompileHistogram::Cacheable); | 276 return bind(compileWithoutOptions, V8CompileHistogram::Cacheable); |
| 305 | 277 |
| 306 // The cacheOptions will guide our strategy: | 278 // The cacheOptions will guide our strategy: |
| 307 // FIXME: Clean up code caching options. crbug.com/455187. | |
| 308 switch (cacheOptions) { | 279 switch (cacheOptions) { |
| 309 case V8CacheOptionsParseMemory: | 280 case V8CacheOptionsParse: |
| 310 // Use parser-cache; in-memory only. | 281 // Use parser-cache; in-memory only. |
| 311 return bind(compileAndConsumeOrProduce, cacheHandler, cacheTag(CacheTagP
arser, cacheHandler), v8::ScriptCompiler::kConsumeParserCache, v8::ScriptCompile
r::kProduceParserCache, false, CachedMetadataHandler::CacheLocally); | 282 return bind(compileAndConsumeOrProduce, cacheHandler, cacheTag(CacheTagP
arser, cacheHandler), v8::ScriptCompiler::kConsumeParserCache, v8::ScriptCompile
r::kProduceParserCache, CachedMetadataHandler::CacheLocally); |
| 312 break; | |
| 313 | |
| 314 case V8CacheOptionsParse: | |
| 315 // Use parser-cache. | |
| 316 return bind(compileAndConsumeOrProduce, cacheHandler, cacheTag(CacheTagP
arser, cacheHandler), v8::ScriptCompiler::kConsumeParserCache, v8::ScriptCompile
r::kProduceParserCache, false, CachedMetadataHandler::SendToPlatform); | |
| 317 break; | |
| 318 | |
| 319 case V8CacheOptionsHeuristicsDefault: | |
| 320 case V8CacheOptionsCode: | |
| 321 // Use code caching. | |
| 322 return bind(compileAndConsumeOrProduce, cacheHandler, cacheTag(CacheTagC
ode, cacheHandler), v8::ScriptCompiler::kConsumeCodeCache, v8::ScriptCompiler::k
ProduceCodeCache, false, CachedMetadataHandler::SendToPlatform); | |
| 323 break; | |
| 324 | |
| 325 case V8CacheOptionsHeuristicsDefaultMobile: | |
| 326 case V8CacheOptionsCodeCompressed: | |
| 327 // Use code caching with compression. | |
| 328 return bind(compileAndConsumeOrProduce, cacheHandler, cacheTag(CacheTagC
odeCompressed, cacheHandler), v8::ScriptCompiler::kConsumeCodeCache, v8::ScriptC
ompiler::kProduceCodeCache, true, CachedMetadataHandler::SendToPlatform); | |
| 329 break; | 283 break; |
| 330 | 284 |
| 331 case V8CacheOptionsDefault: | 285 case V8CacheOptionsDefault: |
| 332 case V8CacheOptionsHeuristics: | 286 case V8CacheOptionsCode: { |
| 333 case V8CacheOptionsHeuristicsMobile: | |
| 334 case V8CacheOptionsRecent: | |
| 335 case V8CacheOptionsRecentSmall: { | |
| 336 // Use code caching for recently seen resources. | 287 // Use code caching for recently seen resources. |
| 337 // Use compression depending on the cache option. | 288 // Use compression depending on the cache option. |
| 338 bool compress = (cacheOptions == V8CacheOptionsRecentSmall || cacheOptio
ns == V8CacheOptionsHeuristicsMobile); | 289 unsigned codeCacheTag = cacheTag(CacheTagCode, cacheHandler); |
| 339 unsigned codeCacheTag = cacheTag(compress ? CacheTagCodeCompressed : Cac
heTagCode, cacheHandler); | |
| 340 CachedMetadata* codeCache = cacheHandler->cachedMetadata(codeCacheTag); | 290 CachedMetadata* codeCache = cacheHandler->cachedMetadata(codeCacheTag); |
| 341 if (codeCache) | 291 if (codeCache) |
| 342 return bind(compileAndConsumeCache, cacheHandler, codeCacheTag, v8::
ScriptCompiler::kConsumeCodeCache, compress); | 292 return bind(compileAndConsumeCache, cacheHandler, codeCacheTag, v8::
ScriptCompiler::kConsumeCodeCache); |
| 343 int hotHours = (cacheOptions == V8CacheOptionsRecent || cacheOptions ==
V8CacheOptionsRecentSmall) ? 36 : 72; | |
| 344 if (!isResourceHotForCaching(cacheHandler, hotHours)) { | 293 if (!isResourceHotForCaching(cacheHandler, hotHours)) { |
| 345 setCacheTimeStamp(cacheHandler); | 294 setCacheTimeStamp(cacheHandler); |
| 346 return bind(compileWithoutOptions, V8CompileHistogram::Cacheable); | 295 return bind(compileWithoutOptions, V8CompileHistogram::Cacheable); |
| 347 } | 296 } |
| 348 return bind(compileAndProduceCache, cacheHandler, codeCacheTag, v8::Scri
ptCompiler::kProduceCodeCache, compress, CachedMetadataHandler::SendToPlatform); | 297 return bind(compileAndProduceCache, cacheHandler, codeCacheTag, v8::Scri
ptCompiler::kProduceCodeCache, CachedMetadataHandler::SendToPlatform); |
| 349 break; | 298 break; |
| 350 } | 299 } |
| 351 | 300 |
| 352 case V8CacheOptionsNone: | 301 case V8CacheOptionsNone: |
| 353 // Shouldn't happen, as this is handled above. | 302 // Shouldn't happen, as this is handled above. |
| 354 // Case is here so that compiler can check all cases are handled. | 303 // Case is here so that compiler can check all cases are handled. |
| 355 ASSERT_NOT_REACHED(); | 304 ASSERT_NOT_REACHED(); |
| 356 break; | 305 break; |
| 357 } | 306 } |
| 358 | 307 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 { | 489 { |
| 541 return cacheTag(CacheTagParser, cacheHandler); | 490 return cacheTag(CacheTagParser, cacheHandler); |
| 542 } | 491 } |
| 543 | 492 |
| 544 unsigned V8ScriptRunner::tagForCodeCache(CachedMetadataHandler* cacheHandler) | 493 unsigned V8ScriptRunner::tagForCodeCache(CachedMetadataHandler* cacheHandler) |
| 545 { | 494 { |
| 546 return cacheTag(CacheTagCode, cacheHandler); | 495 return cacheTag(CacheTagCode, cacheHandler); |
| 547 } | 496 } |
| 548 | 497 |
| 549 } // namespace blink | 498 } // namespace blink |
| OLD | NEW |