| 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 Block(void* base_arg, int size_arg) | 178 Block(void* base_arg, int size_arg) |
| 179 : base(base_arg), size(size_arg) {} | 179 : base(base_arg), size(size_arg) {} |
| 180 | 180 |
| 181 void *base; | 181 void *base; |
| 182 int size; | 182 int size; |
| 183 }; | 183 }; |
| 184 | 184 |
| 185 | 185 |
| 186 TEST(CodeRange) { | 186 TEST(CodeRange) { |
| 187 const int code_range_size = 16*MB; | 187 const int code_range_size = 16*MB; |
| 188 OS::Setup(); |
| 188 Isolate::Current()->code_range()->Setup(code_range_size); | 189 Isolate::Current()->code_range()->Setup(code_range_size); |
| 189 int current_allocated = 0; | 190 int current_allocated = 0; |
| 190 int total_allocated = 0; | 191 int total_allocated = 0; |
| 191 List<Block> blocks(1000); | 192 List<Block> blocks(1000); |
| 192 | 193 |
| 193 while (total_allocated < 5 * code_range_size) { | 194 while (total_allocated < 5 * code_range_size) { |
| 194 if (current_allocated < code_range_size / 10) { | 195 if (current_allocated < code_range_size / 10) { |
| 195 // Allocate a block. | 196 // Allocate a block. |
| 196 // Geometrically distributed sizes, greater than Page::kPageSize. | 197 // Geometrically distributed sizes, greater than Page::kPageSize. |
| 197 size_t requested = (Page::kPageSize << (Pseudorandom() % 6)) + | 198 size_t requested = (Page::kPageSize << (Pseudorandom() % 6)) + |
| (...skipping 13 matching lines...) Expand all Loading... |
| 211 if (index < blocks.length() - 1) { | 212 if (index < blocks.length() - 1) { |
| 212 blocks[index] = blocks.RemoveLast(); | 213 blocks[index] = blocks.RemoveLast(); |
| 213 } else { | 214 } else { |
| 214 blocks.RemoveLast(); | 215 blocks.RemoveLast(); |
| 215 } | 216 } |
| 216 } | 217 } |
| 217 } | 218 } |
| 218 | 219 |
| 219 Isolate::Current()->code_range()->TearDown(); | 220 Isolate::Current()->code_range()->TearDown(); |
| 220 } | 221 } |
| OLD | NEW |