[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>
Wed, 18 Jan 2012 22:59:49 +0000 (23:59 +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: I137b0e88dba81ff2ff46876faa883edb9dd0e4a9
Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
src/3rdparty/v8/src/runtime.cc

index 8010169..939bc89 100644 (file)
@@ -11262,7 +11262,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();
@@ -11276,6 +11276,8 @@ class ScopeIterator {
     } else {
       // Function code
       CompilationInfo info(shared_info);
+      if (shared_info->qml_mode())
+          info.MarkAsQmlMode();
       bool result = ParserApi::Parse(&info);
       ASSERT(result);
       result = Scope::Analyze(&info);
@@ -11360,10 +11362,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_);
       }