Revision: 11284
Author: [email protected]
Date: Thu Apr 12 03:06:32 2012
Log: Cleanup test-alloc unit test case.
This makes the test-alloc test case more robust against changes to the
initial heap size. It correctly simulates a full space now instead of
trying to fill the space up by allocating filler objects.
[email protected]
TEST=cctest/test-alloc
Review URL: https://chromiumcodereview.appspot.com/10071003
http://code.google.com/p/v8/source/detail?r=11284
Modified:
/branches/bleeding_edge/src/spaces.h
/branches/bleeding_edge/test/cctest/test-alloc.cc
=======================================
--- /branches/bleeding_edge/src/spaces.h Mon Apr 2 01:32:31 2012
+++ /branches/bleeding_edge/src/spaces.h Thu Apr 12 03:06:32 2012
@@ -1519,6 +1519,10 @@
accounting_stats_.DeallocateBytes(size_in_bytes - wasted);
return size_in_bytes - wasted;
}
+
+ void ResetFreeList() {
+ free_list_.Reset();
+ }
// Set space allocation info.
void SetTop(Address top, Address limit) {
@@ -2370,11 +2374,6 @@
// Prepares for a mark-compact GC.
virtual void PrepareForMarkCompact();
-
- protected:
- void ResetFreeList() {
- free_list_.Reset();
- }
private:
// The size of objects in this space.
=======================================
--- /branches/bleeding_edge/test/cctest/test-alloc.cc Thu Feb 23 04:11:24
2012
+++ /branches/bleeding_edge/test/cctest/test-alloc.cc Thu Apr 12 03:06:32
2012
@@ -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 @@
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 @@
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());
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev