Reviewers: Hannes Payer,

Message:
PTAL

Description:
Version 3.26.31.7 (merged r21869, r21873)

Do GC if CodeRange fails to allocate a block.

Reduce number of writes to DependentCode array when inserting dependent IC.

BUG=305878
LOG=N

Please review this at https://codereview.chromium.org/349953002/

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

Affected files (+22, -13 lines):
  M src/objects.cc
  M src/spaces.h
  M src/spaces.cc
  M src/version.cc


Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index afb1f488b14ebc55d3c4b1211654035ae4c446dd..22d019f4dbb298e86386989e1ee755a6cd504077 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -12367,8 +12367,17 @@ void DependentCode::AddToDependentICList(Handle<Code> stub) {
   DisallowHeapAllocation no_heap_allocation;
   GroupStartIndexes starts(this);
   int i = starts.at(kWeakICGroup);
-  stub->set_next_code_link(object_at(i));
-  set_object_at(i, *stub);
+  Object* head = object_at(i);
+ // Try to insert the stub after the head of the list to minimize number of + // writes to the DependentCode array, since a write to the array can make it
+  // strong if it was alread marked by incremental marker.
+  if (head->IsCode()) {
+    stub->set_next_code_link(Code::cast(head)->next_code_link());
+    Code::cast(head)->set_next_code_link(*stub);
+  } else {
+    stub->set_next_code_link(head);
+    set_object_at(i, *stub);
+  }
 }


Index: src/spaces.cc
diff --git a/src/spaces.cc b/src/spaces.cc
index 8e923af5480842d180226d8f8bb08e20fd2ffe97..78da3ca673902b04b4a4e56c2e065bac7eecbf2b 100644
--- a/src/spaces.cc
+++ b/src/spaces.cc
@@ -156,12 +156,12 @@ int CodeRange::CompareFreeBlockAddress(const FreeBlock* left,
 }


-void CodeRange::GetNextAllocationBlock(size_t requested) {
+bool CodeRange::GetNextAllocationBlock(size_t requested) {
   for (current_allocation_block_index_++;
        current_allocation_block_index_ < allocation_list_.length();
        current_allocation_block_index_++) {
if (requested <= allocation_list_[current_allocation_block_index_].size) {
-      return;  // Found a large enough allocation block.
+      return true;  // Found a large enough allocation block.
     }
   }

@@ -188,12 +188,12 @@ void CodeRange::GetNextAllocationBlock(size_t requested) {
        current_allocation_block_index_ < allocation_list_.length();
        current_allocation_block_index_++) {
if (requested <= allocation_list_[current_allocation_block_index_].size) {
-      return;  // Found a large enough allocation block.
+      return true;  // Found a large enough allocation block.
     }
   }

   // Code range is full or too fragmented.
-  V8::FatalProcessOutOfMemory("CodeRange::GetNextAllocationBlock");
+  return false;
 }


@@ -203,9 +203,8 @@ Address CodeRange::AllocateRawMemory(const size_t requested_size,
   ASSERT(commit_size <= requested_size);
   ASSERT(current_allocation_block_index_ < allocation_list_.length());
if (requested_size > allocation_list_[current_allocation_block_index_].size) {
-    // Find an allocation block large enough.  This function call may
- // call V8::FatalProcessOutOfMemory if it cannot find a large enough block.
-    GetNextAllocationBlock(requested_size);
+    // Find an allocation block large enough.
+    if (!GetNextAllocationBlock(requested_size)) return NULL;
   }
// Commit the requested memory at the start of the current allocation block. size_t aligned_requested = RoundUp(requested_size, MemoryChunk::kAlignment); @@ -228,7 +227,8 @@ Address CodeRange::AllocateRawMemory(const size_t requested_size,
   allocation_list_[current_allocation_block_index_].start += *allocated;
   allocation_list_[current_allocation_block_index_].size -= *allocated;
   if (*allocated == current.size) {
-    GetNextAllocationBlock(0);  // This block is used up, get the next one.
+    // This block is used up, get the next one.
+    if (!GetNextAllocationBlock(0)) return NULL;
   }
   return current.start;
 }
Index: src/spaces.h
diff --git a/src/spaces.h b/src/spaces.h
index 735f1fbbf2225bf63d5056bd3d75f4efb0b5e9aa..dd410754b06af765c1b0df658d60d205e0a30ae5 100644
--- a/src/spaces.h
+++ b/src/spaces.h
@@ -985,8 +985,8 @@ class CodeRange {
   // Finds a block on the allocation list that contains at least the
   // requested amount of memory.  If none is found, sorts and merges
   // the existing free memory blocks, and searches again.
-  // If none can be found, terminates V8 with FatalProcessOutOfMemory.
-  void GetNextAllocationBlock(size_t requested);
+  // If none can be found, returns false.
+  bool GetNextAllocationBlock(size_t requested);
   // Compares the start addresses of two free blocks.
   static int CompareFreeBlockAddress(const FreeBlock* left,
                                      const FreeBlock* right);
Index: src/version.cc
diff --git a/src/version.cc b/src/version.cc
index 77ad68689f14a99364fa136655c2e9e57d6dc85e..ac185caf52e16b2bd640e0c29bfddb456690cf01 100644
--- a/src/version.cc
+++ b/src/version.cc
@@ -35,7 +35,7 @@
 #define MAJOR_VERSION     3
 #define MINOR_VERSION     26
 #define BUILD_NUMBER      31
-#define PATCH_LEVEL       6
+#define PATCH_LEVEL       7
 // Use 1 for candidates and 0 otherwise.
 // (Boolean macro values are not supported by all preprocessors.)
 #define IS_CANDIDATE_VERSION 0


--
--
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/d/optout.

Reply via email to