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

Unified Diff: test/cctest/test-alloc.cc

Issue 10071003: Cleanup test-alloc unit test case. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/spaces.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-alloc.cc
diff --git a/test/cctest/test-alloc.cc b/test/cctest/test-alloc.cc
index 769fe7be297cc3872691e8957fe925dbe5f2da34..22a4a460b3615952c7f96d5beb26479606c164fe 100644
--- a/test/cctest/test-alloc.cc
+++ b/test/cctest/test-alloc.cc
@@ -34,6 +34,13 @@
using namespace v8::internal;
+static inline void SimulateFullSpace(PagedSpace* space) {
+ space->SetTop(space->limit(), space->limit());
+ space->ResetFreeList();
+ space->ClearStats();
+}
+
+
static MaybeObject* AllocateAfterFailures() {
static int attempts = 0;
if (++attempts < 3) return Failure::RetryAfterGC();
@@ -65,24 +72,12 @@ static MaybeObject* AllocateAfterFailures() {
CHECK(!heap->CopyJSObject(JSObject::cast(object))->IsFailure());
// Old data space.
- OldSpace* old_data_space = heap->old_data_space();
- static const int kOldDataSpaceFillerSize = ByteArray::SizeFor(0);
- while (old_data_space->Available() > kOldDataSpaceFillerSize) {
- CHECK(!heap->AllocateByteArray(0, TENURED)->IsFailure());
- }
+ SimulateFullSpace(heap->old_data_space());
CHECK(!heap->AllocateRawAsciiString(100, TENURED)->IsFailure());
// Old pointer space.
- OldSpace* old_pointer_space = heap->old_pointer_space();
- static const int kOldPointerSpaceFillerLength = 10000;
- static const int kOldPointerSpaceFillerSize = FixedArray::SizeFor(
- kOldPointerSpaceFillerLength);
- while (old_pointer_space->Available() > kOldPointerSpaceFillerSize) {
- CHECK(!heap->AllocateFixedArray(kOldPointerSpaceFillerLength, TENURED)->
- IsFailure());
- }
- CHECK(!heap->AllocateFixedArray(kOldPointerSpaceFillerLength, TENURED)->
- IsFailure());
+ SimulateFullSpace(heap->old_pointer_space());
+ CHECK(!heap->AllocateFixedArray(10000, TENURED)->IsFailure());
// Large object space.
static const int kLargeObjectSpaceFillerLength = 300000;
@@ -97,14 +92,9 @@ static MaybeObject* AllocateAfterFailures() {
IsFailure());
// Map space.
- MapSpace* map_space = heap->map_space();
- static const int kMapSpaceFillerSize = Map::kSize;
- InstanceType instance_type = JS_OBJECT_TYPE;
+ SimulateFullSpace(heap->map_space());
int instance_size = JSObject::kHeaderSize;
- while (map_space->Available() > kMapSpaceFillerSize) {
- CHECK(!heap->AllocateMap(instance_type, instance_size)->IsFailure());
- }
- CHECK(!heap->AllocateMap(instance_type, instance_size)->IsFailure());
+ CHECK(!heap->AllocateMap(JS_OBJECT_TYPE, instance_size)->IsFailure());
// Test that we can allocate in old pointer space and code space.
CHECK(!heap->AllocateFixedArray(100, TENURED)->IsFailure());
« no previous file with comments | « src/spaces.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698