OLD | NEW |
1 // Copyright (c) 2014, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dartino 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 #include "src/shared/assert.h" | 5 #include "src/shared/assert.h" |
6 #include "src/vm/heap.h" | 6 #include "src/vm/heap.h" |
7 #include "src/vm/object_memory.h" | 7 #include "src/vm/object_memory.h" |
8 #include "src/shared/test_case.h" | 8 #include "src/shared/test_case.h" |
9 | 9 |
10 namespace fletch { | 10 namespace dartino { |
11 | 11 |
12 static Chunk* AllocateChunkAndTestIt(SemiSpace* space) { | 12 static Chunk* AllocateChunkAndTestIt(SemiSpace* space) { |
13 // Allocate chunk. | 13 // Allocate chunk. |
14 Chunk* chunk = ObjectMemory::AllocateChunk(space, 4 * KB); | 14 Chunk* chunk = ObjectMemory::AllocateChunk(space, 4 * KB); |
15 EXPECT(chunk->base() != 0); | 15 EXPECT(chunk->base() != 0); |
16 | 16 |
17 // Write to the chunk and check the content. | 17 // Write to the chunk and check the content. |
18 char* chars = reinterpret_cast<char*>(chunk->base()); | 18 char* chars = reinterpret_cast<char*>(chunk->base()); |
19 for (unsigned i = 0; i < chunk->size(); i++) { | 19 for (unsigned i = 0; i < chunk->size(); i++) { |
20 chars[i] = i % 128; | 20 chars[i] = i % 128; |
(...skipping 10 matching lines...) Expand all Loading... |
31 Chunk* second = AllocateChunkAndTestIt(&space); | 31 Chunk* second = AllocateChunkAndTestIt(&space); |
32 | 32 |
33 // Compare. | 33 // Compare. |
34 EXPECT(first != second); | 34 EXPECT(first != second); |
35 | 35 |
36 // Free. | 36 // Free. |
37 ObjectMemory::FreeChunk(first); | 37 ObjectMemory::FreeChunk(first); |
38 ObjectMemory::FreeChunk(second); | 38 ObjectMemory::FreeChunk(second); |
39 } | 39 } |
40 | 40 |
41 } // namespace fletch | 41 } // namespace dartino |
OLD | NEW |