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

Side by Side Diff: src/elements.cc

Issue 1341763002: elements.cc CopyDoubleToObjectElements: avoid excessive HandleScopes (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Extending comment Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/elements.h" 5 #include "src/elements.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/conversions.h" 8 #include "src/conversions.h"
9 #include "src/factory.h" 9 #include "src/factory.h"
10 #include "src/messages.h" 10 #include "src/messages.h"
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 246
247 DCHECK((copy_size + static_cast<int>(to_start)) <= to_base->length() && 247 DCHECK((copy_size + static_cast<int>(to_start)) <= to_base->length() &&
248 (copy_size + static_cast<int>(from_start)) <= from_base->length()); 248 (copy_size + static_cast<int>(from_start)) <= from_base->length());
249 if (copy_size == 0) return; 249 if (copy_size == 0) return;
250 250
251 // From here on, the code below could actually allocate. Therefore the raw 251 // From here on, the code below could actually allocate. Therefore the raw
252 // values are wrapped into handles. 252 // values are wrapped into handles.
253 Isolate* isolate = from_base->GetIsolate(); 253 Isolate* isolate = from_base->GetIsolate();
254 Handle<FixedDoubleArray> from(FixedDoubleArray::cast(from_base), isolate); 254 Handle<FixedDoubleArray> from(FixedDoubleArray::cast(from_base), isolate);
255 Handle<FixedArray> to(FixedArray::cast(to_base), isolate); 255 Handle<FixedArray> to(FixedArray::cast(to_base), isolate);
256 for (int i = 0; i < copy_size; ++i) { 256
257 // create an outer loop to not waste too much time on creating HandleScopes
258 // on the other hand we might overflow a single handle scope depending on
259 // the copy_size
260 int offset = 0;
261 while (offset < copy_size) {
257 HandleScope scope(isolate); 262 HandleScope scope(isolate);
258 if (IsFastSmiElementsKind(to_kind)) { 263 offset += 100;
259 UNIMPLEMENTED(); 264 for (int i = offset - 100; i < offset && i < copy_size; ++i) {
260 } else { 265 if (IsFastSmiElementsKind(to_kind)) {
261 DCHECK(IsFastObjectElementsKind(to_kind)); 266 UNIMPLEMENTED();
262 Handle<Object> value = FixedDoubleArray::get(from, i + from_start); 267 } else {
263 to->set(i + to_start, *value, UPDATE_WRITE_BARRIER); 268 DCHECK(IsFastObjectElementsKind(to_kind));
269 Handle<Object> value = FixedDoubleArray::get(from, i + from_start);
270 to->set(i + to_start, *value, UPDATE_WRITE_BARRIER);
271 }
264 } 272 }
265 } 273 }
266 } 274 }
267 275
268 276
269 static void CopyDoubleToDoubleElements(FixedArrayBase* from_base, 277 static void CopyDoubleToDoubleElements(FixedArrayBase* from_base,
270 uint32_t from_start, 278 uint32_t from_start,
271 FixedArrayBase* to_base, 279 FixedArrayBase* to_base,
272 uint32_t to_start, int raw_copy_size) { 280 uint32_t to_start, int raw_copy_size) {
273 DisallowHeapAllocation no_allocation; 281 DisallowHeapAllocation no_allocation;
(...skipping 2133 matching lines...) Expand 10 before | Expand all | Expand 10 after
2407 } 2415 }
2408 } 2416 }
2409 2417
2410 DCHECK(j == result_len); 2418 DCHECK(j == result_len);
2411 return result_array; 2419 return result_array;
2412 } 2420 }
2413 2421
2414 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; 2422 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL;
2415 } // namespace internal 2423 } // namespace internal
2416 } // namespace v8 2424 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698