Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(967)

Unified Diff: test/cctest/test-heap.cc

Issue 304493002: Remove global pretenuring mode. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-heap.cc
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index 7946d7055d223f6275cba3752427b97e28113514..ce0cec18d3639898763aa84cf2ee3c41a83706f2 100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -2194,98 +2194,60 @@ TEST(OptimizedAllocationAlwaysInNewSpace) {
TEST(OptimizedPretenuringAllocationFolding) {
i::FLAG_allow_natives_syntax = true;
- i::FLAG_max_semi_space_size = 1;
- i::FLAG_allocation_site_pretenuring = false;
+ i::FLAG_expose_gc = true;
CcTest::InitializeVM();
if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
- v8::Local<v8::Value> res = CompileRun(
- "function DataObject() {"
- " this.a = 1.1;"
- " this.b = [{}];"
- " this.c = 1.2;"
- " this.d = [{}];"
- " this.e = 1.3;"
- " this.f = [{}];"
- "}"
- "var number_elements = 20000;"
+ i::ScopedVector<char> source(1024);
+ i::OS::SNPrintF(
+ source,
+ "var number_elements = %d;"
"var elements = new Array();"
"function f() {"
" for (var i = 0; i < number_elements; i++) {"
- " elements[i] = new DataObject();"
+ " elements[i] = [[{}], [1.1]];"
" }"
" return elements[number_elements-1]"
"};"
- "f(); f(); f();"
+ "f(); gc();"
+ "f(); f();"
"%OptimizeFunctionOnNextCall(f);"
- "f();");
-
- Handle<JSObject> o =
- v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
+ "f();",
+ AllocationSite::kPretenureMinimumCreated);
- CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(0)));
- CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(1)));
- CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(2)));
- CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(3)));
- CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(4)));
- CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(5)));
-}
-
-
-TEST(OptimizedPretenuringAllocationFoldingBlocks) {
- i::FLAG_allow_natives_syntax = true;
- i::FLAG_max_semi_space_size = 1;
- i::FLAG_allocation_site_pretenuring = false;
- CcTest::InitializeVM();
- if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
- if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
- v8::HandleScope scope(CcTest::isolate());
+ v8::Local<v8::Value> res = CompileRun(source.start());
- v8::Local<v8::Value> res = CompileRun(
- "var number_elements = 30000;"
- "var elements = new Array(number_elements);"
- "function DataObject() {"
- " this.a = [{}];"
- " this.b = [{}];"
- " this.c = 1.1;"
- " this.d = 1.2;"
- " this.e = [{}];"
- " this.f = 1.3;"
- "}"
- "function f() {"
- " for (var i = 0; i < number_elements; i++) {"
- " elements[i] = new DataObject();"
- " }"
- " return elements[number_elements - 1];"
- "};"
- "f(); f(); f();"
- "%OptimizeFunctionOnNextCall(f);"
- "f();");
+ v8::Local<v8::Value> int_array = v8::Object::Cast(*res)->Get(v8_str("0"));
+ Handle<JSObject> int_array_handle =
+ v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array));
+ v8::Local<v8::Value> double_array = v8::Object::Cast(*res)->Get(v8_str("1"));
+ Handle<JSObject> double_array_handle =
+ v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array));
Handle<JSObject> o =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
-
- CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(0)));
- CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(1)));
- CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(2)));
- CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(3)));
- CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(4)));
- CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(5)));
+ CHECK(CcTest::heap()->InOldPointerSpace(*o));
+ CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle));
+ CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle->elements()));
+ CHECK(CcTest::heap()->InOldPointerSpace(*double_array_handle));
+ CHECK(CcTest::heap()->InOldDataSpace(double_array_handle->elements()));
}
TEST(OptimizedPretenuringObjectArrayLiterals) {
i::FLAG_allow_natives_syntax = true;
- i::FLAG_max_semi_space_size = 1;
+ i::FLAG_expose_gc = true;
CcTest::InitializeVM();
if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
- v8::Local<v8::Value> res = CompileRun(
- "var number_elements = 20000;"
+ i::ScopedVector<char> source(1024);
+ i::OS::SNPrintF(
+ source,
+ "var number_elements = %d;"
"var elements = new Array(number_elements);"
"function f() {"
" for (var i = 0; i < number_elements; i++) {"
@@ -2293,9 +2255,13 @@ TEST(OptimizedPretenuringObjectArrayLiterals) {
" }"
" return elements[number_elements - 1];"
"};"
- "f(); f(); f();"
+ "f(); gc();"
+ "f(); f();"
"%OptimizeFunctionOnNextCall(f);"
- "f();");
+ "f();",
+ AllocationSite::kPretenureMinimumCreated);
+
+ v8::Local<v8::Value> res = CompileRun(source.start());
Handle<JSObject> o =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
@@ -2307,14 +2273,16 @@ TEST(OptimizedPretenuringObjectArrayLiterals) {
TEST(OptimizedPretenuringMixedInObjectProperties) {
i::FLAG_allow_natives_syntax = true;
- i::FLAG_max_semi_space_size = 1;
+ i::FLAG_expose_gc = true;
CcTest::InitializeVM();
if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
- v8::Local<v8::Value> res = CompileRun(
- "var number_elements = 20000;"
+ i::ScopedVector<char> source(1024);
+ i::OS::SNPrintF(
+ source,
+ "var number_elements = %d;"
"var elements = new Array(number_elements);"
"function f() {"
" for (var i = 0; i < number_elements; i++) {"
@@ -2322,9 +2290,13 @@ TEST(OptimizedPretenuringMixedInObjectProperties) {
" }"
" return elements[number_elements - 1];"
"};"
- "f(); f(); f();"
+ "f(); gc();"
+ "f(); f();"
"%OptimizeFunctionOnNextCall(f);"
- "f();");
+ "f();",
+ AllocationSite::kPretenureMinimumCreated);
+
+ v8::Local<v8::Value> res = CompileRun(source.start());
Handle<JSObject> o =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
@@ -2342,14 +2314,16 @@ TEST(OptimizedPretenuringMixedInObjectProperties) {
TEST(OptimizedPretenuringDoubleArrayProperties) {
i::FLAG_allow_natives_syntax = true;
- i::FLAG_max_semi_space_size = 1;
+ i::FLAG_expose_gc = true;
CcTest::InitializeVM();
if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
- v8::Local<v8::Value> res = CompileRun(
- "var number_elements = 30000;"
+ i::ScopedVector<char> source(1024);
+ i::OS::SNPrintF(
+ source,
+ "var number_elements = %d;"
"var elements = new Array(number_elements);"
"function f() {"
" for (var i = 0; i < number_elements; i++) {"
@@ -2357,9 +2331,13 @@ TEST(OptimizedPretenuringDoubleArrayProperties) {
" }"
" return elements[i - 1];"
"};"
- "f(); f(); f();"
+ "f(); gc();"
+ "f(); f();"
"%OptimizeFunctionOnNextCall(f);"
- "f();");
+ "f();",
+ AllocationSite::kPretenureMinimumCreated);
+
+ v8::Local<v8::Value> res = CompileRun(source.start());
Handle<JSObject> o =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
@@ -2371,14 +2349,16 @@ TEST(OptimizedPretenuringDoubleArrayProperties) {
TEST(OptimizedPretenuringdoubleArrayLiterals) {
i::FLAG_allow_natives_syntax = true;
- i::FLAG_max_semi_space_size = 1;
+ i::FLAG_expose_gc = true;
CcTest::InitializeVM();
if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
- v8::Local<v8::Value> res = CompileRun(
- "var number_elements = 30000;"
+ i::ScopedVector<char> source(1024);
+ i::OS::SNPrintF(
+ source,
+ "var number_elements = %d;"
"var elements = new Array(number_elements);"
"function f() {"
" for (var i = 0; i < number_elements; i++) {"
@@ -2386,9 +2366,13 @@ TEST(OptimizedPretenuringdoubleArrayLiterals) {
" }"
" return elements[number_elements - 1];"
"};"
- "f(); f(); f();"
+ "f(); gc();"
+ "f(); f();"
"%OptimizeFunctionOnNextCall(f);"
- "f();");
+ "f();",
+ AllocationSite::kPretenureMinimumCreated);
+
+ v8::Local<v8::Value> res = CompileRun(source.start());
Handle<JSObject> o =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
@@ -2400,14 +2384,16 @@ TEST(OptimizedPretenuringdoubleArrayLiterals) {
TEST(OptimizedPretenuringNestedMixedArrayLiterals) {
i::FLAG_allow_natives_syntax = true;
- i::FLAG_max_semi_space_size = 1;
+ i::FLAG_expose_gc = true;
CcTest::InitializeVM();
if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
- v8::Local<v8::Value> res = CompileRun(
- "var number_elements = 20000;"
+ i::ScopedVector<char> source(1024);
+ i::OS::SNPrintF(
+ source,
+ "var number_elements = 100;"
"var elements = new Array(number_elements);"
"function f() {"
" for (var i = 0; i < number_elements; i++) {"
@@ -2415,9 +2401,13 @@ TEST(OptimizedPretenuringNestedMixedArrayLiterals) {
" }"
" return elements[number_elements - 1];"
"};"
- "f(); f(); f();"
+ "f(); gc();"
+ "f(); f();"
"%OptimizeFunctionOnNextCall(f);"
- "f();");
+ "f();",
+ AllocationSite::kPretenureMinimumCreated);
+
+ v8::Local<v8::Value> res = CompileRun(source.start());
v8::Local<v8::Value> int_array = v8::Object::Cast(*res)->Get(v8_str("0"));
Handle<JSObject> int_array_handle =
@@ -2438,14 +2428,16 @@ TEST(OptimizedPretenuringNestedMixedArrayLiterals) {
TEST(OptimizedPretenuringNestedObjectLiterals) {
i::FLAG_allow_natives_syntax = true;
- i::FLAG_max_semi_space_size = 1;
+ i::FLAG_expose_gc = true;
CcTest::InitializeVM();
if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
- v8::Local<v8::Value> res = CompileRun(
- "var number_elements = 20000;"
+ i::ScopedVector<char> source(1024);
+ i::OS::SNPrintF(
+ source,
+ "var number_elements = %d;"
"var elements = new Array(number_elements);"
"function f() {"
" for (var i = 0; i < number_elements; i++) {"
@@ -2453,9 +2445,13 @@ TEST(OptimizedPretenuringNestedObjectLiterals) {
" }"
" return elements[number_elements - 1];"
"};"
- "f(); f(); f();"
+ "f(); gc();"
+ "f(); f();"
"%OptimizeFunctionOnNextCall(f);"
- "f();");
+ "f();",
+ AllocationSite::kPretenureMinimumCreated);
+
+ v8::Local<v8::Value> res = CompileRun(source.start());
v8::Local<v8::Value> int_array_1 = v8::Object::Cast(*res)->Get(v8_str("0"));
Handle<JSObject> int_array_handle_1 =
@@ -2476,14 +2472,16 @@ TEST(OptimizedPretenuringNestedObjectLiterals) {
TEST(OptimizedPretenuringNestedDoubleLiterals) {
i::FLAG_allow_natives_syntax = true;
- i::FLAG_max_semi_space_size = 1;
+ i::FLAG_expose_gc = true;
CcTest::InitializeVM();
if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
- v8::Local<v8::Value> res = CompileRun(
- "var number_elements = 20000;"
+ i::ScopedVector<char> source(1024);
+ i::OS::SNPrintF(
+ source,
+ "var number_elements = %d;"
"var elements = new Array(number_elements);"
"function f() {"
" for (var i = 0; i < number_elements; i++) {"
@@ -2491,9 +2489,13 @@ TEST(OptimizedPretenuringNestedDoubleLiterals) {
" }"
" return elements[number_elements - 1];"
"};"
- "f(); f(); f();"
+ "f(); gc();"
+ "f(); f();"
"%OptimizeFunctionOnNextCall(f);"
- "f();");
+ "f();",
+ AllocationSite::kPretenureMinimumCreated);
+
+ v8::Local<v8::Value> res = CompileRun(source.start());
v8::Local<v8::Value> double_array_1 =
v8::Object::Cast(*res)->Get(v8_str("0"));
@@ -2517,19 +2519,21 @@ TEST(OptimizedPretenuringNestedDoubleLiterals) {
// Make sure pretenuring feedback is gathered for constructed objects as well
// as for literals.
TEST(OptimizedPretenuringConstructorCalls) {
- if (!FLAG_allocation_site_pretenuring || !i::FLAG_pretenuring_call_new) {
+ if (!i::FLAG_pretenuring_call_new) {
// FLAG_pretenuring_call_new needs to be synced with the snapshot.
return;
}
i::FLAG_allow_natives_syntax = true;
- i::FLAG_max_semi_space_size = 1;
+ i::FLAG_expose_gc = true;
CcTest::InitializeVM();
if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
- v8::Local<v8::Value> res = CompileRun(
- "var number_elements = 20000;"
+ i::ScopedVector<char> source(1024);
+ i::OS::SNPrintF(
+ source,
+ "var number_elements = %d;"
"var elements = new Array(number_elements);"
"function foo() {"
" this.a = 3;"
@@ -2541,9 +2545,13 @@ TEST(OptimizedPretenuringConstructorCalls) {
" }"
" return elements[number_elements - 1];"
"};"
- "f(); f(); f();"
+ "f(); gc();"
+ "f(); f();"
"%OptimizeFunctionOnNextCall(f);"
- "f();");
+ "f();",
+ AllocationSite::kPretenureMinimumCreated);
+
+ v8::Local<v8::Value> res = CompileRun(source.start());
Handle<JSObject> o =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
@@ -2552,56 +2560,68 @@ TEST(OptimizedPretenuringConstructorCalls) {
}
-// Test regular array literals allocation.
-TEST(OptimizedAllocationArrayLiterals) {
+TEST(OptimizedPretenuringCallNew) {
+ if (!i::FLAG_pretenuring_call_new) {
+ // FLAG_pretenuring_call_new needs to be synced with the snapshot.
+ return;
+ }
i::FLAG_allow_natives_syntax = true;
+ i::FLAG_expose_gc = true;
CcTest::InitializeVM();
if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
- v8::Local<v8::Value> res = CompileRun(
+ i::ScopedVector<char> source(1024);
+ i::OS::SNPrintF(
+ source,
+ "var number_elements = 100;"
+ "var elements = new Array(number_elements);"
+ "function g() { this.a = 0; }"
"function f() {"
- " var numbers = new Array(1, 2, 3);"
- " numbers[0] = 3.14;"
- " return numbers;"
+ " for (var i = 0; i < number_elements; i++) {"
+ " elements[i] = new g();"
+ " }"
+ " return elements[number_elements - 1];"
"};"
- "f(); f(); f();"
+ "f(); gc();"
+ "f(); f();"
"%OptimizeFunctionOnNextCall(f);"
- "f();");
- CHECK_EQ(static_cast<int>(3.14),
- v8::Object::Cast(*res)->Get(v8_str("0"))->Int32Value());
+ "f();",
+ AllocationSite::kPretenureMinimumCreated);
+
+ v8::Local<v8::Value> res = CompileRun(source.start());
Handle<JSObject> o =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
-
- CHECK(CcTest::heap()->InNewSpace(o->elements()));
+ CHECK(CcTest::heap()->InOldPointerSpace(*o));
}
-// Test global pretenuring call new.
-TEST(OptimizedPretenuringCallNew) {
+// Test regular array literals allocation.
+TEST(OptimizedAllocationArrayLiterals) {
i::FLAG_allow_natives_syntax = true;
- i::FLAG_allocation_site_pretenuring = false;
- i::FLAG_pretenuring_call_new = true;
CcTest::InitializeVM();
if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
- AlwaysAllocateScope always_allocate(CcTest::i_isolate());
v8::Local<v8::Value> res = CompileRun(
- "function g() { this.a = 0; }"
"function f() {"
- " return new g();"
+ " var numbers = new Array(1, 2, 3);"
+ " numbers[0] = 3.14;"
+ " return numbers;"
"};"
"f(); f(); f();"
"%OptimizeFunctionOnNextCall(f);"
"f();");
+ CHECK_EQ(static_cast<int>(3.14),
+ v8::Object::Cast(*res)->Get(v8_str("0"))->Int32Value());
Handle<JSObject> o =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
- CHECK(CcTest::heap()->InOldPointerSpace(*o));
+
+ CHECK(CcTest::heap()->InNewSpace(o->elements()));
}
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698