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

Side by Side Diff: src/builtins.cc

Issue 11737006: Filter old to new references when moving parts of an object. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/heap.h » ('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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 FixedDoubleArray* src, 330 FixedDoubleArray* src,
331 int src_index, 331 int src_index,
332 int len) { 332 int len) {
333 if (len == 0) return; 333 if (len == 0) return;
334 memmove(dst->data_start() + dst_index, 334 memmove(dst->data_start() + dst_index,
335 src->data_start() + src_index, 335 src->data_start() + src_index,
336 len * kDoubleSize); 336 len * kDoubleSize);
337 } 337 }
338 338
339 339
340 static void MoveElements(Heap* heap,
341 AssertNoAllocation* no_gc,
342 FixedArray* dst,
343 int dst_index,
344 FixedArray* src,
345 int src_index,
346 int len) {
347 if (len == 0) return;
348 ASSERT(dst->map() != HEAP->fixed_cow_array_map());
349 memmove(dst->data_start() + dst_index,
350 src->data_start() + src_index,
351 len * kPointerSize);
352 WriteBarrierMode mode = dst->GetWriteBarrierMode(*no_gc);
353 if (mode == UPDATE_WRITE_BARRIER) {
354 heap->RecordWrites(dst->address(), dst->OffsetOfElementAt(dst_index), len);
355 }
356 heap->incremental_marking()->RecordWrites(dst);
357 }
358
359
360 static void FillWithHoles(Heap* heap, FixedArray* dst, int from, int to) { 340 static void FillWithHoles(Heap* heap, FixedArray* dst, int from, int to) {
361 ASSERT(dst->map() != heap->fixed_cow_array_map()); 341 ASSERT(dst->map() != heap->fixed_cow_array_map());
362 MemsetPointer(dst->data_start() + from, heap->the_hole_value(), to - from); 342 MemsetPointer(dst->data_start() + from, heap->the_hole_value(), to - from);
363 } 343 }
364 344
365 345
366 static void FillWithHoles(FixedDoubleArray* dst, int from, int to) { 346 static void FillWithHoles(FixedDoubleArray* dst, int from, int to) {
367 for (int i = from; i < to; i++) { 347 for (int i = from; i < to; i++) {
368 dst->set_the_hole(i); 348 dst->set_the_hole(i);
369 } 349 }
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 first = heap->undefined_value(); 697 first = heap->undefined_value();
718 } 698 }
719 699
720 if (!heap->lo_space()->Contains(elms_obj)) { 700 if (!heap->lo_space()->Contains(elms_obj)) {
721 array->set_elements(LeftTrimFixedArray(heap, elms_obj, 1)); 701 array->set_elements(LeftTrimFixedArray(heap, elms_obj, 1));
722 } else { 702 } else {
723 // Shift the elements. 703 // Shift the elements.
724 if (elms_obj->IsFixedArray()) { 704 if (elms_obj->IsFixedArray()) {
725 FixedArray* elms = FixedArray::cast(elms_obj); 705 FixedArray* elms = FixedArray::cast(elms_obj);
726 AssertNoAllocation no_gc; 706 AssertNoAllocation no_gc;
727 MoveElements(heap, &no_gc, elms, 0, elms, 1, len - 1); 707 heap->MoveElements(elms, 0, 1, len - 1);
728 elms->set(len - 1, heap->the_hole_value()); 708 elms->set(len - 1, heap->the_hole_value());
729 } else { 709 } else {
730 FixedDoubleArray* elms = FixedDoubleArray::cast(elms_obj); 710 FixedDoubleArray* elms = FixedDoubleArray::cast(elms_obj);
731 MoveDoubleElements(elms, 0, elms, 1, len - 1); 711 MoveDoubleElements(elms, 0, elms, 1, len - 1);
732 elms->set_the_hole(len - 1); 712 elms->set_the_hole(len - 1);
733 } 713 }
734 } 714 }
735 715
736 // Set the length. 716 // Set the length.
737 array->set_length(Smi::FromInt(len - 1)); 717 array->set_length(Smi::FromInt(len - 1));
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 MaybeObject* maybe_failure = accessor->CopyElements( 767 MaybeObject* maybe_failure = accessor->CopyElements(
788 NULL, 0, kind, new_elms, to_add, 768 NULL, 0, kind, new_elms, to_add,
789 ElementsAccessor::kCopyToEndAndInitializeToHole, elms); 769 ElementsAccessor::kCopyToEndAndInitializeToHole, elms);
790 ASSERT(!maybe_failure->IsFailure()); 770 ASSERT(!maybe_failure->IsFailure());
791 USE(maybe_failure); 771 USE(maybe_failure);
792 772
793 elms = new_elms; 773 elms = new_elms;
794 array->set_elements(elms); 774 array->set_elements(elms);
795 } else { 775 } else {
796 AssertNoAllocation no_gc; 776 AssertNoAllocation no_gc;
797 MoveElements(heap, &no_gc, elms, to_add, elms, 0, len); 777 heap->MoveElements(elms, to_add, 0, len);
798 } 778 }
799 779
800 // Add the provided values. 780 // Add the provided values.
801 AssertNoAllocation no_gc; 781 AssertNoAllocation no_gc;
802 WriteBarrierMode mode = elms->GetWriteBarrierMode(no_gc); 782 WriteBarrierMode mode = elms->GetWriteBarrierMode(no_gc);
803 for (int i = 0; i < to_add; i++) { 783 for (int i = 0; i < to_add; i++) {
804 elms->set(i, args[i + 1], mode); 784 elms->set(i, args[i + 1], mode);
805 } 785 }
806 786
807 // Set the length. 787 // Set the length.
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 (len - actual_delete_count - actual_start)); 1033 (len - actual_delete_count - actual_start));
1054 if (trim_array) { 1034 if (trim_array) {
1055 const int delta = actual_delete_count - item_count; 1035 const int delta = actual_delete_count - item_count;
1056 1036
1057 if (elms_obj->IsFixedDoubleArray()) { 1037 if (elms_obj->IsFixedDoubleArray()) {
1058 FixedDoubleArray* elms = FixedDoubleArray::cast(elms_obj); 1038 FixedDoubleArray* elms = FixedDoubleArray::cast(elms_obj);
1059 MoveDoubleElements(elms, delta, elms, 0, actual_start); 1039 MoveDoubleElements(elms, delta, elms, 0, actual_start);
1060 } else { 1040 } else {
1061 FixedArray* elms = FixedArray::cast(elms_obj); 1041 FixedArray* elms = FixedArray::cast(elms_obj);
1062 AssertNoAllocation no_gc; 1042 AssertNoAllocation no_gc;
1063 MoveElements(heap, &no_gc, elms, delta, elms, 0, actual_start); 1043 heap->MoveElements(elms, delta, 0, actual_start);
1064 } 1044 }
1065 1045
1066 elms_obj = LeftTrimFixedArray(heap, elms_obj, delta); 1046 elms_obj = LeftTrimFixedArray(heap, elms_obj, delta);
1067 1047
1068 elms_changed = true; 1048 elms_changed = true;
1069 } else { 1049 } else {
1070 if (elms_obj->IsFixedDoubleArray()) { 1050 if (elms_obj->IsFixedDoubleArray()) {
1071 FixedDoubleArray* elms = FixedDoubleArray::cast(elms_obj); 1051 FixedDoubleArray* elms = FixedDoubleArray::cast(elms_obj);
1072 MoveDoubleElements(elms, actual_start + item_count, 1052 MoveDoubleElements(elms, actual_start + item_count,
1073 elms, actual_start + actual_delete_count, 1053 elms, actual_start + actual_delete_count,
1074 (len - actual_delete_count - actual_start)); 1054 (len - actual_delete_count - actual_start));
1075 FillWithHoles(elms, new_length, len); 1055 FillWithHoles(elms, new_length, len);
1076 } else { 1056 } else {
1077 FixedArray* elms = FixedArray::cast(elms_obj); 1057 FixedArray* elms = FixedArray::cast(elms_obj);
1078 AssertNoAllocation no_gc; 1058 AssertNoAllocation no_gc;
1079 MoveElements(heap, &no_gc, 1059 heap->MoveElements(elms, actual_start + item_count,
1080 elms, actual_start + item_count, 1060 actual_start + actual_delete_count,
1081 elms, actual_start + actual_delete_count, 1061 (len - actual_delete_count - actual_start));
1082 (len - actual_delete_count - actual_start));
1083 FillWithHoles(heap, elms, new_length, len); 1062 FillWithHoles(heap, elms, new_length, len);
1084 } 1063 }
1085 } 1064 }
1086 } else if (item_count > actual_delete_count) { 1065 } else if (item_count > actual_delete_count) {
1087 FixedArray* elms = FixedArray::cast(elms_obj); 1066 FixedArray* elms = FixedArray::cast(elms_obj);
1088 // Currently fixed arrays cannot grow too big, so 1067 // Currently fixed arrays cannot grow too big, so
1089 // we should never hit this case. 1068 // we should never hit this case.
1090 ASSERT((item_count - actual_delete_count) <= (Smi::kMaxValue - len)); 1069 ASSERT((item_count - actual_delete_count) <= (Smi::kMaxValue - len));
1091 1070
1092 // Check if array need to grow. 1071 // Check if array need to grow.
(...skipping 19 matching lines...) Expand all
1112 NULL, actual_start + actual_delete_count, kind, new_elms, 1091 NULL, actual_start + actual_delete_count, kind, new_elms,
1113 actual_start + item_count, 1092 actual_start + item_count,
1114 ElementsAccessor::kCopyToEndAndInitializeToHole, elms); 1093 ElementsAccessor::kCopyToEndAndInitializeToHole, elms);
1115 ASSERT(!maybe_failure->IsFailure()); 1094 ASSERT(!maybe_failure->IsFailure());
1116 USE(maybe_failure); 1095 USE(maybe_failure);
1117 1096
1118 elms_obj = new_elms; 1097 elms_obj = new_elms;
1119 elms_changed = true; 1098 elms_changed = true;
1120 } else { 1099 } else {
1121 AssertNoAllocation no_gc; 1100 AssertNoAllocation no_gc;
1122 MoveElements(heap, &no_gc, 1101 heap->MoveElements(elms, actual_start + item_count,
1123 elms, actual_start + item_count, 1102 actual_start + actual_delete_count,
1124 elms, actual_start + actual_delete_count, 1103 (len - actual_delete_count - actual_start));
1125 (len - actual_delete_count - actual_start));
1126 } 1104 }
1127 } 1105 }
1128 1106
1129 if (IsFastDoubleElementsKind(elements_kind)) { 1107 if (IsFastDoubleElementsKind(elements_kind)) {
1130 FixedDoubleArray* elms = FixedDoubleArray::cast(elms_obj); 1108 FixedDoubleArray* elms = FixedDoubleArray::cast(elms_obj);
1131 for (int k = actual_start; k < actual_start + item_count; k++) { 1109 for (int k = actual_start; k < actual_start + item_count; k++) {
1132 Object* arg = args[3 + k - actual_start]; 1110 Object* arg = args[3 + k - actual_start];
1133 if (arg->IsSmi()) { 1111 if (arg->IsSmi()) {
1134 elms->set(k, Smi::cast(arg)->value()); 1112 elms->set(k, Smi::cast(arg)->value());
1135 } else { 1113 } else {
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after
1942 return Handle<Code>(code_address); \ 1920 return Handle<Code>(code_address); \
1943 } 1921 }
1944 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) 1922 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C)
1945 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) 1923 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A)
1946 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) 1924 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
1947 #undef DEFINE_BUILTIN_ACCESSOR_C 1925 #undef DEFINE_BUILTIN_ACCESSOR_C
1948 #undef DEFINE_BUILTIN_ACCESSOR_A 1926 #undef DEFINE_BUILTIN_ACCESSOR_A
1949 1927
1950 1928
1951 } } // namespace v8::internal 1929 } } // namespace v8::internal
OLDNEW
« 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