| 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 return CopyConstantPoolArrayWithMap(src, src->map()); | 210 return CopyConstantPoolArrayWithMap(src, src->map()); |
| 211 } | 211 } |
| 212 | 212 |
| 213 | 213 |
| 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 HeapProfiler* profiler = isolate_->heap_profiler(); |
| 221 retry_space == OLD_POINTER_SPACE || | |
| 222 retry_space == OLD_DATA_SPACE || | |
| 223 retry_space == LO_SPACE); | |
| 224 #ifdef DEBUG | 221 #ifdef DEBUG |
| 225 if (FLAG_gc_interval >= 0 && | 222 if (FLAG_gc_interval >= 0 && |
| 226 !disallow_allocation_failure_ && | 223 !disallow_allocation_failure_ && |
| 227 Heap::allocation_timeout_-- <= 0) { | 224 Heap::allocation_timeout_-- <= 0) { |
| 228 return Failure::RetryAfterGC(space); | 225 return Failure::RetryAfterGC(space); |
| 229 } | 226 } |
| 230 isolate_->counters()->objs_since_last_full()->Increment(); | 227 isolate_->counters()->objs_since_last_full()->Increment(); |
| 231 isolate_->counters()->objs_since_last_young()->Increment(); | 228 isolate_->counters()->objs_since_last_young()->Increment(); |
| 232 #endif | 229 #endif |
| 230 |
| 231 HeapObject* object; |
| 233 MaybeObject* result; | 232 MaybeObject* result; |
| 234 if (NEW_SPACE == space) { | 233 if (NEW_SPACE == space) { |
| 235 result = new_space_.AllocateRaw(size_in_bytes); | 234 result = new_space_.AllocateRaw(size_in_bytes); |
| 236 if (always_allocate() && result->IsFailure()) { | 235 if (always_allocate() && result->IsFailure() && retry_space != NEW_SPACE) { |
| 237 space = retry_space; | 236 space = retry_space; |
| 238 } else { | 237 } else { |
| 238 if (profiler->is_tracking_allocations() && result->To(&object)) { |
| 239 profiler->NewObjectEvent(object->address(), size_in_bytes); |
| 240 } |
| 239 return result; | 241 return result; |
| 240 } | 242 } |
| 241 } | 243 } |
| 242 | 244 |
| 243 if (OLD_POINTER_SPACE == space) { | 245 if (OLD_POINTER_SPACE == space) { |
| 244 result = old_pointer_space_->AllocateRaw(size_in_bytes); | 246 result = old_pointer_space_->AllocateRaw(size_in_bytes); |
| 245 } else if (OLD_DATA_SPACE == space) { | 247 } else if (OLD_DATA_SPACE == space) { |
| 246 result = old_data_space_->AllocateRaw(size_in_bytes); | 248 result = old_data_space_->AllocateRaw(size_in_bytes); |
| 247 } else if (CODE_SPACE == space) { | 249 } else if (CODE_SPACE == space) { |
| 248 result = code_space_->AllocateRaw(size_in_bytes); | 250 result = code_space_->AllocateRaw(size_in_bytes); |
| 249 } else if (LO_SPACE == space) { | 251 } else if (LO_SPACE == space) { |
| 250 result = lo_space_->AllocateRaw(size_in_bytes, NOT_EXECUTABLE); | 252 result = lo_space_->AllocateRaw(size_in_bytes, NOT_EXECUTABLE); |
| 251 } else if (CELL_SPACE == space) { | 253 } else if (CELL_SPACE == space) { |
| 252 result = cell_space_->AllocateRaw(size_in_bytes); | 254 result = cell_space_->AllocateRaw(size_in_bytes); |
| 253 } else if (PROPERTY_CELL_SPACE == space) { | 255 } else if (PROPERTY_CELL_SPACE == space) { |
| 254 result = property_cell_space_->AllocateRaw(size_in_bytes); | 256 result = property_cell_space_->AllocateRaw(size_in_bytes); |
| 255 } else { | 257 } else { |
| 256 ASSERT(MAP_SPACE == space); | 258 ASSERT(MAP_SPACE == space); |
| 257 result = map_space_->AllocateRaw(size_in_bytes); | 259 result = map_space_->AllocateRaw(size_in_bytes); |
| 258 } | 260 } |
| 259 if (result->IsFailure()) old_gen_exhausted_ = true; | 261 if (result->IsFailure()) old_gen_exhausted_ = true; |
| 262 if (profiler->is_tracking_allocations() && result->To(&object)) { |
| 263 profiler->NewObjectEvent(object->address(), size_in_bytes); |
| 264 } |
| 260 return result; | 265 return result; |
| 261 } | 266 } |
| 262 | 267 |
| 263 | 268 |
| 264 MaybeObject* Heap::NumberFromInt32( | 269 MaybeObject* Heap::NumberFromInt32( |
| 265 int32_t value, PretenureFlag pretenure) { | 270 int32_t value, PretenureFlag pretenure) { |
| 266 if (Smi::IsValid(value)) return Smi::FromInt(value); | 271 if (Smi::IsValid(value)) return Smi::FromInt(value); |
| 267 // Bypass NumberFromDouble to avoid various redundant checks. | 272 // Bypass NumberFromDouble to avoid various redundant checks. |
| 268 return AllocateHeapNumber(FastI2D(value), pretenure); | 273 return AllocateHeapNumber(FastI2D(value), pretenure); |
| 269 } | 274 } |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 #ifdef DEBUG | 864 #ifdef DEBUG |
| 860 Isolate* isolate = Isolate::Current(); | 865 Isolate* isolate = Isolate::Current(); |
| 861 isolate->heap()->disallow_allocation_failure_ = old_state_; | 866 isolate->heap()->disallow_allocation_failure_ = old_state_; |
| 862 #endif | 867 #endif |
| 863 } | 868 } |
| 864 | 869 |
| 865 | 870 |
| 866 } } // namespace v8::internal | 871 } } // namespace v8::internal |
| 867 | 872 |
| 868 #endif // V8_HEAP_INL_H_ | 873 #endif // V8_HEAP_INL_H_ |
| OLD | NEW |