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

Side by Side Diff: src/builtins.cc

Issue 3197010: Version 2.3.10... (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 10 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/arm/simulator-arm.cc ('k') | src/codegen.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 299
300 300
301 static void FillWithHoles(FixedArray* dst, int from, int to) { 301 static void FillWithHoles(FixedArray* dst, int from, int to) {
302 ASSERT(dst->map() != Heap::fixed_cow_array_map()); 302 ASSERT(dst->map() != Heap::fixed_cow_array_map());
303 MemsetPointer(dst->data_start() + from, Heap::the_hole_value(), to - from); 303 MemsetPointer(dst->data_start() + from, Heap::the_hole_value(), to - from);
304 } 304 }
305 305
306 306
307 static FixedArray* LeftTrimFixedArray(FixedArray* elms, int to_trim) { 307 static FixedArray* LeftTrimFixedArray(FixedArray* elms, int to_trim) {
308 ASSERT(elms->map() != Heap::fixed_cow_array_map()); 308 ASSERT(elms->map() != Heap::fixed_cow_array_map());
309 // For now this trick is only applied to fixed arrays in new space. 309 // For now this trick is only applied to fixed arrays in new and paged space.
310 // In large object space the object's start must coincide with chunk 310 // In large object space the object's start must coincide with chunk
311 // and thus the trick is just not applicable. 311 // and thus the trick is just not applicable.
312 // In old space we do not use this trick to avoid dealing with 312 ASSERT(!Heap::lo_space()->Contains(elms));
313 // region dirty marks.
314 ASSERT(Heap::new_space()->Contains(elms));
315 313
316 STATIC_ASSERT(FixedArray::kMapOffset == 0); 314 STATIC_ASSERT(FixedArray::kMapOffset == 0);
317 STATIC_ASSERT(FixedArray::kLengthOffset == kPointerSize); 315 STATIC_ASSERT(FixedArray::kLengthOffset == kPointerSize);
318 STATIC_ASSERT(FixedArray::kHeaderSize == 2 * kPointerSize); 316 STATIC_ASSERT(FixedArray::kHeaderSize == 2 * kPointerSize);
319 317
320 Object** former_start = HeapObject::RawField(elms, 0); 318 Object** former_start = HeapObject::RawField(elms, 0);
321 319
322 const int len = elms->length(); 320 const int len = elms->length();
323 321
322 if (to_trim > FixedArray::kHeaderSize / kPointerSize &&
323 !Heap::new_space()->Contains(elms)) {
324 // If we are doing a big trim in old space then we zap the space that was
325 // formerly part of the array so that the GC (aided by the card-based
326 // remembered set) won't find pointers to new-space there.
327 Object** zap = reinterpret_cast<Object**>(elms->address());
328 zap++; // Header of filler must be at least one word so skip that.
329 for (int i = 1; i < to_trim; i++) {
330 *zap++ = Smi::FromInt(0);
331 }
332 }
324 // Technically in new space this write might be omitted (except for 333 // Technically in new space this write might be omitted (except for
325 // debug mode which iterates through the heap), but to play safer 334 // debug mode which iterates through the heap), but to play safer
326 // we still do it. 335 // we still do it.
327 Heap::CreateFillerObjectAt(elms->address(), to_trim * kPointerSize); 336 Heap::CreateFillerObjectAt(elms->address(), to_trim * kPointerSize);
328 337
329 former_start[to_trim] = Heap::fixed_array_map(); 338 former_start[to_trim] = Heap::fixed_array_map();
330 former_start[to_trim + 1] = Smi::FromInt(len - to_trim); 339 former_start[to_trim + 1] = Smi::FromInt(len - to_trim);
331 340
332 ASSERT_EQ(elms->address() + to_trim * kPointerSize, 341 return FixedArray::cast(HeapObject::FromAddress(
333 (elms + to_trim * kPointerSize)->address()); 342 elms->address() + to_trim * kPointerSize));
334 return elms + to_trim * kPointerSize;
335 } 343 }
336 344
337 345
338 static bool ArrayPrototypeHasNoElements(Context* global_context, 346 static bool ArrayPrototypeHasNoElements(Context* global_context,
339 JSObject* array_proto) { 347 JSObject* array_proto) {
340 // This method depends on non writability of Object and Array prototype 348 // This method depends on non writability of Object and Array prototype
341 // fields. 349 // fields.
342 if (array_proto->elements() != Heap::empty_fixed_array()) return false; 350 if (array_proto->elements() != Heap::empty_fixed_array()) return false;
343 // Hidden prototype 351 // Hidden prototype
344 array_proto = JSObject::cast(array_proto->GetPrototype()); 352 array_proto = JSObject::cast(array_proto->GetPrototype());
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 498
491 int len = Smi::cast(array->length())->value(); 499 int len = Smi::cast(array->length())->value();
492 if (len == 0) return Heap::undefined_value(); 500 if (len == 0) return Heap::undefined_value();
493 501
494 // Get first element 502 // Get first element
495 Object* first = elms->get(0); 503 Object* first = elms->get(0);
496 if (first->IsTheHole()) { 504 if (first->IsTheHole()) {
497 first = Heap::undefined_value(); 505 first = Heap::undefined_value();
498 } 506 }
499 507
500 if (Heap::new_space()->Contains(elms)) { 508 if (!Heap::lo_space()->Contains(elms)) {
501 // As elms still in the same space they used to be (new space), 509 // As elms still in the same space they used to be,
502 // there is no need to update region dirty mark. 510 // there is no need to update region dirty mark.
503 array->set_elements(LeftTrimFixedArray(elms, 1), SKIP_WRITE_BARRIER); 511 array->set_elements(LeftTrimFixedArray(elms, 1), SKIP_WRITE_BARRIER);
504 } else { 512 } else {
505 // Shift the elements. 513 // Shift the elements.
506 AssertNoAllocation no_gc; 514 AssertNoAllocation no_gc;
507 MoveElements(&no_gc, elms, 0, elms, 1, len - 1); 515 MoveElements(&no_gc, elms, 0, elms, 1, len - 1);
508 elms->set(len - 1, Heap::the_hole_value()); 516 elms->set(len - 1, Heap::the_hole_value());
509 } 517 }
510 518
511 // Set the length. 519 // Set the length.
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 // Set the length. 725 // Set the length.
718 result_array->set_length(Smi::FromInt(actual_delete_count)); 726 result_array->set_length(Smi::FromInt(actual_delete_count));
719 } 727 }
720 728
721 int item_count = (n_arguments > 1) ? (n_arguments - 2) : 0; 729 int item_count = (n_arguments > 1) ? (n_arguments - 2) : 0;
722 730
723 int new_length = len - actual_delete_count + item_count; 731 int new_length = len - actual_delete_count + item_count;
724 732
725 if (item_count < actual_delete_count) { 733 if (item_count < actual_delete_count) {
726 // Shrink the array. 734 // Shrink the array.
727 const bool trim_array = Heap::new_space()->Contains(elms) && 735 const bool trim_array = !Heap::lo_space()->Contains(elms) &&
728 ((actual_start + item_count) < 736 ((actual_start + item_count) <
729 (len - actual_delete_count - actual_start)); 737 (len - actual_delete_count - actual_start));
730 if (trim_array) { 738 if (trim_array) {
731 const int delta = actual_delete_count - item_count; 739 const int delta = actual_delete_count - item_count;
732 740
733 if (actual_start > 0) { 741 if (actual_start > 0) {
734 Object** start = elms->data_start(); 742 Object** start = elms->data_start();
735 memmove(start + delta, start, actual_start * kPointerSize); 743 memmove(start + delta, start, actual_start * kPointerSize);
736 } 744 }
737 745
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 if (entry->contains(pc)) { 1535 if (entry->contains(pc)) {
1528 return names_[i]; 1536 return names_[i];
1529 } 1537 }
1530 } 1538 }
1531 } 1539 }
1532 return NULL; 1540 return NULL;
1533 } 1541 }
1534 1542
1535 1543
1536 } } // namespace v8::internal 1544 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/simulator-arm.cc ('k') | src/codegen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698