OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 755 matching lines...) Loading... |
766 } | 766 } |
767 | 767 |
768 // Promote and process all the to-be-promoted objects. | 768 // Promote and process all the to-be-promoted objects. |
769 while (!promotion_queue.is_empty()) { | 769 while (!promotion_queue.is_empty()) { |
770 HeapObject* source; | 770 HeapObject* source; |
771 Map* map; | 771 Map* map; |
772 promotion_queue.remove(&source, &map); | 772 promotion_queue.remove(&source, &map); |
773 // Copy the from-space object to its new location (given by the | 773 // Copy the from-space object to its new location (given by the |
774 // forwarding address) and fix its map. | 774 // forwarding address) and fix its map. |
775 HeapObject* target = source->map_word().ToForwardingAddress(); | 775 HeapObject* target = source->map_word().ToForwardingAddress(); |
| 776 // We don't need to worry about alignment and HeapNumbers here because |
| 777 // a heap number is put in data space directly and not queued up for |
| 778 // copying and scanning for pointers here. |
776 CopyBlock(reinterpret_cast<Object**>(target->address()), | 779 CopyBlock(reinterpret_cast<Object**>(target->address()), |
777 reinterpret_cast<Object**>(source->address()), | 780 reinterpret_cast<Object**>(source->address()), |
778 source->SizeFromMap(map)); | 781 source->SizeFromMap(map)); |
779 target->set_map(map); | 782 target->set_map(map); |
780 | 783 |
781 #if defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING) | 784 #if defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING) |
782 // Update NewSpace stats if necessary. | 785 // Update NewSpace stats if necessary. |
783 RecordCopiedObject(target); | 786 RecordCopiedObject(target); |
784 #endif | 787 #endif |
785 // Visit the newly copied object for pointers to new space. | 788 // Visit the newly copied object for pointers to new space. |
(...skipping 143 matching lines...) Loading... |
929 new_space_.RecordPromotion(obj); | 932 new_space_.RecordPromotion(obj); |
930 } | 933 } |
931 } | 934 } |
932 } | 935 } |
933 #endif // defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING) | 936 #endif // defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING) |
934 | 937 |
935 | 938 |
936 | 939 |
937 HeapObject* Heap::MigrateObject(HeapObject* source, | 940 HeapObject* Heap::MigrateObject(HeapObject* source, |
938 HeapObject* target, | 941 HeapObject* target, |
939 int size) { | 942 int size, |
940 // Copy the content of source to target. | 943 MapWord first_word) { |
941 CopyBlock(reinterpret_cast<Object**>(target->address()), | 944 if (kObjectAlignment == 4 && |
942 reinterpret_cast<Object**>(source->address()), | 945 size == HeapNumber::kSize && |
943 size); | 946 ((reinterpret_cast<intptr_t>(source) & 7) != |
| 947 (reinterpret_cast<intptr_t>(target) & 7)) && |
| 948 first_word.ToMap() == Heap::heap_number_map()) { |
| 949 target->set_map_word(first_word); |
| 950 reinterpret_cast<HeapNumber*>(source)->CopyBodyTo(target); |
| 951 } else { |
| 952 // Copy the content of source to target. |
| 953 CopyBlock(reinterpret_cast<Object**>(target->address()), |
| 954 reinterpret_cast<Object**>(source->address()), |
| 955 size); |
| 956 } |
944 | 957 |
945 // Set the forwarding address. | 958 // Set the forwarding address. |
946 source->set_map_word(MapWord::FromForwardingAddress(target)); | 959 source->set_map_word(MapWord::FromForwardingAddress(target)); |
947 | 960 |
948 #if defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING) | 961 #if defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING) |
949 // Update NewSpace stats if necessary. | 962 // Update NewSpace stats if necessary. |
950 RecordCopiedObject(target); | 963 RecordCopiedObject(target); |
951 #endif | 964 #endif |
952 | 965 |
953 return target; | 966 return target; |
(...skipping 78 matching lines...) Loading... |
1032 // list). | 1045 // list). |
1033 FreeListNode* node = FreeListNode::FromAddress(target->address()); | 1046 FreeListNode* node = FreeListNode::FromAddress(target->address()); |
1034 node->set_size(object_size); | 1047 node->set_size(object_size); |
1035 | 1048 |
1036 *p = target; | 1049 *p = target; |
1037 } else { | 1050 } else { |
1038 // Objects promoted to the data space can be copied immediately | 1051 // Objects promoted to the data space can be copied immediately |
1039 // and not revisited---we will never sweep that space for | 1052 // and not revisited---we will never sweep that space for |
1040 // pointers and the copied objects do not contain pointers to | 1053 // pointers and the copied objects do not contain pointers to |
1041 // new space objects. | 1054 // new space objects. |
1042 *p = MigrateObject(object, target, object_size); | 1055 *p = MigrateObject(object, target, object_size, first_word); |
1043 #ifdef DEBUG | 1056 #ifdef DEBUG |
1044 VerifyNonPointerSpacePointersVisitor v; | 1057 VerifyNonPointerSpacePointersVisitor v; |
1045 (*p)->Iterate(&v); | 1058 (*p)->Iterate(&v); |
1046 #endif | 1059 #endif |
1047 } | 1060 } |
1048 return; | 1061 return; |
1049 } | 1062 } |
1050 } | 1063 } |
1051 } | 1064 } |
1052 // The object should remain in new space or the old space allocation failed. | 1065 // The object should remain in new space or the old space allocation failed. |
1053 Object* result = new_space_.AllocateRaw(object_size); | 1066 Object* result = new_space_.AllocateRaw(object_size); |
1054 // Failed allocation at this point is utterly unexpected. | 1067 // Failed allocation at this point is utterly unexpected. |
1055 ASSERT(!result->IsFailure()); | 1068 ASSERT(!result->IsFailure()); |
1056 *p = MigrateObject(object, HeapObject::cast(result), object_size); | 1069 HeapObject* target = HeapObject::cast(result); |
| 1070 *p = MigrateObject(object, |
| 1071 HeapObject::cast(target), |
| 1072 object_size, |
| 1073 first_word); |
1057 } | 1074 } |
1058 | 1075 |
1059 | 1076 |
1060 void Heap::ScavengePointer(HeapObject** p) { | 1077 void Heap::ScavengePointer(HeapObject** p) { |
1061 ScavengeObject(p, *p); | 1078 ScavengeObject(p, *p); |
1062 } | 1079 } |
1063 | 1080 |
1064 | 1081 |
1065 Object* Heap::AllocatePartialMap(InstanceType instance_type, | 1082 Object* Heap::AllocatePartialMap(InstanceType instance_type, |
1066 int instance_size) { | 1083 int instance_size) { |
(...skipping 2898 matching lines...) Loading... |
3965 for (int i = 0; i < kNumberOfCaches; i++) { | 3982 for (int i = 0; i < kNumberOfCaches; i++) { |
3966 if (caches_[i] != NULL) { | 3983 if (caches_[i] != NULL) { |
3967 delete caches_[i]; | 3984 delete caches_[i]; |
3968 caches_[i] = NULL; | 3985 caches_[i] = NULL; |
3969 } | 3986 } |
3970 } | 3987 } |
3971 } | 3988 } |
3972 | 3989 |
3973 | 3990 |
3974 } } // namespace v8::internal | 3991 } } // namespace v8::internal |
OLD | NEW |