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

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

Issue 282093009: Emit mementos in crankshaft. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE. Created 6 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
« no previous file with comments | « src/objects.h ('k') | test/mjsunit/array-constructor-feedback.js » ('j') | 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 158e146967ce067485272c37ca6df11976066004..459520367c93f9b983fda73e17b9c4de52a17067 100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -2689,6 +2689,64 @@ static int CountMapTransitions(Map* map) {
}
+// Snippet should have a function "f" that returns an object. The object
+// should have a memento behind it in optimized code if there hasn't
+// been enough data to decide on pretenuring.
+static void VerifyResultHasMemento(const char* snippet) {
+ i::ScopedVector<char> source(1024);
+ i::OS::SNPrintF(
+ source,
+ "%s"
+ "f(); gc();"
+ "f(); f();"
+ "%%OptimizeFunctionOnNextCall(f);"
+ "f();",
+ snippet);
+
+ 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));
+ AllocationMemento* memento = CcTest::heap()->FindAllocationMemento(*o);
+ CHECK(memento != NULL);
+}
+
+
+TEST(MementosEmittedFromOptimizedCode) {
+ 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());
+
+ VerifyResultHasMemento("function f() { return [1, 2, 3]; };");
+ VerifyResultHasMemento("function f() { return { foo: 'bar' }; };");
+
+ // String binary ops. Not currently working.
+ // TODO(mvstanton): Talk to benedikt about this. Currently we refuse to
+ // emit mementos in string add if we aren't creating a stub. We should
+ // understand the performance consequences. It seems that we'd need to
+ // 1) allow inlining of stringadd in optimized functions, 2) be able
+ // to pass an allocation site argument to HStringAdd, 3) both.
+ // VerifyResultHasMemento("function f() { return 'hi' + 'gee'; };");
+
+ // The tests below require us to be able to pretenure call new.
+ if (i::FLAG_pretenuring_call_new) {
+ // This allocation could be inlined.
+ VerifyResultHasMemento(
+ "function Blargh() { this.foo = 3; return this; };"
+ "function f() { return new Blargh(); };");
+ // Object isn't inlineable, a stub is called.
+ VerifyResultHasMemento("function f() { return new Object(); };");
+ // Array has a different path, this one will inline the constructor.
+ VerifyResultHasMemento("function f() { return new Array(); };");
+ // This one will call a stub, passing the request to create a memento.
+ VerifyResultHasMemento("function f() { return new Array(100); };");
+ }
+}
+
+
// Test that map transitions are cleared and maps are collected with
// incremental marking as well.
TEST(Regress1465) {
« no previous file with comments | « src/objects.h ('k') | test/mjsunit/array-constructor-feedback.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698