Index: src/compilation-cache.cc |
=================================================================== |
--- src/compilation-cache.cc (revision 4799) |
+++ src/compilation-cache.cc (working copy) |
@@ -79,6 +79,8 @@ |
// young generation. |
void Age(); |
+ bool HasFunction(SharedFunctionInfo* function_info); |
+ |
// GC support. |
void Iterate(ObjectVisitor* v); |
@@ -204,6 +206,27 @@ |
} |
+bool CompilationSubCache::HasFunction(SharedFunctionInfo* function_info) { |
+ if (function_info->script()->IsUndefined() || |
+ Script::cast(function_info->script())->source()->IsUndefined()) { |
+ return false; |
+ } |
+ |
+ String* source = |
+ String::cast(Script::cast(function_info->script())->source()); |
+ // Check all generations. |
+ for (int generation = 0; generation < generations(); generation++) { |
+ if (tables_[generation]->IsUndefined()) continue; |
+ |
+ CompilationCacheTable* table = |
+ CompilationCacheTable::cast(tables_[generation]); |
+ Object* object = table->Lookup(source); |
+ if (object->IsSharedFunctionInfo()) return true; |
+ } |
+ return false; |
+} |
+ |
+ |
void CompilationSubCache::Age() { |
// Age the generations implicitly killing off the oldest. |
for (int i = generations_ - 1; i > 0; i--) { |
@@ -506,6 +529,11 @@ |
} |
+bool CompilationCache::HasFunction(SharedFunctionInfo* function_info) { |
+ return script.HasFunction(function_info); |
+} |
+ |
+ |
void CompilationCache::Iterate(ObjectVisitor* v) { |
for (int i = 0; i < kSubCacheCount; i++) { |
subcaches[i]->Iterate(v); |