[tests] Speed up mjsunit/packed-elements by 1500x
Adding a %SimulateNewspaceFull runtime function speeds up this test from 7m21s to 0.3s (on arm.optdebug with --jitless). Bonus content: - speed up mjsunit/md5 by 23x (5m25s -> 7.5s) - speed up mjsunit/string-replace-gc by 8x (1m37s -> 12s) Bug: v8:9700, v8:9396 Change-Id: Id00d0b83b51192edf1d5493b49b79b5d76e78087 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1807355 Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Commit-Queue: Jakob Kummerow <jkummerow@chromium.org> Cr-Commit-Position: refs/heads/master@{#63829}
This commit is contained in:
parent
c98aa0e275
commit
982412d96f
@ -677,6 +677,46 @@ RUNTIME_FUNCTION(Runtime_SetAllocationTimeout) {
|
|||||||
return ReadOnlyRoots(isolate).undefined_value();
|
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<int>(*space->allocation_limit_address() -
|
||||||
|
*space->allocation_top_address());
|
||||||
|
while (space_remaining > 0) {
|
||||||
|
int length = FixedArrayLenFromSize(space_remaining);
|
||||||
|
if (length > 0) {
|
||||||
|
Handle<FixedArray> 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) {
|
RUNTIME_FUNCTION(Runtime_DebugPrint) {
|
||||||
SealHandleScope shs(isolate);
|
SealHandleScope shs(isolate);
|
||||||
|
@ -515,6 +515,7 @@ namespace internal {
|
|||||||
F(SetWasmCompileControls, 2, 1) \
|
F(SetWasmCompileControls, 2, 1) \
|
||||||
F(SetWasmInstantiateControls, 0, 1) \
|
F(SetWasmInstantiateControls, 0, 1) \
|
||||||
F(SetWasmThreadsEnabled, 1, 1) \
|
F(SetWasmThreadsEnabled, 1, 1) \
|
||||||
|
F(SimulateNewspaceFull, 0, 1) \
|
||||||
F(StringIteratorProtector, 0, 1) \
|
F(StringIteratorProtector, 0, 1) \
|
||||||
F(SystemBreak, 0, 1) \
|
F(SystemBreak, 0, 1) \
|
||||||
F(TraceEnter, 0, 1) \
|
F(TraceEnter, 0, 1) \
|
||||||
|
@ -98,11 +98,15 @@ std::vector<Handle<FixedArray>> CreatePadding(Heap* heap, int padding_size,
|
|||||||
allocate_memory = free_memory;
|
allocate_memory = free_memory;
|
||||||
length = FixedArrayLenFromSize(allocate_memory);
|
length = FixedArrayLenFromSize(allocate_memory);
|
||||||
if (length <= 0) {
|
if (length <= 0) {
|
||||||
// Not enough room to create another fixed array. Let's create a filler.
|
// Not enough room to create another FixedArray, so create a filler.
|
||||||
if (free_memory > (2 * kTaggedSize)) {
|
if (allocation == i::AllocationType::kOld) {
|
||||||
heap->CreateFillerObjectAt(
|
heap->CreateFillerObjectAt(
|
||||||
*heap->old_space()->allocation_top_address(), free_memory,
|
*heap->old_space()->allocation_top_address(), free_memory,
|
||||||
ClearRecordedSlots::kNo);
|
ClearRecordedSlots::kNo);
|
||||||
|
} else {
|
||||||
|
heap->CreateFillerObjectAt(
|
||||||
|
*heap->new_space()->allocation_top_address(), free_memory,
|
||||||
|
ClearRecordedSlots::kNo);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -127,8 +131,9 @@ void AllocateAllButNBytes(v8::internal::NewSpace* space, int extra_bytes,
|
|||||||
if (new_linear_size == 0) return;
|
if (new_linear_size == 0) return;
|
||||||
std::vector<Handle<FixedArray>> handles = heap::CreatePadding(
|
std::vector<Handle<FixedArray>> handles = heap::CreatePadding(
|
||||||
space->heap(), new_linear_size, i::AllocationType::kYoung);
|
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());
|
out_handles->insert(out_handles->end(), handles.begin(), handles.end());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FillCurrentPage(v8::internal::NewSpace* space,
|
void FillCurrentPage(v8::internal::NewSpace* space,
|
||||||
@ -144,8 +149,9 @@ bool FillUpOnePage(v8::internal::NewSpace* space,
|
|||||||
if (space_remaining == 0) return false;
|
if (space_remaining == 0) return false;
|
||||||
std::vector<Handle<FixedArray>> handles = heap::CreatePadding(
|
std::vector<Handle<FixedArray>> handles = heap::CreatePadding(
|
||||||
space->heap(), space_remaining, i::AllocationType::kYoung);
|
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());
|
out_handles->insert(out_handles->end(), handles.begin(), handles.end());
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +84,18 @@ HEAP_TEST(CompactionFullAbortedPage) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
int GetObjectSize(int objects_per_page) {
|
||||||
|
int allocatable =
|
||||||
|
static_cast<int>(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) {
|
HEAP_TEST(CompactionPartiallyAbortedPage) {
|
||||||
if (FLAG_never_compact) return;
|
if (FLAG_never_compact) return;
|
||||||
@ -96,10 +108,7 @@ HEAP_TEST(CompactionPartiallyAbortedPage) {
|
|||||||
FLAG_manual_evacuation_candidates_selection = true;
|
FLAG_manual_evacuation_candidates_selection = true;
|
||||||
|
|
||||||
const int objects_per_page = 10;
|
const int objects_per_page = 10;
|
||||||
const int object_size =
|
const int object_size = GetObjectSize(objects_per_page);
|
||||||
Min(kMaxRegularHeapObjectSize,
|
|
||||||
static_cast<int>(MemoryChunkLayout::AllocatableMemoryInDataPage()) /
|
|
||||||
objects_per_page);
|
|
||||||
|
|
||||||
CcTest::InitializeVM();
|
CcTest::InitializeVM();
|
||||||
Isolate* isolate = CcTest::i_isolate();
|
Isolate* isolate = CcTest::i_isolate();
|
||||||
@ -176,10 +185,7 @@ HEAP_TEST(CompactionPartiallyAbortedPageIntraAbortedPointers) {
|
|||||||
FLAG_manual_evacuation_candidates_selection = true;
|
FLAG_manual_evacuation_candidates_selection = true;
|
||||||
|
|
||||||
const int objects_per_page = 10;
|
const int objects_per_page = 10;
|
||||||
const int object_size =
|
const int object_size = GetObjectSize(objects_per_page);
|
||||||
Min(kMaxRegularHeapObjectSize,
|
|
||||||
static_cast<int>(MemoryChunkLayout::AllocatableMemoryInDataPage()) /
|
|
||||||
objects_per_page);
|
|
||||||
|
|
||||||
CcTest::InitializeVM();
|
CcTest::InitializeVM();
|
||||||
Isolate* isolate = CcTest::i_isolate();
|
Isolate* isolate = CcTest::i_isolate();
|
||||||
@ -270,10 +276,7 @@ HEAP_TEST(CompactionPartiallyAbortedPageWithStoreBufferEntries) {
|
|||||||
FLAG_manual_evacuation_candidates_selection = true;
|
FLAG_manual_evacuation_candidates_selection = true;
|
||||||
|
|
||||||
const int objects_per_page = 10;
|
const int objects_per_page = 10;
|
||||||
const int object_size =
|
const int object_size = GetObjectSize(objects_per_page);
|
||||||
Min(kMaxRegularHeapObjectSize,
|
|
||||||
static_cast<int>(MemoryChunkLayout::AllocatableMemoryInDataPage()) /
|
|
||||||
objects_per_page);
|
|
||||||
|
|
||||||
CcTest::InitializeVM();
|
CcTest::InitializeVM();
|
||||||
Isolate* isolate = CcTest::i_isolate();
|
Isolate* isolate = CcTest::i_isolate();
|
||||||
|
@ -201,11 +201,9 @@ To know our further pleasure in this case,\n\
|
|||||||
To old Free-town, our common judgment-place.\n\
|
To old Free-town, our common judgment-place.\n\
|
||||||
Once more, on pain of death, all men depart.\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;
|
plainText += plainText;
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(hex_md5("abc"), "900150983cd24fb0d6963f7d28e17f72");
|
assertEquals("900150983cd24fb0d6963f7d28e17f72", hex_md5("abc"));
|
||||||
for (var i = 0; i < 11; ++i) {
|
assertEquals("6c843ffbdd773e88ae4ac4a5df79a784", hex_md5(plainText));
|
||||||
assertEquals(hex_md5(plainText), "1b8719c72d5d8bfd06e096ef6c6288c5");
|
|
||||||
}
|
|
||||||
|
@ -295,7 +295,6 @@
|
|||||||
'compare-known-objects-slow': [SKIP],
|
'compare-known-objects-slow': [SKIP],
|
||||||
'compiler/array-multiple-receiver-maps': [SKIP],
|
'compiler/array-multiple-receiver-maps': [SKIP],
|
||||||
# Tests taking too long
|
# Tests taking too long
|
||||||
'packed-elements': [SKIP],
|
|
||||||
'regress/regress-1122': [SKIP],
|
'regress/regress-1122': [SKIP],
|
||||||
'regress/regress-331444': [SKIP],
|
'regress/regress-331444': [SKIP],
|
||||||
'regress/regress-353551': [SKIP],
|
'regress/regress-353551': [SKIP],
|
||||||
@ -486,7 +485,6 @@
|
|||||||
'math-floor-of-div-nosudiv': [PASS, SLOW],
|
'math-floor-of-div-nosudiv': [PASS, SLOW],
|
||||||
'math-floor-of-div': [PASS, SLOW],
|
'math-floor-of-div': [PASS, SLOW],
|
||||||
'messages': [PASS, SLOW],
|
'messages': [PASS, SLOW],
|
||||||
'packed-elements': [PASS, SLOW],
|
|
||||||
'regress/regress-2790': [PASS, SLOW],
|
'regress/regress-2790': [PASS, SLOW],
|
||||||
'regress/regress-331444': [PASS, SLOW],
|
'regress/regress-331444': [PASS, SLOW],
|
||||||
'regress/regress-490': [PASS, SLOW],
|
'regress/regress-490': [PASS, SLOW],
|
||||||
@ -525,7 +523,6 @@
|
|||||||
|
|
||||||
# Pass but take too long with the simulator in debug mode.
|
# Pass but take too long with the simulator in debug mode.
|
||||||
'array-sort': [PASS, SLOW],
|
'array-sort': [PASS, SLOW],
|
||||||
'packed-elements': [SKIP],
|
|
||||||
'regexp-global': [SKIP],
|
'regexp-global': [SKIP],
|
||||||
'math-floor-of-div': [PASS, SLOW],
|
'math-floor-of-div': [PASS, SLOW],
|
||||||
'math-floor-of-div-nosudiv': [PASS, SLOW],
|
'math-floor-of-div-nosudiv': [PASS, SLOW],
|
||||||
@ -660,7 +657,6 @@
|
|||||||
# Slow tests.
|
# Slow tests.
|
||||||
'array-sort': [PASS, SLOW],
|
'array-sort': [PASS, SLOW],
|
||||||
'compiler/osr-with-args': [PASS, SLOW],
|
'compiler/osr-with-args': [PASS, SLOW],
|
||||||
'packed-elements': [PASS, SLOW],
|
|
||||||
'regress/regress-2790': [PASS, SLOW],
|
'regress/regress-2790': [PASS, SLOW],
|
||||||
'regress/regress-91008': [PASS, SLOW],
|
'regress/regress-91008': [PASS, SLOW],
|
||||||
'regress/regress-json-stringify-gc': [PASS, SLOW],
|
'regress/regress-json-stringify-gc': [PASS, SLOW],
|
||||||
@ -944,7 +940,6 @@
|
|||||||
'regress/regress-crbug-482998': [PASS, SLOW],
|
'regress/regress-crbug-482998': [PASS, SLOW],
|
||||||
'regress/regress-91008': [PASS, SLOW],
|
'regress/regress-91008': [PASS, SLOW],
|
||||||
'regress/regress-779407': [PASS, SLOW],
|
'regress/regress-779407': [PASS, SLOW],
|
||||||
'packed-elements': [PASS, SLOW],
|
|
||||||
'harmony/regexp-property-lu-ui': [PASS, SLOW],
|
'harmony/regexp-property-lu-ui': [PASS, SLOW],
|
||||||
'whitespaces': [PASS, SLOW],
|
'whitespaces': [PASS, SLOW],
|
||||||
'generated-transition-stub': [PASS, SLOW],
|
'generated-transition-stub': [PASS, SLOW],
|
||||||
@ -1017,10 +1012,8 @@
|
|||||||
}], # variant == stress and (arch == arm or arch == arm64) and simulator_run
|
}], # 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
|
# Slow tests: https://crbug.com/v8/7783
|
||||||
'md5': [SKIP],
|
|
||||||
'packed-elements': [SKIP],
|
|
||||||
'regress/regress-crbug-319860': [SKIP],
|
'regress/regress-crbug-319860': [SKIP],
|
||||||
'wasm/asm-wasm-f32': [SKIP],
|
'wasm/asm-wasm-f32': [SKIP],
|
||||||
'wasm/asm-wasm-f64': [SKIP],
|
'wasm/asm-wasm-f64': [SKIP],
|
||||||
|
@ -92,12 +92,15 @@ function test6() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_with_optimization(f) {
|
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);
|
%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);
|
%OptimizeFunctionOnNextCall(f);
|
||||||
for (i = 0; i < 25000; ++i) f(); // Make sure GC happens
|
f();
|
||||||
|
%SimulateNewspaceFull(); // Make sure GC happens.
|
||||||
|
f();
|
||||||
}
|
}
|
||||||
|
|
||||||
test_with_optimization(test1);
|
test_with_optimization(test1);
|
||||||
|
@ -25,31 +25,22 @@
|
|||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
//
|
// Regression test for the r1513 fix.
|
||||||
// Regression test for the r1512 fix.
|
|
||||||
|
// Flags: --allow-natives-syntax
|
||||||
|
|
||||||
var foo = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
var foo = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
||||||
|
assertEquals(39, foo.length);
|
||||||
|
|
||||||
foo = foo + foo;
|
for (var i = 0; i < 12; i++) {
|
||||||
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;
|
|
||||||
|
|
||||||
foo.replace(/[b]/, "c"); // Flatten foo.
|
foo = %FlattenString(foo);
|
||||||
|
|
||||||
var moving_string = "b" + "c";
|
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);
|
||||||
|
Loading…
Reference in New Issue
Block a user