elements.cc CopyDoubleToObjectElements: avoid excessive HandleScopes

BUG=

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

Cr-Commit-Position: refs/heads/master@{#30717}
This commit is contained in:
cbruni 2015-09-14 07:29:46 -07:00 committed by Commit bot
parent a0bc7651ab
commit 43a04030b8

View File

@ -253,14 +253,22 @@ static void CopyDoubleToObjectElements(FixedArrayBase* from_base,
Isolate* isolate = from_base->GetIsolate();
Handle<FixedDoubleArray> from(FixedDoubleArray::cast(from_base), isolate);
Handle<FixedArray> to(FixedArray::cast(to_base), isolate);
for (int i = 0; i < copy_size; ++i) {
// create an outer loop to not waste too much time on creating HandleScopes
// on the other hand we might overflow a single handle scope depending on
// the copy_size
int offset = 0;
while (offset < copy_size) {
HandleScope scope(isolate);
if (IsFastSmiElementsKind(to_kind)) {
UNIMPLEMENTED();
} else {
DCHECK(IsFastObjectElementsKind(to_kind));
Handle<Object> value = FixedDoubleArray::get(from, i + from_start);
to->set(i + to_start, *value, UPDATE_WRITE_BARRIER);
offset += 100;
for (int i = offset - 100; i < offset && i < copy_size; ++i) {
if (IsFastSmiElementsKind(to_kind)) {
UNIMPLEMENTED();
} else {
DCHECK(IsFastObjectElementsKind(to_kind));
Handle<Object> value = FixedDoubleArray::get(from, i + from_start);
to->set(i + to_start, *value, UPDATE_WRITE_BARRIER);
}
}
}
}