From 61e04e2867d5057ae594316112ad48d4e9407d4f Mon Sep 17 00:00:00 2001 From: Leszek Swirski Date: Tue, 14 Nov 2017 16:48:34 +0000 Subject: [PATCH] [compiler] Add new "no cache reason" enum values Add enum values to the "no cache reason" API which reflect new types of no-cache reason we will want to distinguish. Also, renames one of the enum values (BecauseExtension -> BecauseV8Extension) because it was confusing. It's a V8-only type of no cache reason, so it shouldn't affect embedders. Bug: chromium:769203 Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng Change-Id: I41d4ecfb35b2e91b71562b4f23b15d20f16a943c Reviewed-on: https://chromium-review.googlesource.com/769010 Reviewed-by: Mythri Alle Reviewed-by: Adam Klein Commit-Queue: Leszek Swirski Cr-Commit-Position: refs/heads/master@{#49367} --- include/v8.h | 5 ++++- src/bootstrapper.cc | 2 +- src/compiler.cc | 20 ++++++++++++++++---- src/counters.h | 2 +- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/include/v8.h b/include/v8.h index 1346ad67f2..de0c7c0437 100644 --- a/include/v8.h +++ b/include/v8.h @@ -1449,7 +1449,10 @@ class V8_EXPORT ScriptCompiler { kNoCacheBecauseInspector, kNoCacheBecauseScriptTooSmall, kNoCacheBecauseCacheTooCold, - kNoCacheBecauseExtension, + kNoCacheBecauseV8Extension, + kNoCacheBecauseExtensionModule, + kNoCacheBecausePacScript, + kNoCacheBecauseInDocumentWrite }; /** diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index c580cd6278..409d3a46a7 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -3759,7 +3759,7 @@ bool Genesis::CompileExtension(Isolate* isolate, v8::Extension* extension) { source, script_name, 0, 0, ScriptOriginOptions(), MaybeHandle(), context, extension, nullptr, ScriptCompiler::kNoCompileOptions, - ScriptCompiler::kNoCacheBecauseExtension, EXTENSION_CODE, + ScriptCompiler::kNoCacheBecauseV8Extension, EXTENSION_CODE, MaybeHandle()); if (!maybe_function_info.ToHandle(&function_info)) return false; cache->Add(name, function_info); diff --git a/src/compiler.cc b/src/compiler.cc index 58532caa73..68b3e0911c 100644 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -1251,9 +1251,12 @@ struct ScriptCompileTimerScope { kNoCacheBecauseCachingDisabled, kNoCacheBecauseModule, kNoCacheBecauseStreamingSource, - kNoCacheBecauseExtension, + kNoCacheBecauseV8Extension, kHitIsolateCacheWhenProduceCodeCache, kHitIsolateCacheWhenConsumeCodeCache, + kNoCacheBecauseExtensionModule, + kNoCacheBecausePacScript, + kNoCacheBecauseInDocumentWrite, kCount }; @@ -1350,8 +1353,14 @@ struct ScriptCompileTimerScope { return CacheBehaviour::kNoCacheBecauseModule; case ScriptCompiler::kNoCacheBecauseStreamingSource: return CacheBehaviour::kNoCacheBecauseStreamingSource; - case ScriptCompiler::kNoCacheBecauseExtension: - return CacheBehaviour::kNoCacheBecauseExtension; + case ScriptCompiler::kNoCacheBecauseV8Extension: + return CacheBehaviour::kNoCacheBecauseV8Extension; + case ScriptCompiler::kNoCacheBecauseExtensionModule: + return CacheBehaviour::kNoCacheBecauseExtensionModule; + case ScriptCompiler::kNoCacheBecausePacScript: + return CacheBehaviour::kNoCacheBecausePacScript; + case ScriptCompiler::kNoCacheBecauseInDocumentWrite: + return CacheBehaviour::kNoCacheBecauseInDocumentWrite; } UNREACHABLE(); } @@ -1394,7 +1403,10 @@ struct ScriptCompileTimerScope { // TODO(leszeks): Count separately or remove entirely once we have // background compilation. case CacheBehaviour::kNoCacheBecauseStreamingSource: - case CacheBehaviour::kNoCacheBecauseExtension: + case CacheBehaviour::kNoCacheBecauseV8Extension: + case CacheBehaviour::kNoCacheBecauseExtensionModule: + case CacheBehaviour::kNoCacheBecausePacScript: + case CacheBehaviour::kNoCacheBecauseInDocumentWrite: return isolate_->counters()->compile_script_no_cache_other(); case CacheBehaviour::kCount: diff --git a/src/counters.h b/src/counters.h index f5d0dc4318..2f824db796 100644 --- a/src/counters.h +++ b/src/counters.h @@ -1065,7 +1065,7 @@ class RuntimeCallTimerScope { 20) \ HR(wasm_lazy_compilation_throughput, V8.WasmLazyCompilationThroughput, 1, \ 10000, 50) \ - HR(compile_script_cache_behaviour, V8.CompileScript.CacheBehaviour, 0, 15, 16) + HR(compile_script_cache_behaviour, V8.CompileScript.CacheBehaviour, 0, 18, 19) #define HISTOGRAM_TIMER_LIST(HT) \ /* Garbage collection timers. */ \