| OLD | NEW | 
|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "src/v8.h" | 5 #include "src/v8.h" | 
| 6 | 6 | 
| 7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" | 
| 8 #include "src/base/platform/platform.h" | 8 #include "src/base/platform/platform.h" | 
| 9 #include "src/full-codegen.h" | 9 #include "src/full-codegen.h" | 
| 10 #include "src/heap/mark-compact.h" | 10 #include "src/heap/mark-compact.h" | 
| (...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 868   // We are guarding code pages: the last OS page will be protected as | 868   // We are guarding code pages: the last OS page will be protected as | 
| 869   // non-writable. | 869   // non-writable. | 
| 870   return Page::kPageSize - static_cast<int>(base::OS::CommitPageSize()); | 870   return Page::kPageSize - static_cast<int>(base::OS::CommitPageSize()); | 
| 871 } | 871 } | 
| 872 | 872 | 
| 873 | 873 | 
| 874 bool MemoryAllocator::CommitExecutableMemory(base::VirtualMemory* vm, | 874 bool MemoryAllocator::CommitExecutableMemory(base::VirtualMemory* vm, | 
| 875                                              Address start, size_t commit_size, | 875                                              Address start, size_t commit_size, | 
| 876                                              size_t reserved_size) { | 876                                              size_t reserved_size) { | 
| 877   // Commit page header (not executable). | 877   // Commit page header (not executable). | 
| 878   if (!vm->Commit(start, CodePageGuardStartOffset(), false)) { | 878   Address header = start; | 
| 879     return false; | 879   size_t header_size = CodePageGuardStartOffset(); | 
|  | 880   if (vm->Commit(header, header_size, false)) { | 
|  | 881     // Create guard page after the header. | 
|  | 882     if (vm->Guard(start + CodePageGuardStartOffset())) { | 
|  | 883       // Commit page body (executable). | 
|  | 884       Address body = start + CodePageAreaStartOffset(); | 
|  | 885       size_t body_size = commit_size - CodePageGuardStartOffset(); | 
|  | 886       if (vm->Commit(body, body_size, true)) { | 
|  | 887         // Create guard page before the end. | 
|  | 888         if (vm->Guard(start + reserved_size - CodePageGuardSize())) { | 
|  | 889           UpdateAllocatedSpaceLimits(start, start + CodePageAreaStartOffset() + | 
|  | 890                                                 commit_size - | 
|  | 891                                                 CodePageGuardStartOffset()); | 
|  | 892           return true; | 
|  | 893         } | 
|  | 894         vm->Uncommit(body, body_size); | 
|  | 895       } | 
|  | 896     } | 
|  | 897     vm->Uncommit(header, header_size); | 
| 880   } | 898   } | 
| 881 | 899   return false; | 
| 882   // Create guard page after the header. |  | 
| 883   if (!vm->Guard(start + CodePageGuardStartOffset())) { |  | 
| 884     return false; |  | 
| 885   } |  | 
| 886 |  | 
| 887   // Commit page body (executable). |  | 
| 888   if (!vm->Commit(start + CodePageAreaStartOffset(), |  | 
| 889                   commit_size - CodePageGuardStartOffset(), true)) { |  | 
| 890     return false; |  | 
| 891   } |  | 
| 892 |  | 
| 893   // Create guard page before the end. |  | 
| 894   if (!vm->Guard(start + reserved_size - CodePageGuardSize())) { |  | 
| 895     return false; |  | 
| 896   } |  | 
| 897 |  | 
| 898   UpdateAllocatedSpaceLimits(start, start + CodePageAreaStartOffset() + |  | 
| 899                                         commit_size - |  | 
| 900                                         CodePageGuardStartOffset()); |  | 
| 901   return true; |  | 
| 902 } | 900 } | 
| 903 | 901 | 
| 904 | 902 | 
| 905 // ----------------------------------------------------------------------------- | 903 // ----------------------------------------------------------------------------- | 
| 906 // MemoryChunk implementation | 904 // MemoryChunk implementation | 
| 907 | 905 | 
| 908 void MemoryChunk::IncrementLiveBytesFromMutator(Address address, int by) { | 906 void MemoryChunk::IncrementLiveBytesFromMutator(Address address, int by) { | 
| 909   MemoryChunk* chunk = MemoryChunk::FromAddress(address); | 907   MemoryChunk* chunk = MemoryChunk::FromAddress(address); | 
| 910   if (!chunk->InNewSpace() && !static_cast<Page*>(chunk)->WasSwept()) { | 908   if (!chunk->InNewSpace() && !static_cast<Page*>(chunk)->WasSwept()) { | 
| 911     static_cast<PagedSpace*>(chunk->owner())->IncrementUnsweptFreeBytes(-by); | 909     static_cast<PagedSpace*>(chunk->owner())->IncrementUnsweptFreeBytes(-by); | 
| (...skipping 2212 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3124     object->ShortPrint(); | 3122     object->ShortPrint(); | 
| 3125     PrintF("\n"); | 3123     PrintF("\n"); | 
| 3126   } | 3124   } | 
| 3127   printf(" --------------------------------------\n"); | 3125   printf(" --------------------------------------\n"); | 
| 3128   printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3126   printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 
| 3129 } | 3127 } | 
| 3130 | 3128 | 
| 3131 #endif  // DEBUG | 3129 #endif  // DEBUG | 
| 3132 } | 3130 } | 
| 3133 }  // namespace v8::internal | 3131 }  // namespace v8::internal | 
| OLD | NEW | 
|---|