Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Unified Diff: src/objects.cc

Issue 1026113004: Reload length of retained_maps array after GC. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove unused var Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.h ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index f7d0fd5b65fc5fa923c7dfbccf9cda42128a6795..14217aac7c315092c7a2907d1c789d14a421a024 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -8277,9 +8277,14 @@ Handle<WeakFixedArray> WeakFixedArray::Allocate(
}
-Handle<ArrayList> ArrayList::Add(Handle<ArrayList> array, Handle<Object> obj) {
+Handle<ArrayList> ArrayList::Add(Handle<ArrayList> array, Handle<Object> obj,
+ AddMode mode) {
int length = array->Length();
array = EnsureSpace(array, length + 1);
+ if (mode == kReloadLengthAfterAllocation) {
+ DCHECK(array->Length() <= length);
+ length = array->Length();
+ }
array->Set(length, *obj);
array->SetLength(length + 1);
return array;
@@ -8287,9 +8292,12 @@ Handle<ArrayList> ArrayList::Add(Handle<ArrayList> array, Handle<Object> obj) {
Handle<ArrayList> ArrayList::Add(Handle<ArrayList> array, Handle<Object> obj1,
- Handle<Object> obj2) {
+ Handle<Object> obj2, AddMode mode) {
int length = array->Length();
array = EnsureSpace(array, length + 2);
+ if (mode == kReloadLengthAfterAllocation) {
+ length = array->Length();
Erik Corry 2015/03/25 09:53:07 Missing DCHECK from the single-argument version.
+ }
array->Set(length, *obj1);
array->Set(length + 1, *obj2);
array->SetLength(length + 2);
@@ -8299,10 +8307,12 @@ Handle<ArrayList> ArrayList::Add(Handle<ArrayList> array, Handle<Object> obj1,
Handle<ArrayList> ArrayList::EnsureSpace(Handle<ArrayList> array, int length) {
int capacity = array->length();
Erik Corry 2015/03/25 09:53:07 // This is the length of the FixedArray
+ bool empty = (capacity == 0);
if (capacity < kFirstIndex + length) {
capacity = kFirstIndex + length;
capacity = capacity + Max(capacity / 2, 2);
Erik Corry 2015/03/25 09:53:07 Division by 2 of a signed value can be an expensiv
array = Handle<ArrayList>::cast(FixedArray::CopySize(array, capacity));
+ if (empty) array->SetLength(0);
Erik Corry 2015/03/25 09:53:06 // This sets the length of the ArrayList, using th
}
return array;
}
« no previous file with comments | « src/objects.h ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698