diff --git a/src/runtime/runtime-test.cc b/src/runtime/runtime-test.cc index be7a7d954a..b77deefa19 100644 --- a/src/runtime/runtime-test.cc +++ b/src/runtime/runtime-test.cc @@ -677,6 +677,46 @@ RUNTIME_FUNCTION(Runtime_SetAllocationTimeout) { return ReadOnlyRoots(isolate).undefined_value(); } +namespace { + +int FixedArrayLenFromSize(int size) { + return Min((size - FixedArray::kHeaderSize) / kTaggedSize, + FixedArray::kMaxRegularLength); +} + +void FillUpOneNewSpacePage(Isolate* isolate, Heap* heap) { + NewSpace* space = heap->new_space(); + int space_remaining = static_cast(*space->allocation_limit_address() - + *space->allocation_top_address()); + while (space_remaining > 0) { + int length = FixedArrayLenFromSize(space_remaining); + if (length > 0) { + Handle padding = + isolate->factory()->NewFixedArray(length, AllocationType::kYoung); + DCHECK(heap->new_space()->Contains(*padding)); + space_remaining -= padding->Size(); + } else { + // Not enough room to create another fixed array. Create a filler. + heap->CreateFillerObjectAt(*heap->new_space()->allocation_top_address(), + space_remaining, ClearRecordedSlots::kNo); + break; + } + } +} + +} // namespace + +RUNTIME_FUNCTION(Runtime_SimulateNewspaceFull) { + HandleScope scope(isolate); + Heap* heap = isolate->heap(); + NewSpace* space = heap->new_space(); + PauseAllocationObserversScope pause_observers(heap); + do { + FillUpOneNewSpacePage(isolate, heap); + } while (space->AddFreshPage()); + + return ReadOnlyRoots(isolate).undefined_value(); +} RUNTIME_FUNCTION(Runtime_DebugPrint) { SealHandleScope shs(isolate); diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h index 27e629596f..f5d7648c16 100644 --- a/src/runtime/runtime.h +++ b/src/runtime/runtime.h @@ -515,6 +515,7 @@ namespace internal { F(SetWasmCompileControls, 2, 1) \ F(SetWasmInstantiateControls, 0, 1) \ F(SetWasmThreadsEnabled, 1, 1) \ + F(SimulateNewspaceFull, 0, 1) \ F(StringIteratorProtector, 0, 1) \ F(SystemBreak, 0, 1) \ F(TraceEnter, 0, 1) \ diff --git a/test/cctest/heap/heap-utils.cc b/test/cctest/heap/heap-utils.cc index 8b53dab9c5..3fa2714a61 100644 --- a/test/cctest/heap/heap-utils.cc +++ b/test/cctest/heap/heap-utils.cc @@ -98,11 +98,15 @@ std::vector> CreatePadding(Heap* heap, int padding_size, allocate_memory = free_memory; length = FixedArrayLenFromSize(allocate_memory); if (length <= 0) { - // Not enough room to create another fixed array. Let's create a filler. - if (free_memory > (2 * kTaggedSize)) { + // Not enough room to create another FixedArray, so create a filler. + if (allocation == i::AllocationType::kOld) { heap->CreateFillerObjectAt( *heap->old_space()->allocation_top_address(), free_memory, ClearRecordedSlots::kNo); + } else { + heap->CreateFillerObjectAt( + *heap->new_space()->allocation_top_address(), free_memory, + ClearRecordedSlots::kNo); } break; } @@ -127,8 +131,9 @@ void AllocateAllButNBytes(v8::internal::NewSpace* space, int extra_bytes, if (new_linear_size == 0) return; std::vector> handles = heap::CreatePadding( space->heap(), new_linear_size, i::AllocationType::kYoung); - if (out_handles != nullptr) + if (out_handles != nullptr) { out_handles->insert(out_handles->end(), handles.begin(), handles.end()); + } } void FillCurrentPage(v8::internal::NewSpace* space, @@ -144,8 +149,9 @@ bool FillUpOnePage(v8::internal::NewSpace* space, if (space_remaining == 0) return false; std::vector> handles = heap::CreatePadding( space->heap(), space_remaining, i::AllocationType::kYoung); - if (out_handles != nullptr) + if (out_handles != nullptr) { out_handles->insert(out_handles->end(), handles.begin(), handles.end()); + } return true; } diff --git a/test/cctest/heap/test-compaction.cc b/test/cctest/heap/test-compaction.cc index 354b380234..fb8338f0a2 100644 --- a/test/cctest/heap/test-compaction.cc +++ b/test/cctest/heap/test-compaction.cc @@ -84,6 +84,18 @@ HEAP_TEST(CompactionFullAbortedPage) { } } +namespace { + +int GetObjectSize(int objects_per_page) { + int allocatable = + static_cast(MemoryChunkLayout::AllocatableMemoryInDataPage()); + // Make sure that object_size is a multiple of kTaggedSize. + int object_size = + ((allocatable / kTaggedSize) / objects_per_page) * kTaggedSize; + return Min(kMaxRegularHeapObjectSize, object_size); +} + +} // namespace HEAP_TEST(CompactionPartiallyAbortedPage) { if (FLAG_never_compact) return; @@ -96,10 +108,7 @@ HEAP_TEST(CompactionPartiallyAbortedPage) { FLAG_manual_evacuation_candidates_selection = true; const int objects_per_page = 10; - const int object_size = - Min(kMaxRegularHeapObjectSize, - static_cast(MemoryChunkLayout::AllocatableMemoryInDataPage()) / - objects_per_page); + const int object_size = GetObjectSize(objects_per_page); CcTest::InitializeVM(); Isolate* isolate = CcTest::i_isolate(); @@ -176,10 +185,7 @@ HEAP_TEST(CompactionPartiallyAbortedPageIntraAbortedPointers) { FLAG_manual_evacuation_candidates_selection = true; const int objects_per_page = 10; - const int object_size = - Min(kMaxRegularHeapObjectSize, - static_cast(MemoryChunkLayout::AllocatableMemoryInDataPage()) / - objects_per_page); + const int object_size = GetObjectSize(objects_per_page); CcTest::InitializeVM(); Isolate* isolate = CcTest::i_isolate(); @@ -270,10 +276,7 @@ HEAP_TEST(CompactionPartiallyAbortedPageWithStoreBufferEntries) { FLAG_manual_evacuation_candidates_selection = true; const int objects_per_page = 10; - const int object_size = - Min(kMaxRegularHeapObjectSize, - static_cast(MemoryChunkLayout::AllocatableMemoryInDataPage()) / - objects_per_page); + const int object_size = GetObjectSize(objects_per_page); CcTest::InitializeVM(); Isolate* isolate = CcTest::i_isolate(); diff --git a/test/mjsunit/md5.js b/test/mjsunit/md5.js index 38dc802312..b2dbc1e45a 100644 --- a/test/mjsunit/md5.js +++ b/test/mjsunit/md5.js @@ -201,11 +201,9 @@ To know our further pleasure in this case,\n\ To old Free-town, our common judgment-place.\n\ Once more, on pain of death, all men depart.\n" -for (var i = 0; i < 4; ++i) { +for (var i = 0; i < 2; ++i) { plainText += plainText; } -assertEquals(hex_md5("abc"), "900150983cd24fb0d6963f7d28e17f72"); -for (var i = 0; i < 11; ++i) { - assertEquals(hex_md5(plainText), "1b8719c72d5d8bfd06e096ef6c6288c5"); -} +assertEquals("900150983cd24fb0d6963f7d28e17f72", hex_md5("abc")); +assertEquals("6c843ffbdd773e88ae4ac4a5df79a784", hex_md5(plainText)); diff --git a/test/mjsunit/mjsunit.status b/test/mjsunit/mjsunit.status index 1461816317..c168d83b13 100644 --- a/test/mjsunit/mjsunit.status +++ b/test/mjsunit/mjsunit.status @@ -295,7 +295,6 @@ 'compare-known-objects-slow': [SKIP], 'compiler/array-multiple-receiver-maps': [SKIP], # Tests taking too long - 'packed-elements': [SKIP], 'regress/regress-1122': [SKIP], 'regress/regress-331444': [SKIP], 'regress/regress-353551': [SKIP], @@ -486,7 +485,6 @@ 'math-floor-of-div-nosudiv': [PASS, SLOW], 'math-floor-of-div': [PASS, SLOW], 'messages': [PASS, SLOW], - 'packed-elements': [PASS, SLOW], 'regress/regress-2790': [PASS, SLOW], 'regress/regress-331444': [PASS, SLOW], 'regress/regress-490': [PASS, SLOW], @@ -525,7 +523,6 @@ # Pass but take too long with the simulator in debug mode. 'array-sort': [PASS, SLOW], - 'packed-elements': [SKIP], 'regexp-global': [SKIP], 'math-floor-of-div': [PASS, SLOW], 'math-floor-of-div-nosudiv': [PASS, SLOW], @@ -660,7 +657,6 @@ # Slow tests. 'array-sort': [PASS, SLOW], 'compiler/osr-with-args': [PASS, SLOW], - 'packed-elements': [PASS, SLOW], 'regress/regress-2790': [PASS, SLOW], 'regress/regress-91008': [PASS, SLOW], 'regress/regress-json-stringify-gc': [PASS, SLOW], @@ -944,7 +940,6 @@ 'regress/regress-crbug-482998': [PASS, SLOW], 'regress/regress-91008': [PASS, SLOW], 'regress/regress-779407': [PASS, SLOW], - 'packed-elements': [PASS, SLOW], 'harmony/regexp-property-lu-ui': [PASS, SLOW], 'whitespaces': [PASS, SLOW], 'generated-transition-stub': [PASS, SLOW], @@ -1017,10 +1012,8 @@ }], # variant == stress and (arch == arm or arch == arm64) and simulator_run ############################################################################## -['variant == nooptimization and (arch == arm or arch == arm64) and simulator_run', { +['variant in (nooptimization, jitless) and arch in (arm, arm64) and simulator_run', { # Slow tests: https://crbug.com/v8/7783 - 'md5': [SKIP], - 'packed-elements': [SKIP], 'regress/regress-crbug-319860': [SKIP], 'wasm/asm-wasm-f32': [SKIP], 'wasm/asm-wasm-f64': [SKIP], diff --git a/test/mjsunit/packed-elements.js b/test/mjsunit/packed-elements.js index d0df553451..85630e7954 100644 --- a/test/mjsunit/packed-elements.js +++ b/test/mjsunit/packed-elements.js @@ -92,12 +92,15 @@ function test6() { } function test_with_optimization(f) { - // Run tests in a loop to make sure that inlined Array() constructor runs out - // of new space memory and must fall back on runtime impl. %PrepareFunctionForOptimization(f); - for (i = 0; i < 25000; ++i) f(); + for (i = 0; i < 3; ++i) f(); + // Cause the inlined Array() constructor to fall back to the runtime impl. + %SimulateNewspaceFull(); + f(); %OptimizeFunctionOnNextCall(f); - for (i = 0; i < 25000; ++i) f(); // Make sure GC happens + f(); + %SimulateNewspaceFull(); // Make sure GC happens. + f(); } test_with_optimization(test1); diff --git a/test/mjsunit/string-replace-gc.js b/test/mjsunit/string-replace-gc.js index 2f1efd8813..56b6a09da1 100644 --- a/test/mjsunit/string-replace-gc.js +++ b/test/mjsunit/string-replace-gc.js @@ -25,31 +25,22 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Regression test for the r1512 fix. +// Regression test for the r1513 fix. + +// Flags: --allow-natives-syntax var foo = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; +assertEquals(39, foo.length); -foo = foo + foo; -foo = foo + foo; -foo = foo + foo; -foo = foo + foo; -foo = foo + foo; -foo = foo + foo; -foo = foo + foo; -foo = foo + foo; -foo = foo + foo; -foo = foo + foo; -foo = foo + foo; -foo = foo + foo; -foo = foo + foo; -foo = foo + foo; -foo = foo + foo; +for (var i = 0; i < 12; i++) { + foo = foo + foo; +} -foo.replace(/[b]/, "c"); // Flatten foo. +foo = %FlattenString(foo); var moving_string = "b" + "c"; -var bar = foo.replace(/[a]/g, moving_string); +var bar = foo.replace(/a/g, moving_string); -print(bar.length); +// 39 * 2^12 * 2 +assertEquals(319488, bar.length);