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

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

Issue 254623002: Simplify feedback vector creation and store in SharedFunctionInfo. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Code comments Created 6 years, 8 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/x64/full-codegen-x64.cc ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-compiler.cc
diff --git a/test/cctest/test-compiler.cc b/test/cctest/test-compiler.cc
index cc9258aa15643e40be6b30ae9c66b92d334c85b5..9974ff570208929692f29c315be250f3da3efe92 100644
--- a/test/cctest/test-compiler.cc
+++ b/test/cctest/test-compiler.cc
@@ -290,6 +290,78 @@ TEST(GetScriptLineNumber) {
}
+TEST(FeedbackVectorPreservedAcrossRecompiles) {
+ if (i::FLAG_always_opt || !i::FLAG_crankshaft) return;
+ i::FLAG_allow_natives_syntax = true;
+ CcTest::InitializeVM();
+ if (!CcTest::i_isolate()->use_crankshaft()) return;
+ v8::HandleScope scope(CcTest::isolate());
+
+ // Make sure function f has a call that uses a type feedback slot.
+ CompileRun("function fun() {};"
+ "fun1 = fun;"
+ "function f(a) { a(); } f(fun1);");
+
+ Handle<JSFunction> f =
+ v8::Utils::OpenHandle(
+ *v8::Handle<v8::Function>::Cast(
+ CcTest::global()->Get(v8_str("f"))));
+
+ // We shouldn't have deoptimization support. We want to recompile and
+ // verify that our feedback vector preserves information.
+ CHECK(!f->shared()->has_deoptimization_support());
+ Handle<FixedArray> feedback_vector(f->shared()->feedback_vector());
+
+ // Verify that we gathered feedback.
+ CHECK_EQ(1, feedback_vector->length());
+ CHECK(feedback_vector->get(0)->IsJSFunction());
+
+ CompileRun("%OptimizeFunctionOnNextCall(f); f(fun1);");
+
+ // Verify that the feedback is still "gathered" despite a recompilation
+ // of the full code.
+ CHECK(f->IsOptimized());
+ CHECK(f->shared()->has_deoptimization_support());
+ CHECK(f->shared()->feedback_vector()->get(0)->IsJSFunction());
+}
+
+
+TEST(FeedbackVectorUnaffectedByScopeChanges) {
+ if (i::FLAG_always_opt || !i::FLAG_lazy) return;
+ CcTest::InitializeVM();
+ v8::HandleScope scope(CcTest::isolate());
+
+ CompileRun("function builder() {"
+ " call_target = function() { return 3; };"
+ " return (function() {"
+ " eval('');"
+ " return function() {"
+ " 'use strict';"
+ " call_target();"
+ " }"
+ " })();"
+ "}"
+ "morphing_call = builder();");
+
+ Handle<JSFunction> f =
+ v8::Utils::OpenHandle(
+ *v8::Handle<v8::Function>::Cast(
+ CcTest::global()->Get(v8_str("morphing_call"))));
+
+ // morphing_call should have one feedback vector slot for the call to
+ // call_target().
+ CHECK_EQ(1, f->shared()->feedback_vector()->length());
+ // And yet it's not compiled.
+ CHECK(!f->shared()->is_compiled());
+
+ CompileRun("morphing_call();");
+
+ // The vector should have the same size despite the new scoping.
+ CHECK_EQ(1, f->shared()->feedback_vector()->length());
+ CHECK(f->shared()->is_compiled());
+}
+
+
// Test that optimized code for different closures is actually shared
// immediately by the FastNewClosureStub when run in the same context.
TEST(OptimizedCodeSharing) {
« no previous file with comments | « src/x64/full-codegen-x64.cc ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698