Reviewers: Vyacheslav Egorov,

Description:
This patch fixes Heap::ClearJSFunctionResultCaches() the same way
that Heap::ClearNormalizedMapCache() was implemented in r5654.
The existing code effectively does not clear the JSFunctionResultCaches
at all.  With this patch, the caches are now cleared during a GC.

This patch has been tested by running tools/test.py.
There is only one failure:
obj/test/release/cctest test-api/Threading
--testing_serialization_file=obj/test/release/serdes_Threading

However, the failure is due to Heap::ClearNormalizedMapCaches()
expecting to fetch a NormalizedMapCache instance but instead gets
something that is all of the following:

HeapObject Symbol JSObject UndetectableObject AccessCheckNeeded

i.e. the Is<XXX>() test returns true for the above.

When I comment out the one line in my patch where I actually clear
the cache, the test passes again.  It looks like there's a hidden
bug in the serialization code, and this patch merely exposed it
when the cache is made to be cleared as expected.



Please review this at http://codereview.chromium.org/4187007/show

SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/

Affected files:
  M     src/heap.cc


Index: src/heap.cc
===================================================================
--- src/heap.cc (revision 5726)
+++ src/heap.cc (working copy)
@@ -581,25 +581,22 @@
 }


-class ClearThreadJSFunctionResultCachesVisitor: public ThreadVisitor  {
-  virtual void VisitThread(ThreadLocalTop* top) {
-    Context* context = top->context_;
-    if (context == NULL) return;
+void Heap::ClearJSFunctionResultCaches() {
+  if (Bootstrapper::IsActive()) return;

+  Object* context = global_contexts_list_;
+  while (!context->IsUndefined()) {
+    // Get the caches for this context:
     FixedArray* caches =
-      context->global()->global_context()->jsfunction_result_caches();
+      Context::cast(context)->jsfunction_result_caches();
+    // Clear the caches:
     int length = caches->length();
     for (int i = 0; i < length; i++) {
       JSFunctionResultCache::cast(caches->get(i))->Clear();
     }
+    // Get the next context:
+    context = Context::cast(context)->get(Context::NEXT_CONTEXT_LINK);
   }
-};
-
-
-void Heap::ClearJSFunctionResultCaches() {
-  if (Bootstrapper::IsActive()) return;
-  ClearThreadJSFunctionResultCachesVisitor visitor;
-  ThreadManager::IterateArchivedThreads(&visitor);
 }




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

Reply via email to