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

Side by Side Diff: src/elements.cc

Issue 11414155: Ensure double arrays are filled with holes when extended from variations of empty arrays. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: u Created 8 years 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/arm/stub-cache-arm.cc ('k') | src/ia32/stub-cache-ia32.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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 int packed_size, 368 int packed_size,
369 int raw_copy_size) { 369 int raw_copy_size) {
370 int copy_size = raw_copy_size; 370 int copy_size = raw_copy_size;
371 uint32_t to_end; 371 uint32_t to_end;
372 if (raw_copy_size < 0) { 372 if (raw_copy_size < 0) {
373 ASSERT(raw_copy_size == ElementsAccessor::kCopyToEnd || 373 ASSERT(raw_copy_size == ElementsAccessor::kCopyToEnd ||
374 raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole); 374 raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole);
375 copy_size = from->length() - from_start; 375 copy_size = from->length() - from_start;
376 if (raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole) { 376 if (raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole) {
377 to_end = to->length(); 377 to_end = to->length();
378 for (uint32_t i = to_start + copy_size; i < to_end; ++i) {
379 to->set_the_hole(i);
380 }
378 } else { 381 } else {
379 to_end = to_start + static_cast<uint32_t>(copy_size); 382 to_end = to_start + static_cast<uint32_t>(copy_size);
380 } 383 }
381 } else { 384 } else {
382 to_end = to_start + static_cast<uint32_t>(copy_size); 385 to_end = to_start + static_cast<uint32_t>(copy_size);
383 } 386 }
384 ASSERT(static_cast<int>(to_end) <= to->length()); 387 ASSERT(static_cast<int>(to_end) <= to->length());
385 ASSERT(packed_size >= 0 && packed_size <= copy_size); 388 ASSERT(packed_size >= 0 && packed_size <= copy_size);
386 ASSERT((copy_size + static_cast<int>(to_start)) <= to->length() && 389 ASSERT((copy_size + static_cast<int>(to_start)) <= to->length() &&
387 (copy_size + static_cast<int>(from_start)) <= from->length()); 390 (copy_size + static_cast<int>(from_start)) <= from->length());
388 if (copy_size == 0) return; 391 if (copy_size == 0) return;
389 for (uint32_t from_end = from_start + static_cast<uint32_t>(packed_size); 392 for (uint32_t from_end = from_start + static_cast<uint32_t>(packed_size);
390 from_start < from_end; from_start++, to_start++) { 393 from_start < from_end; from_start++, to_start++) {
391 Object* smi = from->get(from_start); 394 Object* smi = from->get(from_start);
392 ASSERT(!smi->IsTheHole()); 395 ASSERT(!smi->IsTheHole());
393 to->set(to_start, Smi::cast(smi)->value()); 396 to->set(to_start, Smi::cast(smi)->value());
394 } 397 }
395
396 while (to_start < to_end) {
397 to->set_the_hole(to_start++);
398 }
399 } 398 }
400 399
401 400
402 static void CopyObjectToDoubleElements(FixedArray* from, 401 static void CopyObjectToDoubleElements(FixedArray* from,
403 uint32_t from_start, 402 uint32_t from_start,
404 FixedDoubleArray* to, 403 FixedDoubleArray* to,
405 uint32_t to_start, 404 uint32_t to_start,
406 int raw_copy_size) { 405 int raw_copy_size) {
407 int copy_size = raw_copy_size; 406 int copy_size = raw_copy_size;
408 if (raw_copy_size < 0) { 407 if (raw_copy_size < 0) {
(...skipping 1447 matching lines...) Expand 10 before | Expand all | Expand 10 after
1856 if (!maybe_obj->To(&new_backing_store)) return maybe_obj; 1855 if (!maybe_obj->To(&new_backing_store)) return maybe_obj;
1857 new_backing_store->set(0, length); 1856 new_backing_store->set(0, length);
1858 { MaybeObject* result = array->SetContent(new_backing_store); 1857 { MaybeObject* result = array->SetContent(new_backing_store);
1859 if (result->IsFailure()) return result; 1858 if (result->IsFailure()) return result;
1860 } 1859 }
1861 return array; 1860 return array;
1862 } 1861 }
1863 1862
1864 1863
1865 } } // namespace v8::internal 1864 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/stub-cache-arm.cc ('k') | src/ia32/stub-cache-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698