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

Side by Side Diff: src/mark-compact.cc

Issue 19726011: Merged r15848, r15849 into trunk branch. (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 7 years, 5 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 | « no previous file | src/spaces.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 2704 matching lines...) Expand 10 before | Expand all | Expand 10 after
2715 // to encounter pointers to dead new space objects during traversal of pointers 2715 // to encounter pointers to dead new space objects during traversal of pointers
2716 // to new space. We should clear them to avoid encountering them during next 2716 // to new space. We should clear them to avoid encountering them during next
2717 // pointer iteration. This is an issue if the store buffer overflows and we 2717 // pointer iteration. This is an issue if the store buffer overflows and we
2718 // have to scan the entire old space, including dead objects, looking for 2718 // have to scan the entire old space, including dead objects, looking for
2719 // pointers to new space. 2719 // pointers to new space.
2720 void MarkCompactCollector::MigrateObject(Address dst, 2720 void MarkCompactCollector::MigrateObject(Address dst,
2721 Address src, 2721 Address src,
2722 int size, 2722 int size,
2723 AllocationSpace dest) { 2723 AllocationSpace dest) {
2724 HEAP_PROFILE(heap(), ObjectMoveEvent(src, dst)); 2724 HEAP_PROFILE(heap(), ObjectMoveEvent(src, dst));
2725 if (dest == OLD_POINTER_SPACE || dest == LO_SPACE) { 2725 // TODO(hpayer): Replace that check with an assert.
2726 CHECK(dest != LO_SPACE && size <= Page::kMaxNonCodeHeapObjectSize);
2727 // Objects in old pointer space and old data space can just be moved by
2728 // compaction to a different page in the same space.
2729 // TODO(hpayer): Replace that following checks with asserts.
2730 CHECK(!heap_->old_pointer_space()->Contains(src) ||
2731 (heap_->old_pointer_space()->Contains(dst) &&
2732 heap_->TargetSpace(HeapObject::FromAddress(src)) ==
2733 heap_->old_pointer_space()));
2734 CHECK(!heap_->old_data_space()->Contains(src) ||
2735 (heap_->old_data_space()->Contains(dst) &&
2736 heap_->TargetSpace(HeapObject::FromAddress(src)) ==
2737 heap_->old_data_space()));
2738 if (dest == OLD_POINTER_SPACE) {
2739 // TODO(hpayer): Replace this check with an assert.
2740 CHECK(heap_->TargetSpace(HeapObject::FromAddress(src)) ==
2741 heap_->old_pointer_space());
2726 Address src_slot = src; 2742 Address src_slot = src;
2727 Address dst_slot = dst; 2743 Address dst_slot = dst;
2728 ASSERT(IsAligned(size, kPointerSize)); 2744 ASSERT(IsAligned(size, kPointerSize));
2729 2745
2730 for (int remaining = size / kPointerSize; remaining > 0; remaining--) { 2746 for (int remaining = size / kPointerSize; remaining > 0; remaining--) {
2731 Object* value = Memory::Object_at(src_slot); 2747 Object* value = Memory::Object_at(src_slot);
2732 2748
2733 Memory::Object_at(dst_slot) = value; 2749 Memory::Object_at(dst_slot) = value;
2734 2750
2735 if (heap_->InNewSpace(value)) { 2751 if (heap_->InNewSpace(value)) {
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
2887 if (map_word.IsForwardingAddress()) { 2903 if (map_word.IsForwardingAddress()) {
2888 return String::cast(map_word.ToForwardingAddress()); 2904 return String::cast(map_word.ToForwardingAddress());
2889 } 2905 }
2890 2906
2891 return String::cast(*p); 2907 return String::cast(*p);
2892 } 2908 }
2893 2909
2894 2910
2895 bool MarkCompactCollector::TryPromoteObject(HeapObject* object, 2911 bool MarkCompactCollector::TryPromoteObject(HeapObject* object,
2896 int object_size) { 2912 int object_size) {
2913 // TODO(hpayer): Replace that check with an assert.
2914 CHECK(object_size <= Page::kMaxNonCodeHeapObjectSize);
2915
2916 OldSpace* target_space = heap()->TargetSpace(object);
2917
2918 ASSERT(target_space == heap()->old_pointer_space() ||
2919 target_space == heap()->old_data_space());
2897 Object* result; 2920 Object* result;
2898 2921 MaybeObject* maybe_result = target_space->AllocateRaw(object_size);
2899 if (object_size > Page::kMaxNonCodeHeapObjectSize) { 2922 if (maybe_result->ToObject(&result)) {
2900 MaybeObject* maybe_result = 2923 HeapObject* target = HeapObject::cast(result);
2901 heap()->lo_space()->AllocateRaw(object_size, NOT_EXECUTABLE); 2924 MigrateObject(target->address(),
2902 if (maybe_result->ToObject(&result)) { 2925 object->address(),
2903 HeapObject* target = HeapObject::cast(result); 2926 object_size,
2904 MigrateObject(target->address(), 2927 target_space->identity());
2905 object->address(), 2928 heap()->mark_compact_collector()->tracer()->
2906 object_size, 2929 increment_promoted_objects_size(object_size);
2907 LO_SPACE); 2930 return true;
2908 heap()->mark_compact_collector()->tracer()->
2909 increment_promoted_objects_size(object_size);
2910 return true;
2911 }
2912 } else {
2913 OldSpace* target_space = heap()->TargetSpace(object);
2914
2915 ASSERT(target_space == heap()->old_pointer_space() ||
2916 target_space == heap()->old_data_space());
2917 MaybeObject* maybe_result = target_space->AllocateRaw(object_size);
2918 if (maybe_result->ToObject(&result)) {
2919 HeapObject* target = HeapObject::cast(result);
2920 MigrateObject(target->address(),
2921 object->address(),
2922 object_size,
2923 target_space->identity());
2924 heap()->mark_compact_collector()->tracer()->
2925 increment_promoted_objects_size(object_size);
2926 return true;
2927 }
2928 } 2931 }
2929 2932
2930 return false; 2933 return false;
2931 } 2934 }
2932 2935
2933 2936
2934 void MarkCompactCollector::EvacuateNewSpace() { 2937 void MarkCompactCollector::EvacuateNewSpace() {
2935 // There are soft limits in the allocation code, designed trigger a mark 2938 // There are soft limits in the allocation code, designed trigger a mark
2936 // sweep collection by failing allocations. But since we are already in 2939 // sweep collection by failing allocations. But since we are already in
2937 // a mark-sweep allocation, there is no sense in trying to trigger one. 2940 // a mark-sweep allocation, there is no sense in trying to trigger one.
(...skipping 1373 matching lines...) Expand 10 before | Expand all | Expand 10 after
4311 while (buffer != NULL) { 4314 while (buffer != NULL) {
4312 SlotsBuffer* next_buffer = buffer->next(); 4315 SlotsBuffer* next_buffer = buffer->next();
4313 DeallocateBuffer(buffer); 4316 DeallocateBuffer(buffer);
4314 buffer = next_buffer; 4317 buffer = next_buffer;
4315 } 4318 }
4316 *buffer_address = NULL; 4319 *buffer_address = NULL;
4317 } 4320 }
4318 4321
4319 4322
4320 } } // namespace v8::internal 4323 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/spaces.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698