| Index: src/spaces.cc
|
| diff --git a/src/spaces.cc b/src/spaces.cc
|
| index e62d381a18399242cefb7c8877c0e57a322b74c8..13f80d81a87b4f3939a3b6fb3c04809f7cd7c1aa 100644
|
| --- a/src/spaces.cc
|
| +++ b/src/spaces.cc
|
| @@ -228,10 +228,10 @@ Address CodeRange::AllocateRawMemory(const size_t requested_size,
|
| }
|
| ASSERT(*allocated <= current.size);
|
| ASSERT(IsAddressAligned(current.start, MemoryChunk::kAlignment));
|
| - if (!MemoryAllocator::CommitExecutableMemory(code_range_,
|
| - current.start,
|
| - commit_size,
|
| - *allocated)) {
|
| + if (!isolate_->memory_allocator()->CommitExecutableMemory(code_range_,
|
| + current.start,
|
| + commit_size,
|
| + *allocated)) {
|
| *allocated = 0;
|
| return NULL;
|
| }
|
| @@ -245,7 +245,7 @@ Address CodeRange::AllocateRawMemory(const size_t requested_size,
|
|
|
|
|
| bool CodeRange::CommitRawMemory(Address start, size_t length) {
|
| - return code_range_->Commit(start, length, true);
|
| + return isolate_->memory_allocator()->CommitMemory(start, length, EXECUTABLE);
|
| }
|
|
|
|
|
| @@ -278,7 +278,9 @@ MemoryAllocator::MemoryAllocator(Isolate* isolate)
|
| capacity_(0),
|
| capacity_executable_(0),
|
| size_(0),
|
| - size_executable_(0) {
|
| + size_executable_(0),
|
| + lowest_ever_allocated_(reinterpret_cast<void*>(-1)),
|
| + highest_ever_allocated_(reinterpret_cast<void*>(0)) {
|
| }
|
|
|
|
|
| @@ -304,6 +306,17 @@ void MemoryAllocator::TearDown() {
|
| }
|
|
|
|
|
| +bool MemoryAllocator::CommitMemory(Address base,
|
| + size_t size,
|
| + Executability executable) {
|
| + if (!VirtualMemory::CommitRegion(base, size, executable == EXECUTABLE)) {
|
| + return false;
|
| + }
|
| + UpdateAllocatedSpaceLimits(base, base + size);
|
| + return true;
|
| +}
|
| +
|
| +
|
| void MemoryAllocator::FreeMemory(VirtualMemory* reservation,
|
| Executability executable) {
|
| // TODO(gc) make code_range part of memory allocator?
|
| @@ -383,7 +396,9 @@ Address MemoryAllocator::AllocateAlignedMemory(size_t reserve_size,
|
| base = NULL;
|
| }
|
| } else {
|
| - if (!reservation.Commit(base, commit_size, false)) {
|
| + if (reservation.Commit(base, commit_size, false)) {
|
| + UpdateAllocatedSpaceLimits(base, base + commit_size);
|
| + } else {
|
| base = NULL;
|
| }
|
| }
|
| @@ -509,7 +524,10 @@ bool MemoryChunk::CommitArea(size_t requested) {
|
| Address start = address() + committed_size + guard_size;
|
| size_t length = commit_size - committed_size;
|
| if (reservation_.IsReserved()) {
|
| - if (!reservation_.Commit(start, length, IsFlagSet(IS_EXECUTABLE))) {
|
| + Executability executable = IsFlagSet(IS_EXECUTABLE)
|
| + ? EXECUTABLE : NOT_EXECUTABLE;
|
| + if (!heap()->isolate()->memory_allocator()->CommitMemory(
|
| + start, length, executable)) {
|
| return false;
|
| }
|
| } else {
|
| @@ -763,7 +781,7 @@ void MemoryAllocator::Free(MemoryChunk* chunk) {
|
| bool MemoryAllocator::CommitBlock(Address start,
|
| size_t size,
|
| Executability executable) {
|
| - if (!VirtualMemory::CommitRegion(start, size, executable)) return false;
|
| + if (!CommitMemory(start, size, executable)) return false;
|
|
|
| if (Heap::ShouldZapGarbage()) {
|
| ZapBlock(start, size);
|
| @@ -899,6 +917,9 @@ bool MemoryAllocator::CommitExecutableMemory(VirtualMemory* vm,
|
| return false;
|
| }
|
|
|
| + UpdateAllocatedSpaceLimits(start,
|
| + start + CodePageAreaStartOffset() +
|
| + commit_size - CodePageGuardStartOffset());
|
| return true;
|
| }
|
|
|
| @@ -1777,8 +1798,7 @@ void SemiSpaceIterator::Initialize(Address start,
|
|
|
| #ifdef DEBUG
|
| // heap_histograms is shared, always clear it before using it.
|
| -static void ClearHistograms() {
|
| - Isolate* isolate = Isolate::Current();
|
| +static void ClearHistograms(Isolate* isolate) {
|
| // We reset the name each time, though it hasn't changed.
|
| #define DEF_TYPE_NAME(name) isolate->heap_histograms()[name].set_name(#name);
|
| INSTANCE_TYPE_LIST(DEF_TYPE_NAME)
|
| @@ -1829,8 +1849,7 @@ static int CollectHistogramInfo(HeapObject* obj) {
|
| }
|
|
|
|
|
| -static void ReportHistogram(bool print_spill) {
|
| - Isolate* isolate = Isolate::Current();
|
| +static void ReportHistogram(Isolate* isolate, bool print_spill) {
|
| PrintF("\n Object Histogram:\n");
|
| for (int i = 0; i <= LAST_TYPE; i++) {
|
| if (isolate->heap_histograms()[i].number() > 0) {
|
| @@ -2685,8 +2704,7 @@ HeapObject* PagedSpace::SlowAllocateRaw(int size_in_bytes) {
|
|
|
|
|
| #ifdef DEBUG
|
| -void PagedSpace::ReportCodeStatistics() {
|
| - Isolate* isolate = Isolate::Current();
|
| +void PagedSpace::ReportCodeStatistics(Isolate* isolate) {
|
| CommentStatistic* comments_statistics =
|
| isolate->paged_space_comments_statistics();
|
| ReportCodeKindStatistics(isolate->code_kind_statistics());
|
| @@ -2703,8 +2721,7 @@ void PagedSpace::ReportCodeStatistics() {
|
| }
|
|
|
|
|
| -void PagedSpace::ResetCodeStatistics() {
|
| - Isolate* isolate = Isolate::Current();
|
| +void PagedSpace::ResetCodeStatistics(Isolate* isolate) {
|
| CommentStatistic* comments_statistics =
|
| isolate->paged_space_comments_statistics();
|
| ClearCodeKindStatistics(isolate->code_kind_statistics());
|
| @@ -2819,11 +2836,11 @@ void PagedSpace::ReportStatistics() {
|
| Capacity(), Waste(), Available(), pct);
|
|
|
| if (was_swept_conservatively_) return;
|
| - ClearHistograms();
|
| + ClearHistograms(heap()->isolate());
|
| HeapObjectIterator obj_it(this);
|
| for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next())
|
| CollectHistogramInfo(obj);
|
| - ReportHistogram(true);
|
| + ReportHistogram(heap()->isolate(), true);
|
| }
|
| #endif
|
|
|
| @@ -3160,7 +3177,7 @@ void LargeObjectSpace::Print() {
|
| void LargeObjectSpace::ReportStatistics() {
|
| PrintF(" size: %" V8_PTR_PREFIX "d\n", size_);
|
| int num_objects = 0;
|
| - ClearHistograms();
|
| + ClearHistograms(heap()->isolate());
|
| LargeObjectIterator it(this);
|
| for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) {
|
| num_objects++;
|
| @@ -3169,7 +3186,7 @@ void LargeObjectSpace::ReportStatistics() {
|
|
|
| PrintF(" number of objects %d, "
|
| "size of objects %" V8_PTR_PREFIX "d\n", num_objects, objects_size_);
|
| - if (num_objects > 0) ReportHistogram(false);
|
| + if (num_objects > 0) ReportHistogram(heap()->isolate(), false);
|
| }
|
|
|
|
|
|
|