| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 return object; | 196 return object; |
| 197 } | 197 } |
| 198 | 198 |
| 199 return Failure::RetryAfterGC(identity()); | 199 return Failure::RetryAfterGC(identity()); |
| 200 } | 200 } |
| 201 | 201 |
| 202 | 202 |
| 203 // ----------------------------------------------------------------------------- | 203 // ----------------------------------------------------------------------------- |
| 204 // NewSpace | 204 // NewSpace |
| 205 | 205 |
| 206 MaybeObject* NewSpace::AllocateRawInternal(int size_in_bytes, | 206 MaybeObject* NewSpace::AllocateRawInternal(int size_in_bytes) { |
| 207 AllocationInfo* alloc_info) { | 207 Address new_top = allocation_info_.top + size_in_bytes; |
| 208 Address new_top = alloc_info->top + size_in_bytes; | 208 if (new_top > allocation_info_.limit) { |
| 209 if (new_top > alloc_info->limit) return Failure::RetryAfterGC(); | 209 Address high = to_space_.high(); |
| 210 if (allocation_info_.limit < high) { |
| 211 allocation_info_.limit = Min( |
| 212 allocation_info_.limit + inline_alloction_limit_step_, |
| 213 high); |
| 214 return AllocateRawInternal(size_in_bytes); |
| 215 } |
| 216 return Failure::RetryAfterGC(); |
| 217 } |
| 210 | 218 |
| 211 Object* obj = HeapObject::FromAddress(alloc_info->top); | 219 Object* obj = HeapObject::FromAddress(allocation_info_.top); |
| 212 alloc_info->top = new_top; | 220 allocation_info_.top = new_top; |
| 213 #ifdef DEBUG | 221 ASSERT_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_); |
| 214 SemiSpace* space = | |
| 215 (alloc_info == &allocation_info_) ? &to_space_ : &from_space_; | |
| 216 ASSERT(space->low() <= alloc_info->top | |
| 217 && alloc_info->top <= space->high() | |
| 218 && alloc_info->limit == space->high()); | |
| 219 #endif | |
| 220 | 222 |
| 221 IncrementalMarking::Step(size_in_bytes); | 223 int bytes_allocated = new_top - top_on_previous_step_; |
| 224 IncrementalMarking::Step(bytes_allocated); |
| 225 top_on_previous_step_ = new_top; |
| 222 | 226 |
| 223 return obj; | 227 return obj; |
| 224 } | 228 } |
| 225 | 229 |
| 226 | 230 |
| 227 template <typename StringType> | 231 template <typename StringType> |
| 228 void NewSpace::ShrinkStringAtAllocationBoundary(String* string, int length) { | 232 void NewSpace::ShrinkStringAtAllocationBoundary(String* string, int length) { |
| 229 ASSERT(length <= string->length()); | 233 ASSERT(length <= string->length()); |
| 230 ASSERT(string->IsSeqString()); | 234 ASSERT(string->IsSeqString()); |
| 231 ASSERT(string->address() + StringType::SizeFor(string->length()) == | 235 ASSERT(string->address() + StringType::SizeFor(string->length()) == |
| 232 allocation_info_.top); | 236 allocation_info_.top); |
| 233 allocation_info_.top = | 237 allocation_info_.top = |
| 234 string->address() + StringType::SizeFor(length); | 238 string->address() + StringType::SizeFor(length); |
| 235 string->set_length(length); | 239 string->set_length(length); |
| 236 } | 240 } |
| 237 | 241 |
| 238 | 242 |
| 239 bool FreeListNode::IsFreeListNode(HeapObject* object) { | 243 bool FreeListNode::IsFreeListNode(HeapObject* object) { |
| 240 return object->map() == Heap::raw_unchecked_free_space_map() | 244 return object->map() == Heap::raw_unchecked_free_space_map() |
| 241 || object->map() == Heap::raw_unchecked_one_pointer_filler_map() | 245 || object->map() == Heap::raw_unchecked_one_pointer_filler_map() |
| 242 || object->map() == Heap::raw_unchecked_two_pointer_filler_map(); | 246 || object->map() == Heap::raw_unchecked_two_pointer_filler_map(); |
| 243 } | 247 } |
| 244 | 248 |
| 245 } } // namespace v8::internal | 249 } } // namespace v8::internal |
| 246 | 250 |
| 247 #endif // V8_SPACES_INL_H_ | 251 #endif // V8_SPACES_INL_H_ |
| OLD | NEW |