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

Side by Side Diff: src/builtins.cc

Issue 702243003: Basic array capacity feedback via allocation sites. Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Update. Created 6 years, 1 month 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 | src/elements.cc » ('j') | 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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/arguments.h" 8 #include "src/arguments.h"
9 #include "src/base/once.h" 9 #include "src/base/once.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 int capacity = new_length + (new_length >> 1) + 16; 341 int capacity = new_length + (new_length >> 1) + 16;
342 Handle<FixedArray> new_elms = 342 Handle<FixedArray> new_elms =
343 isolate->factory()->NewUninitializedFixedArray(capacity); 343 isolate->factory()->NewUninitializedFixedArray(capacity);
344 344
345 ElementsAccessor* accessor = array->GetElementsAccessor(); 345 ElementsAccessor* accessor = array->GetElementsAccessor();
346 accessor->CopyElements( 346 accessor->CopyElements(
347 elms_obj, 0, kind, new_elms, 0, 347 elms_obj, 0, kind, new_elms, 0,
348 ElementsAccessor::kCopyToEndAndInitializeToHole); 348 ElementsAccessor::kCopyToEndAndInitializeToHole);
349 349
350 elms = new_elms; 350 elms = new_elms;
351
352 // Do we have an AllocationMemento, to store this feedback?
353 AllocationMemento* memento =
354 isolate->heap()->FindAllocationMemento(*array);
355 if (memento != NULL && memento->IsValid()) {
356 AllocationSite* site = memento->GetAllocationSite();
357 site->DigestInitialElementsCapacityFeedback(new_length);
358 }
351 } 359 }
352 360
353 // Add the provided values. 361 // Add the provided values.
354 DisallowHeapAllocation no_gc; 362 DisallowHeapAllocation no_gc;
355 WriteBarrierMode mode = elms->GetWriteBarrierMode(no_gc); 363 WriteBarrierMode mode = elms->GetWriteBarrierMode(no_gc);
356 for (int index = 0; index < to_add; index++) { 364 for (int index = 0; index < to_add; index++) {
357 elms->set(index + len, args[index + 1], mode); 365 elms->set(index + len, args[index + 1], mode);
358 } 366 }
359 367
360 if (*elms != array->elements()) { 368 if (*elms != array->elements()) {
(...skipping 1284 matching lines...) Expand 10 before | Expand all | Expand 10 after
1645 } 1653 }
1646 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) 1654 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C)
1647 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) 1655 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A)
1648 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) 1656 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H)
1649 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) 1657 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
1650 #undef DEFINE_BUILTIN_ACCESSOR_C 1658 #undef DEFINE_BUILTIN_ACCESSOR_C
1651 #undef DEFINE_BUILTIN_ACCESSOR_A 1659 #undef DEFINE_BUILTIN_ACCESSOR_A
1652 1660
1653 1661
1654 } } // namespace v8::internal 1662 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/elements.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698