| 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 | 193 |
| 194 while (total_allocated < 5 * code_range_size) { | 194 while (total_allocated < 5 * code_range_size) { |
| 195 if (current_allocated < code_range_size / 10) { | 195 if (current_allocated < code_range_size / 10) { |
| 196 // Allocate a block. | 196 // Allocate a block. |
| 197 // Geometrically distributed sizes, greater than Page::kPageSize. | 197 // Geometrically distributed sizes, greater than Page::kPageSize. |
| 198 size_t requested = (Page::kPageSize << (Pseudorandom() % 6)) + | 198 size_t requested = (Page::kPageSize << (Pseudorandom() % 6)) + |
| 199 Pseudorandom() % 5000 + 1; | 199 Pseudorandom() % 5000 + 1; |
| 200 size_t allocated = 0; | 200 size_t allocated = 0; |
| 201 void* base = Isolate::Current()->code_range()-> | 201 void* base = Isolate::Current()->code_range()-> |
| 202 AllocateRawMemory(requested, &allocated); | 202 AllocateRawMemory(requested, &allocated); |
| 203 CHECK(base != NULL); |
| 203 blocks.Add(Block(base, static_cast<int>(allocated))); | 204 blocks.Add(Block(base, static_cast<int>(allocated))); |
| 204 current_allocated += static_cast<int>(allocated); | 205 current_allocated += static_cast<int>(allocated); |
| 205 total_allocated += static_cast<int>(allocated); | 206 total_allocated += static_cast<int>(allocated); |
| 206 } else { | 207 } else { |
| 207 // Free a block. | 208 // Free a block. |
| 208 int index = Pseudorandom() % blocks.length(); | 209 int index = Pseudorandom() % blocks.length(); |
| 209 Isolate::Current()->code_range()->FreeRawMemory( | 210 Isolate::Current()->code_range()->FreeRawMemory( |
| 210 blocks[index].base, blocks[index].size); | 211 blocks[index].base, blocks[index].size); |
| 211 current_allocated -= blocks[index].size; | 212 current_allocated -= blocks[index].size; |
| 212 if (index < blocks.length() - 1) { | 213 if (index < blocks.length() - 1) { |
| 213 blocks[index] = blocks.RemoveLast(); | 214 blocks[index] = blocks.RemoveLast(); |
| 214 } else { | 215 } else { |
| 215 blocks.RemoveLast(); | 216 blocks.RemoveLast(); |
| 216 } | 217 } |
| 217 } | 218 } |
| 218 } | 219 } |
| 219 | 220 |
| 220 Isolate::Current()->code_range()->TearDown(); | 221 Isolate::Current()->code_range()->TearDown(); |
| 221 } | 222 } |
| OLD | NEW |