From 43a04030b8c71549ef7608fe831d6633918dd52c Mon Sep 17 00:00:00 2001 From: cbruni Date: Mon, 14 Sep 2015 07:29:46 -0700 Subject: [PATCH] elements.cc CopyDoubleToObjectElements: avoid excessive HandleScopes BUG= Review URL: https://codereview.chromium.org/1341763002 Cr-Commit-Position: refs/heads/master@{#30717} --- src/elements.cc | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/elements.cc b/src/elements.cc index 3b3cda0abf..ff3e29888b 100644 --- a/src/elements.cc +++ b/src/elements.cc @@ -253,14 +253,22 @@ static void CopyDoubleToObjectElements(FixedArrayBase* from_base, Isolate* isolate = from_base->GetIsolate(); Handle from(FixedDoubleArray::cast(from_base), isolate); Handle 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 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 value = FixedDoubleArray::get(from, i + from_start); + to->set(i + to_start, *value, UPDATE_WRITE_BARRIER); + } } } }