| 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 TestMemoryAllocatorScope test_allocator_scope(isolate, memory_allocator); | 215 TestMemoryAllocatorScope test_allocator_scope(isolate, memory_allocator); |
| 216 CodeRange* code_range = new CodeRange(isolate); | 216 CodeRange* code_range = new CodeRange(isolate); |
| 217 const size_t code_range_size = 4 * pageSize; | 217 const size_t code_range_size = 4 * pageSize; |
| 218 if (!code_range->SetUp( | 218 if (!code_range->SetUp( |
| 219 code_range_size + | 219 code_range_size + |
| 220 RoundUp(v8::base::OS::CommitPageSize() * kReservedCodeRangePages, | 220 RoundUp(v8::base::OS::CommitPageSize() * kReservedCodeRangePages, |
| 221 MemoryChunk::kAlignment) + | 221 MemoryChunk::kAlignment) + |
| 222 v8::internal::MemoryAllocator::CodePageAreaSize())) { | 222 v8::internal::MemoryAllocator::CodePageAreaSize())) { |
| 223 return; | 223 return; |
| 224 } | 224 } |
| 225 |
| 225 Address address; | 226 Address address; |
| 226 size_t size; | 227 size_t size; |
| 228 size_t request_size = code_range_size - 2 * pageSize; |
| 227 address = code_range->AllocateRawMemory( | 229 address = code_range->AllocateRawMemory( |
| 228 code_range_size - 2 * pageSize, code_range_size - 2 * pageSize, &size); | 230 request_size, request_size - (2 * MemoryAllocator::CodePageGuardSize()), |
| 231 &size); |
| 229 CHECK(address != NULL); | 232 CHECK(address != NULL); |
| 233 |
| 230 Address null_address; | 234 Address null_address; |
| 231 size_t null_size; | 235 size_t null_size; |
| 236 request_size = code_range_size - pageSize; |
| 232 null_address = code_range->AllocateRawMemory( | 237 null_address = code_range->AllocateRawMemory( |
| 233 code_range_size - pageSize, code_range_size - pageSize, &null_size); | 238 request_size, request_size - (2 * MemoryAllocator::CodePageGuardSize()), |
| 239 &null_size); |
| 234 CHECK(null_address == NULL); | 240 CHECK(null_address == NULL); |
| 241 |
| 235 code_range->FreeRawMemory(address, size); | 242 code_range->FreeRawMemory(address, size); |
| 236 delete code_range; | 243 delete code_range; |
| 237 memory_allocator->TearDown(); | 244 memory_allocator->TearDown(); |
| 238 delete memory_allocator; | 245 delete memory_allocator; |
| 239 } | 246 } |
| 240 | 247 |
| 241 | 248 |
| 242 static unsigned int Pseudorandom() { | 249 static unsigned int Pseudorandom() { |
| 243 static uint32_t lo = 2345; | 250 static uint32_t lo = 2345; |
| 244 lo = 18273 * (lo & 0xFFFFF) + (lo >> 16); | 251 lo = 18273 * (lo & 0xFFFFF) + (lo >> 16); |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 | 634 |
| 628 // Turn the allocation into a proper object so isolate teardown won't | 635 // Turn the allocation into a proper object so isolate teardown won't |
| 629 // crash. | 636 // crash. |
| 630 HeapObject* free_space = NULL; | 637 HeapObject* free_space = NULL; |
| 631 CHECK(allocation.To(&free_space)); | 638 CHECK(allocation.To(&free_space)); |
| 632 new_space->heap()->CreateFillerObjectAt(free_space->address(), 80); | 639 new_space->heap()->CreateFillerObjectAt(free_space->address(), 80); |
| 633 } | 640 } |
| 634 } | 641 } |
| 635 isolate->Dispose(); | 642 isolate->Dispose(); |
| 636 } | 643 } |
| OLD | NEW |