Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Side by Side Diff: test/cctest/test-spaces.cc

Issue 910333004: Contribution of PowerPC port (continuation of 422063005) - PPC opt 2 (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Updated to remove non-test changes Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/test-heap.cc ('k') | test/cctest/test-weakmaps.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 200
201 memory_allocator->Free(memory_chunk); 201 memory_allocator->Free(memory_chunk);
202 memory_allocator->TearDown(); 202 memory_allocator->TearDown();
203 delete memory_allocator; 203 delete memory_allocator;
204 } 204 }
205 205
206 206
207 TEST(Regress3540) { 207 TEST(Regress3540) {
208 Isolate* isolate = CcTest::i_isolate(); 208 Isolate* isolate = CcTest::i_isolate();
209 Heap* heap = isolate->heap(); 209 Heap* heap = isolate->heap();
210 const int pageSize = Page::kPageSize;
210 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); 211 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate);
211 CHECK( 212 CHECK(
212 memory_allocator->SetUp(heap->MaxReserved(), heap->MaxExecutableSize())); 213 memory_allocator->SetUp(heap->MaxReserved(), heap->MaxExecutableSize()));
213 TestMemoryAllocatorScope test_allocator_scope(isolate, memory_allocator); 214 TestMemoryAllocatorScope test_allocator_scope(isolate, memory_allocator);
214 CodeRange* code_range = new CodeRange(isolate); 215 CodeRange* code_range = new CodeRange(isolate);
215 const size_t code_range_size = 4 * MB; 216 const size_t code_range_size = 4 * pageSize;
216 if (!code_range->SetUp( 217 if (!code_range->SetUp(
217 code_range_size + 218 code_range_size +
218 RoundUp(v8::base::OS::CommitPageSize() * kReservedCodeRangePages, 219 RoundUp(v8::base::OS::CommitPageSize() * kReservedCodeRangePages,
219 MemoryChunk::kAlignment) + 220 MemoryChunk::kAlignment) +
220 v8::internal::MemoryAllocator::CodePageAreaSize())) { 221 v8::internal::MemoryAllocator::CodePageAreaSize())) {
221 return; 222 return;
222 } 223 }
223 Address address; 224 Address address;
224 size_t size; 225 size_t size;
225 address = code_range->AllocateRawMemory(code_range_size - 2 * MB, 226 address = code_range->AllocateRawMemory(
226 code_range_size - 2 * MB, &size); 227 code_range_size - 2 * pageSize, code_range_size - 2 * pageSize, &size);
227 CHECK(address != NULL); 228 CHECK(address != NULL);
228 Address null_address; 229 Address null_address;
229 size_t null_size; 230 size_t null_size;
230 null_address = code_range->AllocateRawMemory( 231 null_address = code_range->AllocateRawMemory(
231 code_range_size - MB, code_range_size - MB, &null_size); 232 code_range_size - pageSize, code_range_size - pageSize, &null_size);
232 CHECK(null_address == NULL); 233 CHECK(null_address == NULL);
233 code_range->FreeRawMemory(address, size); 234 code_range->FreeRawMemory(address, size);
234 delete code_range; 235 delete code_range;
235 memory_allocator->TearDown(); 236 memory_allocator->TearDown();
236 delete memory_allocator; 237 delete memory_allocator;
237 } 238 }
238 239
239 240
240 static unsigned int Pseudorandom() { 241 static unsigned int Pseudorandom() {
241 static uint32_t lo = 2345; 242 static uint32_t lo = 2345;
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 416
416 CHECK(lo->FindObject(ho->address()) == obj); 417 CHECK(lo->FindObject(ho->address()) == obj);
417 418
418 CHECK(lo->Contains(ho)); 419 CHECK(lo->Contains(ho));
419 420
420 while (true) { 421 while (true) {
421 intptr_t available = lo->Available(); 422 intptr_t available = lo->Available();
422 { AllocationResult allocation = lo->AllocateRaw(lo_size, NOT_EXECUTABLE); 423 { AllocationResult allocation = lo->AllocateRaw(lo_size, NOT_EXECUTABLE);
423 if (allocation.IsRetry()) break; 424 if (allocation.IsRetry()) break;
424 } 425 }
425 CHECK(lo->Available() < available); 426 // The available value is conservative such that it may report
427 // zero prior to heap exhaustion.
428 CHECK(lo->Available() < available || available == 0);
426 } 429 }
427 430
428 CHECK(!lo->IsEmpty()); 431 CHECK(!lo->IsEmpty());
429 432
430 CHECK(lo->AllocateRaw(lo_size, NOT_EXECUTABLE).IsRetry()); 433 CHECK(lo->AllocateRaw(lo_size, NOT_EXECUTABLE).IsRetry());
431 } 434 }
432 435
433 436
434 TEST(SizeOfFirstPageIsLargeEnough) { 437 TEST(SizeOfFirstPageIsLargeEnough) {
435 if (i::FLAG_always_opt) return; 438 if (i::FLAG_always_opt) return;
(...skipping 17 matching lines...) Expand all
453 if (i == CODE_SPACE && i::FLAG_debug_code) continue; 456 if (i == CODE_SPACE && i::FLAG_debug_code) continue;
454 CHECK_EQ(1, isolate->heap()->paged_space(i)->CountTotalPages()); 457 CHECK_EQ(1, isolate->heap()->paged_space(i)->CountTotalPages());
455 } 458 }
456 459
457 // No large objects required to perform the above steps. 460 // No large objects required to perform the above steps.
458 CHECK(isolate->heap()->lo_space()->IsEmpty()); 461 CHECK(isolate->heap()->lo_space()->IsEmpty());
459 } 462 }
460 463
461 464
462 UNINITIALIZED_TEST(NewSpaceGrowsToTargetCapacity) { 465 UNINITIALIZED_TEST(NewSpaceGrowsToTargetCapacity) {
463 FLAG_target_semi_space_size = 2; 466 FLAG_target_semi_space_size = 2 * (Page::kPageSize / MB);
464 if (FLAG_optimize_for_size) return; 467 if (FLAG_optimize_for_size) return;
465 468
466 v8::Isolate* isolate = v8::Isolate::New(); 469 v8::Isolate* isolate = v8::Isolate::New();
467 { 470 {
468 v8::Isolate::Scope isolate_scope(isolate); 471 v8::Isolate::Scope isolate_scope(isolate);
469 v8::HandleScope handle_scope(isolate); 472 v8::HandleScope handle_scope(isolate);
470 v8::Context::New(isolate)->Enter(); 473 v8::Context::New(isolate)->Enter();
471 474
472 Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate); 475 Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate);
473 476
(...skipping 16 matching lines...) Expand all
490 493
491 // Turn the allocation into a proper object so isolate teardown won't 494 // Turn the allocation into a proper object so isolate teardown won't
492 // crash. 495 // crash.
493 HeapObject* free_space = NULL; 496 HeapObject* free_space = NULL;
494 CHECK(allocation.To(&free_space)); 497 CHECK(allocation.To(&free_space));
495 new_space->heap()->CreateFillerObjectAt(free_space->address(), 80); 498 new_space->heap()->CreateFillerObjectAt(free_space->address(), 80);
496 } 499 }
497 } 500 }
498 isolate->Dispose(); 501 isolate->Dispose();
499 } 502 }
OLDNEW
« no previous file with comments | « test/cctest/test-heap.cc ('k') | test/cctest/test-weakmaps.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698