OLD | NEW |
---|---|
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 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
670 void Heap::PerformScavenge() { | 670 void Heap::PerformScavenge() { |
671 GCTracer tracer(this, NULL, NULL); | 671 GCTracer tracer(this, NULL, NULL); |
672 if (incremental_marking()->IsStopped()) { | 672 if (incremental_marking()->IsStopped()) { |
673 PerformGarbageCollection(SCAVENGER, &tracer); | 673 PerformGarbageCollection(SCAVENGER, &tracer); |
674 } else { | 674 } else { |
675 PerformGarbageCollection(MARK_COMPACTOR, &tracer); | 675 PerformGarbageCollection(MARK_COMPACTOR, &tracer); |
676 } | 676 } |
677 } | 677 } |
678 | 678 |
679 | 679 |
680 void Heap::MoveElements(FixedArray* dst, int dst_index, FixedArray* src, | |
681 int src_index, int len) { | |
682 if (len == 0) return; | |
683 | |
684 ASSERT(dst->map() != HEAP->fixed_cow_array_map()); | |
685 Object** dst_objects = dst->data_start() + dst_index; | |
686 memmove(dst_objects, | |
687 src->data_start() + src_index, | |
688 len * kPointerSize); | |
689 for (int i = 0; i < len; i++) { | |
690 if (!InNewSpace(src) && InNewSpace(dst_objects[i])) { | |
Michael Starzinger
2013/01/08 13:46:32
As discussed offline, this second loop is no longe
Hannes Payer (out of office)
2013/01/09 09:32:46
I will submit an optimization in a follow-up CL.
| |
691 RecordWrite(dst->address(), dst->OffsetOfElementAt(dst_index + i)); | |
692 } | |
693 } | |
694 incremental_marking()->RecordWrites(dst); | |
695 } | |
696 | |
697 | |
680 #ifdef VERIFY_HEAP | 698 #ifdef VERIFY_HEAP |
681 // Helper class for verifying the symbol table. | 699 // Helper class for verifying the symbol table. |
682 class SymbolTableVerifier : public ObjectVisitor { | 700 class SymbolTableVerifier : public ObjectVisitor { |
683 public: | 701 public: |
684 void VisitPointers(Object** start, Object** end) { | 702 void VisitPointers(Object** start, Object** end) { |
685 // Visit all HeapObject pointers in [start, end). | 703 // Visit all HeapObject pointers in [start, end). |
686 for (Object** p = start; p < end; p++) { | 704 for (Object** p = start; p < end; p++) { |
687 if ((*p)->IsHeapObject()) { | 705 if ((*p)->IsHeapObject()) { |
688 // Check that the symbol is actually a symbol. | 706 // Check that the symbol is actually a symbol. |
689 CHECK((*p)->IsTheHole() || (*p)->IsUndefined() || (*p)->IsSymbol()); | 707 CHECK((*p)->IsTheHole() || (*p)->IsUndefined() || (*p)->IsSymbol()); |
(...skipping 4276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4966 | 4984 |
4967 | 4985 |
4968 MUST_USE_RESULT static MaybeObject* AllocateFixedArrayWithFiller( | 4986 MUST_USE_RESULT static MaybeObject* AllocateFixedArrayWithFiller( |
4969 Heap* heap, | 4987 Heap* heap, |
4970 int length, | 4988 int length, |
4971 PretenureFlag pretenure, | 4989 PretenureFlag pretenure, |
4972 Object* filler) { | 4990 Object* filler) { |
4973 ASSERT(length >= 0); | 4991 ASSERT(length >= 0); |
4974 ASSERT(heap->empty_fixed_array()->IsFixedArray()); | 4992 ASSERT(heap->empty_fixed_array()->IsFixedArray()); |
4975 if (length == 0) return heap->empty_fixed_array(); | 4993 if (length == 0) return heap->empty_fixed_array(); |
4976 | |
4977 ASSERT(!heap->InNewSpace(filler)); | 4994 ASSERT(!heap->InNewSpace(filler)); |
4978 Object* result; | 4995 Object* result; |
4979 { MaybeObject* maybe_result = heap->AllocateRawFixedArray(length, pretenure); | 4996 { MaybeObject* maybe_result = heap->AllocateRawFixedArray(length, pretenure); |
4980 if (!maybe_result->ToObject(&result)) return maybe_result; | 4997 if (!maybe_result->ToObject(&result)) return maybe_result; |
4981 } | 4998 } |
4982 | 4999 |
4983 HeapObject::cast(result)->set_map_no_write_barrier(heap->fixed_array_map()); | 5000 HeapObject::cast(result)->set_map_no_write_barrier(heap->fixed_array_map()); |
4984 FixedArray* array = FixedArray::cast(result); | 5001 FixedArray* array = FixedArray::cast(result); |
4985 array->set_length(length); | 5002 array->set_length(length); |
4986 MemsetPointer(array->data_start(), filler, length); | 5003 MemsetPointer(array->data_start(), filler, length); |
(...skipping 2369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7356 static_cast<int>(object_sizes_last_time_[index])); | 7373 static_cast<int>(object_sizes_last_time_[index])); |
7357 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) | 7374 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) |
7358 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 7375 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
7359 | 7376 |
7360 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 7377 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
7361 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 7378 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
7362 ClearObjectStats(); | 7379 ClearObjectStats(); |
7363 } | 7380 } |
7364 | 7381 |
7365 } } // namespace v8::internal | 7382 } } // namespace v8::internal |
OLD | NEW |