| 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 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 Address new_space_front = new_space_.ToSpaceLow(); | 660 Address new_space_front = new_space_.ToSpaceLow(); |
| 661 promotion_queue.Initialize(new_space_.ToSpaceHigh()); | 661 promotion_queue.Initialize(new_space_.ToSpaceHigh()); |
| 662 | 662 |
| 663 ScavengeVisitor scavenge_visitor; | 663 ScavengeVisitor scavenge_visitor; |
| 664 // Copy roots. | 664 // Copy roots. |
| 665 IterateRoots(&scavenge_visitor); | 665 IterateRoots(&scavenge_visitor); |
| 666 | 666 |
| 667 // Copy objects reachable from weak pointers. | 667 // Copy objects reachable from weak pointers. |
| 668 GlobalHandles::IterateWeakRoots(&scavenge_visitor); | 668 GlobalHandles::IterateWeakRoots(&scavenge_visitor); |
| 669 | 669 |
| 670 #if V8_HOST_ARCH_64_BIT |
| 671 // TODO(X64): Make this go away again. We currently disable RSets for |
| 672 // 64-bit-mode. |
| 673 HeapObjectIterator old_pointer_iterator(old_pointer_space_); |
| 674 while (old_pointer_iterator.has_next()) { |
| 675 HeapObject* heap_object = old_pointer_iterator.next(); |
| 676 heap_object->Iterate(&scavenge_visitor); |
| 677 } |
| 678 HeapObjectIterator map_iterator(map_space_); |
| 679 while (map_iterator.has_next()) { |
| 680 HeapObject* heap_object = map_iterator.next(); |
| 681 heap_object->Iterate(&scavenge_visitor); |
| 682 } |
| 683 LargeObjectIterator lo_iterator(lo_space_); |
| 684 while (lo_iterator.has_next()) { |
| 685 HeapObject* heap_object = lo_iterator.next(); |
| 686 if (heap_object->IsFixedArray()) { |
| 687 heap_object->Iterate(&scavenge_visitor); |
| 688 } |
| 689 } |
| 690 #else // V8_HOST_ARCH_64_BIT |
| 670 // Copy objects reachable from the old generation. By definition, | 691 // Copy objects reachable from the old generation. By definition, |
| 671 // there are no intergenerational pointers in code or data spaces. | 692 // there are no intergenerational pointers in code or data spaces. |
| 672 IterateRSet(old_pointer_space_, &ScavengePointer); | 693 IterateRSet(old_pointer_space_, &ScavengePointer); |
| 673 IterateRSet(map_space_, &ScavengePointer); | 694 IterateRSet(map_space_, &ScavengePointer); |
| 674 lo_space_->IterateRSet(&ScavengePointer); | 695 lo_space_->IterateRSet(&ScavengePointer); |
| 696 #endif // V8_HOST_ARCH_64_BIT |
| 675 | 697 |
| 676 do { | 698 do { |
| 677 ASSERT(new_space_front <= new_space_.top()); | 699 ASSERT(new_space_front <= new_space_.top()); |
| 678 | 700 |
| 679 // The addresses new_space_front and new_space_.top() define a | 701 // The addresses new_space_front and new_space_.top() define a |
| 680 // queue of unprocessed copied objects. Process them until the | 702 // queue of unprocessed copied objects. Process them until the |
| 681 // queue is empty. | 703 // queue is empty. |
| 682 while (new_space_front < new_space_.top()) { | 704 while (new_space_front < new_space_.top()) { |
| 683 HeapObject* object = HeapObject::FromAddress(new_space_front); | 705 HeapObject* object = HeapObject::FromAddress(new_space_front); |
| 684 object->Iterate(&scavenge_visitor); | 706 object->Iterate(&scavenge_visitor); |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 992 | 1014 |
| 993 | 1015 |
| 994 bool Heap::CreateInitialMaps() { | 1016 bool Heap::CreateInitialMaps() { |
| 995 Object* obj = AllocatePartialMap(MAP_TYPE, Map::kSize); | 1017 Object* obj = AllocatePartialMap(MAP_TYPE, Map::kSize); |
| 996 if (obj->IsFailure()) return false; | 1018 if (obj->IsFailure()) return false; |
| 997 | 1019 |
| 998 // Map::cast cannot be used due to uninitialized map field. | 1020 // Map::cast cannot be used due to uninitialized map field. |
| 999 meta_map_ = reinterpret_cast<Map*>(obj); | 1021 meta_map_ = reinterpret_cast<Map*>(obj); |
| 1000 meta_map()->set_map(meta_map()); | 1022 meta_map()->set_map(meta_map()); |
| 1001 | 1023 |
| 1002 obj = AllocatePartialMap(FIXED_ARRAY_TYPE, Array::kHeaderSize); | 1024 obj = AllocatePartialMap(FIXED_ARRAY_TYPE, FixedArray::kHeaderSize); |
| 1003 if (obj->IsFailure()) return false; | 1025 if (obj->IsFailure()) return false; |
| 1004 fixed_array_map_ = Map::cast(obj); | 1026 fixed_array_map_ = Map::cast(obj); |
| 1005 | 1027 |
| 1006 obj = AllocatePartialMap(ODDBALL_TYPE, Oddball::kSize); | 1028 obj = AllocatePartialMap(ODDBALL_TYPE, Oddball::kSize); |
| 1007 if (obj->IsFailure()) return false; | 1029 if (obj->IsFailure()) return false; |
| 1008 oddball_map_ = Map::cast(obj); | 1030 oddball_map_ = Map::cast(obj); |
| 1009 | 1031 |
| 1010 // Allocate the empty array | 1032 // Allocate the empty array |
| 1011 obj = AllocateEmptyFixedArray(); | 1033 obj = AllocateEmptyFixedArray(); |
| 1012 if (obj->IsFailure()) return false; | 1034 if (obj->IsFailure()) return false; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 if (obj->IsFailure()) return false; | 1071 if (obj->IsFailure()) return false; |
| 1050 proxy_map_ = Map::cast(obj); | 1072 proxy_map_ = Map::cast(obj); |
| 1051 | 1073 |
| 1052 #define ALLOCATE_STRING_MAP(type, size, name) \ | 1074 #define ALLOCATE_STRING_MAP(type, size, name) \ |
| 1053 obj = AllocateMap(type, size); \ | 1075 obj = AllocateMap(type, size); \ |
| 1054 if (obj->IsFailure()) return false; \ | 1076 if (obj->IsFailure()) return false; \ |
| 1055 name##_map_ = Map::cast(obj); | 1077 name##_map_ = Map::cast(obj); |
| 1056 STRING_TYPE_LIST(ALLOCATE_STRING_MAP); | 1078 STRING_TYPE_LIST(ALLOCATE_STRING_MAP); |
| 1057 #undef ALLOCATE_STRING_MAP | 1079 #undef ALLOCATE_STRING_MAP |
| 1058 | 1080 |
| 1059 obj = AllocateMap(SHORT_STRING_TYPE, SeqTwoByteString::kHeaderSize); | 1081 obj = AllocateMap(SHORT_STRING_TYPE, SeqTwoByteString::kAlignedSize); |
| 1060 if (obj->IsFailure()) return false; | 1082 if (obj->IsFailure()) return false; |
| 1061 undetectable_short_string_map_ = Map::cast(obj); | 1083 undetectable_short_string_map_ = Map::cast(obj); |
| 1062 undetectable_short_string_map_->set_is_undetectable(); | 1084 undetectable_short_string_map_->set_is_undetectable(); |
| 1063 | 1085 |
| 1064 obj = AllocateMap(MEDIUM_STRING_TYPE, SeqTwoByteString::kHeaderSize); | 1086 obj = AllocateMap(MEDIUM_STRING_TYPE, SeqTwoByteString::kAlignedSize); |
| 1065 if (obj->IsFailure()) return false; | 1087 if (obj->IsFailure()) return false; |
| 1066 undetectable_medium_string_map_ = Map::cast(obj); | 1088 undetectable_medium_string_map_ = Map::cast(obj); |
| 1067 undetectable_medium_string_map_->set_is_undetectable(); | 1089 undetectable_medium_string_map_->set_is_undetectable(); |
| 1068 | 1090 |
| 1069 obj = AllocateMap(LONG_STRING_TYPE, SeqTwoByteString::kHeaderSize); | 1091 obj = AllocateMap(LONG_STRING_TYPE, SeqTwoByteString::kAlignedSize); |
| 1070 if (obj->IsFailure()) return false; | 1092 if (obj->IsFailure()) return false; |
| 1071 undetectable_long_string_map_ = Map::cast(obj); | 1093 undetectable_long_string_map_ = Map::cast(obj); |
| 1072 undetectable_long_string_map_->set_is_undetectable(); | 1094 undetectable_long_string_map_->set_is_undetectable(); |
| 1073 | 1095 |
| 1074 obj = AllocateMap(SHORT_ASCII_STRING_TYPE, SeqAsciiString::kHeaderSize); | 1096 obj = AllocateMap(SHORT_ASCII_STRING_TYPE, SeqAsciiString::kAlignedSize); |
| 1075 if (obj->IsFailure()) return false; | 1097 if (obj->IsFailure()) return false; |
| 1076 undetectable_short_ascii_string_map_ = Map::cast(obj); | 1098 undetectable_short_ascii_string_map_ = Map::cast(obj); |
| 1077 undetectable_short_ascii_string_map_->set_is_undetectable(); | 1099 undetectable_short_ascii_string_map_->set_is_undetectable(); |
| 1078 | 1100 |
| 1079 obj = AllocateMap(MEDIUM_ASCII_STRING_TYPE, SeqAsciiString::kHeaderSize); | 1101 obj = AllocateMap(MEDIUM_ASCII_STRING_TYPE, SeqAsciiString::kAlignedSize); |
| 1080 if (obj->IsFailure()) return false; | 1102 if (obj->IsFailure()) return false; |
| 1081 undetectable_medium_ascii_string_map_ = Map::cast(obj); | 1103 undetectable_medium_ascii_string_map_ = Map::cast(obj); |
| 1082 undetectable_medium_ascii_string_map_->set_is_undetectable(); | 1104 undetectable_medium_ascii_string_map_->set_is_undetectable(); |
| 1083 | 1105 |
| 1084 obj = AllocateMap(LONG_ASCII_STRING_TYPE, SeqAsciiString::kHeaderSize); | 1106 obj = AllocateMap(LONG_ASCII_STRING_TYPE, SeqAsciiString::kAlignedSize); |
| 1085 if (obj->IsFailure()) return false; | 1107 if (obj->IsFailure()) return false; |
| 1086 undetectable_long_ascii_string_map_ = Map::cast(obj); | 1108 undetectable_long_ascii_string_map_ = Map::cast(obj); |
| 1087 undetectable_long_ascii_string_map_->set_is_undetectable(); | 1109 undetectable_long_ascii_string_map_->set_is_undetectable(); |
| 1088 | 1110 |
| 1089 obj = AllocateMap(BYTE_ARRAY_TYPE, Array::kHeaderSize); | 1111 obj = AllocateMap(BYTE_ARRAY_TYPE, Array::kAlignedSize); |
| 1090 if (obj->IsFailure()) return false; | 1112 if (obj->IsFailure()) return false; |
| 1091 byte_array_map_ = Map::cast(obj); | 1113 byte_array_map_ = Map::cast(obj); |
| 1092 | 1114 |
| 1093 obj = AllocateMap(CODE_TYPE, Code::kHeaderSize); | 1115 obj = AllocateMap(CODE_TYPE, Code::kHeaderSize); |
| 1094 if (obj->IsFailure()) return false; | 1116 if (obj->IsFailure()) return false; |
| 1095 code_map_ = Map::cast(obj); | 1117 code_map_ = Map::cast(obj); |
| 1096 | 1118 |
| 1097 obj = AllocateMap(FILLER_TYPE, kPointerSize); | 1119 obj = AllocateMap(FILLER_TYPE, kPointerSize); |
| 1098 if (obj->IsFailure()) return false; | 1120 if (obj->IsFailure()) return false; |
| 1099 one_word_filler_map_ = Map::cast(obj); | 1121 one_word_filler_map_ = Map::cast(obj); |
| (...skipping 2334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3434 #ifdef DEBUG | 3456 #ifdef DEBUG |
| 3435 bool Heap::GarbageCollectionGreedyCheck() { | 3457 bool Heap::GarbageCollectionGreedyCheck() { |
| 3436 ASSERT(FLAG_gc_greedy); | 3458 ASSERT(FLAG_gc_greedy); |
| 3437 if (Bootstrapper::IsActive()) return true; | 3459 if (Bootstrapper::IsActive()) return true; |
| 3438 if (disallow_allocation_failure()) return true; | 3460 if (disallow_allocation_failure()) return true; |
| 3439 return CollectGarbage(0, NEW_SPACE); | 3461 return CollectGarbage(0, NEW_SPACE); |
| 3440 } | 3462 } |
| 3441 #endif | 3463 #endif |
| 3442 | 3464 |
| 3443 } } // namespace v8::internal | 3465 } } // namespace v8::internal |
| OLD | NEW |