OLD | NEW |
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 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1066 ASSERT(!forwarded->IsFailure()); | 1066 ASSERT(!forwarded->IsFailure()); |
1067 Encode(object, object_size, forwarded, offset); | 1067 Encode(object, object_size, forwarded, offset); |
1068 | 1068 |
1069 #ifdef DEBUG | 1069 #ifdef DEBUG |
1070 if (FLAG_gc_verbose) { | 1070 if (FLAG_gc_verbose) { |
1071 PrintF("forward %p -> %p.\n", object->address(), | 1071 PrintF("forward %p -> %p.\n", object->address(), |
1072 HeapObject::cast(forwarded)->address()); | 1072 HeapObject::cast(forwarded)->address()); |
1073 } | 1073 } |
1074 #endif | 1074 #endif |
1075 if (!is_prev_alive) { // Transition from non-live to live. | 1075 if (!is_prev_alive) { // Transition from non-live to live. |
1076 EncodeFreeRegion(free_start, current - free_start); | 1076 EncodeFreeRegion(free_start, static_cast<int>(current - free_start)); |
1077 is_prev_alive = true; | 1077 is_prev_alive = true; |
1078 } | 1078 } |
1079 } else { // Non-live object. | 1079 } else { // Non-live object. |
1080 object_size = object->Size(); | 1080 object_size = object->Size(); |
1081 ProcessNonLive(object); | 1081 ProcessNonLive(object); |
1082 if (is_prev_alive) { // Transition from live to non-live. | 1082 if (is_prev_alive) { // Transition from live to non-live. |
1083 free_start = current; | 1083 free_start = current; |
1084 is_prev_alive = false; | 1084 is_prev_alive = false; |
1085 } | 1085 } |
1086 } | 1086 } |
1087 } | 1087 } |
1088 | 1088 |
1089 // If we ended on a free region, mark it. | 1089 // If we ended on a free region, mark it. |
1090 if (!is_prev_alive) EncodeFreeRegion(free_start, end - free_start); | 1090 if (!is_prev_alive) { |
| 1091 EncodeFreeRegion(free_start, static_cast<int>(end - free_start)); |
| 1092 } |
1091 } | 1093 } |
1092 | 1094 |
1093 | 1095 |
1094 // Functions to encode the forwarding pointers in each compactable space. | 1096 // Functions to encode the forwarding pointers in each compactable space. |
1095 void MarkCompactCollector::EncodeForwardingAddressesInNewSpace() { | 1097 void MarkCompactCollector::EncodeForwardingAddressesInNewSpace() { |
1096 int ignored; | 1098 int ignored; |
1097 EncodeForwardingAddressesInRange<MCAllocateFromNewSpace, | 1099 EncodeForwardingAddressesInRange<MCAllocateFromNewSpace, |
1098 EncodeForwardingAddressInNewSpace, | 1100 EncodeForwardingAddressInNewSpace, |
1099 IgnoreNonLiveObject>( | 1101 IgnoreNonLiveObject>( |
1100 Heap::new_space()->bottom(), | 1102 Heap::new_space()->bottom(), |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1161 HeapObject* object; | 1163 HeapObject* object; |
1162 | 1164 |
1163 for (Address current = p->ObjectAreaStart(); | 1165 for (Address current = p->ObjectAreaStart(); |
1164 current < p->AllocationTop(); | 1166 current < p->AllocationTop(); |
1165 current += object->Size()) { | 1167 current += object->Size()) { |
1166 object = HeapObject::FromAddress(current); | 1168 object = HeapObject::FromAddress(current); |
1167 if (object->IsMarked()) { | 1169 if (object->IsMarked()) { |
1168 object->ClearMark(); | 1170 object->ClearMark(); |
1169 MarkCompactCollector::tracer()->decrement_marked_count(); | 1171 MarkCompactCollector::tracer()->decrement_marked_count(); |
1170 if (!is_previous_alive) { // Transition from free to live. | 1172 if (!is_previous_alive) { // Transition from free to live. |
1171 dealloc(free_start, current - free_start); | 1173 dealloc(free_start, static_cast<int>(current - free_start)); |
1172 is_previous_alive = true; | 1174 is_previous_alive = true; |
1173 } | 1175 } |
1174 } else { | 1176 } else { |
1175 if (object->IsCode()) { | 1177 if (object->IsCode()) { |
1176 // Notify the logger that compiled code has been collected. | 1178 // Notify the logger that compiled code has been collected. |
1177 LOG(CodeDeleteEvent(Code::cast(object)->address())); | 1179 LOG(CodeDeleteEvent(Code::cast(object)->address())); |
1178 } | 1180 } |
1179 if (is_previous_alive) { // Transition from live to free. | 1181 if (is_previous_alive) { // Transition from live to free. |
1180 free_start = current; | 1182 free_start = current; |
1181 is_previous_alive = false; | 1183 is_previous_alive = false; |
1182 } | 1184 } |
1183 } | 1185 } |
1184 // The object is now unmarked for the call to Size() at the top of the | 1186 // The object is now unmarked for the call to Size() at the top of the |
1185 // loop. | 1187 // loop. |
1186 } | 1188 } |
1187 | 1189 |
1188 // If the last region was not live we need to deallocate from | 1190 // If the last region was not live we need to deallocate from |
1189 // free_start to the allocation top in the page. | 1191 // free_start to the allocation top in the page. |
1190 if (!is_previous_alive) { | 1192 if (!is_previous_alive) { |
1191 int free_size = p->AllocationTop() - free_start; | 1193 int free_size = static_cast<int>(p->AllocationTop() - free_start); |
1192 if (free_size > 0) { | 1194 if (free_size > 0) { |
1193 dealloc(free_start, free_size); | 1195 dealloc(free_start, free_size); |
1194 } | 1196 } |
1195 } | 1197 } |
1196 } | 1198 } |
1197 } | 1199 } |
1198 | 1200 |
1199 | 1201 |
1200 void MarkCompactCollector::DeallocateOldPointerBlock(Address start, | 1202 void MarkCompactCollector::DeallocateOldPointerBlock(Address start, |
1201 int size_in_bytes) { | 1203 int size_in_bytes) { |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1806 | 1808 |
1807 void MarkCompactCollector::RebuildRSets() { | 1809 void MarkCompactCollector::RebuildRSets() { |
1808 #ifdef DEBUG | 1810 #ifdef DEBUG |
1809 ASSERT(state_ == RELOCATE_OBJECTS); | 1811 ASSERT(state_ == RELOCATE_OBJECTS); |
1810 state_ = REBUILD_RSETS; | 1812 state_ = REBUILD_RSETS; |
1811 #endif | 1813 #endif |
1812 Heap::RebuildRSets(); | 1814 Heap::RebuildRSets(); |
1813 } | 1815 } |
1814 | 1816 |
1815 } } // namespace v8::internal | 1817 } } // namespace v8::internal |
OLD | NEW |