| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 MaybeObject* Heap::AllocateRaw(int size_in_bytes, | 214 MaybeObject* Heap::AllocateRaw(int size_in_bytes, |
| 215 AllocationSpace space, | 215 AllocationSpace space, |
| 216 AllocationSpace retry_space) { | 216 AllocationSpace retry_space) { |
| 217 ASSERT(AllowHandleAllocation::IsAllowed()); | 217 ASSERT(AllowHandleAllocation::IsAllowed()); |
| 218 ASSERT(AllowHeapAllocation::IsAllowed()); | 218 ASSERT(AllowHeapAllocation::IsAllowed()); |
| 219 ASSERT(gc_state_ == NOT_IN_GC); | 219 ASSERT(gc_state_ == NOT_IN_GC); |
| 220 ASSERT(space != NEW_SPACE || | 220 ASSERT(space != NEW_SPACE || |
| 221 retry_space == OLD_POINTER_SPACE || | 221 retry_space == OLD_POINTER_SPACE || |
| 222 retry_space == OLD_DATA_SPACE || | 222 retry_space == OLD_DATA_SPACE || |
| 223 retry_space == LO_SPACE); | 223 retry_space == LO_SPACE); |
| 224 HeapProfiler* profiler = isolate_->heap_profiler(); |
| 224 #ifdef DEBUG | 225 #ifdef DEBUG |
| 225 if (FLAG_gc_interval >= 0 && | 226 if (FLAG_gc_interval >= 0 && |
| 226 !disallow_allocation_failure_ && | 227 !disallow_allocation_failure_ && |
| 227 Heap::allocation_timeout_-- <= 0) { | 228 Heap::allocation_timeout_-- <= 0) { |
| 228 return Failure::RetryAfterGC(space); | 229 return Failure::RetryAfterGC(space); |
| 229 } | 230 } |
| 230 isolate_->counters()->objs_since_last_full()->Increment(); | 231 isolate_->counters()->objs_since_last_full()->Increment(); |
| 231 isolate_->counters()->objs_since_last_young()->Increment(); | 232 isolate_->counters()->objs_since_last_young()->Increment(); |
| 232 #endif | 233 #endif |
| 234 |
| 235 HeapObject* object; |
| 233 MaybeObject* result; | 236 MaybeObject* result; |
| 234 if (NEW_SPACE == space) { | 237 if (NEW_SPACE == space) { |
| 235 result = new_space_.AllocateRaw(size_in_bytes); | 238 result = new_space_.AllocateRaw(size_in_bytes); |
| 236 if (always_allocate() && result->IsFailure()) { | 239 if (always_allocate() && result->IsFailure()) { |
| 237 space = retry_space; | 240 space = retry_space; |
| 238 } else { | 241 } else { |
| 242 if (profiler->is_tracking_allocations() && result->To(&object)) { |
| 243 profiler->NewObjectEvent(object->address(), size_in_bytes); |
| 244 } |
| 239 return result; | 245 return result; |
| 240 } | 246 } |
| 241 } | 247 } |
| 242 | 248 |
| 243 if (OLD_POINTER_SPACE == space) { | 249 if (OLD_POINTER_SPACE == space) { |
| 244 result = old_pointer_space_->AllocateRaw(size_in_bytes); | 250 result = old_pointer_space_->AllocateRaw(size_in_bytes); |
| 245 } else if (OLD_DATA_SPACE == space) { | 251 } else if (OLD_DATA_SPACE == space) { |
| 246 result = old_data_space_->AllocateRaw(size_in_bytes); | 252 result = old_data_space_->AllocateRaw(size_in_bytes); |
| 247 } else if (CODE_SPACE == space) { | 253 } else if (CODE_SPACE == space) { |
| 248 result = code_space_->AllocateRaw(size_in_bytes); | 254 result = code_space_->AllocateRaw(size_in_bytes); |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 #ifdef DEBUG | 877 #ifdef DEBUG |
| 872 Isolate* isolate = Isolate::Current(); | 878 Isolate* isolate = Isolate::Current(); |
| 873 isolate->heap()->disallow_allocation_failure_ = old_state_; | 879 isolate->heap()->disallow_allocation_failure_ = old_state_; |
| 874 #endif | 880 #endif |
| 875 } | 881 } |
| 876 | 882 |
| 877 | 883 |
| 878 } } // namespace v8::internal | 884 } } // namespace v8::internal |
| 879 | 885 |
| 880 #endif // V8_HEAP_INL_H_ | 886 #endif // V8_HEAP_INL_H_ |
| OLD | NEW |