| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/assert.h" | 5 #include "platform/assert.h" |
| 6 #include "vm/freelist.h" | 6 #include "vm/freelist.h" |
| 7 #include "vm/unit_test.h" | 7 #include "vm/unit_test.h" |
| 8 | 8 |
| 9 namespace dart { | 9 namespace dart { |
| 10 | 10 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 delete[] objects; | 152 delete[] objects; |
| 153 } | 153 } |
| 154 | 154 |
| 155 | 155 |
| 156 TEST_CASE(FreeListProtectedVariableSizeObjects) { | 156 TEST_CASE(FreeListProtectedVariableSizeObjects) { |
| 157 FreeList* free_list = new FreeList(); | 157 FreeList* free_list = new FreeList(); |
| 158 const intptr_t kBlobSize = 8 * KB; | 158 const intptr_t kBlobSize = 8 * KB; |
| 159 const intptr_t kMinSize = 2 * kWordSize; | 159 const intptr_t kMinSize = 2 * kWordSize; |
| 160 uword* objects = new uword[kBlobSize / kMinSize]; | 160 uword* objects = new uword[kBlobSize / kMinSize]; |
| 161 for (intptr_t i = 0; i < kBlobSize / kMinSize; ++i) { | 161 for (intptr_t i = 0; i < kBlobSize / kMinSize; ++i) { |
| 162 objects[i] = NULL; | 162 objects[i] = static_cast<uword>(NULL); |
| 163 } | 163 } |
| 164 | 164 |
| 165 VirtualMemory* blob = VirtualMemory::ReserveAligned(kBlobSize, 4096); | 165 VirtualMemory* blob = VirtualMemory::ReserveAligned(kBlobSize, 4096); |
| 166 blob->Commit(/* is_executable = */ false); | 166 blob->Commit(/* is_executable = */ false); |
| 167 blob->Protect(VirtualMemory::kReadWrite); | 167 blob->Protect(VirtualMemory::kReadWrite); |
| 168 | 168 |
| 169 // Enqueue the large blob as one free block. | 169 // Enqueue the large blob as one free block. |
| 170 free_list->Free(blob->start(), blob->size()); | 170 free_list->Free(blob->start(), blob->size()); |
| 171 | 171 |
| 172 // Write protect the whole region. | 172 // Write protect the whole region. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 187 e0 = Allocate(free_list, 3 * KB - 2 * kWordSize, true); | 187 e0 = Allocate(free_list, 3 * KB - 2 * kWordSize, true); |
| 188 ASSERT(e0); | 188 ASSERT(e0); |
| 189 | 189 |
| 190 // Delete the memory associated with the test. | 190 // Delete the memory associated with the test. |
| 191 delete blob; | 191 delete blob; |
| 192 delete free_list; | 192 delete free_list; |
| 193 delete[] objects; | 193 delete[] objects; |
| 194 } | 194 } |
| 195 | 195 |
| 196 } // namespace dart | 196 } // namespace dart |
| OLD | NEW |