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

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

Issue 132963012: Pretenure call new support. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Comment response. Created 6 years, 10 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
Index: test/cctest/test-heap.cc
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index ff9e51a621ab7f4c634d4de79722134265c8eabf..a5ba0ffeee5e6cad0eddee2dc58d8416908f2a35 100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -2512,6 +2512,43 @@ TEST(OptimizedPretenuringNestedDoubleLiterals) {
}
+// Make sure pretenuring feedback is gathered for constructed objects as well
+// as for literals.
+TEST(OptimizedPretenuringConstructorCalls) {
+ i::FLAG_allow_natives_syntax = true;
+ i::FLAG_allocation_site_pretenuring = true;
+ i::FLAG_pretenuring_call_new = true;
+ i::FLAG_max_new_space_size = 2048;
+ 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;"
+ "var elements = new Array(number_elements);"
+ "function foo() {"
+ " this.a = 3;"
+ " this.b = {};"
+ " return this;"
Hannes Payer (out of office) 2014/02/18 16:24:26 remove return this;
mvstanton 2014/02/19 08:40:26 Done.
+ "}"
+ "function f() {"
+ " for (var i = 0; i < number_elements; i++) {"
+ " elements[i] = new foo();"
+ " }"
+ " return elements[number_elements - 1];"
+ "};"
+ "f(); f(); f();"
+ "%OptimizeFunctionOnNextCall(f);"
+ "f();");
+
+ Handle<JSObject> o =
+ v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
+
+ CHECK(CcTest::heap()->InOldPointerSpace(*o));
+}
+
+
// Test regular array literals allocation.
TEST(OptimizedAllocationArrayLiterals) {
i::FLAG_allow_natives_syntax = true;
@@ -2539,6 +2576,7 @@ TEST(OptimizedAllocationArrayLiterals) {
}
+// Test that a form of call-new pretenuring works even without allocation sites.
Hannes Payer (out of office) 2014/02/18 16:24:26 Test global pretenuring of call new.
mvstanton 2014/02/19 08:40:26 Done.
TEST(OptimizedPretenuringCallNew) {
i::FLAG_allow_natives_syntax = true;
i::FLAG_allocation_site_pretenuring = false;

Powered by Google App Engine
This is Rietveld 408576698