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

Unified Diff: src/builtins.cc

Issue 207613004: Do not left-trim arrays when concurrent sweeping is active. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/heap.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins.cc
diff --git a/src/builtins.cc b/src/builtins.cc
index b48de7f2cd52378eb5e706e1951fba1031192c4f..3e97f7648a5f4c328011d4b564e9c35bad96ff34 100644
--- a/src/builtins.cc
+++ b/src/builtins.cc
@@ -610,7 +610,7 @@ BUILTIN(ArrayShift) {
first = heap->undefined_value();
}
- if (!heap->lo_space()->Contains(elms_obj)) {
+ if (!heap->CanMoveObjectStart(elms_obj)) {
array->set_elements(LeftTrimFixedArray(heap, elms_obj, 1));
} else {
// Shift the elements.
@@ -950,8 +950,23 @@ BUILTIN(ArraySplice) {
heap->MoveElements(elms, delta, 0, actual_start);
}
- elms_obj = LeftTrimFixedArray(heap, elms_obj, delta);
-
+ if (heap->CanMoveObjectStart(elms_obj)) {
+ // On the fast path we move the start of the object in memory.
+ elms_obj = LeftTrimFixedArray(heap, elms_obj, delta);
+ } else {
+ // This is the slow path. We are going to move the elements to the left
+ // by copying them. For trimmed values we store the hole.
+ if (elms_obj->IsFixedDoubleArray()) {
+ FixedDoubleArray* elms = FixedDoubleArray::cast(elms_obj);
+ MoveDoubleElements(elms, 0, elms, delta, len - delta);
+ FillWithHoles(elms, len - delta, len);
+ } else {
+ FixedArray* elms = FixedArray::cast(elms_obj);
+ DisallowHeapAllocation no_gc;
+ heap->MoveElements(elms, 0, delta, len - delta);
+ FillWithHoles(heap, elms, len - delta, len);
+ }
+ }
elms_changed = true;
} else {
if (elms_obj->IsFixedDoubleArray()) {
« no previous file with comments | « no previous file | src/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698