| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0583c3d commit f8acf2d
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,6 +14,14 @@ | |||
| 14 | 14 | #endif | |
| 15 | 15 | ||
| 16 | 16 | namespace node { | |
| 17 | + | ||
| 18 | + using v8::Function; | ||
| 19 | + using v8::Local; | ||
| 20 | + using v8::Module; | ||
| 21 | + using v8::ScriptCompiler; | ||
| 22 | + using v8::String; | ||
| 23 | + | ||
| 24 | + namespace { | ||
| 17 | 25 | std::string Uint32ToHex(uint32_t crc) { | |
| 18 | 26 | std::string str; | |
| 19 | 27 | str.reserve(8); | |
@@ -40,8 +48,7 @@ std::string GetCacheVersionTag() { | |||
| 40 | 48 | // This should be fine on Windows, as there local directories tend to be | |
| 41 | 49 | // user-specific. | |
| 42 | 50 | std::string tag = std::string(NODE_VERSION) + '-' + std::string(NODE_ARCH) + | |
| 43 | - '-' + | ||
| 44 | - Uint32ToHex(v8::ScriptCompiler::CachedDataVersionTag()); | ||
| 51 | + '-' + Uint32ToHex(ScriptCompiler::CachedDataVersionTag()); | ||
| 45 | 52 | #ifdef NODE_IMPLEMENTS_POSIX_CREDENTIALS | |
| 46 | 53 | tag += '-' + std::to_string(getuid()); | |
| 47 | 54 | #endif | |
@@ -55,6 +62,7 @@ uint32_t GetCacheKey(std::string_view filename, CachedCodeType type) { | |||
| 55 | 62 | crc, reinterpret_cast<const Bytef*>(filename.data()), filename.length()); | |
| 56 | 63 | return crc; | |
| 57 | 64 | } | |
| 65 | + } // namespace | ||
| 58 | 66 | ||
| 59 | 67 | template <typename... Args> | |
| 60 | 68 | inline void CompileCacheHandler::Debug(const char* format, | |
@@ -64,13 +72,13 @@ inline void CompileCacheHandler::Debug(const char* format, | |||
| 64 | 72 | } | |
| 65 | 73 | } | |
| 66 | 74 | ||
| 67 | - v8::ScriptCompiler::CachedData* CompileCacheEntry::CopyCache() const { | ||
| 75 | + ScriptCompiler::CachedData* CompileCacheEntry::CopyCache() const { | ||
| 68 | 76 | DCHECK_NOT_NULL(cache); | |
| 69 | 77 | int cache_size = cache->length; | |
| 70 | 78 | uint8_t* data = new uint8_t[cache_size]; | |
| 71 | 79 | memcpy(data, cache->data, cache_size); | |
| 72 | - return new v8::ScriptCompiler::CachedData( | ||
| 73 | - data, cache_size, v8::ScriptCompiler::CachedData::BufferOwned); | ||
| 80 | + return new ScriptCompiler::CachedData( | ||
| 81 | + data, cache_size, ScriptCompiler::CachedData::BufferOwned); | ||
| 74 | 82 | } | |
| 75 | 83 | ||
| 76 | 84 | // Used for identifying and verifying a file is a compile cache file. | |
@@ -210,15 +218,14 @@ void CompileCacheHandler::ReadCacheFile(CompileCacheEntry* entry) { | |||
| 210 | 218 | return; | |
| 211 | 219 | } | |
| 212 | 220 | ||
| 213 | - entry->cache.reset(new v8::ScriptCompiler::CachedData( | ||
| 214 | - buffer, total_read, v8::ScriptCompiler::CachedData::BufferOwned)); | ||
| 221 | + entry->cache.reset(new ScriptCompiler::CachedData( | ||
| 222 | + buffer, total_read, ScriptCompiler::CachedData::BufferOwned)); | ||
| 215 | 223 | Debug(" success, size=%d\n", total_read); | |
| 216 | 224 | } | |
| 217 | 225 | ||
| 218 | - CompileCacheEntry* CompileCacheHandler::GetOrInsert( | ||
| 219 | - v8::Local<v8::String> code, | ||
| 220 | - v8::Local<v8::String> filename, | ||
| 221 | - CachedCodeType type) { | ||
| 226 | + CompileCacheEntry* CompileCacheHandler::GetOrInsert(Local<String> code, | ||
| 227 | + Local<String> filename, | ||
| 228 | + CachedCodeType type) { | ||
| 222 | 229 | DCHECK(!compile_cache_dir_.empty()); | |
| 223 | 230 | ||
| 224 | 231 | Utf8Value filename_utf8(isolate_, filename); | |
@@ -259,18 +266,17 @@ CompileCacheEntry* CompileCacheHandler::GetOrInsert( | |||
| 259 | 266 | return result; | |
| 260 | 267 | } | |
| 261 | 268 | ||
| 262 | - v8::ScriptCompiler::CachedData* SerializeCodeCache( | ||
| 263 | - v8::Local<v8::Function> func) { | ||
| 264 | - return v8::ScriptCompiler::CreateCodeCacheForFunction(func); | ||
| 269 | + ScriptCompiler::CachedData* SerializeCodeCache(Local<Function> func) { | ||
| 270 | + return ScriptCompiler::CreateCodeCacheForFunction(func); | ||
| 265 | 271 | } | |
| 266 | 272 | ||
| 267 | - v8::ScriptCompiler::CachedData* SerializeCodeCache(v8::Local<v8::Module> mod) { | ||
| 268 | - return v8::ScriptCompiler::CreateCodeCache(mod->GetUnboundModuleScript()); | ||
| 273 | + ScriptCompiler::CachedData* SerializeCodeCache(Local<Module> mod) { | ||
| 274 | + return ScriptCompiler::CreateCodeCache(mod->GetUnboundModuleScript()); | ||
| 269 | 275 | } | |
| 270 | 276 | ||
| 271 | 277 | template <typename T> | |
| 272 | 278 | void CompileCacheHandler::MaybeSaveImpl(CompileCacheEntry* entry, | |
| 273 | - v8::Local<T> func_or_mod, | ||
| 279 | + Local<T> func_or_mod, | ||
| 274 | 280 | bool rejected) { | |
| 275 | 281 | DCHECK_NOT_NULL(entry); | |
| 276 | 282 | Debug("[compile cache] V8 code cache for %s %s was %s, ", | |
@@ -286,21 +292,21 @@ void CompileCacheHandler::MaybeSaveImpl(CompileCacheEntry* entry, | |||
| 286 | 292 | Debug("%s the in-memory entry\n", | |
| 287 | 293 | entry->cache == nullptr ? "initializing" : "refreshing"); | |
| 288 | 294 | ||
| 289 | - v8::ScriptCompiler::CachedData* data = SerializeCodeCache(func_or_mod); | ||
| 290 | - DCHECK_EQ(data->buffer_policy, v8::ScriptCompiler::CachedData::BufferOwned); | ||
| 295 | + ScriptCompiler::CachedData* data = SerializeCodeCache(func_or_mod); | ||
| 296 | + DCHECK_EQ(data->buffer_policy, ScriptCompiler::CachedData::BufferOwned); | ||
| 291 | 297 | entry->refreshed = true; | |
| 292 | 298 | entry->cache.reset(data); | |
| 293 | 299 | } | |
| 294 | 300 | ||
| 295 | 301 | void CompileCacheHandler::MaybeSave(CompileCacheEntry* entry, | |
| 296 | - v8::Local<v8::Module> mod, | ||
| 302 | + Local<Module> mod, | ||
| 297 | 303 | bool rejected) { | |
| 298 | 304 | DCHECK(mod->IsSourceTextModule()); | |
| 299 | 305 | MaybeSaveImpl(entry, mod, rejected); | |
| 300 | 306 | } | |
| 301 | 307 | ||
| 302 | 308 | void CompileCacheHandler::MaybeSave(CompileCacheEntry* entry, | |
| 303 | - v8::Local<v8::Function> func, | ||
| 309 | + Local<Function> func, | ||
| 304 | 310 | bool rejected) { | |
| 305 | 311 | MaybeSaveImpl(entry, func, rejected); | |
| 306 | 312 | } | |
@@ -319,8 +325,8 @@ void CompileCacheHandler::MaybeSave(CompileCacheEntry* entry, | |||
| 319 | 325 | int cache_size = static_cast<int>(transpiled.size()); | |
| 320 | 326 | uint8_t* data = new uint8_t[cache_size]; | |
| 321 | 327 | memcpy(data, transpiled.data(), cache_size); | |
| 322 | - entry->cache.reset(new v8::ScriptCompiler::CachedData( | ||
| 323 | - data, cache_size, v8::ScriptCompiler::CachedData::BufferOwned)); | ||
| 328 | + entry->cache.reset(new ScriptCompiler::CachedData( | ||
| 329 | + data, cache_size, ScriptCompiler::CachedData::BufferOwned)); | ||
| 324 | 330 | entry->refreshed = true; | |
| 325 | 331 | } | |
| 326 | 332 | ||
@@ -377,7 +383,7 @@ void CompileCacheHandler::Persist() { | |||
| 377 | 383 | } | |
| 378 | 384 | ||
| 379 | 385 | DCHECK_EQ(entry->cache->buffer_policy, | |
| 380 | - v8::ScriptCompiler::CachedData::BufferOwned); | ||
| 386 | + ScriptCompiler::CachedData::BufferOwned); | ||
| 381 | 387 | char* cache_ptr = | |
| 382 | 388 | reinterpret_cast<char*>(const_cast<uint8_t*>(entry->cache->data)); | |
| 383 | 389 | uint32_t cache_size = static_cast<uint32_t>(entry->cache->length); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments