[V8] Fix crash when querying for scopes
authorAurindam Jana <aurindam.jana@nokia.com>
Tue, 10 Jan 2012 18:33:44 +0000 (19:33 +0100)
committerQt by Nokia <qt-info@nokia.com>
Thu, 1 Mar 2012 11:04:01 +0000 (12:04 +0100)
For function code, the compilation info was incorrectly
marked as global if the shared_info had qml_mode set.
The ASSERT for the length of nested scopes failed when
querying for scopes and hence the crash. This fix sets the
qml_mode for function code correctly.

Fixes https://bugreports.qt.nokia.com/browse/QTBUG-23256

This patch should be squashed into
-- 2fe857938c3d1683df88133582bc3e7736264b10 [V8] Introduce a
QML compilation mode -- in the next v8 rebase as this code
only improves code in that patch.

Change-Id: Ibc969432cd245ace40602e9e2f5824b2287e8107
Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
Reviewed-by: Simon Hausmann <simon.hausmann@nokia.com>
src/3rdparty/v8/src/runtime.cc

index 7c34c36..a8a5f4c 100644 (file)
@@ -11255,7 +11255,7 @@ class ScopeIterator {
     ZoneScope zone_scope(isolate, DELETE_ON_EXIT);
     Handle<Script> script(Script::cast(shared_info->script()));
     Scope* scope;
-    if (index >= 0 || shared_info->qml_mode()) {
+    if (index >= 0) {
       // Global code
       CompilationInfo info(script);
       info.MarkAsGlobal();
@@ -11267,6 +11267,8 @@ class ScopeIterator {
     } else {
       // Function code
       CompilationInfo info(shared_info);
+      if (shared_info->qml_mode())
+          info.MarkAsQmlMode();
       CHECK(ParserApi::Parse(&info));
       CHECK(Scope::Analyze(&info));
       scope = info.function()->scope();
@@ -11349,10 +11351,7 @@ class ScopeIterator {
         return Handle<JSObject>(CurrentContext()->global());
       case ScopeIterator::ScopeTypeLocal: {
         Handle<SerializedScopeInfo> scope_info = nested_scope_chain_.last();
-        if (scope_info->IsQmlMode())
-            ASSERT(nested_scope_chain_.length() == 2);
-        else
-            ASSERT(nested_scope_chain_.length() == 1);
+        ASSERT(nested_scope_chain_.length() == 1);
         // Materialize the content of the local scope into a JSObject.
         return MaterializeLocalScope(isolate_, frame_, inlined_frame_index_);
       }