| 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 25 matching lines...) Expand all Loading... |
| 36 #endif | 36 #endif |
| 37 | 37 |
| 38 #include <utility> | 38 #include <utility> |
| 39 | 39 |
| 40 #include "src/v8.h" | 40 #include "src/v8.h" |
| 41 | 41 |
| 42 #include "src/full-codegen/full-codegen.h" | 42 #include "src/full-codegen/full-codegen.h" |
| 43 #include "src/global-handles.h" | 43 #include "src/global-handles.h" |
| 44 #include "test/cctest/cctest.h" | 44 #include "test/cctest/cctest.h" |
| 45 #include "test/cctest/heap/heap-tester.h" | 45 #include "test/cctest/heap/heap-tester.h" |
| 46 #include "test/cctest/heap/utils-inl.h" | 46 #include "test/cctest/heap/heap-utils.h" |
| 47 | |
| 48 | 47 |
| 49 using namespace v8::internal; | 48 using namespace v8::internal; |
| 50 using v8::Just; | 49 using v8::Just; |
| 51 | 50 |
| 52 | 51 |
| 53 TEST(MarkingDeque) { | 52 TEST(MarkingDeque) { |
| 54 CcTest::InitializeVM(); | 53 CcTest::InitializeVM(); |
| 55 int mem_size = 20 * kPointerSize; | 54 int mem_size = 20 * kPointerSize; |
| 56 byte* mem = NewArray<byte>(20*kPointerSize); | 55 byte* mem = NewArray<byte>(20*kPointerSize); |
| 57 Address low = reinterpret_cast<Address>(mem); | 56 Address low = reinterpret_cast<Address>(mem); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 69 while (!s.IsEmpty()) { | 68 while (!s.IsEmpty()) { |
| 70 Address value = s.Pop()->address(); | 69 Address value = s.Pop()->address(); |
| 71 current_address -= kPointerSize; | 70 current_address -= kPointerSize; |
| 72 CHECK_EQ(current_address, value); | 71 CHECK_EQ(current_address, value); |
| 73 } | 72 } |
| 74 | 73 |
| 75 CHECK_EQ(original_address, current_address); | 74 CHECK_EQ(original_address, current_address); |
| 76 DeleteArray(mem); | 75 DeleteArray(mem); |
| 77 } | 76 } |
| 78 | 77 |
| 78 TEST(Promotion) { |
| 79 CcTest::InitializeVM(); |
| 80 Isolate* isolate = CcTest::i_isolate(); |
| 81 { |
| 82 v8::HandleScope sc(CcTest::isolate()); |
| 83 Heap* heap = isolate->heap(); |
| 79 | 84 |
| 80 HEAP_TEST(Promotion) { | 85 heap::SealCurrentObjects(heap); |
| 81 CcTest::InitializeVM(); | |
| 82 Heap* heap = CcTest::heap(); | |
| 83 heap->ConfigureHeap(1, 1, 1, 0); | |
| 84 | 86 |
| 85 v8::HandleScope sc(CcTest::isolate()); | 87 int array_length = |
| 88 heap::FixedArrayLenFromSize(Page::kMaxRegularHeapObjectSize); |
| 89 Handle<FixedArray> array = isolate->factory()->NewFixedArray(array_length); |
| 86 | 90 |
| 87 // Allocate a fixed array in the new space. | 91 // Array should be in the new space. |
| 88 int array_length = | 92 CHECK(heap->InSpace(*array, NEW_SPACE)); |
| 89 (Page::kMaxRegularHeapObjectSize - FixedArray::kHeaderSize) / | 93 heap->CollectAllGarbage(); |
| 90 (4 * kPointerSize); | 94 heap->CollectAllGarbage(); |
| 91 Object* obj = heap->AllocateFixedArray(array_length).ToObjectChecked(); | 95 CHECK(heap->InSpace(*array, OLD_SPACE)); |
| 92 Handle<FixedArray> array(FixedArray::cast(obj)); | 96 } |
| 93 | |
| 94 // Array should be in the new space. | |
| 95 CHECK(heap->InSpace(*array, NEW_SPACE)); | |
| 96 | |
| 97 // Call mark compact GC, so array becomes an old object. | |
| 98 heap->CollectAllGarbage(); | |
| 99 heap->CollectAllGarbage(); | |
| 100 | |
| 101 // Array now sits in the old space | |
| 102 CHECK(heap->InSpace(*array, OLD_SPACE)); | |
| 103 } | 97 } |
| 104 | 98 |
| 105 | |
| 106 HEAP_TEST(NoPromotion) { | 99 HEAP_TEST(NoPromotion) { |
| 107 CcTest::InitializeVM(); | 100 CcTest::InitializeVM(); |
| 108 Heap* heap = CcTest::heap(); | 101 Isolate* isolate = CcTest::i_isolate(); |
| 109 heap->ConfigureHeap(1, 1, 1, 0); | 102 { |
| 103 v8::HandleScope sc(CcTest::isolate()); |
| 104 Heap* heap = isolate->heap(); |
| 110 | 105 |
| 111 v8::HandleScope sc(CcTest::isolate()); | 106 heap::SealCurrentObjects(heap); |
| 112 | 107 |
| 113 // Allocate a big fixed array in the new space. | 108 int array_length = |
| 114 int array_length = | 109 heap::FixedArrayLenFromSize(Page::kMaxRegularHeapObjectSize); |
| 115 (Page::kMaxRegularHeapObjectSize - FixedArray::kHeaderSize) / | 110 Handle<FixedArray> array = isolate->factory()->NewFixedArray(array_length); |
| 116 (2 * kPointerSize); | |
| 117 Object* obj = heap->AllocateFixedArray(array_length).ToObjectChecked(); | |
| 118 Handle<FixedArray> array(FixedArray::cast(obj)); | |
| 119 | 111 |
| 120 // Array should be in the new space. | 112 heap->set_force_oom(true); |
| 121 CHECK(heap->InSpace(*array, NEW_SPACE)); | 113 // Array should be in the new space. |
| 122 | 114 CHECK(heap->InSpace(*array, NEW_SPACE)); |
| 123 // Simulate a full old space to make promotion fail. | 115 heap->CollectAllGarbage(); |
| 124 SimulateFullSpace(heap->old_space()); | 116 heap->CollectAllGarbage(); |
| 125 | 117 CHECK(heap->InSpace(*array, NEW_SPACE)); |
| 126 // Call mark compact GC, and it should pass. | 118 } |
| 127 heap->CollectGarbage(OLD_SPACE); | |
| 128 } | 119 } |
| 129 | 120 |
| 130 | |
| 131 HEAP_TEST(MarkCompactCollector) { | 121 HEAP_TEST(MarkCompactCollector) { |
| 132 FLAG_incremental_marking = false; | 122 FLAG_incremental_marking = false; |
| 133 FLAG_retain_maps_for_n_gc = 0; | 123 FLAG_retain_maps_for_n_gc = 0; |
| 134 CcTest::InitializeVM(); | 124 CcTest::InitializeVM(); |
| 135 Isolate* isolate = CcTest::i_isolate(); | 125 Isolate* isolate = CcTest::i_isolate(); |
| 136 Heap* heap = CcTest::heap(); | 126 Heap* heap = CcTest::heap(); |
| 137 Factory* factory = isolate->factory(); | 127 Factory* factory = isolate->factory(); |
| 138 | 128 |
| 139 v8::HandleScope sc(CcTest::isolate()); | 129 v8::HandleScope sc(CcTest::isolate()); |
| 140 Handle<JSGlobalObject> global(isolate->context()->global_object()); | 130 Handle<JSGlobalObject> global(isolate->context()->global_object()); |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 | 477 |
| 488 | 478 |
| 489 TEST(RegressJoinThreadsOnIsolateDeinit) { | 479 TEST(RegressJoinThreadsOnIsolateDeinit) { |
| 490 intptr_t size_limit = ShortLivingIsolate() * 2; | 480 intptr_t size_limit = ShortLivingIsolate() * 2; |
| 491 for (int i = 0; i < 10; i++) { | 481 for (int i = 0; i < 10; i++) { |
| 492 CHECK_GT(size_limit, ShortLivingIsolate()); | 482 CHECK_GT(size_limit, ShortLivingIsolate()); |
| 493 } | 483 } |
| 494 } | 484 } |
| 495 | 485 |
| 496 #endif // __linux__ and !USE_SIMULATOR | 486 #endif // __linux__ and !USE_SIMULATOR |
| OLD | NEW |