Reviewers: Vyacheslav Egorov,

Message:
Please take a look.

I know that this approach is just a crude approximation of optimal behavior, but
it's better than nothing for now.

Description:
Only clear monomorphic ICs on GC after Context exit


Please review this at https://chromiumcodereview.appspot.com/9255014/

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

Affected files:
  M src/api.cc
  M src/isolate.h
  M src/isolate.cc
  M src/mark-compact.cc


Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index bac3069308ed5e6f95ba0ef77ebd1ff98b583e95..4146bd4c1d8469dfab3ccfd9cf8254e070fa9956 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -741,6 +741,7 @@ void Context::Exit() {
   i::Context* last_context =
       isolate->handle_scope_implementer()->RestoreContext();
   isolate->set_context(last_context);
+  isolate->set_context_exit_happened(true);
 }


Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index f66a22db133c6689f7b7010d20b6c07d6d9f2011..82af337d905f15b4bcda189453e8708bae85956f 100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -1,4 +1,4 @@
-// Copyright 2011 the V8 project authors. All rights reserved.
+// Copyright 2012 the V8 project authors. All rights reserved.
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
 // met:
@@ -1454,7 +1454,8 @@ Isolate::Isolate()
       has_installed_extensions_(false),
       string_tracker_(NULL),
       regexp_stack_(NULL),
-      embedder_data_(NULL) {
+      embedder_data_(NULL),
+      context_exit_happened_(false) {
   TRACE_ISOLATE(constructor);

   memset(isolate_addresses_, 0,
Index: src/isolate.h
diff --git a/src/isolate.h b/src/isolate.h
index 898c1783dd42d9f5e9eb0f9064d6aaf57a813249..89793f8c74a0005ffde50b829639825cfa3b2303 100644
--- a/src/isolate.h
+++ b/src/isolate.h
@@ -1023,6 +1023,13 @@ class Isolate {
     thread_local_top_.top_lookup_result_ = top;
   }

+  bool context_exit_happened() {
+    return context_exit_happened_;
+  }
+  void set_context_exit_happened(bool context_exit_happened) {
+    context_exit_happened_ = context_exit_happened;
+  }
+
  private:
   Isolate();

@@ -1188,6 +1195,10 @@ class Isolate {
unibrow::Mapping<unibrow::Ecma262Canonicalize> interp_canonicalize_mapping_;
   void* embedder_data_;

+  // The garbage collector should be a little more aggressive when it knows
+  // that a context was recently exited.
+  bool context_exit_happened_;
+
 #if defined(V8_TARGET_ARCH_ARM) && !defined(__arm__) || \
     defined(V8_TARGET_ARCH_MIPS) && !defined(__mips__)
   bool simulator_initialized_;
Index: src/mark-compact.cc
diff --git a/src/mark-compact.cc b/src/mark-compact.cc
index 87e4bf9f04fedb3ad25a7859bd9a4e29a3179da1..2c59c886deb7d41bb7bcbb7398092d08f7bb6bb7 100644
--- a/src/mark-compact.cc
+++ b/src/mark-compact.cc
@@ -1,4 +1,4 @@
-// Copyright 2011 the V8 project authors. All rights reserved.
+// Copyright 2012 the V8 project authors. All rights reserved.
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are
 // met:
@@ -881,7 +881,9 @@ class StaticMarkingVisitor : public StaticVisitorBase {
   static inline void VisitCodeTarget(Heap* heap, RelocInfo* rinfo) {
     ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode()));
     Code* target = Code::GetCodeFromTargetAddress(rinfo->target_address());
-    if (FLAG_cleanup_code_caches_at_gc && target->is_inline_cache_stub()) {
+    if (FLAG_cleanup_code_caches_at_gc && target->is_inline_cache_stub()
+        && (target->ic_state() == MEGAMORPHIC || Serializer::enabled() ||
+            heap->isolate()->context_exit_happened())) {
       IC::Clear(rinfo->pc());
       target = Code::GetCodeFromTargetAddress(rinfo->target_address());
     } else {
@@ -2180,6 +2182,8 @@ void MarkCompactCollector::AfterMarking() {

   // Clean up dead objects from the runtime profiler.
   heap()->isolate()->runtime_profiler()->RemoveDeadSamples();
+
+  heap()->isolate()->set_context_exit_happened(false);
 }




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

Reply via email to