| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 13 matching lines...) Expand all Loading... |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include "src/v8.h" | 28 #include "src/v8.h" |
| 29 #include "test/cctest/cctest.h" | 29 #include "test/cctest/cctest.h" |
| 30 | 30 |
| 31 #include "src/accessors.h" | 31 #include "src/accessors.h" |
| 32 #include "src/api.h" | 32 #include "src/api.h" |
| 33 #include "test/cctest/heap/heap-tester.h" | 33 #include "test/cctest/heap/heap-tester.h" |
| 34 #include "test/cctest/heap/utils-inl.h" | 34 #include "test/cctest/heap/heap-utils.h" |
| 35 | 35 |
| 36 using namespace v8::internal; | 36 using namespace v8::internal; |
| 37 | 37 |
| 38 | 38 |
| 39 AllocationResult v8::internal::HeapTester::AllocateAfterFailures() { | 39 AllocationResult v8::internal::HeapTester::AllocateAfterFailures() { |
| 40 Heap* heap = CcTest::heap(); | 40 Heap* heap = CcTest::heap(); |
| 41 | 41 |
| 42 // New space. | 42 // New space. |
| 43 heap->AllocateByteArray(100).ToObjectChecked(); | 43 heap->AllocateByteArray(100).ToObjectChecked(); |
| 44 heap->AllocateFixedArray(100, NOT_TENURED).ToObjectChecked(); | 44 heap->AllocateFixedArray(100, NOT_TENURED).ToObjectChecked(); |
| 45 | 45 |
| 46 // Make sure we can allocate through optimized allocation functions | 46 // Make sure we can allocate through optimized allocation functions |
| 47 // for specific kinds. | 47 // for specific kinds. |
| 48 heap->AllocateFixedArray(100).ToObjectChecked(); | 48 heap->AllocateFixedArray(100).ToObjectChecked(); |
| 49 heap->AllocateHeapNumber(0.42).ToObjectChecked(); | 49 heap->AllocateHeapNumber(0.42).ToObjectChecked(); |
| 50 Object* object = heap->AllocateJSObject( | 50 Object* object = heap->AllocateJSObject( |
| 51 *CcTest::i_isolate()->object_function()).ToObjectChecked(); | 51 *CcTest::i_isolate()->object_function()).ToObjectChecked(); |
| 52 heap->CopyJSObject(JSObject::cast(object)).ToObjectChecked(); | 52 heap->CopyJSObject(JSObject::cast(object)).ToObjectChecked(); |
| 53 | 53 |
| 54 // Old data space. | 54 // Old data space. |
| 55 SimulateFullSpace(heap->old_space()); | 55 heap::SimulateFullSpace(heap->old_space()); |
| 56 heap->AllocateByteArray(100, TENURED).ToObjectChecked(); | 56 heap->AllocateByteArray(100, TENURED).ToObjectChecked(); |
| 57 | 57 |
| 58 // Old pointer space. | 58 // Old pointer space. |
| 59 SimulateFullSpace(heap->old_space()); | 59 heap::SimulateFullSpace(heap->old_space()); |
| 60 heap->AllocateFixedArray(10000, TENURED).ToObjectChecked(); | 60 heap->AllocateFixedArray(10000, TENURED).ToObjectChecked(); |
| 61 | 61 |
| 62 // Large object space. | 62 // Large object space. |
| 63 static const int kLargeObjectSpaceFillerLength = 3 * (Page::kPageSize / 10); | 63 static const int kLargeObjectSpaceFillerLength = 3 * (Page::kPageSize / 10); |
| 64 static const int kLargeObjectSpaceFillerSize = FixedArray::SizeFor( | 64 static const int kLargeObjectSpaceFillerSize = FixedArray::SizeFor( |
| 65 kLargeObjectSpaceFillerLength); | 65 kLargeObjectSpaceFillerLength); |
| 66 CHECK(kLargeObjectSpaceFillerSize > heap->old_space()->AreaSize()); | 66 CHECK(kLargeObjectSpaceFillerSize > heap->old_space()->AreaSize()); |
| 67 while (heap->OldGenerationSpaceAvailable() > kLargeObjectSpaceFillerSize) { | 67 while (heap->OldGenerationSpaceAvailable() > kLargeObjectSpaceFillerSize) { |
| 68 heap->AllocateFixedArray( | 68 heap->AllocateFixedArray( |
| 69 kLargeObjectSpaceFillerLength, TENURED).ToObjectChecked(); | 69 kLargeObjectSpaceFillerLength, TENURED).ToObjectChecked(); |
| 70 } | 70 } |
| 71 heap->AllocateFixedArray( | 71 heap->AllocateFixedArray( |
| 72 kLargeObjectSpaceFillerLength, TENURED).ToObjectChecked(); | 72 kLargeObjectSpaceFillerLength, TENURED).ToObjectChecked(); |
| 73 | 73 |
| 74 // Map space. | 74 // Map space. |
| 75 SimulateFullSpace(heap->map_space()); | 75 heap::SimulateFullSpace(heap->map_space()); |
| 76 int instance_size = JSObject::kHeaderSize; | 76 int instance_size = JSObject::kHeaderSize; |
| 77 heap->AllocateMap(JS_OBJECT_TYPE, instance_size).ToObjectChecked(); | 77 heap->AllocateMap(JS_OBJECT_TYPE, instance_size).ToObjectChecked(); |
| 78 | 78 |
| 79 // Test that we can allocate in old pointer space and code space. | 79 // Test that we can allocate in old pointer space and code space. |
| 80 SimulateFullSpace(heap->code_space()); | 80 heap::SimulateFullSpace(heap->code_space()); |
| 81 heap->AllocateFixedArray(100, TENURED).ToObjectChecked(); | 81 heap->AllocateFixedArray(100, TENURED).ToObjectChecked(); |
| 82 heap->CopyCode(CcTest::i_isolate()->builtins()->builtin( | 82 heap->CopyCode(CcTest::i_isolate()->builtins()->builtin( |
| 83 Builtins::kIllegal)).ToObjectChecked(); | 83 Builtins::kIllegal)).ToObjectChecked(); |
| 84 | 84 |
| 85 // Return success. | 85 // Return success. |
| 86 return heap->true_value(); | 86 return heap->true_value(); |
| 87 } | 87 } |
| 88 | 88 |
| 89 | 89 |
| 90 Handle<Object> v8::internal::HeapTester::TestAllocateAfterFailures() { | 90 Handle<Object> v8::internal::HeapTester::TestAllocateAfterFailures() { |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 code_range.FreeRawMemory(blocks[index].base, blocks[index].size); | 243 code_range.FreeRawMemory(blocks[index].base, blocks[index].size); |
| 244 current_allocated -= blocks[index].size; | 244 current_allocated -= blocks[index].size; |
| 245 if (index < blocks.length() - 1) { | 245 if (index < blocks.length() - 1) { |
| 246 blocks[index] = blocks.RemoveLast(); | 246 blocks[index] = blocks.RemoveLast(); |
| 247 } else { | 247 } else { |
| 248 blocks.RemoveLast(); | 248 blocks.RemoveLast(); |
| 249 } | 249 } |
| 250 } | 250 } |
| 251 } | 251 } |
| 252 } | 252 } |
| OLD | NEW |