From 7d469e82e274d334c7d03d81b10d225c59d30798 Mon Sep 17 00:00:00 2001 From: David McFarland Date: Sat, 25 May 2013 22:54:44 -0300 Subject: Fix and test for assert/crash in v8 inlining of local functions in qml mode When v8 tries to inline a local function which has been flagged is_qml_global, the assert "CHECK(location_ != __null)" fails. This happens because of the early out in RecordTypeFeedback for is_qml_global. I've limited the early out to UNALLOCATED variables with is_qml_global. bug: https://bugreports.qt-project.org/browse/QTBUG-31366 Change-Id: I360ef1a05a970589159686cf3100cb70de9ae29d Reviewed-by: Alan Alpert Reviewed-by: Lars Knoll --- src/3rdparty/v8/src/ast.cc | 2 +- tests/auto/v8/tst_v8.cpp | 6 ++++++ tests/auto/v8/v8main.cpp | 1 + tests/auto/v8/v8test.cpp | 34 ++++++++++++++++++++++++++++++++++ tests/auto/v8/v8test.h | 1 + 5 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/3rdparty/v8/src/ast.cc b/src/3rdparty/v8/src/ast.cc index 3015b1e..5d7baf2 100644 --- a/src/3rdparty/v8/src/ast.cc +++ b/src/3rdparty/v8/src/ast.cc @@ -566,7 +566,7 @@ void Call::RecordTypeFeedback(TypeFeedbackOracle* oracle, Property* property = expression()->AsProperty(); if (property == NULL) { if (VariableProxy *proxy = expression()->AsVariableProxy()) { - if (proxy->var()->is_qml_global()) + if (proxy->var()->IsUnallocated() && proxy->var()->is_qml_global()) return; } diff --git a/tests/auto/v8/tst_v8.cpp b/tests/auto/v8/tst_v8.cpp index 7461ce3..d4193e4 100644 --- a/tests/auto/v8/tst_v8.cpp +++ b/tests/auto/v8/tst_v8.cpp @@ -69,6 +69,7 @@ private slots: void completehash(); void stringhashcomparison(); void qmlmodevariables(); + void qmlmodeinlinelocal(); }; void tst_v8::eval() @@ -146,6 +147,11 @@ void tst_v8::qmlmodevariables() QVERIFY(v8test_qmlmodevariables()); } +void tst_v8::qmlmodeinlinelocal() +{ + QVERIFY(v8test_qmlmodeinlinelocal()); +} + int main(int argc, char *argv[]) { V8::SetFlagsFromCommandLine(&argc, argv, true); diff --git a/tests/auto/v8/v8main.cpp b/tests/auto/v8/v8main.cpp index 5ec41ad..21440fd 100644 --- a/tests/auto/v8/v8main.cpp +++ b/tests/auto/v8/v8main.cpp @@ -75,6 +75,7 @@ int main(int argc, char *argv[]) RUN_TEST(fallbackpropertyhandler_nonempty); RUN_TEST(completehash); RUN_TEST(qmlmodevariables); + RUN_TEST(qmlmodeinlinelocal); return exit_status; } diff --git a/tests/auto/v8/v8test.cpp b/tests/auto/v8/v8test.cpp index 6621846..6429cd7 100644 --- a/tests/auto/v8/v8test.cpp +++ b/tests/auto/v8/v8test.cpp @@ -1210,3 +1210,37 @@ cleanup: ENDTEST(); } + +// test for https://bugreports.qt-project.org/browse/QTBUG-31366 +// assert/crash when inlining local functions in qml mode +bool v8test_qmlmodeinlinelocal() +{ + BEGINTEST(); + + HandleScope handle_scope; + Persistent context = Context::New(); + Context::Scope context_scope(context); + + Local qmlglobal = Object::New(); + + Local source = String::New( + "function func() {" + "function local_function () {" + "}" + // high enough to get it to opt; 10000 seems to be too low + "for (var i = 0; i < 100000; ++i) local_function();" + "}" + "func();" + ); + + Local