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

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

Issue 1211453002: Reland "Keep a canonical list of shared function infos." (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix alwaysopt Created 5 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/x87/full-codegen-x87.cc ('k') | test/mjsunit/regress/regress-4121.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 e0c2818c8ddda0da50a250795c298c18e0f5bdec..668fb01e1723de450e396ac176e23e0202d8c9e2 100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -5924,6 +5924,53 @@ TEST(MessageObjectLeak) {
}
+static void CheckEqualSharedFunctionInfos(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ Handle<Object> obj1 = v8::Utils::OpenHandle(*args[0]);
+ Handle<Object> obj2 = v8::Utils::OpenHandle(*args[1]);
+ Handle<JSFunction> fun1 = Handle<JSFunction>::cast(obj1);
+ Handle<JSFunction> fun2 = Handle<JSFunction>::cast(obj2);
+ CHECK(fun1->shared() == fun2->shared());
+}
+
+
+static void RemoveCodeAndGC(const v8::FunctionCallbackInfo<v8::Value>& args) {
+ Isolate* isolate = CcTest::i_isolate();
+ Handle<Object> obj = v8::Utils::OpenHandle(*args[0]);
+ Handle<JSFunction> fun = Handle<JSFunction>::cast(obj);
+ fun->ReplaceCode(*isolate->builtins()->CompileLazy());
+ fun->shared()->ReplaceCode(*isolate->builtins()->CompileLazy());
+ isolate->heap()->CollectAllAvailableGarbage("remove code and gc");
+}
+
+
+TEST(CanonicalSharedFunctionInfo) {
+ CcTest::InitializeVM();
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate);
+ global->Set(isolate, "check", v8::FunctionTemplate::New(
+ isolate, CheckEqualSharedFunctionInfos));
+ global->Set(isolate, "remove",
+ v8::FunctionTemplate::New(isolate, RemoveCodeAndGC));
+ v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global);
+ v8::Context::Scope cscope(context);
+ CompileRun(
+ "function f() { return function g() {}; }"
+ "var g1 = f();"
+ "remove(f);"
+ "var g2 = f();"
+ "check(g1, g2);");
+
+ CompileRun(
+ "function f() { return (function() { return function g() {}; })(); }"
+ "var g1 = f();"
+ "remove(f);"
+ "var g2 = f();"
+ "check(g1, g2);");
+}
+
+
TEST(OldGenerationAllocationThroughput) {
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
« no previous file with comments | « src/x87/full-codegen-x87.cc ('k') | test/mjsunit/regress/regress-4121.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698