Reduce number of writes to DependentCode array when inserting dependent IC.
authorulan@chromium.org <ulan@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 17 Jun 2014 13:22:34 +0000 (13:22 +0000)
committerulan@chromium.org <ulan@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 17 Jun 2014 13:22:34 +0000 (13:22 +0000)
BUG=305878
LOG=Y
R=hpayer@chromium.org

Review URL: https://codereview.chromium.org/339843004

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21873 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/objects.cc

index 06c4a4b..f852f4d 100644 (file)
@@ -12061,8 +12061,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);
+  }
 }