| 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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 { | 188 { |
| 189 double now = WTF::currentTime(); | 189 double now = WTF::currentTime(); |
| 190 unsigned tag = cacheTag(CacheTagTimeStamp, cacheHandler); | 190 unsigned tag = cacheTag(CacheTagTimeStamp, cacheHandler); |
| 191 cacheHandler->clearCachedMetadata(CachedMetadataHandler::CacheLocally); | 191 cacheHandler->clearCachedMetadata(CachedMetadataHandler::CacheLocally); |
| 192 cacheHandler->setCachedMetadata(tag, reinterpret_cast<char*>(&now), sizeof(n
ow), CachedMetadataHandler::SendToPlatform); | 192 cacheHandler->setCachedMetadata(tag, reinterpret_cast<char*>(&now), sizeof(n
ow), CachedMetadataHandler::SendToPlatform); |
| 193 } | 193 } |
| 194 | 194 |
| 195 // Check previously stored timestamp. | 195 // Check previously stored timestamp. |
| 196 bool isResourceHotForCaching(CachedMetadataHandler* cacheHandler, int hotHours) | 196 bool isResourceHotForCaching(CachedMetadataHandler* cacheHandler, int hotHours) |
| 197 { | 197 { |
| 198 const double kCacheWithinSeconds = hotHours * 60 * 60; | 198 const double cacheWithinSeconds = hotHours * 60 * 60; |
| 199 unsigned tag = cacheTag(CacheTagTimeStamp, cacheHandler); | 199 unsigned tag = cacheTag(CacheTagTimeStamp, cacheHandler); |
| 200 CachedMetadata* cachedMetadata = cacheHandler->cachedMetadata(tag); | 200 CachedMetadata* cachedMetadata = cacheHandler->cachedMetadata(tag); |
| 201 if (!cachedMetadata) | 201 if (!cachedMetadata) |
| 202 return false; | 202 return false; |
| 203 double timeStamp; | 203 double timeStamp; |
| 204 const int size = sizeof(timeStamp); | 204 const int size = sizeof(timeStamp); |
| 205 ASSERT(cachedMetadata->size() == size); | 205 ASSERT(cachedMetadata->size() == size); |
| 206 memcpy(&timeStamp, cachedMetadata->data(), size); | 206 memcpy(&timeStamp, cachedMetadata->data(), size); |
| 207 return (WTF::currentTime() - timeStamp) < kCacheWithinSeconds; | 207 return (WTF::currentTime() - timeStamp) < cacheWithinSeconds; |
| 208 } | 208 } |
| 209 | 209 |
| 210 // Final compile call for a streamed compilation. Most decisions have already | 210 // Final compile call for a streamed compilation. Most decisions have already |
| 211 // been made, but we need to write back data into the cache. | 211 // been made, but we need to write back data into the cache. |
| 212 v8::MaybeLocal<v8::Script> postStreamCompile(V8CacheOptions cacheOptions, Cached
MetadataHandler* cacheHandler, ScriptStreamer* streamer, v8::Isolate* isolate, v
8::Local<v8::String> code, v8::ScriptOrigin origin) | 212 v8::MaybeLocal<v8::Script> postStreamCompile(V8CacheOptions cacheOptions, Cached
MetadataHandler* cacheHandler, ScriptStreamer* streamer, v8::Isolate* isolate, v
8::Local<v8::String> code, v8::ScriptOrigin origin) |
| 213 { | 213 { |
| 214 V8CompileHistogram histogramScope(V8CompileHistogram::Noncacheable); | 214 V8CompileHistogram histogramScope(V8CompileHistogram::Noncacheable); |
| 215 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); |
| 216 | 216 |
| 217 if (!cacheHandler) | 217 if (!cacheHandler) |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 { | 493 { |
| 494 return cacheTag(CacheTagParser, cacheHandler); | 494 return cacheTag(CacheTagParser, cacheHandler); |
| 495 } | 495 } |
| 496 | 496 |
| 497 unsigned V8ScriptRunner::tagForCodeCache(CachedMetadataHandler* cacheHandler) | 497 unsigned V8ScriptRunner::tagForCodeCache(CachedMetadataHandler* cacheHandler) |
| 498 { | 498 { |
| 499 return cacheTag(CacheTagCode, cacheHandler); | 499 return cacheTag(CacheTagCode, cacheHandler); |
| 500 } | 500 } |
| 501 | 501 |
| 502 } // namespace blink | 502 } // namespace blink |
| OLD | NEW |