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

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

Issue 2632003: Flushing of code from functions that we expect not to use again.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 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-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
===================================================================
--- test/cctest/test-heap.cc (revision 4799)
+++ test/cctest/test-heap.cc (working copy)
@@ -957,3 +957,42 @@
// Check that region covering inobject property 1 is marked dirty.
CHECK(page->IsRegionDirty(clone_addr + (object_size - kPointerSize)));
}
+
+TEST(TestCodeFlushing) {
+ i::FLAG_allow_natives_syntax = true;
+ InitializeVM();
+ v8::HandleScope scope;
+ const char* source = "function foo() {"
+ " var x = 42;"
+ " var y = 42;"
+ " var z = x + y;"
+ "};"
+ "foo()";
+ Handle<String> foo_name = Factory::LookupAsciiSymbol("foo");
+
+ // This compile will add the code to the compilation cache.
+ CompileRun(source);
+
+ // Check function is compiled.
+ Object* func_value = Top::context()->global()->GetProperty(*foo_name);
+ CHECK(func_value->IsJSFunction());
+ Handle<JSFunction> function(JSFunction::cast(func_value));
+ CHECK(function->shared()->is_compiled());
+
+ Heap::CollectAllGarbage(true);
+ Heap::CollectAllGarbage(true);
+
+ // foo should still be in the compilation cache and therefore not
+ // have been removed.
+ CHECK(function->shared()->is_compiled());
+ Heap::CollectAllGarbage(true);
+ Heap::CollectAllGarbage(true);
+ Heap::CollectAllGarbage(true);
+ Heap::CollectAllGarbage(true);
+
+ // foo should no longer be in the compilation cache
+ CHECK(!function->shared()->is_compiled());
+ // Call foo to get it recompiled.
+ CompileRun("foo()");
+ CHECK(function->shared()->is_compiled());
+}
« 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