| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 isolate->InitializeLoggingAndCounters(); | 208 isolate->InitializeLoggingAndCounters(); |
| 209 Heap* heap = isolate->heap(); | 209 Heap* heap = isolate->heap(); |
| 210 CHECK(heap->ConfigureHeapDefault()); | 210 CHECK(heap->ConfigureHeapDefault()); |
| 211 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); | 211 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); |
| 212 CHECK( | 212 CHECK( |
| 213 memory_allocator->SetUp(heap->MaxReserved(), heap->MaxExecutableSize())); | 213 memory_allocator->SetUp(heap->MaxReserved(), heap->MaxExecutableSize())); |
| 214 TestMemoryAllocatorScope test_allocator_scope(isolate, memory_allocator); | 214 TestMemoryAllocatorScope test_allocator_scope(isolate, memory_allocator); |
| 215 CodeRange* code_range = new CodeRange(isolate); | 215 CodeRange* code_range = new CodeRange(isolate); |
| 216 const size_t code_range_size = 4 * MB; | 216 const size_t code_range_size = 4 * MB; |
| 217 if (!code_range->SetUp(code_range_size)) return; | 217 if (!code_range->SetUp(code_range_size)) return; |
| 218 size_t allocated_size; | 218 Address address; |
| 219 Address result; | 219 size_t size; |
| 220 for (int i = 0; i < 5; i++) { | 220 address = code_range->AllocateRawMemory(code_range_size - MB, |
| 221 result = code_range->AllocateRawMemory( | 221 code_range_size - MB, &size); |
| 222 code_range_size - MB, code_range_size - MB, &allocated_size); | 222 CHECK(address != NULL); |
| 223 CHECK((result != NULL) == (i == 0)); | 223 Address null_address; |
| 224 } | 224 size_t null_size; |
| 225 null_address = code_range->AllocateRawMemory( |
| 226 code_range_size - MB, code_range_size - MB, &null_size); |
| 227 CHECK(null_address == NULL); |
| 228 code_range->FreeRawMemory(address, size); |
| 229 delete code_range; |
| 230 memory_allocator->TearDown(); |
| 231 delete memory_allocator; |
| 225 } | 232 } |
| 226 | 233 |
| 227 | 234 |
| 228 static unsigned int Pseudorandom() { | 235 static unsigned int Pseudorandom() { |
| 229 static uint32_t lo = 2345; | 236 static uint32_t lo = 2345; |
| 230 lo = 18273 * (lo & 0xFFFFF) + (lo >> 16); | 237 lo = 18273 * (lo & 0xFFFFF) + (lo >> 16); |
| 231 return lo & 0xFFFFF; | 238 return lo & 0xFFFFF; |
| 232 } | 239 } |
| 233 | 240 |
| 234 | 241 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 CompileRun("/*empty*/"); | 453 CompileRun("/*empty*/"); |
| 447 for (int i = FIRST_PAGED_SPACE; i <= LAST_PAGED_SPACE; i++) { | 454 for (int i = FIRST_PAGED_SPACE; i <= LAST_PAGED_SPACE; i++) { |
| 448 // Debug code can be very large, so skip CODE_SPACE if we are generating it. | 455 // Debug code can be very large, so skip CODE_SPACE if we are generating it. |
| 449 if (i == CODE_SPACE && i::FLAG_debug_code) continue; | 456 if (i == CODE_SPACE && i::FLAG_debug_code) continue; |
| 450 CHECK_EQ(1, isolate->heap()->paged_space(i)->CountTotalPages()); | 457 CHECK_EQ(1, isolate->heap()->paged_space(i)->CountTotalPages()); |
| 451 } | 458 } |
| 452 | 459 |
| 453 // No large objects required to perform the above steps. | 460 // No large objects required to perform the above steps. |
| 454 CHECK(isolate->heap()->lo_space()->IsEmpty()); | 461 CHECK(isolate->heap()->lo_space()->IsEmpty()); |
| 455 } | 462 } |
| OLD | NEW |