Make ArrayList::Elements() static in order to be GC-safe

NOTREECHECKS=true

Change-Id: I4ebd05d41d524ac0583b507fcdf7d4c15136d3b8
Reviewed-on: https://chromium-review.googlesource.com/567548
Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
Commit-Queue: Adam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46570}
This commit is contained in:
Adam Klein 2017-07-11 16:44:36 -07:00 committed by Commit Bot
parent 892d49a695
commit 5562f6a276
3 changed files with 11 additions and 8 deletions

View File

@ -1000,10 +1000,11 @@ Handle<JSObject> ConvertToJSObject(Isolate* isolate,
ArrayList::cast(feedback->get(value_index)));
int position = Smi::ToInt(key);
JSObject::AddDataElement(type_profile, position,
isolate->factory()->NewJSArrayWithElements(
position_specific_types->Elements()),
PropertyAttributes::NONE)
JSObject::AddDataElement(
type_profile, position,
isolate->factory()->NewJSArrayWithElements(
ArrayList::Elements(position_specific_types)),
PropertyAttributes::NONE)
.ToHandleChecked();
}
}

View File

@ -10136,10 +10136,12 @@ Handle<ArrayList> ArrayList::New(Isolate* isolate, int size) {
return result;
}
Handle<FixedArray> ArrayList::Elements() const {
Handle<FixedArray> result = GetIsolate()->factory()->NewFixedArray(Length());
Handle<FixedArray> ArrayList::Elements(Handle<ArrayList> array) {
int length = array->Length();
Handle<FixedArray> result =
array->GetIsolate()->factory()->NewFixedArray(length);
// Do not copy the first entry, i.e., the length.
CopyTo(kFirstIndex, *result, 0, Length());
array->CopyTo(kFirstIndex, *result, 0, length);
return result;
}

View File

@ -3026,7 +3026,7 @@ class ArrayList : public FixedArray {
// Return a copy of the list of size Length() without the first entry. The
// number returned by Length() is stored in the first entry.
Handle<FixedArray> Elements() const;
static Handle<FixedArray> Elements(Handle<ArrayList> array);
bool IsFull();
DECL_CAST(ArrayList)