OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 if (current_allocated < code_range_size / 10) { | 197 if (current_allocated < code_range_size / 10) { |
198 // Allocate a block. | 198 // Allocate a block. |
199 // Geometrically distributed sizes, greater than | 199 // Geometrically distributed sizes, greater than |
200 // Page::kMaxNonCodeHeapObjectSize (which is greater than code page area). | 200 // Page::kMaxNonCodeHeapObjectSize (which is greater than code page area). |
201 // TODO(gc): instead of using 3 use some contant based on code_range_size | 201 // TODO(gc): instead of using 3 use some contant based on code_range_size |
202 // kMaxHeapObjectSize. | 202 // kMaxHeapObjectSize. |
203 size_t requested = | 203 size_t requested = |
204 (Page::kMaxNonCodeHeapObjectSize << (Pseudorandom() % 3)) + | 204 (Page::kMaxNonCodeHeapObjectSize << (Pseudorandom() % 3)) + |
205 Pseudorandom() % 5000 + 1; | 205 Pseudorandom() % 5000 + 1; |
206 size_t allocated = 0; | 206 size_t allocated = 0; |
207 Address base = code_range->AllocateRawMemory(requested, &allocated); | 207 Address base = code_range->AllocateRawMemory(requested, |
| 208 requested, |
| 209 &allocated); |
208 CHECK(base != NULL); | 210 CHECK(base != NULL); |
209 blocks.Add(Block(base, static_cast<int>(allocated))); | 211 blocks.Add(Block(base, static_cast<int>(allocated))); |
210 current_allocated += static_cast<int>(allocated); | 212 current_allocated += static_cast<int>(allocated); |
211 total_allocated += static_cast<int>(allocated); | 213 total_allocated += static_cast<int>(allocated); |
212 } else { | 214 } else { |
213 // Free a block. | 215 // Free a block. |
214 int index = Pseudorandom() % blocks.length(); | 216 int index = Pseudorandom() % blocks.length(); |
215 code_range->FreeRawMemory(blocks[index].base, blocks[index].size); | 217 code_range->FreeRawMemory(blocks[index].base, blocks[index].size); |
216 current_allocated -= blocks[index].size; | 218 current_allocated -= blocks[index].size; |
217 if (index < blocks.length() - 1) { | 219 if (index < blocks.length() - 1) { |
218 blocks[index] = blocks.RemoveLast(); | 220 blocks[index] = blocks.RemoveLast(); |
219 } else { | 221 } else { |
220 blocks.RemoveLast(); | 222 blocks.RemoveLast(); |
221 } | 223 } |
222 } | 224 } |
223 } | 225 } |
224 | 226 |
225 code_range->TearDown(); | 227 code_range->TearDown(); |
226 delete code_range; | 228 delete code_range; |
227 } | 229 } |
OLD | NEW |