From b624783b1bfdafc888c66566812dcbf8feaaadd2 Mon Sep 17 00:00:00 2001 From: "ulan@chromium.org" Date: Tue, 17 Jun 2014 13:22:34 +0000 Subject: [PATCH] Reduce number of writes to DependentCode array when inserting dependent IC. 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 | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/objects.cc b/src/objects.cc index 06c4a4b..f852f4d 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -12061,8 +12061,17 @@ void DependentCode::AddToDependentICList(Handle 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); + } } -- 2.7.4