Reviewers: Sven Panne,
Description:
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
Please review this at https://chromiumcodereview.appspot.com/10071003/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/spaces.h
M test/cctest/test-alloc.cc
Index: src/spaces.h
diff --git a/src/spaces.h b/src/spaces.h
index
90f62f3938bbeaf844873a6368892a892c540809..de9f0b596668b6271ac982e1bb72c6e57f5a9f96
100644
--- a/src/spaces.h
+++ b/src/spaces.h
@@ -1520,6 +1520,10 @@ class PagedSpace : public Space {
return size_in_bytes - wasted;
}
+ void ResetFreeList() {
+ free_list_.Reset();
+ }
+
// Set space allocation info.
void SetTop(Address top, Address limit) {
ASSERT(top == limit ||
@@ -2371,11 +2375,6 @@ class FixedSpace : public PagedSpace {
// Prepares for a mark-compact GC.
virtual void PrepareForMarkCompact();
- protected:
- void ResetFreeList() {
- free_list_.Reset();
- }
-
private:
// The size of objects in this space.
int object_size_in_bytes_;
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());
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev