Revision: 19189
Author:   [email protected]
Date:     Fri Feb  7 09:54:52 2014 UTC
Log:      The allocation sites scratchpad becomes a heap data structure.

BUG=
[email protected], [email protected]

Review URL: https://codereview.chromium.org/143153008
http://code.google.com/p/v8/source/detail?r=19189

Modified:
 /branches/bleeding_edge/include/v8.h
 /branches/bleeding_edge/src/heap-inl.h
 /branches/bleeding_edge/src/heap.cc
 /branches/bleeding_edge/src/heap.h

=======================================
--- /branches/bleeding_edge/include/v8.h        Thu Jan 30 10:33:53 2014 UTC
+++ /branches/bleeding_edge/include/v8.h        Fri Feb  7 09:54:52 2014 UTC
@@ -5398,7 +5398,7 @@
   static const int kNullValueRootIndex = 7;
   static const int kTrueValueRootIndex = 8;
   static const int kFalseValueRootIndex = 9;
-  static const int kEmptyStringRootIndex = 146;
+  static const int kEmptyStringRootIndex = 147;

   static const int kNodeClassIdOffset = 1 * kApiPointerSize;
   static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3;
=======================================
--- /branches/bleeding_edge/src/heap-inl.h      Wed Feb  5 09:29:04 2014 UTC
+++ /branches/bleeding_edge/src/heap-inl.h      Fri Feb  7 09:54:52 2014 UTC
@@ -517,12 +517,8 @@
   AllocationMemento* memento = AllocationMemento::cast(candidate);
   if (!memento->IsValid()) return;

-  if (memento->GetAllocationSite()->IncrementMementoFoundCount() &&
-      heap->allocation_sites_scratchpad_length <
-      kAllocationSiteScratchpadSize) {
-    heap->allocation_sites_scratchpad[
-        heap->allocation_sites_scratchpad_length++] =
-        memento->GetAllocationSite();
+  if (memento->GetAllocationSite()->IncrementMementoFoundCount()) {
+    heap->AddAllocationSiteToScratchpad(memento->GetAllocationSite());
   }
 }

=======================================
--- /branches/bleeding_edge/src/heap.cc Thu Feb  6 10:30:13 2014 UTC
+++ /branches/bleeding_edge/src/heap.cc Fri Feb  7 09:54:52 2014 UTC
@@ -150,7 +150,7 @@
 #ifdef VERIFY_HEAP
       no_weak_object_verification_scope_depth_(0),
 #endif
-      allocation_sites_scratchpad_length(0),
+      allocation_sites_scratchpad_length_(0),
       promotion_queue_(this),
       configured_(false),
       external_string_table_(this),
@@ -516,16 +516,17 @@
     // If the scratchpad overflowed, we have to iterate over the allocation
     // sites list.
     bool use_scratchpad =
-        allocation_sites_scratchpad_length < kAllocationSiteScratchpadSize;
+ allocation_sites_scratchpad_length_ < kAllocationSiteScratchpadSize;

     int i = 0;
     Object* list_element = allocation_sites_list();
     bool trigger_deoptimization = false;
     while (use_scratchpad ?
-              i < allocation_sites_scratchpad_length :
+              i < allocation_sites_scratchpad_length_ :
               list_element->IsAllocationSite()) {
       AllocationSite* site = use_scratchpad ?
- allocation_sites_scratchpad[i] : AllocationSite::cast(list_element);
+          AllocationSite::cast(allocation_sites_scratchpad()->get(i)) :
+          AllocationSite::cast(list_element);
       allocation_mementos_found += site->memento_found_count();
       if (site->memento_found_count() > 0) {
         active_allocation_sites++;
@@ -546,7 +547,7 @@

     if (trigger_deoptimization) isolate_->stack_guard()->DeoptMarkedCode();

-    allocation_sites_scratchpad_length = 0;
+    FlushAllocationSitesScratchpad();

     if (FLAG_trace_pretenuring_statistics &&
         (allocation_mementos_found > 0 ||
@@ -3300,6 +3301,12 @@
   // Handling of script id generation is in Factory::NewScript.
   set_last_script_id(Smi::FromInt(v8::Script::kNoScriptId));

+  { MaybeObject* maybe_obj = AllocateAllocationSitesScratchpad();
+    if (!maybe_obj->ToObject(&obj)) return false;
+  }
+  set_allocation_sites_scratchpad(FixedArray::cast(obj));
+  InitializeAllocationSitesScratchpad();
+
   // Initialize keyed lookup cache.
   isolate_->keyed_lookup_cache()->Clear();

@@ -3587,6 +3594,39 @@
   if (!maybe->To<Object>(&number)) return maybe;
   return NumberToString(number, check_number_string_cache);
 }
+
+
+MaybeObject* Heap::AllocateAllocationSitesScratchpad() {
+  MaybeObject* maybe_obj =
+      AllocateFixedArray(kAllocationSiteScratchpadSize, TENURED);
+  return maybe_obj;
+}
+
+
+void Heap::FlushAllocationSitesScratchpad() {
+  for (int i = 0; i < allocation_sites_scratchpad_length_; i++) {
+    allocation_sites_scratchpad()->set_undefined(i);
+  }
+  allocation_sites_scratchpad_length_ = 0;
+}
+
+
+void Heap::InitializeAllocationSitesScratchpad() {
+  ASSERT(allocation_sites_scratchpad()->length() ==
+         kAllocationSiteScratchpadSize);
+  for (int i = 0; i < kAllocationSiteScratchpadSize; i++) {
+    allocation_sites_scratchpad()->set_undefined(i);
+  }
+}
+
+
+void Heap::AddAllocationSiteToScratchpad(AllocationSite* site) {
+ if (allocation_sites_scratchpad_length_ < kAllocationSiteScratchpadSize) {
+    allocation_sites_scratchpad()->set(
+        allocation_sites_scratchpad_length_, site);
+    allocation_sites_scratchpad_length_++;
+  }
+}


 Map* Heap::MapForExternalArrayType(ExternalArrayType array_type) {
=======================================
--- /branches/bleeding_edge/src/heap.h  Tue Feb  4 10:30:36 2014 UTC
+++ /branches/bleeding_edge/src/heap.h  Fri Feb  7 09:54:52 2014 UTC
@@ -202,7 +202,8 @@
V(SeededNumberDictionary, empty_slow_element_dictionary, \ EmptySlowElementDictionary) \ V(Symbol, observed_symbol, ObservedSymbol) \
-  V(FixedArray, materialized_objects, MaterializedObjects)
+ V(FixedArray, materialized_objects, MaterializedObjects) \
+  V(FixedArray, allocation_sites_scratchpad, AllocationSitesScratchpad)

 #define ROOT_LIST(V)                                  \
   STRONG_ROOT_LIST(V)                                 \
@@ -2285,6 +2286,18 @@
   // Flush the number to string cache.
   void FlushNumberStringCache();

+  // Allocates a fixed-size allocation sites scratchpad.
+  MUST_USE_RESULT MaybeObject* AllocateAllocationSitesScratchpad();
+
+  // Sets used allocation sites entries to undefined.
+  void FlushAllocationSitesScratchpad();
+
+  // Initializes the allocation sites scratchpad with undefined values.
+  void InitializeAllocationSitesScratchpad();
+
+  // Adds an allocation site to the scratchpad if there is space left.
+  void AddAllocationSiteToScratchpad(AllocationSite* site);
+
   void UpdateSurvivalRateTrend(int start_new_space_size);

   enum SurvivalRateTrend { INCREASING, STABLE, DECREASING, FLUCTUATING };
@@ -2457,10 +2470,8 @@
   int no_weak_object_verification_scope_depth_;
 #endif

-
   static const int kAllocationSiteScratchpadSize = 256;
-  int allocation_sites_scratchpad_length;
- AllocationSite* allocation_sites_scratchpad[kAllocationSiteScratchpadSize];
+  int allocation_sites_scratchpad_length_;

   static const int kMaxMarkSweepsInIdleRound = 7;
   static const int kIdleScavengeThreshold = 5;

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to