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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #ifdef DEBUG | 44 #ifdef DEBUG |
45 if (FLAG_gc_interval >= 0 && | 45 if (FLAG_gc_interval >= 0 && |
46 !disallow_allocation_failure_ && | 46 !disallow_allocation_failure_ && |
47 Heap::allocation_timeout_-- <= 0) { | 47 Heap::allocation_timeout_-- <= 0) { |
48 return Failure::RetryAfterGC(size_in_bytes, space); | 48 return Failure::RetryAfterGC(size_in_bytes, space); |
49 } | 49 } |
50 Counters::objs_since_last_full.Increment(); | 50 Counters::objs_since_last_full.Increment(); |
51 Counters::objs_since_last_young.Increment(); | 51 Counters::objs_since_last_young.Increment(); |
52 #endif | 52 #endif |
53 if (NEW_SPACE == space) { | 53 if (NEW_SPACE == space) { |
54 return new_space_->AllocateRaw(size_in_bytes); | 54 return new_space_.AllocateRaw(size_in_bytes); |
55 } | 55 } |
56 | 56 |
57 Object* result; | 57 Object* result; |
58 if (OLD_POINTER_SPACE == space) { | 58 if (OLD_POINTER_SPACE == space) { |
59 result = old_pointer_space_->AllocateRaw(size_in_bytes); | 59 result = old_pointer_space_->AllocateRaw(size_in_bytes); |
60 } else if (OLD_DATA_SPACE == space) { | 60 } else if (OLD_DATA_SPACE == space) { |
61 result = old_data_space_->AllocateRaw(size_in_bytes); | 61 result = old_data_space_->AllocateRaw(size_in_bytes); |
62 } else if (CODE_SPACE == space) { | 62 } else if (CODE_SPACE == space) { |
63 result = code_space_->AllocateRaw(size_in_bytes); | 63 result = code_space_->AllocateRaw(size_in_bytes); |
64 } else if (LO_SPACE == space) { | 64 } else if (LO_SPACE == space) { |
(...skipping 28 matching lines...) Expand all Loading... |
93 Counters::objs_since_last_full.Increment(); | 93 Counters::objs_since_last_full.Increment(); |
94 Counters::objs_since_last_young.Increment(); | 94 Counters::objs_since_last_young.Increment(); |
95 #endif | 95 #endif |
96 Object* result = map_space_->AllocateRaw(size_in_bytes); | 96 Object* result = map_space_->AllocateRaw(size_in_bytes); |
97 if (result->IsFailure()) old_gen_exhausted_ = true; | 97 if (result->IsFailure()) old_gen_exhausted_ = true; |
98 return result; | 98 return result; |
99 } | 99 } |
100 | 100 |
101 | 101 |
102 bool Heap::InNewSpace(Object* object) { | 102 bool Heap::InNewSpace(Object* object) { |
103 return new_space_->Contains(object); | 103 return new_space_.Contains(object); |
104 } | 104 } |
105 | 105 |
106 | 106 |
107 bool Heap::InFromSpace(Object* object) { | 107 bool Heap::InFromSpace(Object* object) { |
108 return new_space_->FromSpaceContains(object); | 108 return new_space_.FromSpaceContains(object); |
109 } | 109 } |
110 | 110 |
111 | 111 |
112 bool Heap::InToSpace(Object* object) { | 112 bool Heap::InToSpace(Object* object) { |
113 return new_space_->ToSpaceContains(object); | 113 return new_space_.ToSpaceContains(object); |
114 } | 114 } |
115 | 115 |
116 | 116 |
117 bool Heap::ShouldBePromoted(Address old_address, int object_size) { | 117 bool Heap::ShouldBePromoted(Address old_address, int object_size) { |
118 // An object should be promoted if: | 118 // An object should be promoted if: |
119 // - the object has survived a scavenge operation or | 119 // - the object has survived a scavenge operation or |
120 // - to space is already 25% full. | 120 // - to space is already 25% full. |
121 return old_address < new_space_->age_mark() | 121 return old_address < new_space_.age_mark() |
122 || (new_space_->Size() + object_size) >= (new_space_->Capacity() >> 2); | 122 || (new_space_.Size() + object_size) >= (new_space_.Capacity() >> 2); |
123 } | 123 } |
124 | 124 |
125 | 125 |
126 void Heap::RecordWrite(Address address, int offset) { | 126 void Heap::RecordWrite(Address address, int offset) { |
127 if (new_space_->Contains(address)) return; | 127 if (new_space_.Contains(address)) return; |
128 ASSERT(!new_space_->FromSpaceContains(address)); | 128 ASSERT(!new_space_.FromSpaceContains(address)); |
129 SLOW_ASSERT(Contains(address + offset)); | 129 SLOW_ASSERT(Contains(address + offset)); |
130 Page::SetRSet(address, offset); | 130 Page::SetRSet(address, offset); |
131 } | 131 } |
132 | 132 |
133 | 133 |
134 OldSpace* Heap::TargetSpace(HeapObject* object) { | 134 OldSpace* Heap::TargetSpace(HeapObject* object) { |
135 // Heap numbers and sequential strings are promoted to old data space, all | 135 // Heap numbers and sequential strings are promoted to old data space, all |
136 // other object types are promoted to old pointer space. We do not use | 136 // other object types are promoted to old pointer space. We do not use |
137 // object->IsHeapNumber() and object->IsSeqString() because we already | 137 // object->IsHeapNumber() and object->IsSeqString() because we already |
138 // know that object has the heap object tag. | 138 // know that object has the heap object tag. |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 allocation_allowed_ = new_state; | 229 allocation_allowed_ = new_state; |
230 return old; | 230 return old; |
231 } | 231 } |
232 | 232 |
233 #endif | 233 #endif |
234 | 234 |
235 | 235 |
236 } } // namespace v8::internal | 236 } } // namespace v8::internal |
237 | 237 |
238 #endif // V8_HEAP_INL_H_ | 238 #endif // V8_HEAP_INL_H_ |
OLD | NEW |