OLD | NEW |
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 List<Block> blocks(1000); | 188 List<Block> blocks(1000); |
189 | 189 |
190 while (total_allocated < 5 * code_range_size) { | 190 while (total_allocated < 5 * code_range_size) { |
191 if (current_allocated < code_range_size / 10) { | 191 if (current_allocated < code_range_size / 10) { |
192 // Allocate a block. | 192 // Allocate a block. |
193 // Geometrically distributed sizes, greater than Page::kPageSize. | 193 // Geometrically distributed sizes, greater than Page::kPageSize. |
194 size_t requested = (Page::kPageSize << (Pseudorandom() % 6)) + | 194 size_t requested = (Page::kPageSize << (Pseudorandom() % 6)) + |
195 Pseudorandom() % 5000 + 1; | 195 Pseudorandom() % 5000 + 1; |
196 size_t allocated = 0; | 196 size_t allocated = 0; |
197 void* base = CodeRange::AllocateRawMemory(requested, &allocated); | 197 void* base = CodeRange::AllocateRawMemory(requested, &allocated); |
198 blocks.Add(Block(base, allocated)); | 198 blocks.Add(Block(base, static_cast<int>(allocated))); |
199 current_allocated += allocated; | 199 current_allocated += static_cast<int>(allocated); |
200 total_allocated += allocated; | 200 total_allocated += static_cast<int>(allocated); |
201 } else { | 201 } else { |
202 // Free a block. | 202 // Free a block. |
203 int index = Pseudorandom() % blocks.length(); | 203 int index = Pseudorandom() % blocks.length(); |
204 CodeRange::FreeRawMemory(blocks[index].base, blocks[index].size); | 204 CodeRange::FreeRawMemory(blocks[index].base, blocks[index].size); |
205 current_allocated -= blocks[index].size; | 205 current_allocated -= blocks[index].size; |
206 if (index < blocks.length() - 1) { | 206 if (index < blocks.length() - 1) { |
207 blocks[index] = blocks.RemoveLast(); | 207 blocks[index] = blocks.RemoveLast(); |
208 } else { | 208 } else { |
209 blocks.RemoveLast(); | 209 blocks.RemoveLast(); |
210 } | 210 } |
211 } | 211 } |
212 } | 212 } |
213 | 213 |
214 CodeRange::TearDown(); | 214 CodeRange::TearDown(); |
215 } | 215 } |
OLD | NEW |