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

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

Issue 652543007: Add support for a target new space size (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: updates Created 6 years, 2 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/cctest.h ('k') | no next file » | 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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 CompileRun("/*empty*/"); 449 CompileRun("/*empty*/");
450 for (int i = FIRST_PAGED_SPACE; i <= LAST_PAGED_SPACE; i++) { 450 for (int i = FIRST_PAGED_SPACE; i <= LAST_PAGED_SPACE; i++) {
451 // Debug code can be very large, so skip CODE_SPACE if we are generating it. 451 // Debug code can be very large, so skip CODE_SPACE if we are generating it.
452 if (i == CODE_SPACE && i::FLAG_debug_code) continue; 452 if (i == CODE_SPACE && i::FLAG_debug_code) continue;
453 CHECK_EQ(1, isolate->heap()->paged_space(i)->CountTotalPages()); 453 CHECK_EQ(1, isolate->heap()->paged_space(i)->CountTotalPages());
454 } 454 }
455 455
456 // No large objects required to perform the above steps. 456 // No large objects required to perform the above steps.
457 CHECK(isolate->heap()->lo_space()->IsEmpty()); 457 CHECK(isolate->heap()->lo_space()->IsEmpty());
458 } 458 }
459
460
461 static inline void FillCurrentPage(v8::internal::NewSpace* space) {
462 int new_linear_size = static_cast<int>(*space->allocation_limit_address() -
463 *space->allocation_top_address());
464 if (new_linear_size == 0) return;
465 v8::internal::AllocationResult allocation =
466 space->AllocateRaw(new_linear_size);
467 v8::internal::FreeListNode* node =
468 v8::internal::FreeListNode::cast(allocation.ToObjectChecked());
469 node->set_size(space->heap(), new_linear_size);
470 }
471
472
473 UNINITIALIZED_TEST(NewSpaceGrowsToTargetCapacity) {
474 FLAG_target_semi_space_size = 2;
475
476 v8::Isolate* isolate = v8::Isolate::New();
477 {
478 v8::Isolate::Scope isolate_scope(isolate);
479 v8::HandleScope handle_scope(isolate);
480 v8::Context::New(isolate)->Enter();
481
482 Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate);
483
484 NewSpace* new_space = i_isolate->heap()->new_space();
485
486 // This test doesn't work if we start with a non-default new space
487 // configuration.
488 if (new_space->InitialTotalCapacity() == Page::kPageSize) {
489 CHECK(new_space->CommittedMemory() == new_space->InitialTotalCapacity());
490
491 // Fill up the first (and only) page of the semi space.
492 FillCurrentPage(new_space);
493
494 // Try to allocate out of the new space. A new page should be added and
495 // the
496 // allocation should succeed.
497 v8::internal::AllocationResult allocation = new_space->AllocateRaw(80);
498 CHECK(!allocation.IsRetry());
499 CHECK(new_space->CommittedMemory() == 2 * Page::kPageSize);
500
501 // Turn the allocation into a proper object so isolate teardown won't
502 // crash.
503 v8::internal::FreeListNode* node =
504 v8::internal::FreeListNode::cast(allocation.ToObjectChecked());
505 node->set_size(new_space->heap(), 80);
506 }
507 }
508 isolate->Dispose();
509 }
OLDNEW
« no previous file with comments | « test/cctest/cctest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698