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

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

Issue 259173003: Kiss goodbye to MaybeObject. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebase + addressed comments Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-serialize.cc ('k') | test/cctest/test-symbols.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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 heap->MaxExecutableSize())); 321 heap->MaxExecutableSize()));
322 TestMemoryAllocatorScope test_scope(isolate, memory_allocator); 322 TestMemoryAllocatorScope test_scope(isolate, memory_allocator);
323 323
324 NewSpace new_space(heap); 324 NewSpace new_space(heap);
325 325
326 CHECK(new_space.SetUp(CcTest::heap()->ReservedSemiSpaceSize(), 326 CHECK(new_space.SetUp(CcTest::heap()->ReservedSemiSpaceSize(),
327 CcTest::heap()->ReservedSemiSpaceSize())); 327 CcTest::heap()->ReservedSemiSpaceSize()));
328 CHECK(new_space.HasBeenSetUp()); 328 CHECK(new_space.HasBeenSetUp());
329 329
330 while (new_space.Available() >= Page::kMaxRegularHeapObjectSize) { 330 while (new_space.Available() >= Page::kMaxRegularHeapObjectSize) {
331 Object* obj = 331 Object* obj = new_space.AllocateRaw(
332 new_space.AllocateRaw(Page::kMaxRegularHeapObjectSize)-> 332 Page::kMaxRegularHeapObjectSize).ToObjectChecked();
333 ToObjectUnchecked();
334 CHECK(new_space.Contains(HeapObject::cast(obj))); 333 CHECK(new_space.Contains(HeapObject::cast(obj)));
335 } 334 }
336 335
337 new_space.TearDown(); 336 new_space.TearDown();
338 memory_allocator->TearDown(); 337 memory_allocator->TearDown();
339 delete memory_allocator; 338 delete memory_allocator;
340 } 339 }
341 340
342 341
343 TEST(OldSpace) { 342 TEST(OldSpace) {
344 Isolate* isolate = CcTest::i_isolate(); 343 Isolate* isolate = CcTest::i_isolate();
345 isolate->InitializeLoggingAndCounters(); 344 isolate->InitializeLoggingAndCounters();
346 Heap* heap = isolate->heap(); 345 Heap* heap = isolate->heap();
347 CHECK(heap->ConfigureHeapDefault()); 346 CHECK(heap->ConfigureHeapDefault());
348 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); 347 MemoryAllocator* memory_allocator = new MemoryAllocator(isolate);
349 CHECK(memory_allocator->SetUp(heap->MaxReserved(), 348 CHECK(memory_allocator->SetUp(heap->MaxReserved(),
350 heap->MaxExecutableSize())); 349 heap->MaxExecutableSize()));
351 TestMemoryAllocatorScope test_scope(isolate, memory_allocator); 350 TestMemoryAllocatorScope test_scope(isolate, memory_allocator);
352 351
353 OldSpace* s = new OldSpace(heap, 352 OldSpace* s = new OldSpace(heap,
354 heap->MaxOldGenerationSize(), 353 heap->MaxOldGenerationSize(),
355 OLD_POINTER_SPACE, 354 OLD_POINTER_SPACE,
356 NOT_EXECUTABLE); 355 NOT_EXECUTABLE);
357 CHECK(s != NULL); 356 CHECK(s != NULL);
358 357
359 CHECK(s->SetUp()); 358 CHECK(s->SetUp());
360 359
361 while (s->Available() > 0) { 360 while (s->Available() > 0) {
362 s->AllocateRaw(Page::kMaxRegularHeapObjectSize)->ToObjectUnchecked(); 361 s->AllocateRaw(Page::kMaxRegularHeapObjectSize).ToObjectChecked();
363 } 362 }
364 363
365 s->TearDown(); 364 s->TearDown();
366 delete s; 365 delete s;
367 memory_allocator->TearDown(); 366 memory_allocator->TearDown();
368 delete memory_allocator; 367 delete memory_allocator;
369 } 368 }
370 369
371 370
372 TEST(LargeObjectSpace) { 371 TEST(LargeObjectSpace) {
373 v8::V8::Initialize(); 372 v8::V8::Initialize();
374 373
375 LargeObjectSpace* lo = CcTest::heap()->lo_space(); 374 LargeObjectSpace* lo = CcTest::heap()->lo_space();
376 CHECK(lo != NULL); 375 CHECK(lo != NULL);
377 376
378 int lo_size = Page::kPageSize; 377 int lo_size = Page::kPageSize;
379 378
380 Object* obj = lo->AllocateRaw(lo_size, NOT_EXECUTABLE)->ToObjectUnchecked(); 379 Object* obj = lo->AllocateRaw(lo_size, NOT_EXECUTABLE).ToObjectChecked();
381 CHECK(obj->IsHeapObject()); 380 CHECK(obj->IsHeapObject());
382 381
383 HeapObject* ho = HeapObject::cast(obj); 382 HeapObject* ho = HeapObject::cast(obj);
384 383
385 CHECK(lo->Contains(HeapObject::cast(obj))); 384 CHECK(lo->Contains(HeapObject::cast(obj)));
386 385
387 CHECK(lo->FindObject(ho->address()) == obj); 386 CHECK(lo->FindObject(ho->address()) == obj);
388 387
389 CHECK(lo->Contains(ho)); 388 CHECK(lo->Contains(ho));
390 389
391 while (true) { 390 while (true) {
392 intptr_t available = lo->Available(); 391 intptr_t available = lo->Available();
393 { MaybeObject* maybe_obj = lo->AllocateRaw(lo_size, NOT_EXECUTABLE); 392 { AllocationResult allocation = lo->AllocateRaw(lo_size, NOT_EXECUTABLE);
394 if (!maybe_obj->ToObject(&obj)) break; 393 if (allocation.IsRetry()) break;
395 } 394 }
396 CHECK(lo->Available() < available); 395 CHECK(lo->Available() < available);
397 }; 396 };
398 397
399 CHECK(!lo->IsEmpty()); 398 CHECK(!lo->IsEmpty());
400 399
401 CHECK(lo->AllocateRaw(lo_size, NOT_EXECUTABLE)->IsFailure()); 400 CHECK(lo->AllocateRaw(lo_size, NOT_EXECUTABLE).IsRetry());
402 } 401 }
403 402
404 403
405 TEST(SizeOfFirstPageIsLargeEnough) { 404 TEST(SizeOfFirstPageIsLargeEnough) {
406 if (i::FLAG_always_opt) return; 405 if (i::FLAG_always_opt) return;
407 CcTest::InitializeVM(); 406 CcTest::InitializeVM();
408 Isolate* isolate = CcTest::i_isolate(); 407 Isolate* isolate = CcTest::i_isolate();
409 408
410 // Freshly initialized VM gets by with one page per space. 409 // Freshly initialized VM gets by with one page per space.
411 for (int i = FIRST_PAGED_SPACE; i <= LAST_PAGED_SPACE; i++) { 410 for (int i = FIRST_PAGED_SPACE; i <= LAST_PAGED_SPACE; i++) {
412 CHECK_EQ(1, isolate->heap()->paged_space(i)->CountTotalPages()); 411 CHECK_EQ(1, isolate->heap()->paged_space(i)->CountTotalPages());
413 } 412 }
414 413
415 // Executing the empty script gets by with one page per space. 414 // Executing the empty script gets by with one page per space.
416 HandleScope scope(isolate); 415 HandleScope scope(isolate);
417 CompileRun("/*empty*/"); 416 CompileRun("/*empty*/");
418 for (int i = FIRST_PAGED_SPACE; i <= LAST_PAGED_SPACE; i++) { 417 for (int i = FIRST_PAGED_SPACE; i <= LAST_PAGED_SPACE; i++) {
419 CHECK_EQ(1, isolate->heap()->paged_space(i)->CountTotalPages()); 418 CHECK_EQ(1, isolate->heap()->paged_space(i)->CountTotalPages());
420 } 419 }
421 420
422 // No large objects required to perform the above steps. 421 // No large objects required to perform the above steps.
423 CHECK(isolate->heap()->lo_space()->IsEmpty()); 422 CHECK(isolate->heap()->lo_space()->IsEmpty());
424 } 423 }
OLDNEW
« no previous file with comments | « test/cctest/test-serialize.cc ('k') | test/cctest/test-symbols.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698