~ubuntu-branches/ubuntu/trusty/libv8/trusty

« back to all changes in this revision

Viewing changes to test/cctest/test-alloc.cc

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2012-02-20 14:08:17 UTC
  • mfrom: (15.1.24 sid)
  • Revision ID: package-import@ubuntu.com-20120220140817-bsvmeoa4sxsj5hbz
Tags: 3.7.12.22-3
Fix mipsel build, allow test debug-step-3 to fail (non-crucial)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright 2007-2008 the V8 project authors. All rights reserved.
 
1
// Copyright 2011 the V8 project authors. All rights reserved.
2
2
// Redistribution and use in source and binary forms, with or without
3
3
// modification, are permitted provided that the following conditions are
4
4
// met:
72
72
  }
73
73
  CHECK(!heap->AllocateRawAsciiString(100, TENURED)->IsFailure());
74
74
 
 
75
  // Old pointer space.
 
76
  OldSpace* old_pointer_space = heap->old_pointer_space();
 
77
  static const int kOldPointerSpaceFillerLength = 10000;
 
78
  static const int kOldPointerSpaceFillerSize = FixedArray::SizeFor(
 
79
      kOldPointerSpaceFillerLength);
 
80
  while (old_pointer_space->Available() > kOldPointerSpaceFillerSize) {
 
81
    CHECK(!heap->AllocateFixedArray(kOldPointerSpaceFillerLength, TENURED)->
 
82
          IsFailure());
 
83
  }
 
84
  CHECK(!heap->AllocateFixedArray(kOldPointerSpaceFillerLength, TENURED)->
 
85
        IsFailure());
 
86
 
75
87
  // Large object space.
76
 
  while (!heap->OldGenerationAllocationLimitReached()) {
77
 
    CHECK(!heap->AllocateFixedArray(10000, TENURED)->IsFailure());
 
88
  static const int kLargeObjectSpaceFillerLength = 300000;
 
89
  static const int kLargeObjectSpaceFillerSize = FixedArray::SizeFor(
 
90
      kLargeObjectSpaceFillerLength);
 
91
  ASSERT(kLargeObjectSpaceFillerSize > heap->MaxObjectSizeInPagedSpace());
 
92
  while (heap->OldGenerationSpaceAvailable() > kLargeObjectSpaceFillerSize) {
 
93
    CHECK(!heap->AllocateFixedArray(kLargeObjectSpaceFillerLength, TENURED)->
 
94
          IsFailure());
78
95
  }
79
 
  CHECK(!heap->AllocateFixedArray(10000, TENURED)->IsFailure());
 
96
  CHECK(!heap->AllocateFixedArray(kLargeObjectSpaceFillerLength, TENURED)->
 
97
        IsFailure());
80
98
 
81
99
  // Map space.
82
100
  MapSpace* map_space = heap->map_space();
175
193
// Plain old data class.  Represents a block of allocated memory.
176
194
class Block {
177
195
 public:
178
 
  Block(void* base_arg, int size_arg)
 
196
  Block(Address base_arg, int size_arg)
179
197
      : base(base_arg), size(size_arg) {}
180
198
 
181
 
  void *base;
 
199
  Address base;
182
200
  int size;
183
201
};
184
202
 
185
203
 
186
204
TEST(CodeRange) {
187
 
  const int code_range_size = 16*MB;
 
205
  const int code_range_size = 32*MB;
188
206
  OS::Setup();
189
207
  Isolate::Current()->InitializeLoggingAndCounters();
190
208
  CodeRange* code_range = new CodeRange(Isolate::Current());
196
214
  while (total_allocated < 5 * code_range_size) {
197
215
    if (current_allocated < code_range_size / 10) {
198
216
      // Allocate a block.
199
 
      // Geometrically distributed sizes, greater than Page::kPageSize.
200
 
      size_t requested = (Page::kPageSize << (Pseudorandom() % 6)) +
 
217
      // Geometrically distributed sizes, greater than Page::kMaxHeapObjectSize.
 
218
      // TODO(gc): instead of using 3 use some contant based on code_range_size
 
219
      // kMaxHeapObjectSize.
 
220
      size_t requested = (Page::kMaxHeapObjectSize << (Pseudorandom() % 3)) +
201
221
           Pseudorandom() % 5000 + 1;
202
222
      size_t allocated = 0;
203
 
      void* base = code_range->AllocateRawMemory(requested, &allocated);
 
223
      Address base = code_range->AllocateRawMemory(requested, &allocated);
204
224
      CHECK(base != NULL);
205
225
      blocks.Add(Block(base, static_cast<int>(allocated)));
206
226
      current_allocated += static_cast<int>(allocated);