| OLD | NEW |
| 1 // Copyright 2006-2010 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2010 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 ASSERT(alloc_info->VerifyPagedAllocation()); | 195 ASSERT(alloc_info->VerifyPagedAllocation()); |
| 196 accounting_stats_.AllocateBytes(size_in_bytes); | 196 accounting_stats_.AllocateBytes(size_in_bytes); |
| 197 return HeapObject::FromAddress(current_top); | 197 return HeapObject::FromAddress(current_top); |
| 198 } | 198 } |
| 199 | 199 |
| 200 | 200 |
| 201 // Raw allocation. | 201 // Raw allocation. |
| 202 MaybeObject* PagedSpace::AllocateRaw(int size_in_bytes) { | 202 MaybeObject* PagedSpace::AllocateRaw(int size_in_bytes) { |
| 203 ASSERT(HasBeenSetup()); | 203 ASSERT(HasBeenSetup()); |
| 204 ASSERT_OBJECT_SIZE(size_in_bytes); | 204 ASSERT_OBJECT_SIZE(size_in_bytes); |
| 205 |
| 205 HeapObject* object = AllocateLinearly(&allocation_info_, size_in_bytes); | 206 HeapObject* object = AllocateLinearly(&allocation_info_, size_in_bytes); |
| 206 if (object != NULL) return object; | 207 if (object != NULL) { |
| 208 IncrementalMarking::Step(size_in_bytes); |
| 209 return object; |
| 210 } |
| 207 | 211 |
| 208 object = SlowAllocateRaw(size_in_bytes); | 212 object = SlowAllocateRaw(size_in_bytes); |
| 209 if (object != NULL) return object; | 213 if (object != NULL) { |
| 214 IncrementalMarking::Step(size_in_bytes); |
| 215 return object; |
| 216 } |
| 210 | 217 |
| 211 return Failure::RetryAfterGC(identity()); | 218 return Failure::RetryAfterGC(identity()); |
| 212 } | 219 } |
| 213 | 220 |
| 214 | 221 |
| 215 // ----------------------------------------------------------------------------- | 222 // ----------------------------------------------------------------------------- |
| 216 // NewSpace | 223 // NewSpace |
| 217 | 224 |
| 218 MaybeObject* NewSpace::AllocateRawInternal(int size_in_bytes, | 225 MaybeObject* NewSpace::AllocateRawInternal(int size_in_bytes, |
| 219 AllocationInfo* alloc_info) { | 226 AllocationInfo* alloc_info) { |
| 220 Address new_top = alloc_info->top + size_in_bytes; | 227 Address new_top = alloc_info->top + size_in_bytes; |
| 221 if (new_top > alloc_info->limit) return Failure::RetryAfterGC(); | 228 if (new_top > alloc_info->limit) return Failure::RetryAfterGC(); |
| 222 | 229 |
| 223 Object* obj = HeapObject::FromAddress(alloc_info->top); | 230 Object* obj = HeapObject::FromAddress(alloc_info->top); |
| 224 alloc_info->top = new_top; | 231 alloc_info->top = new_top; |
| 225 #ifdef DEBUG | 232 #ifdef DEBUG |
| 226 SemiSpace* space = | 233 SemiSpace* space = |
| 227 (alloc_info == &allocation_info_) ? &to_space_ : &from_space_; | 234 (alloc_info == &allocation_info_) ? &to_space_ : &from_space_; |
| 228 ASSERT(space->low() <= alloc_info->top | 235 ASSERT(space->low() <= alloc_info->top |
| 229 && alloc_info->top <= space->high() | 236 && alloc_info->top <= space->high() |
| 230 && alloc_info->limit == space->high()); | 237 && alloc_info->limit == space->high()); |
| 231 #endif | 238 #endif |
| 239 |
| 240 IncrementalMarking::Step(size_in_bytes); |
| 241 |
| 232 return obj; | 242 return obj; |
| 233 } | 243 } |
| 234 | 244 |
| 235 | 245 |
| 236 template <typename StringType> | 246 template <typename StringType> |
| 237 void NewSpace::ShrinkStringAtAllocationBoundary(String* string, int length) { | 247 void NewSpace::ShrinkStringAtAllocationBoundary(String* string, int length) { |
| 238 ASSERT(length <= string->length()); | 248 ASSERT(length <= string->length()); |
| 239 ASSERT(string->IsSeqString()); | 249 ASSERT(string->IsSeqString()); |
| 240 ASSERT(string->address() + StringType::SizeFor(string->length()) == | 250 ASSERT(string->address() + StringType::SizeFor(string->length()) == |
| 241 allocation_info_.top); | 251 allocation_info_.top); |
| 242 allocation_info_.top = | 252 allocation_info_.top = |
| 243 string->address() + StringType::SizeFor(length); | 253 string->address() + StringType::SizeFor(length); |
| 244 string->set_length(length); | 254 string->set_length(length); |
| 245 } | 255 } |
| 246 | 256 |
| 247 | 257 |
| 248 bool FreeListNode::IsFreeListNode(HeapObject* object) { | 258 bool FreeListNode::IsFreeListNode(HeapObject* object) { |
| 249 return object->map() == Heap::raw_unchecked_byte_array_map() | 259 return object->map() == Heap::raw_unchecked_byte_array_map() |
| 250 || object->map() == Heap::raw_unchecked_one_pointer_filler_map() | 260 || object->map() == Heap::raw_unchecked_one_pointer_filler_map() |
| 251 || object->map() == Heap::raw_unchecked_two_pointer_filler_map(); | 261 || object->map() == Heap::raw_unchecked_two_pointer_filler_map(); |
| 252 } | 262 } |
| 253 | 263 |
| 254 } } // namespace v8::internal | 264 } } // namespace v8::internal |
| 255 | 265 |
| 256 #endif // V8_SPACES_INL_H_ | 266 #endif // V8_SPACES_INL_H_ |
| OLD | NEW |