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

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

Issue 17580011: Added pretenuring support for fast literal allocation in old data space. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 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
« src/hydrogen.cc ('K') | « src/hydrogen.cc ('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 170dbd490a9a93fa57a3a2dad7a622642c114a14..fae6be2afedd84ee6322a2ee71b8685d63d1be08 100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -2109,8 +2109,7 @@ TEST(OptimizedAllocationAlwaysInNewSpace) {
}
-// Test pretenuring of array literals allocated with HAllocate.
-TEST(OptimizedPretenuringArrayLiterals) {
+TEST(OptimizedPretenuringIntegerArrayLiterals) {
i::FLAG_allow_natives_syntax = true;
CcTest::InitializeVM();
if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return;
@@ -2122,7 +2121,6 @@ TEST(OptimizedPretenuringArrayLiterals) {
v8::Local<v8::Value> res = CompileRun(
"function f() {"
" var numbers = [1, 2, 3];"
- " numbers[0] = {};"
" return numbers;"
"};"
"f(); f(); f();"
@@ -2133,21 +2131,29 @@ TEST(OptimizedPretenuringArrayLiterals) {
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
CHECK(HEAP->InOldPointerSpace(o->elements()));
+ CHECK(HEAP->InOldPointerSpace(*o));
}
-TEST(OptimizedPretenuringSimpleArrayLiterals) {
+static void OptimizedPretenuringMixedInObjectProperties(bool full) {
i::FLAG_allow_natives_syntax = true;
- i::FLAG_pretenuring = false;
CcTest::InitializeVM();
if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
+ HEAP->SetNewSpaceHighPromotionModeActive(true);
AlwaysAllocateScope always_allocate;
+
+ if (full) {
+ PagedSpace* old_pointer_space = HEAP->old_pointer_space();
+ SimulateFullSpace(old_pointer_space);
+ }
+
v8::Local<v8::Value> res = CompileRun(
"function f() {"
- " return [1, 2, 3];"
+ " var numbers = {a: {c: 2.2, d: {}}, b: 1.1};"
+ " return numbers;"
"};"
"f(); f(); f();"
"%OptimizeFunctionOnNextCall(f);"
@@ -2156,7 +2162,247 @@ TEST(OptimizedPretenuringSimpleArrayLiterals) {
Handle<JSObject> o =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
- CHECK(HEAP->InNewSpace(*o));
+ CHECK(HEAP->InOldPointerSpace(*o));
+ CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(0)));
+ CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(1)));
+
+ JSObject* inner_object = reinterpret_cast<JSObject*>(o->RawFastPropertyAt(0));
+ CHECK(HEAP->InOldPointerSpace(inner_object));
+ CHECK(HEAP->InOldDataSpace(inner_object->RawFastPropertyAt(0)));
+ CHECK(HEAP->InOldPointerSpace(inner_object->RawFastPropertyAt(1)));
+}
+
+
+TEST(OptimizedPretenuringMixedInObjectProperties) {
+ OptimizedPretenuringMixedInObjectProperties(false);
+}
+
+
+TEST(OptimizedPretenuringMixedInObjectPropertiesFullHeap) {
+ OptimizedPretenuringMixedInObjectProperties(true);
+}
+
+
+static void OptimizedPretenuringDoubleArrayProperties(bool full) {
+ i::FLAG_allow_natives_syntax = true;
+ CcTest::InitializeVM();
+ if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return;
+ if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
+ v8::HandleScope scope(CcTest::isolate());
+ HEAP->SetNewSpaceHighPromotionModeActive(true);
+
+ AlwaysAllocateScope always_allocate;
Michael Starzinger 2013/06/24 15:04:47 Is the AlwaysAllocateScope really necessary here?
Hannes Payer (out of office) 2013/06/24 16:44:22 Done.
+
+ if (full) {
Michael Starzinger 2013/06/24 15:04:47 As discussed offline: This will not really trigger
Hannes Payer (out of office) 2013/06/24 16:44:22 Done.
+ PagedSpace* old_pointer_space = HEAP->old_pointer_space();
+ SimulateFullSpace(old_pointer_space);
+ }
+
+ v8::Local<v8::Value> res = CompileRun(
+ "function f() {"
+ " var numbers = {a: 1.1, b: 2.2};"
+ " return numbers;"
+ "};"
+ "f(); f(); f();"
+ "%OptimizeFunctionOnNextCall(f);"
+ "f();");
+
+ Handle<JSObject> o =
+ v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
+
+ CHECK(HEAP->InOldPointerSpace(*o));
+ CHECK(HEAP->InOldDataSpace(o->properties()));
+}
+
+
+TEST(OptimizedPretenuringDoubleArrayProperties) {
+ OptimizedPretenuringDoubleArrayProperties(false);
+}
+
+
+TEST(OptimizedPretenuringDoubleArrayPropertiesFullHeap) {
+ OptimizedPretenuringDoubleArrayProperties(true);
+}
+
+
+static void OptimizedPretenuringdoubleArrayLiterals(bool full) {
+ i::FLAG_allow_natives_syntax = true;
+ CcTest::InitializeVM();
+ if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return;
+ if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
+ v8::HandleScope scope(CcTest::isolate());
+ HEAP->SetNewSpaceHighPromotionModeActive(true);
+
+ AlwaysAllocateScope always_allocate;
+
+ if (full) {
+ PagedSpace* old_pointer_space = HEAP->old_pointer_space();
+ SimulateFullSpace(old_pointer_space);
+ }
+
+ v8::Local<v8::Value> res = CompileRun(
+ "function f() {"
+ " var numbers = [1.1, 2.2, 3.3];"
+ " return numbers;"
+ "};"
+ "f(); f(); f();"
+ "%OptimizeFunctionOnNextCall(f);"
+ "f();");
+
+ Handle<JSObject> o =
+ v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
+
+ CHECK(HEAP->InOldDataSpace(o->elements()));
+ CHECK(HEAP->InOldPointerSpace(*o));
+}
+
+
+TEST(OptimizedPretenuringdoubleArrayLiterals) {
+ OptimizedPretenuringdoubleArrayLiterals(false);
+}
+
+
+TEST(OptimizedPretenuringdoubleArrayLiteralsFullHeap) {
+ OptimizedPretenuringdoubleArrayLiterals(true);
+}
+
+
+static void OptimizedPretenuringNestedMixedArrayLiterals(bool full) {
+ i::FLAG_allow_natives_syntax = true;
+ CcTest::InitializeVM();
+ if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return;
+ if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
+ v8::HandleScope scope(CcTest::isolate());
+ HEAP->SetNewSpaceHighPromotionModeActive(true);
+
+ AlwaysAllocateScope always_allocate;
+
+ if (full) {
+ PagedSpace* old_pointer_space = HEAP->old_pointer_space();
+ SimulateFullSpace(old_pointer_space);
+ }
+
+ v8::Local<v8::Value> res = CompileRun(
+ "function f() {"
+ " var numbers = [[1, 2, 3],[1.1, 2.2, 3.3]];"
+ " return numbers;"
+ "};"
+ "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(HEAP->InOldPointerSpace(*o));
+ CHECK(HEAP->InOldPointerSpace(*int_array_handle));
+ CHECK(HEAP->InOldPointerSpace(int_array_handle->elements()));
+ CHECK(HEAP->InOldPointerSpace(*double_array_handle));
+ CHECK(HEAP->InOldDataSpace(double_array_handle->elements()));
+}
+
+
+TEST(OptimizedPretenuringNestedMixedArrayLiterals) {
+ OptimizedPretenuringNestedMixedArrayLiterals(false);
+}
+
+
+TEST(OptimizedPretenuringNestedMixedArrayLiteralsFullHeap) {
+ OptimizedPretenuringNestedMixedArrayLiterals(true);
+}
+
+
+TEST(OptimizedPretenuringNestedIntegerLiterals) {
+ i::FLAG_allow_natives_syntax = true;
+ CcTest::InitializeVM();
+ if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return;
+ if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
+ v8::HandleScope scope(CcTest::isolate());
+ HEAP->SetNewSpaceHighPromotionModeActive(true);
+
+ AlwaysAllocateScope always_allocate;
+ v8::Local<v8::Value> res = CompileRun(
+ "function f() {"
+ " var numbers = [[1, 1, 1],[2, 2, 2]];"
+ " return numbers;"
+ "};"
+ "f(); f(); f();"
+ "%OptimizeFunctionOnNextCall(f);"
+ "f();");
+
+ v8::Local<v8::Value> int_array_1 = v8::Object::Cast(*res)->Get(v8_str("0"));
+ Handle<JSObject> int_array_handle_1 =
+ v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array_1));
+ v8::Local<v8::Value> int_array_2 = v8::Object::Cast(*res)->Get(v8_str("1"));
+ Handle<JSObject> int_array_handle_2 =
+ v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array_2));
+
+ Handle<JSObject> o =
+ v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
+ CHECK(HEAP->InOldPointerSpace(*o));
+ CHECK(HEAP->InOldPointerSpace(*int_array_handle_1));
+ CHECK(HEAP->InOldPointerSpace(int_array_handle_1->elements()));
+ CHECK(HEAP->InOldPointerSpace(*int_array_handle_2));
+ CHECK(HEAP->InOldPointerSpace(int_array_handle_2->elements()));
+}
+
+
+static void TestOptimizedPretenuringNestedDoubleLiterals(bool full) {
+ i::FLAG_allow_natives_syntax = true;
+ CcTest::InitializeVM();
+ if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return;
+ if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
+ v8::HandleScope scope(CcTest::isolate());
+ HEAP->SetNewSpaceHighPromotionModeActive(true);
+
+ AlwaysAllocateScope always_allocate;
+
+ if (full) {
+ PagedSpace* old_pointer_space = HEAP->old_pointer_space();
+ SimulateFullSpace(old_pointer_space);
+ }
+
+ v8::Local<v8::Value> res = CompileRun(
+ "function f() {"
+ " var numbers = [[1.1, 1.2, 1.3],[2.1, 2.2, 2.3]];"
+ " return numbers;"
+ "};"
+ "f(); f(); f();"
+ "%OptimizeFunctionOnNextCall(f);"
+ "f();");
+
+ v8::Local<v8::Value> double_array_1 =
+ v8::Object::Cast(*res)->Get(v8_str("0"));
+ Handle<JSObject> double_array_handle_1 =
+ v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array_1));
+ v8::Local<v8::Value> double_array_2 =
+ v8::Object::Cast(*res)->Get(v8_str("1"));
+ Handle<JSObject> double_array_handle_2 =
+ v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array_2));
+
+ Handle<JSObject> o =
+ v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
+ CHECK(HEAP->InOldPointerSpace(*o));
+ CHECK(HEAP->InOldPointerSpace(*double_array_handle_1));
+ CHECK(HEAP->InOldDataSpace(double_array_handle_1->elements()));
+ CHECK(HEAP->InOldPointerSpace(*double_array_handle_2));
+ CHECK(HEAP->InOldDataSpace(double_array_handle_2->elements()));
+}
+
+
+TEST(OptimizedPretenuringNestedDoubleLiterals) {
+ TestOptimizedPretenuringNestedDoubleLiterals(false);
+}
+
+
+TEST(OptimizedPretenuringNestedDoubleLiteralsFullHeap) {
+ TestOptimizedPretenuringNestedDoubleLiterals(true);
}
« src/hydrogen.cc ('K') | « src/hydrogen.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698