Commit 44518ef3 authored by Creddy's avatar Creddy Committed by Commit Bot

Unit test to document the pretenuring behavior of nested literals

Change-Id: I02710e807fa2cd36849b4ab9d76cde2e99f02911
Reviewed-on: https://chromium-review.googlesource.com/1107983
Commit-Queue: Chandan Reddy <chandanreddy@google.com>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53910}
parent c2f1090d
......@@ -2374,6 +2374,49 @@ TEST(OptimizedPretenuringObjectArrayLiterals) {
CHECK(CcTest::heap()->InOldSpace(*o));
}
TEST(OptimizedPretenuringNestedInObjectProperties) {
FLAG_allow_natives_syntax = true;
FLAG_expose_gc = true;
CcTest::InitializeVM();
if (!CcTest::i_isolate()->use_optimizer() || FLAG_always_opt) return;
if (FLAG_gc_global || FLAG_stress_compaction ||
FLAG_stress_incremental_marking) {
return;
}
v8::HandleScope scope(CcTest::isolate());
// Grow new space until maximum capacity reached.
while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) {
CcTest::heap()->new_space()->Grow();
}
// Keep the nested literal alive while its root is freed
i::ScopedVector<char> source(1024);
i::SNPrintF(source,
"let number_elements = %d;"
"let elements = new Array(number_elements);"
"function f() {"
" for (let i = 0; i < number_elements; i++) {"
" let l = {a: {c: 2.2, d: {e: 3.3}}, b: 1.1}; "
" elements[i] = l.a;"
" }"
" return elements[number_elements-1];"
"};"
"f(); gc(); gc();"
"f(); f();"
"%%OptimizeFunctionOnNextCall(f);"
"f();",
kPretenureCreationCount);
v8::Local<v8::Value> res = CompileRun(source.start());
i::Handle<JSObject> o = Handle<JSObject>::cast(
v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res)));
// Nested literal sites are only pretenured if the top level
// literal is pretenured
CHECK(CcTest::heap()->InNewSpace(*o));
}
TEST(OptimizedPretenuringMixedInObjectProperties) {
FLAG_allow_natives_syntax = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment