Revision: 19854
Author: [email protected]
Date: Wed Mar 12 15:18:17 2014 UTC
Log: Fix for bug 351257: type feedback vector initialization issue.
The feedback vector is stored in the shared function info, and there
is an effort to reuse it when re-running full code generation as a
prelude to creating optimized code. However we shouldn't reuse the
vector for lazily compiled methods on first compile, as scoping analysis
can change the allocation of vector slots.
BUG=351257
LOG=N
[email protected], [email protected]
Review URL: https://codereview.chromium.org/196723003
http://code.google.com/p/v8/source/detail?r=19854
Modified:
/branches/bleeding_edge/src/compiler.cc
/branches/bleeding_edge/test/cctest/test-compiler.cc
=======================================
--- /branches/bleeding_edge/src/compiler.cc Tue Mar 11 14:41:22 2014 UTC
+++ /branches/bleeding_edge/src/compiler.cc Wed Mar 12 15:18:17 2014 UTC
@@ -141,13 +141,11 @@
}
set_bailout_reason(kUnknown);
- if (!shared_info().is_null()) {
- FixedArray* info_feedback_vector = shared_info()->feedback_vector();
- if (info_feedback_vector->length() > 0) {
- // We should initialize the CompilationInfo feedback vector from the
- // passed in shared info, rather than creating a new one.
- feedback_vector_ = Handle<FixedArray>(info_feedback_vector, isolate);
- }
+ if (!shared_info().is_null() && shared_info()->is_compiled()) {
+ // We should initialize the CompilationInfo feedback vector from the
+ // passed in shared info, rather than creating a new one.
+ feedback_vector_ = Handle<FixedArray>(shared_info()->feedback_vector(),
+ isolate);
}
}
=======================================
--- /branches/bleeding_edge/test/cctest/test-compiler.cc Tue Mar 11
14:41:22 2014 UTC
+++ /branches/bleeding_edge/test/cctest/test-compiler.cc Wed Mar 12
15:18:17 2014 UTC
@@ -345,6 +345,43 @@
CHECK(f->shared()->has_deoptimization_support());
CHECK(f->shared()->feedback_vector()->get(0)->IsJSFunction());
}
+
+
+TEST(FeedbackVectorRecreatedOnScopeChanges) {
+ 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(), scoping analysis having been performed.
+ CHECK_EQ(1, f->shared()->feedback_vector()->length());
+ // And yet it's not compiled.
+ CHECK(!f->shared()->is_compiled());
+
+ CompileRun("morphing_call();");
+
+ // On scoping analysis after lazy compile, the call is now a global
+ // call which needs no feedback vector slot.
+ CHECK_EQ(0, f->shared()->feedback_vector()->length());
+ CHECK(f->shared()->is_compiled());
+}
// Test that optimized code for different closures is actually shared
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.