Revision: 4900
Author: [email protected]
Date: Fri Jun 18 13:14:40 2010
Log: [Isolates] CompilationCache was moved to Isolate.
Landing for Maxim Mossienko, original codereview: http://codereview.chromium.org/2804009/show

Review URL: http://codereview.chromium.org/2867013
http://code.google.com/p/v8/source/detail?r=4900

Modified:
 /branches/experimental/isolates/src/compilation-cache.cc
 /branches/experimental/isolates/src/compilation-cache.h
 /branches/experimental/isolates/src/compiler.cc
 /branches/experimental/isolates/src/debug.cc
 /branches/experimental/isolates/src/heap.cc
 /branches/experimental/isolates/src/isolate.cc
 /branches/experimental/isolates/src/isolate.h
 /branches/experimental/isolates/src/jsregexp.cc
 /branches/experimental/isolates/test/cctest/test-api.cc

=======================================
--- /branches/experimental/isolates/src/compilation-cache.cc Wed Jun 9 16:02:44 2010 +++ /branches/experimental/isolates/src/compilation-cache.cc Fri Jun 18 13:14:40 2010
@@ -33,8 +33,6 @@
 namespace v8 {
 namespace internal {

-// The number of sub caches covering the different types to cache.
-static const int kSubCacheCount = 4;

 // The number of generations for each sub cache.
 // The number of ScriptGenerations is carefully chosen based on histograms.
@@ -47,141 +45,18 @@
 // Initial size of each compilation cache table allocated.
 static const int kInitialCacheSize = 64;

-// Index for the first generation in the cache.
-static const int kFirstGeneration = 0;
-
-// The compilation cache consists of several generational sub-caches which uses -// this class as a base class. A sub-cache contains a compilation cache tables -// for each generation of the sub-cache. Since the same source code string has -// different compiled code for scripts and evals, we use separate sub-caches
-// for different compilation modes, to avoid retrieving the wrong result.
-class CompilationSubCache {
- public:
- explicit CompilationSubCache(int generations): generations_(generations) {
-    tables_ = NewArray<Object*>(generations);
-  }
-
-  ~CompilationSubCache() { DeleteArray(tables_); }
-
-  // Get the compilation cache tables for a specific generation.
-  Handle<CompilationCacheTable> GetTable(int generation);
-
-  // Accessors for first generation.
-  Handle<CompilationCacheTable> GetFirstTable() {
-    return GetTable(kFirstGeneration);
-  }
-  void SetFirstTable(Handle<CompilationCacheTable> value) {
-    ASSERT(kFirstGeneration < generations_);
-    tables_[kFirstGeneration] = *value;
-  }
-
-  // Age the sub-cache by evicting the oldest generation and creating a new
-  // young generation.
-  void Age();
-
-  bool HasFunction(SharedFunctionInfo* function_info);
-
-  // GC support.
-  void Iterate(ObjectVisitor* v);
-
-  // Clear this sub-cache evicting all its content.
-  void Clear();
-
-  // Number of generations in this sub-cache.
-  inline int generations() { return generations_; }
-
- private:
-  int generations_;  // Number of generations.
-  Object** tables_;  // Compilation cache tables - one for each generation.
-
-  DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationSubCache);
-};
-
-
-// Sub-cache for scripts.
-class CompilationCacheScript : public CompilationSubCache {
- public:
-  explicit CompilationCacheScript(int generations)
-      : CompilationSubCache(generations) { }
-
-  Handle<SharedFunctionInfo> Lookup(Handle<String> source,
-                                    Handle<Object> name,
-                                    int line_offset,
-                                    int column_offset);
- void Put(Handle<String> source, Handle<SharedFunctionInfo> function_info);
-
- private:
-  // Note: Returns a new hash table if operation results in expansion.
-  Handle<CompilationCacheTable> TablePut(
-      Handle<String> source, Handle<SharedFunctionInfo> function_info);
-
-  bool HasOrigin(Handle<SharedFunctionInfo> function_info,
-                 Handle<Object> name,
-                 int line_offset,
-                 int column_offset);
-
-  DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheScript);
-};
-
-
-// Sub-cache for eval scripts.
-class CompilationCacheEval: public CompilationSubCache {
- public:
-  explicit CompilationCacheEval(int generations)
-      : CompilationSubCache(generations) { }
-
-  Handle<SharedFunctionInfo> Lookup(Handle<String> source,
-                                    Handle<Context> context);
-
-  void Put(Handle<String> source,
-           Handle<Context> context,
-           Handle<SharedFunctionInfo> function_info);
-
- private:
-  // Note: Returns a new hash table if operation results in expansion.
-  Handle<CompilationCacheTable> TablePut(
-      Handle<String> source,
-      Handle<Context> context,
-      Handle<SharedFunctionInfo> function_info);
-
-  DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheEval);
-};
-
-
-// Sub-cache for regular expressions.
-class CompilationCacheRegExp: public CompilationSubCache {
- public:
-  explicit CompilationCacheRegExp(int generations)
-      : CompilationSubCache(generations) { }
-
-  Handle<FixedArray> Lookup(Handle<String> source, JSRegExp::Flags flags);
-
-  void Put(Handle<String> source,
-           JSRegExp::Flags flags,
-           Handle<FixedArray> data);
- private:
-  // Note: Returns a new hash table if operation results in expansion.
-  Handle<CompilationCacheTable> TablePut(Handle<String> source,
-                                         JSRegExp::Flags flags,
-                                         Handle<FixedArray> data);
-
-  DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheRegExp);
-};
-
-
-// Statically allocate all the sub-caches.
-static CompilationCacheScript script(kScriptGenerations);
-static CompilationCacheEval eval_global(kEvalGlobalGenerations);
-static CompilationCacheEval eval_contextual(kEvalContextualGenerations);
-static CompilationCacheRegExp reg_exp(kRegExpGenerations);
-static CompilationSubCache* subcaches[kSubCacheCount] =
-    {&script, &eval_global, &eval_contextual, &reg_exp};
-
-
-// Current enable state of the compilation cache.
-static bool enabled = true;
-static inline bool IsEnabled() {
-  return FLAG_compilation_cache && enabled;
+
+CompilationCache::CompilationCache()
+    : script_(kScriptGenerations),
+      eval_global_(kEvalGlobalGenerations),
+      eval_contextual_(kEvalContextualGenerations),
+      reg_exp_(kRegExpGenerations),
+      enabled_(true) {
+  CompilationSubCache* subcaches[kSubCacheCount] =
+    {&script_, &eval_global_, &eval_contextual_, &reg_exp_};
+  for (int i = 0; i < kSubCacheCount; ++i) {
+    subcaches_[i] = subcaches[i];
+  }
 }


@@ -303,6 +178,7 @@
     }
   }

+  // TODO(isolates): make it per isolate
   static void* script_histogram = StatsTable::CreateHistogram(
       "V8.ScriptCache",
       0,
@@ -452,7 +328,7 @@
     return Handle<SharedFunctionInfo>::null();
   }

-  return script.Lookup(source, name, line_offset, column_offset);
+  return script_.Lookup(source, name, line_offset, column_offset);
 }


@@ -465,9 +341,9 @@

   Handle<SharedFunctionInfo> result;
   if (is_global) {
-    result = eval_global.Lookup(source, context);
+    result = eval_global_.Lookup(source, context);
   } else {
-    result = eval_contextual.Lookup(source, context);
+    result = eval_contextual_.Lookup(source, context);
   }
   return result;
 }
@@ -479,7 +355,7 @@
     return Handle<FixedArray>::null();
   }

-  return reg_exp.Lookup(source, flags);
+  return reg_exp_.Lookup(source, flags);
 }


@@ -489,7 +365,7 @@
     return;
   }

-  script.Put(source, function_info);
+  script_.Put(source, function_info);
 }


@@ -503,9 +379,9 @@

   HandleScope scope;
   if (is_global) {
-    eval_global.Put(source, context, function_info);
+    eval_global_.Put(source, context, function_info);
   } else {
-    eval_contextual.Put(source, context, function_info);
+    eval_contextual_.Put(source, context, function_info);
   }
 }

@@ -518,43 +394,43 @@
     return;
   }

-  reg_exp.Put(source, flags, data);
+  reg_exp_.Put(source, flags, data);
 }


 void CompilationCache::Clear() {
   for (int i = 0; i < kSubCacheCount; i++) {
-    subcaches[i]->Clear();
+    subcaches_[i]->Clear();
   }
 }


 bool CompilationCache::HasFunction(SharedFunctionInfo* function_info) {
-  return script.HasFunction(function_info);
+  return script_.HasFunction(function_info);
 }


 void CompilationCache::Iterate(ObjectVisitor* v) {
   for (int i = 0; i < kSubCacheCount; i++) {
-    subcaches[i]->Iterate(v);
+    subcaches_[i]->Iterate(v);
   }
 }


 void CompilationCache::MarkCompactPrologue() {
   for (int i = 0; i < kSubCacheCount; i++) {
-    subcaches[i]->Age();
+    subcaches_[i]->Age();
   }
 }


 void CompilationCache::Enable() {
-  enabled = true;
+  enabled_ = true;
 }


 void CompilationCache::Disable() {
-  enabled = false;
+  enabled_ = false;
   Clear();
 }

=======================================
--- /branches/experimental/isolates/src/compilation-cache.h Wed Jun 9 16:02:44 2010 +++ /branches/experimental/isolates/src/compilation-cache.h Fri Jun 18 13:14:40 2010
@@ -32,6 +32,128 @@
 namespace internal {


+// The compilation cache consists of several generational sub-caches which uses +// this class as a base class. A sub-cache contains a compilation cache tables +// for each generation of the sub-cache. Since the same source code string has +// different compiled code for scripts and evals, we use separate sub-caches
+// for different compilation modes, to avoid retrieving the wrong result.
+class CompilationSubCache {
+ public:
+ explicit CompilationSubCache(int generations): generations_(generations) {
+    tables_ = NewArray<Object*>(generations);
+  }
+
+  ~CompilationSubCache() { DeleteArray(tables_); }
+
+  // Index for the first generation in the cache.
+  static const int kFirstGeneration = 0;
+
+  // Get the compilation cache tables for a specific generation.
+  Handle<CompilationCacheTable> GetTable(int generation);
+
+  // Accessors for first generation.
+  Handle<CompilationCacheTable> GetFirstTable() {
+    return GetTable(kFirstGeneration);
+  }
+  void SetFirstTable(Handle<CompilationCacheTable> value) {
+    ASSERT(kFirstGeneration < generations_);
+    tables_[kFirstGeneration] = *value;
+  }
+
+  // Age the sub-cache by evicting the oldest generation and creating a new
+  // young generation.
+  void Age();
+
+  bool HasFunction(SharedFunctionInfo* function_info);
+
+  // GC support.
+  void Iterate(ObjectVisitor* v);
+
+  // Clear this sub-cache evicting all its content.
+  void Clear();
+
+  // Number of generations in this sub-cache.
+  inline int generations() { return generations_; }
+
+ private:
+  int generations_;  // Number of generations.
+  Object** tables_;  // Compilation cache tables - one for each generation.
+
+  DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationSubCache);
+};
+
+
+// Sub-cache for scripts.
+class CompilationCacheScript : public CompilationSubCache {
+ public:
+  explicit CompilationCacheScript(int generations)
+      : CompilationSubCache(generations) { }
+
+  Handle<SharedFunctionInfo> Lookup(Handle<String> source,
+                                    Handle<Object> name,
+                                    int line_offset,
+                                    int column_offset);
+ void Put(Handle<String> source, Handle<SharedFunctionInfo> function_info);
+
+ private:
+  // Note: Returns a new hash table if operation results in expansion.
+  Handle<CompilationCacheTable> TablePut(
+      Handle<String> source, Handle<SharedFunctionInfo> function_info);
+
+  bool HasOrigin(Handle<SharedFunctionInfo> function_info,
+                 Handle<Object> name,
+                 int line_offset,
+                 int column_offset);
+
+  DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheScript);
+};
+
+
+// Sub-cache for eval scripts.
+class CompilationCacheEval: public CompilationSubCache {
+ public:
+  explicit CompilationCacheEval(int generations)
+      : CompilationSubCache(generations) { }
+
+  Handle<SharedFunctionInfo> Lookup(Handle<String> source,
+                                    Handle<Context> context);
+
+  void Put(Handle<String> source,
+           Handle<Context> context,
+           Handle<SharedFunctionInfo> function_info);
+
+ private:
+  // Note: Returns a new hash table if operation results in expansion.
+  Handle<CompilationCacheTable> TablePut(
+      Handle<String> source,
+      Handle<Context> context,
+      Handle<SharedFunctionInfo> function_info);
+
+  DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheEval);
+};
+
+
+// Sub-cache for regular expressions.
+class CompilationCacheRegExp: public CompilationSubCache {
+ public:
+  explicit CompilationCacheRegExp(int generations)
+      : CompilationSubCache(generations) { }
+
+  Handle<FixedArray> Lookup(Handle<String> source, JSRegExp::Flags flags);
+
+  void Put(Handle<String> source,
+           JSRegExp::Flags flags,
+           Handle<FixedArray> data);
+ private:
+  // Note: Returns a new hash table if operation results in expansion.
+  Handle<CompilationCacheTable> TablePut(Handle<String> source,
+                                         JSRegExp::Flags flags,
+                                         Handle<FixedArray> data);
+
+  DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheRegExp);
+};
+
+
 // The compilation cache keeps shared function infos for compiled
 // scripts and evals. The shared function infos are looked up using
 // the source string as the key. For regular expressions the
@@ -41,59 +163,79 @@
   // Finds the script shared function info for a source
   // string. Returns an empty handle if the cache doesn't contain a
   // script for the given source string with the right origin.
-  static Handle<SharedFunctionInfo> LookupScript(Handle<String> source,
-                                                 Handle<Object> name,
-                                                 int line_offset,
-                                                 int column_offset);
+  Handle<SharedFunctionInfo> LookupScript(Handle<String> source,
+                                          Handle<Object> name,
+                                          int line_offset,
+                                          int column_offset);

   // Finds the shared function info for a source string for eval in a
   // given context.  Returns an empty handle if the cache doesn't
   // contain a script for the given source string.
-  static Handle<SharedFunctionInfo> LookupEval(Handle<String> source,
-                                               Handle<Context> context,
-                                               bool is_global);
+  Handle<SharedFunctionInfo> LookupEval(Handle<String> source,
+                                        Handle<Context> context,
+                                        bool is_global);

   // Returns the regexp data associated with the given regexp if it
   // is in cache, otherwise an empty handle.
-  static Handle<FixedArray> LookupRegExp(Handle<String> source,
-                                         JSRegExp::Flags flags);
+  Handle<FixedArray> LookupRegExp(Handle<String> source,
+                                  JSRegExp::Flags flags);

   // Associate the (source, kind) pair to the shared function
   // info. This may overwrite an existing mapping.
-  static void PutScript(Handle<String> source,
-                        Handle<SharedFunctionInfo> function_info);
+  void PutScript(Handle<String> source,
+                 Handle<SharedFunctionInfo> function_info);

   // Associate the (source, context->closure()->shared(), kind) triple
   // with the shared function info. This may overwrite an existing mapping.
-  static void PutEval(Handle<String> source,
-                      Handle<Context> context,
-                      bool is_global,
-                      Handle<SharedFunctionInfo> function_info);
+  void PutEval(Handle<String> source,
+               Handle<Context> context,
+               bool is_global,
+               Handle<SharedFunctionInfo> function_info);

   // Associate the (source, flags) pair to the given regexp data.
   // This may overwrite an existing mapping.
-  static void PutRegExp(Handle<String> source,
-                        JSRegExp::Flags flags,
-                        Handle<FixedArray> data);
+  void PutRegExp(Handle<String> source,
+                 JSRegExp::Flags flags,
+                 Handle<FixedArray> data);

   // Clear the cache - also used to initialize the cache at startup.
-  static void Clear();
+  void Clear();


-  static bool HasFunction(SharedFunctionInfo* function_info);
+  bool HasFunction(SharedFunctionInfo* function_info);

   // GC support.
-  static void Iterate(ObjectVisitor* v);
+  void Iterate(ObjectVisitor* v);

   // Notify the cache that a mark-sweep garbage collection is about to
   // take place. This is used to retire entries from the cache to
   // avoid keeping them alive too long without using them.
-  static void MarkCompactPrologue();
+  void MarkCompactPrologue();

// Enable/disable compilation cache. Used by debugger to disable compilation
   // cache during debugging to make sure new scripts are always compiled.
-  static void Enable();
-  static void Disable();
+  void Enable();
+  void Disable();
+ private:
+  CompilationCache();
+
+  // The number of sub caches covering the different types to cache.
+  static const int kSubCacheCount = 4;
+
+  CompilationCacheScript script_;
+  CompilationCacheEval eval_global_;
+  CompilationCacheEval eval_contextual_;
+  CompilationCacheRegExp reg_exp_;
+  CompilationSubCache* subcaches_[kSubCacheCount];
+
+  // Current enable state of the compilation cache.
+  bool enabled_;
+
+  bool IsEnabled() { return FLAG_compilation_cache && enabled_; }
+
+  friend class Isolate;
+
+  DISALLOW_COPY_AND_ASSIGN(CompilationCache);
 };


=======================================
--- /branches/experimental/isolates/src/compiler.cc     Wed Jun  9 16:02:44 2010
+++ /branches/experimental/isolates/src/compiler.cc     Fri Jun 18 13:14:40 2010
@@ -293,13 +293,15 @@
   // The VM is in the COMPILER state until exiting this function.
   VMState state(COMPILER);

+ CompilationCache* compilation_cache = Isolate::Current()->compilation_cache();
+
   // Do a lookup in the compilation cache but not for extensions.
   Handle<SharedFunctionInfo> result;
   if (extension == NULL) {
-    result = CompilationCache::LookupScript(source,
-                                            script_name,
-                                            line_offset,
-                                            column_offset);
+    result = compilation_cache->LookupScript(source,
+                                             script_name,
+                                             line_offset,
+                                             column_offset);
   }

   if (result.is_null()) {
@@ -334,7 +336,7 @@
                               extension,
                               pre_data);
     if (extension == NULL && !result.is_null()) {
-      CompilationCache::PutScript(source, result);
+      compilation_cache->PutScript(source, result);
     }

     // Get rid of the pre-parsing data (if necessary).
@@ -363,13 +365,15 @@
   // The VM is in the COMPILER state until exiting this function.
   VMState state(COMPILER);

+ CompilationCache* compilation_cache = Isolate::Current()->compilation_cache();
+
   // Do a lookup in the compilation cache; if the entry is not there,
   // invoke the compiler and add the result to the cache.  If we're
   // evaluating json we bypass the cache since we can't be sure a
   // potential value in the cache has been validated.
   Handle<SharedFunctionInfo> result;
   if (validate == DONT_VALIDATE_JSON)
-    result = CompilationCache::LookupEval(source, context, is_global);
+    result = compilation_cache->LookupEval(source, context, is_global);

   if (result.is_null()) {
     // Create a script object describing the script to be compiled.
@@ -384,7 +388,7 @@
     if (!result.is_null() && validate != VALIDATE_JSON) {
       // For json it's unlikely that we'll ever see exactly the same
       // string again so we don't use the compilation cache.
-      CompilationCache::PutEval(source, context, is_global, result);
+      compilation_cache->PutEval(source, context, is_global, result);
     }
   }

=======================================
--- /branches/experimental/isolates/src/debug.cc        Wed Jun 16 17:13:33 2010
+++ /branches/experimental/isolates/src/debug.cc        Fri Jun 18 13:14:40 2010
@@ -2465,12 +2465,13 @@


 void Debugger::ListenersChanged() {
+  Isolate* isolate = Isolate::Current();
   if (IsDebuggerActive()) {
     // Disable the compilation cache when the debugger is active.
-    CompilationCache::Disable();
+    isolate->compilation_cache()->Disable();
     debugger_unload_pending_ = false;
   } else {
-    CompilationCache::Enable();
+    isolate->compilation_cache()->Enable();
     // Unload the debugger if event listener and message handler cleared.
     // Schedule this for later, because we may be in non-V8 thread.
     debugger_unload_pending_ = true;
=======================================
--- /branches/experimental/isolates/src/heap.cc Thu Jun 17 06:14:39 2010
+++ /branches/experimental/isolates/src/heap.cc Fri Jun 18 13:14:40 2010
@@ -688,7 +688,7 @@
   isolate_->context_slot_cache()->Clear();
   isolate_->descriptor_lookup_cache()->Clear();

-  CompilationCache::MarkCompactPrologue();
+  isolate_->compilation_cache()->MarkCompactPrologue();

   Top::MarkCompactPrologue(is_compacting);
   ThreadManager::MarkCompactPrologue(is_compacting);
@@ -1658,7 +1658,7 @@
   isolate_->descriptor_lookup_cache()->Clear();

   // Initialize compilation cache.
-  CompilationCache::Clear();
+  isolate_->compilation_cache()->Clear();

   return true;
 }
@@ -2222,7 +2222,8 @@
   if (function_info->is_toplevel()) return;

   // If this function is in the compilation cache we do not flush the code.
-  if (CompilationCache::HasFunction(function_info)) return;
+  if (Isolate::Current()->compilation_cache()->HasFunction(function_info))
+      return;

   // Make sure we are not referencing the code from the stack.
   for (StackFrameIterator it; !it.done(); it.Advance()) {
@@ -3224,7 +3225,7 @@
     // Before doing the mark-sweep collections we clear the
     // compilation cache to avoid hanging on to source code and
     // generated code for cached functions.
-    CompilationCache::Clear();
+    isolate_->compilation_cache()->Clear();

     CollectAllGarbage(false);
     new_space_.Shrink();
@@ -3778,7 +3779,7 @@
   Debug::Iterate(v);
 #endif
   v->Synchronize("debug");
-  CompilationCache::Iterate(v);
+  isolate_->compilation_cache()->Iterate(v);
   v->Synchronize("compilationcache");

   // Iterate over local handles in handle scopes.
=======================================
--- /branches/experimental/isolates/src/isolate.cc      Thu Jun 17 06:14:39 2010
+++ /branches/experimental/isolates/src/isolate.cc      Fri Jun 18 13:14:40 2010
@@ -30,6 +30,7 @@
 #include "v8.h"

 #include "bootstrapper.h"
+#include "compilation-cache.h"
 #include "debug.h"
 #include "heap-profiler.h"
 #include "isolate.h"
@@ -109,6 +110,7 @@
 Isolate::Isolate()
     : state_(UNINITIALIZED),
       bootstrapper_(NULL),
+      compilation_cache_(new CompilationCache()),
       cpu_features_(NULL),
       break_access_(OS::CreateMutex()),
       stub_cache_(NULL),
@@ -152,6 +154,8 @@
   stub_cache_ = NULL;
   delete cpu_features_;
   cpu_features_ = NULL;
+  delete compilation_cache_;
+  compilation_cache_ = NULL;
   delete bootstrapper_;
   bootstrapper_ = NULL;

=======================================
--- /branches/experimental/isolates/src/isolate.h       Thu Jun 17 06:14:39 2010
+++ /branches/experimental/isolates/src/isolate.h       Fri Jun 18 13:14:40 2010
@@ -39,6 +39,7 @@
 namespace internal {

 class Bootstrapper;
+class CompilationCache;
 class ContextSlotCache;
 class CpuFeatures;
 class Deserializer;
@@ -195,6 +196,7 @@
   // Accessors.
   Bootstrapper* bootstrapper() { return bootstrapper_; }
   CpuFeatures* cpu_features() { return cpu_features_; }
+  CompilationCache* compilation_cache() { return compilation_cache_; }
   StackGuard* stack_guard() { return &stack_guard_; }
   Heap* heap() { return &heap_; }
   StubCache* stub_cache() { return stub_cache_; }
@@ -261,6 +263,7 @@
   State state_;

   Bootstrapper* bootstrapper_;
+  CompilationCache* compilation_cache_;
   CpuFeatures* cpu_features_;
   Mutex* break_access_;
   Heap heap_;
=======================================
--- /branches/experimental/isolates/src/jsregexp.cc     Mon Apr 26 08:10:42 2010
+++ /branches/experimental/isolates/src/jsregexp.cc     Fri Jun 18 13:14:40 2010
@@ -111,7 +111,8 @@
                                    Handle<String> pattern,
                                    Handle<String> flag_str) {
   JSRegExp::Flags flags = RegExpFlagsFromString(flag_str);
- Handle<FixedArray> cached = CompilationCache::LookupRegExp(pattern, flags); + CompilationCache* compilation_cache = Isolate::Current()->compilation_cache(); + Handle<FixedArray> cached = compilation_cache->LookupRegExp(pattern, flags);
   bool in_cache = !cached.is_null();
   LOG(RegExpCompileEvent(re, in_cache));

@@ -151,7 +152,7 @@
   // Compilation succeeded so the data is set on the regexp
   // and we can store it in the cache.
   Handle<FixedArray> data(FixedArray::cast(re->data()));
-  CompilationCache::PutRegExp(pattern, flags, data);
+  compilation_cache->PutRegExp(pattern, flags, data);

   return re;
 }
=======================================
--- /branches/experimental/isolates/test/cctest/test-api.cc Wed Jun 16 17:13:33 2010 +++ /branches/experimental/isolates/test/cctest/test-api.cc Fri Jun 18 13:14:40 2010
@@ -384,7 +384,7 @@
     HEAP->CollectAllGarbage(false);
     CHECK_EQ(0, TestResource::dispose_count);
   }
-  v8::internal::CompilationCache::Clear();
+  v8::internal::Isolate::Current()->compilation_cache()->Clear();
   HEAP->CollectAllGarbage(false);
   CHECK_EQ(1, TestResource::dispose_count);
 }
@@ -405,7 +405,7 @@
     HEAP->CollectAllGarbage(false);
     CHECK_EQ(0, TestAsciiResource::dispose_count);
   }
-  v8::internal::CompilationCache::Clear();
+  v8::internal::Isolate::Current()->compilation_cache()->Clear();
   HEAP->CollectAllGarbage(false);
   CHECK_EQ(1, TestAsciiResource::dispose_count);
 }
@@ -430,7 +430,7 @@
     HEAP->CollectAllGarbage(false);
     CHECK_EQ(0, TestResource::dispose_count);
   }
-  v8::internal::CompilationCache::Clear();
+  v8::internal::Isolate::Current()->compilation_cache()->Clear();
   HEAP->CollectAllGarbage(false);
   CHECK_EQ(1, TestResource::dispose_count);
 }
@@ -456,7 +456,7 @@
     HEAP->CollectAllGarbage(false);
     CHECK_EQ(0, TestAsciiResource::dispose_count);
   }
-  v8::internal::CompilationCache::Clear();
+  v8::internal::Isolate::Current()->compilation_cache()->Clear();
   HEAP->CollectAllGarbage(false);
   CHECK_EQ(1, TestAsciiResource::dispose_count);
 }
@@ -648,7 +648,7 @@
     HEAP->CollectAllGarbage(false);
     CHECK_EQ(0, TestAsciiResource::dispose_count);
   }
-  v8::internal::CompilationCache::Clear();
+  v8::internal::Isolate::Current()->compilation_cache()->Clear();
   HEAP->CollectAllGarbage(false);
   CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls);
   CHECK_EQ(0, TestAsciiResource::dispose_count);
@@ -669,7 +669,7 @@
     HEAP->CollectAllGarbage(false);
     CHECK_EQ(0, TestAsciiResource::dispose_count);
   }
-  v8::internal::CompilationCache::Clear();
+  v8::internal::Isolate::Current()->compilation_cache()->Clear();
   HEAP->CollectAllGarbage(false);
   CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls);
   CHECK_EQ(1, TestAsciiResource::dispose_count);
@@ -708,7 +708,7 @@
     CHECK(value->IsNumber());
     CHECK_EQ(68, value->Int32Value());
   }
-  v8::internal::CompilationCache::Clear();
+  v8::internal::Isolate::Current()->compilation_cache()->Clear();
   HEAP->CollectAllGarbage(false);
   HEAP->CollectAllGarbage(false);
 }

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to