| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 Page* invalid_page = isolate->memory_allocator()->FreePages(first_page); | 151 Page* invalid_page = isolate->memory_allocator()->FreePages(first_page); |
| 152 CHECK(!invalid_page->is_valid()); | 152 CHECK(!invalid_page->is_valid()); |
| 153 | 153 |
| 154 isolate->memory_allocator()->TearDown(); | 154 isolate->memory_allocator()->TearDown(); |
| 155 } | 155 } |
| 156 | 156 |
| 157 | 157 |
| 158 TEST(NewSpace) { | 158 TEST(NewSpace) { |
| 159 OS::Setup(); | 159 OS::Setup(); |
| 160 CHECK(HEAP->ConfigureHeapDefault()); | 160 CHECK(HEAP->ConfigureHeapDefault()); |
| 161 CHECK(Isolate::Current()->memory_allocator()->Setup(HEAP->MaxReserved(), | 161 CHECK(Isolate::Current()->memory_allocator()->Setup( |
| 162 HEAP->MaxExecutableSize())
); | 162 HEAP->MaxReserved(), HEAP->MaxExecutableSize())); |
| 163 | 163 |
| 164 NewSpace new_space(HEAP); | 164 NewSpace new_space(HEAP); |
| 165 | 165 |
| 166 void* chunk = | 166 void* chunk = |
| 167 Isolate::Current()->memory_allocator()->ReserveInitialChunk( | 167 Isolate::Current()->memory_allocator()->ReserveInitialChunk( |
| 168 4 * HEAP->ReservedSemiSpaceSize()); | 168 4 * HEAP->ReservedSemiSpaceSize()); |
| 169 CHECK(chunk != NULL); | 169 CHECK(chunk != NULL); |
| 170 Address start = RoundUp(static_cast<Address>(chunk), | 170 Address start = RoundUp(static_cast<Address>(chunk), |
| 171 2 * HEAP->ReservedSemiSpaceSize()); | 171 2 * HEAP->ReservedSemiSpaceSize()); |
| 172 CHECK(new_space.Setup(start, 2 * HEAP->ReservedSemiSpaceSize())); | 172 CHECK(new_space.Setup(start, 2 * HEAP->ReservedSemiSpaceSize())); |
| 173 CHECK(new_space.HasBeenSetup()); | 173 CHECK(new_space.HasBeenSetup()); |
| 174 | 174 |
| 175 while (new_space.Available() >= Page::kMaxHeapObjectSize) { | 175 while (new_space.Available() >= Page::kMaxHeapObjectSize) { |
| 176 Object* obj = | 176 Object* obj = |
| 177 new_space.AllocateRaw(Page::kMaxHeapObjectSize)->ToObjectUnchecked(); | 177 new_space.AllocateRaw(Page::kMaxHeapObjectSize)->ToObjectUnchecked(); |
| 178 CHECK(new_space.Contains(HeapObject::cast(obj))); | 178 CHECK(new_space.Contains(HeapObject::cast(obj))); |
| 179 } | 179 } |
| 180 | 180 |
| 181 new_space.TearDown(); | 181 new_space.TearDown(); |
| 182 Isolate::Current()->memory_allocator()->TearDown(); | 182 Isolate::Current()->memory_allocator()->TearDown(); |
| 183 } | 183 } |
| 184 | 184 |
| 185 | 185 |
| 186 TEST(OldSpace) { | 186 TEST(OldSpace) { |
| 187 OS::Setup(); | 187 OS::Setup(); |
| 188 CHECK(HEAP->ConfigureHeapDefault()); | 188 CHECK(HEAP->ConfigureHeapDefault()); |
| 189 CHECK(Isolate::Current()->memory_allocator()->Setup(HEAP->MaxReserved(), | 189 CHECK(Isolate::Current()->memory_allocator()->Setup( |
| 190 HEAP->MaxExecutableSize())
); | 190 HEAP->MaxReserved(), HEAP->MaxExecutableSize())); |
| 191 | 191 |
| 192 OldSpace* s = new OldSpace(HEAP, | 192 OldSpace* s = new OldSpace(HEAP, |
| 193 HEAP->MaxOldGenerationSize(), | 193 HEAP->MaxOldGenerationSize(), |
| 194 OLD_POINTER_SPACE, | 194 OLD_POINTER_SPACE, |
| 195 NOT_EXECUTABLE); | 195 NOT_EXECUTABLE); |
| 196 CHECK(s != NULL); | 196 CHECK(s != NULL); |
| 197 | 197 |
| 198 void* chunk = | 198 void* chunk = |
| 199 Isolate::Current()->memory_allocator()->ReserveInitialChunk( | 199 Isolate::Current()->memory_allocator()->ReserveInitialChunk( |
| 200 4 * HEAP->ReservedSemiSpaceSize()); | 200 4 * HEAP->ReservedSemiSpaceSize()); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 | 247 |
| 248 CHECK(!lo->IsEmpty()); | 248 CHECK(!lo->IsEmpty()); |
| 249 | 249 |
| 250 CHECK(lo->AllocateRaw(lo_size)->IsFailure()); | 250 CHECK(lo->AllocateRaw(lo_size)->IsFailure()); |
| 251 | 251 |
| 252 lo->TearDown(); | 252 lo->TearDown(); |
| 253 delete lo; | 253 delete lo; |
| 254 | 254 |
| 255 Isolate::Current()->memory_allocator()->TearDown(); | 255 Isolate::Current()->memory_allocator()->TearDown(); |
| 256 } | 256 } |
| OLD | NEW |