| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 // When a target requires the code range feature, we put all code objects | 103 // When a target requires the code range feature, we put all code objects |
| 104 // in a kMaximalCodeRangeSize range of virtual address space, so that | 104 // in a kMaximalCodeRangeSize range of virtual address space, so that |
| 105 // they can call each other with near calls. | 105 // they can call each other with near calls. |
| 106 if (kRequiresCodeRange) { | 106 if (kRequiresCodeRange) { |
| 107 requested = kMaximalCodeRangeSize; | 107 requested = kMaximalCodeRangeSize; |
| 108 } else { | 108 } else { |
| 109 return true; | 109 return true; |
| 110 } | 110 } |
| 111 } | 111 } |
| 112 | 112 |
| 113 if (requested < kMinimumCodeRangeSize) { |
| 114 requested = kMinimumCodeRangeSize; |
| 115 } |
| 116 |
| 113 DCHECK(!kRequiresCodeRange || requested <= kMaximalCodeRangeSize); | 117 DCHECK(!kRequiresCodeRange || requested <= kMaximalCodeRangeSize); |
| 114 code_range_ = new base::VirtualMemory(requested); | 118 code_range_ = new base::VirtualMemory(requested); |
| 115 CHECK(code_range_ != NULL); | 119 CHECK(code_range_ != NULL); |
| 116 if (!code_range_->IsReserved()) { | 120 if (!code_range_->IsReserved()) { |
| 117 delete code_range_; | 121 delete code_range_; |
| 118 code_range_ = NULL; | 122 code_range_ = NULL; |
| 119 return false; | 123 return false; |
| 120 } | 124 } |
| 121 | 125 |
| 122 // We are sure that we have mapped a block of requested addresses. | 126 // We are sure that we have mapped a block of requested addresses. |
| 123 DCHECK(code_range_->size() == requested); | 127 DCHECK(code_range_->size() == requested); |
| 124 LOG(isolate_, NewEvent("CodeRange", code_range_->address(), requested)); | |
| 125 Address base = reinterpret_cast<Address>(code_range_->address()); | 128 Address base = reinterpret_cast<Address>(code_range_->address()); |
| 126 Address aligned_base = | 129 |
| 127 RoundUp(reinterpret_cast<Address>(code_range_->address()), | 130 // On some platforms, specifically Win64, we need to reserve some pages at |
| 128 MemoryChunk::kAlignment); | 131 // the beginning of an executable space. |
| 132 if (kReservedCodeRangePages) { |
| 133 if (!code_range_->Commit( |
| 134 base, kReservedCodeRangePages * base::OS::CommitPageSize(), true)) { |
| 135 delete code_range_; |
| 136 code_range_ = NULL; |
| 137 return false; |
| 138 } |
| 139 base += kReservedCodeRangePages * base::OS::CommitPageSize(); |
| 140 } |
| 141 Address aligned_base = RoundUp(base, MemoryChunk::kAlignment); |
| 129 size_t size = code_range_->size() - (aligned_base - base); | 142 size_t size = code_range_->size() - (aligned_base - base); |
| 130 allocation_list_.Add(FreeBlock(aligned_base, size)); | 143 allocation_list_.Add(FreeBlock(aligned_base, size)); |
| 131 current_allocation_block_index_ = 0; | 144 current_allocation_block_index_ = 0; |
| 145 |
| 146 LOG(isolate_, NewEvent("CodeRange", code_range_->address(), requested)); |
| 132 return true; | 147 return true; |
| 133 } | 148 } |
| 134 | 149 |
| 135 | 150 |
| 136 int CodeRange::CompareFreeBlockAddress(const FreeBlock* left, | 151 int CodeRange::CompareFreeBlockAddress(const FreeBlock* left, |
| 137 const FreeBlock* right) { | 152 const FreeBlock* right) { |
| 138 // The entire point of CodeRange is that the difference between two | 153 // The entire point of CodeRange is that the difference between two |
| 139 // addresses in the range can be represented as a signed 32-bit int, | 154 // addresses in the range can be represented as a signed 32-bit int, |
| 140 // so the cast is semantically correct. | 155 // so the cast is semantically correct. |
| 141 return static_cast<int>(left->start - right->start); | 156 return static_cast<int>(left->start - right->start); |
| (...skipping 2954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3096 object->ShortPrint(); | 3111 object->ShortPrint(); |
| 3097 PrintF("\n"); | 3112 PrintF("\n"); |
| 3098 } | 3113 } |
| 3099 printf(" --------------------------------------\n"); | 3114 printf(" --------------------------------------\n"); |
| 3100 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3115 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
| 3101 } | 3116 } |
| 3102 | 3117 |
| 3103 #endif // DEBUG | 3118 #endif // DEBUG |
| 3104 } | 3119 } |
| 3105 } // namespace v8::internal | 3120 } // namespace v8::internal |
| OLD | NEW |