Index: src/spaces-inl.h |
diff --git a/src/spaces-inl.h b/src/spaces-inl.h |
index be2ae2a57db248234ab9f92726beec0168a49709..86782d7aea22acf9703f2beea5276f6b03bdb838 100644 |
--- a/src/spaces-inl.h |
+++ b/src/spaces-inl.h |
@@ -28,6 +28,7 @@ |
#ifndef V8_SPACES_INL_H_ |
#define V8_SPACES_INL_H_ |
+#include "heap-profiler.h" |
#include "isolate.h" |
#include "spaces.h" |
#include "v8memory.h" |
@@ -273,36 +274,38 @@ HeapObject* PagedSpace::AllocateLinearly(int size_in_bytes) { |
// Raw allocation. |
-MaybeObject* PagedSpace::AllocateRaw(int size_in_bytes) { |
- HeapObject* object = AllocateLinearly(size_in_bytes); |
- if (object != NULL) { |
- if (identity() == CODE_SPACE) { |
- SkipList::Update(object->address(), size_in_bytes); |
- } |
- return object; |
- } |
+MaybeObject* PagedSpace::AllocateRaw(int size_in_bytes, |
+ AllocationType event) { |
+ HeapObject* object = NULL; |
- ASSERT(!heap()->linear_allocation() || |
- (anchor_.next_chunk() == &anchor_ && |
- anchor_.prev_chunk() == &anchor_)); |
+ do { |
+ object = AllocateLinearly(size_in_bytes); |
+ if (object != NULL) break; |
- object = free_list_.Allocate(size_in_bytes); |
- if (object != NULL) { |
- if (identity() == CODE_SPACE) { |
- SkipList::Update(object->address(), size_in_bytes); |
- } |
- return object; |
+ ASSERT(!heap()->linear_allocation() || |
+ (anchor_.next_chunk() == &anchor_ && |
+ anchor_.prev_chunk() == &anchor_)); |
+ |
+ object = free_list_.Allocate(size_in_bytes); |
+ if (object != NULL) break; |
+ |
+ object = SlowAllocateRaw(size_in_bytes); |
+ } while (false); |
Hannes Payer (out of office)
2013/10/02 18:00:29
I don't like the goto emulation here. Why don't we
Alexandra Mikhaylova
2013/10/03 16:27:55
Ok, corrected it keeping the original method.
|
+ |
+ if (object == NULL) return Failure::RetryAfterGC(identity()); |
+ |
+ if (identity() == CODE_SPACE) { |
+ SkipList::Update(object->address(), size_in_bytes); |
} |
- object = SlowAllocateRaw(size_in_bytes); |
- if (object != NULL) { |
- if (identity() == CODE_SPACE) { |
- SkipList::Update(object->address(), size_in_bytes); |
+ if (event == NEW_OBJECT) { |
+ HeapProfiler* profiler = heap()->isolate()->heap_profiler(); |
+ if (profiler->is_tracking_allocations()) { |
+ profiler->NewObjectEvent(object->address(), size_in_bytes); |
} |
- return object; |
} |
- return Failure::RetryAfterGC(identity()); |
+ return object; |
} |
@@ -332,10 +335,15 @@ MaybeObject* NewSpace::AllocateRaw(int size_in_bytes) { |
return SlowAllocateRaw(size_in_bytes); |
} |
- Object* obj = HeapObject::FromAddress(old_top); |
+ HeapObject* obj = HeapObject::FromAddress(old_top); |
allocation_info_.top += size_in_bytes; |
ASSERT_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_); |
+ HeapProfiler* profiler = heap()->isolate()->heap_profiler(); |
+ if (profiler->is_tracking_allocations()) { |
+ profiler->NewObjectEvent(obj->address(), size_in_bytes); |
+ } |
+ |
return obj; |
} |