diff options
author | Ben Murdoch <benm@google.com> | 2011-05-05 13:52:32 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-05-10 15:41:47 +0100 |
commit | b0fe1620dcb4135ac3ab2d66ff93072373911299 (patch) | |
tree | 3487cdc7e01ec56a6f84ea20f4bae596a0b73986 /src/compilation-cache.cc | |
parent | df5bff59602802b769e994b0dc1d8869a27fa40c (diff) | |
download | android_external_v8-b0fe1620dcb4135ac3ab2d66ff93072373911299.tar.gz android_external_v8-b0fe1620dcb4135ac3ab2d66ff93072373911299.tar.bz2 android_external_v8-b0fe1620dcb4135ac3ab2d66ff93072373911299.zip |
Update V8 to r6101 as required by WebKit r74534
Change-Id: I7f84af8dd732f11898fd644b2c2b1538914cb78d
Diffstat (limited to 'src/compilation-cache.cc')
-rw-r--r-- | src/compilation-cache.cc | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/compilation-cache.cc b/src/compilation-cache.cc index 6e4e4bff..38438cb9 100644 --- a/src/compilation-cache.cc +++ b/src/compilation-cache.cc @@ -86,6 +86,9 @@ class CompilationSubCache { // Clear this sub-cache evicting all its content. void Clear(); + // Remove given shared function info from sub-cache. + void Remove(Handle<SharedFunctionInfo> function_info); + // Number of generations in this sub-cache. inline int generations() { return generations_; } @@ -249,6 +252,18 @@ void CompilationSubCache::Clear() { } +void CompilationSubCache::Remove(Handle<SharedFunctionInfo> function_info) { + // Probe the script generation tables. Make sure not to leak handles + // into the caller's handle scope. + { HandleScope scope; + for (int generation = 0; generation < generations(); generation++) { + Handle<CompilationCacheTable> table = GetTable(generation); + table->Remove(*function_info); + } + } +} + + // We only re-use a cached function for some script source code if the // script originates from the same place. This is to avoid issues // when reporting errors, etc. @@ -467,6 +482,15 @@ void CompilationCacheRegExp::Put(Handle<String> source, } +void CompilationCache::Remove(Handle<SharedFunctionInfo> function_info) { + if (!IsEnabled()) return; + + eval_global.Remove(function_info); + eval_contextual.Remove(function_info); + script.Remove(function_info); +} + + Handle<SharedFunctionInfo> CompilationCache::LookupScript(Handle<String> source, Handle<Object> name, int line_offset, @@ -545,6 +569,45 @@ void CompilationCache::PutRegExp(Handle<String> source, } +static bool SourceHashCompare(void* key1, void* key2) { + return key1 == key2; +} + + +static HashMap* EagerOptimizingSet() { + static HashMap map(&SourceHashCompare); + return ↦ +} + + +bool CompilationCache::ShouldOptimizeEagerly(Handle<JSFunction> function) { + if (FLAG_opt_eagerly) return true; + uint32_t hash = function->SourceHash(); + void* key = reinterpret_cast<void*>(hash); + return EagerOptimizingSet()->Lookup(key, hash, false) != NULL; +} + + +void CompilationCache::MarkForEagerOptimizing(Handle<JSFunction> function) { + uint32_t hash = function->SourceHash(); + void* key = reinterpret_cast<void*>(hash); + EagerOptimizingSet()->Lookup(key, hash, true); +} + + +void CompilationCache::MarkForLazyOptimizing(Handle<JSFunction> function) { + uint32_t hash = function->SourceHash(); + void* key = reinterpret_cast<void*>(hash); + EagerOptimizingSet()->Remove(key, hash); +} + + +void CompilationCache::ResetEagerOptimizingData() { + HashMap* set = EagerOptimizingSet(); + if (set->occupancy() > 0) set->Clear(); +} + + void CompilationCache::Clear() { for (int i = 0; i < kSubCacheCount; i++) { subcaches[i]->Clear(); |