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

Unified Diff: test/cctest/test-mementos.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-mementos.cc
diff --git a/test/cctest/test-mementos.cc b/test/cctest/test-mementos.cc
index f59eef9485f8257ef158117dc5b6e69a2f82da09..45307168c95ff6c4d3c7af4a0d3e8550eac97548 100644
--- a/test/cctest/test-mementos.cc
+++ b/test/cctest/test-mementos.cc
@@ -57,3 +57,47 @@ TEST(Regress340063) {
// current new space top pointer.
heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
}
+
+
+TEST(PretenuringCallNew) {
+ CcTest::InitializeVM();
+ if (!i::FLAG_allocation_site_pretenuring) return;
+ if (!i::FLAG_pretenuring_call_new) return;
+
+ v8::HandleScope scope(CcTest::isolate());
+ Isolate* isolate = CcTest::i_isolate();
+ Heap* heap = isolate->heap();
+
+ // We need to create several instances to get past the slack-tracking
+ // phase, where mementos aren't emitted.
+ int call_count = 10;
+ CHECK_GE(call_count, SharedFunctionInfo::kGenerousAllocationCount);
+ i::ScopedVector<char> test_buf(1024);
+ const char* program =
+ "function f() {"
+ " this.a = 3;"
+ " this.b = {};"
+ " return this;"
+ "};"
+ "var a;"
+ "for(var i = 0; i < %d; i++) {"
+ " a = new f();"
+ "}"
+ "a;";
Hannes Payer (out of office) 2014/02/18 16:24:26 a == return a; ?
mvstanton 2014/02/19 08:40:26 Done.
+ i::OS::SNPrintF(test_buf, program, call_count);
+ v8::Local<v8::Value> res = CompileRun(test_buf.start());
+ Handle<JSObject> o =
+ v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
+
+ // The object of class f should have a memento secreted behind it.
+ Address memento_address = o->address() + o->map()->instance_size();
+ AllocationMemento* memento =
+ reinterpret_cast<AllocationMemento*>(memento_address + kHeapObjectTag);
+ CHECK_EQ(memento->map(), heap->allocation_memento_map());
+
+ // Furthermore, how many mementos did we create? The count should match
+ // call_count - SharedFunctionInfo::kGenerousAllocationCount.
+ AllocationSite* site = memento->GetAllocationSite();
+ CHECK_EQ(call_count - SharedFunctionInfo::kGenerousAllocationCount,
+ site->pretenure_create_count()->value());
+}

Powered by Google App Engine
This is Rietveld 408576698