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

Side by Side Diff: src/elements.cc

Issue 11280054: Ensure CopyElementsImpl is always executed so it fills in holes even if from_size is 0. Allow Fixed… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added castOrEmptyFixedArray Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/objects.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 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 ElementsKind elements_kind = from_holder->GetElementsKind(); 689 ElementsKind elements_kind = from_holder->GetElementsKind();
690 bool is_packed = IsFastPackedElementsKind(elements_kind) && 690 bool is_packed = IsFastPackedElementsKind(elements_kind) &&
691 from_holder->IsJSArray(); 691 from_holder->IsJSArray();
692 if (is_packed) { 692 if (is_packed) {
693 packed_size = Smi::cast(JSArray::cast(from_holder)->length())->value(); 693 packed_size = Smi::cast(JSArray::cast(from_holder)->length())->value();
694 if (copy_size >= 0 && packed_size > copy_size) { 694 if (copy_size >= 0 && packed_size > copy_size) {
695 packed_size = copy_size; 695 packed_size = copy_size;
696 } 696 }
697 } 697 }
698 } 698 }
699 if (from->length() == 0 || copy_size == 0) {
700 return from;
701 }
702 return ElementsAccessorSubclass::CopyElementsImpl( 699 return ElementsAccessorSubclass::CopyElementsImpl(
703 from, from_start, to, to_kind, to_start, packed_size, copy_size); 700 from, from_start, to, to_kind, to_start, packed_size, copy_size);
704 } 701 }
705 702
706 MUST_USE_RESULT virtual MaybeObject* AddElementsToFixedArray( 703 MUST_USE_RESULT virtual MaybeObject* AddElementsToFixedArray(
707 Object* receiver, 704 Object* receiver,
708 JSObject* holder, 705 JSObject* holder,
709 FixedArray* to, 706 FixedArray* to,
710 FixedArrayBase* from) { 707 FixedArrayBase* from) {
711 int len0 = to->length(); 708 int len0 = to->length();
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 if (IsFastSmiOrObjectElementsKind(to_kind)) { 1012 if (IsFastSmiOrObjectElementsKind(to_kind)) {
1016 CopyObjectToObjectElements( 1013 CopyObjectToObjectElements(
1017 FixedArray::cast(from), KindTraits::Kind, from_start, 1014 FixedArray::cast(from), KindTraits::Kind, from_start,
1018 FixedArray::cast(to), to_kind, to_start, copy_size); 1015 FixedArray::cast(to), to_kind, to_start, copy_size);
1019 } else if (IsFastDoubleElementsKind(to_kind)) { 1016 } else if (IsFastDoubleElementsKind(to_kind)) {
1020 if (IsFastSmiElementsKind(KindTraits::Kind)) { 1017 if (IsFastSmiElementsKind(KindTraits::Kind)) {
1021 if (IsFastPackedElementsKind(KindTraits::Kind) && 1018 if (IsFastPackedElementsKind(KindTraits::Kind) &&
1022 packed_size != kPackedSizeNotKnown) { 1019 packed_size != kPackedSizeNotKnown) {
1023 CopyPackedSmiToDoubleElements( 1020 CopyPackedSmiToDoubleElements(
1024 FixedArray::cast(from), from_start, 1021 FixedArray::cast(from), from_start,
1025 FixedDoubleArray::cast(to), to_start, 1022 FixedDoubleArray::castOrEmptyFixedArray(to), to_start,
1026 packed_size, copy_size); 1023 packed_size, copy_size);
1027 } else { 1024 } else {
1028 CopySmiToDoubleElements( 1025 CopySmiToDoubleElements(
1029 FixedArray::cast(from), from_start, 1026 FixedArray::cast(from), from_start,
1030 FixedDoubleArray::cast(to), to_start, copy_size); 1027 FixedDoubleArray::castOrEmptyFixedArray(to), to_start, copy_size);
1031 } 1028 }
1032 } else { 1029 } else {
1033 CopyObjectToDoubleElements( 1030 CopyObjectToDoubleElements(
1034 FixedArray::cast(from), from_start, 1031 FixedArray::cast(from), from_start,
1035 FixedDoubleArray::cast(to), to_start, copy_size); 1032 FixedDoubleArray::castOrEmptyFixedArray(to), to_start, copy_size);
1036 } 1033 }
1037 } else { 1034 } else {
1038 UNREACHABLE(); 1035 UNREACHABLE();
1039 } 1036 }
1040 return to->GetHeap()->undefined_value(); 1037 return to->GetHeap()->undefined_value();
1041 } 1038 }
1042 1039
1043 1040
1044 static MaybeObject* SetFastElementsCapacityAndLength(JSObject* obj, 1041 static MaybeObject* SetFastElementsCapacityAndLength(JSObject* obj,
1045 uint32_t capacity, 1042 uint32_t capacity,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 ElementsKind to_kind, 1126 ElementsKind to_kind,
1130 uint32_t to_start, 1127 uint32_t to_start,
1131 int packed_size, 1128 int packed_size,
1132 int copy_size) { 1129 int copy_size) {
1133 switch (to_kind) { 1130 switch (to_kind) {
1134 case FAST_SMI_ELEMENTS: 1131 case FAST_SMI_ELEMENTS:
1135 case FAST_ELEMENTS: 1132 case FAST_ELEMENTS:
1136 case FAST_HOLEY_SMI_ELEMENTS: 1133 case FAST_HOLEY_SMI_ELEMENTS:
1137 case FAST_HOLEY_ELEMENTS: 1134 case FAST_HOLEY_ELEMENTS:
1138 return CopyDoubleToObjectElements( 1135 return CopyDoubleToObjectElements(
1139 FixedDoubleArray::cast(from), from_start, FixedArray::cast(to), 1136 FixedDoubleArray::castOrEmptyFixedArray(from), from_start,
1140 to_kind, to_start, copy_size); 1137 FixedArray::cast(to), to_kind, to_start, copy_size);
1141 case FAST_DOUBLE_ELEMENTS: 1138 case FAST_DOUBLE_ELEMENTS:
1142 case FAST_HOLEY_DOUBLE_ELEMENTS: 1139 case FAST_HOLEY_DOUBLE_ELEMENTS:
1143 CopyDoubleToDoubleElements(FixedDoubleArray::cast(from), from_start, 1140 CopyDoubleToDoubleElements(
1144 FixedDoubleArray::cast(to), 1141 FixedDoubleArray::castOrEmptyFixedArray(from), from_start,
1145 to_start, copy_size); 1142 FixedDoubleArray::castOrEmptyFixedArray(to), to_start, copy_size);
1146 return from; 1143 return from;
1147 default: 1144 default:
1148 UNREACHABLE(); 1145 UNREACHABLE();
1149 } 1146 }
1150 return to->GetHeap()->undefined_value(); 1147 return to->GetHeap()->undefined_value();
1151 } 1148 }
1152 }; 1149 };
1153 1150
1154 1151
1155 class FastPackedDoubleElementsAccessor 1152 class FastPackedDoubleElementsAccessor
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
1469 case FAST_HOLEY_SMI_ELEMENTS: 1466 case FAST_HOLEY_SMI_ELEMENTS:
1470 case FAST_HOLEY_ELEMENTS: 1467 case FAST_HOLEY_ELEMENTS:
1471 CopyDictionaryToObjectElements( 1468 CopyDictionaryToObjectElements(
1472 SeededNumberDictionary::cast(from), from_start, 1469 SeededNumberDictionary::cast(from), from_start,
1473 FixedArray::cast(to), to_kind, to_start, copy_size); 1470 FixedArray::cast(to), to_kind, to_start, copy_size);
1474 return from; 1471 return from;
1475 case FAST_DOUBLE_ELEMENTS: 1472 case FAST_DOUBLE_ELEMENTS:
1476 case FAST_HOLEY_DOUBLE_ELEMENTS: 1473 case FAST_HOLEY_DOUBLE_ELEMENTS:
1477 CopyDictionaryToDoubleElements( 1474 CopyDictionaryToDoubleElements(
1478 SeededNumberDictionary::cast(from), from_start, 1475 SeededNumberDictionary::cast(from), from_start,
1479 FixedDoubleArray::cast(to), to_start, copy_size); 1476 FixedDoubleArray::castOrEmptyFixedArray(to), to_start,
1477 copy_size);
1480 return from; 1478 return from;
1481 default: 1479 default:
1482 UNREACHABLE(); 1480 UNREACHABLE();
1483 } 1481 }
1484 return to->GetHeap()->undefined_value(); 1482 return to->GetHeap()->undefined_value();
1485 } 1483 }
1486 1484
1487 1485
1488 protected: 1486 protected:
1489 friend class ElementsAccessorBase<DictionaryElementsAccessor, 1487 friend class ElementsAccessorBase<DictionaryElementsAccessor,
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
1858 if (!maybe_obj->To(&new_backing_store)) return maybe_obj; 1856 if (!maybe_obj->To(&new_backing_store)) return maybe_obj;
1859 new_backing_store->set(0, length); 1857 new_backing_store->set(0, length);
1860 { MaybeObject* result = array->SetContent(new_backing_store); 1858 { MaybeObject* result = array->SetContent(new_backing_store);
1861 if (result->IsFailure()) return result; 1859 if (result->IsFailure()) return result;
1862 } 1860 }
1863 return array; 1861 return array;
1864 } 1862 }
1865 1863
1866 1864
1867 } } // namespace v8::internal 1865 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698