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

Side by Side Diff: src/elements.cc

Issue 10820047: Make sure double to int conversion is correct. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments. Created 8 years, 4 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 | « src/conversions.h ('k') | src/runtime.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 // 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 782 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 array->initialize_elements(); 793 array->initialize_elements();
794 } else { 794 } else {
795 backing_store->set_length(length); 795 backing_store->set_length(length);
796 Address filler_start = backing_store->address() + 796 Address filler_start = backing_store->address() +
797 BackingStore::OffsetOfElementAt(length); 797 BackingStore::OffsetOfElementAt(length);
798 int filler_size = (old_capacity - length) * ElementSize; 798 int filler_size = (old_capacity - length) * ElementSize;
799 array->GetHeap()->CreateFillerObjectAt(filler_start, filler_size); 799 array->GetHeap()->CreateFillerObjectAt(filler_start, filler_size);
800 } 800 }
801 } else { 801 } else {
802 // Otherwise, fill the unused tail with holes. 802 // Otherwise, fill the unused tail with holes.
803 int old_length = FastD2I(array->length()->Number()); 803 int old_length = FastD2IChecked(array->length()->Number());
804 for (int i = length; i < old_length; i++) { 804 for (int i = length; i < old_length; i++) {
805 backing_store->set_the_hole(i); 805 backing_store->set_the_hole(i);
806 } 806 }
807 } 807 }
808 return length_object; 808 return length_object;
809 } 809 }
810 810
811 // Check whether the backing store should be expanded. 811 // Check whether the backing store should be expanded.
812 uint32_t min = JSObject::NewElementsCapacity(old_capacity); 812 uint32_t min = JSObject::NewElementsCapacity(old_capacity);
813 uint32_t new_capacity = length > min ? length : min; 813 uint32_t new_capacity = length > min ? length : min;
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after
1681 if (!maybe_obj->To(&new_backing_store)) return maybe_obj; 1681 if (!maybe_obj->To(&new_backing_store)) return maybe_obj;
1682 new_backing_store->set(0, length); 1682 new_backing_store->set(0, length);
1683 { MaybeObject* result = array->SetContent(new_backing_store); 1683 { MaybeObject* result = array->SetContent(new_backing_store);
1684 if (result->IsFailure()) return result; 1684 if (result->IsFailure()) return result;
1685 } 1685 }
1686 return array; 1686 return array;
1687 } 1687 }
1688 1688
1689 1689
1690 } } // namespace v8::internal 1690 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/conversions.h ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698