| 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/unit_test.h" | 6 #include "vm/unit_test.h" |
| 7 #include "vm/virtual_memory.h" | 7 #include "vm/virtual_memory.h" |
| 8 | 8 |
| 9 namespace dart { | 9 namespace dart { |
| 10 | 10 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 delete vm; | 69 delete vm; |
| 70 } | 70 } |
| 71 for (intptr_t i = 0; i < kIterations; ++i) { | 71 for (intptr_t i = 0; i < kIterations; ++i) { |
| 72 VirtualMemory* vm = VirtualMemory::Reserve(kVirtualMemoryBlockSize); | 72 VirtualMemory* vm = VirtualMemory::Reserve(kVirtualMemoryBlockSize); |
| 73 vm->Commit(false); | 73 vm->Commit(false); |
| 74 vm->Truncate(0, false); | 74 vm->Truncate(0, false); |
| 75 delete vm; | 75 delete vm; |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 | 78 |
| 79 |
| 80 UNIT_TEST_CASE(VirtualMemoryCommitPartial) { |
| 81 const intptr_t kVirtualMemoryBlockSize = 3 * MB; |
| 82 VirtualMemory* vm = VirtualMemory::Reserve(kVirtualMemoryBlockSize); |
| 83 EXPECT(vm != NULL); |
| 84 // Commit only the middle MB and write to it. |
| 85 const uword commit_start = vm->start() + (1 * MB); |
| 86 const intptr_t kCommitSize = 1 * MB; |
| 87 vm->Commit(commit_start, kCommitSize, false); |
| 88 char* buf = reinterpret_cast<char*>(commit_start); |
| 89 buf[0] = 'f'; |
| 90 buf[1] = 'o'; |
| 91 buf[2] = 'o'; |
| 92 buf[3] = 0; |
| 93 EXPECT_STREQ("foo", buf); |
| 94 delete vm; |
| 95 } |
| 96 |
| 79 } // namespace dart | 97 } // namespace dart |
| OLD | NEW |