Avoid creating the activation object in most cases
authorLars Knoll <lars.knoll@digia.com>
Thu, 13 Dec 2012 12:46:49 +0000 (13:46 +0100)
committerSimon Hausmann <simon.hausmann@digia.com>
Thu, 13 Dec 2012 12:52:33 +0000 (13:52 +0100)
it's now only being used for the global context, and
in case a non strict eval defines an additional variable
in any other context.

Change-Id: Ib6531bfce8d19634af79cc813d38c41f5348f961
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
qmljs_environment.cpp

index e717851..ef55252 100644 (file)
@@ -234,10 +234,8 @@ bool ExecutionContext::deleteProperty(String *name)
                 w = w->next;
             }
         }
-        if (ctx->activation) {
-            if (ctx->activation->__hasProperty__(this, name))
-                return ctx->activation->__delete__(this, name);
-        }
+        if (ctx->activation && ctx->activation->__hasProperty__(this, name))
+            return ctx->activation->__delete__(this, name);
     }
     if (strictMode)
         throwSyntaxError(0);
@@ -336,13 +334,9 @@ Value ExecutionContext::getPropertyNoThrow(String *name)
 
 void ExecutionContext::inplaceBitOp(Value value, String *name, BinOp op)
 {
-    for (ExecutionContext *ctx = this; ctx; ctx = ctx->outer()) {
-        if (ctx->activation) {
-            if (ctx->activation->inplaceBinOp(value, name, op, this))
-                return;
-        }
-    }
-    throwReferenceError(Value::fromString(name));
+    Value rhs = getProperty(name);
+    value = op(value, rhs, this);
+    setProperty(name, value);
 }
 
 void ExecutionContext::throwError(Value value)
@@ -411,10 +405,7 @@ void ExecutionContext::initCallContext(ExecutionContext *parent, const Value tha
     if (function->varCount)
         std::fill(locals, locals + function->varCount, Value::undefinedValue());
 
-    if (function->needsActivation)
-        activation = engine->newActivationObject();
-    else
-        activation = 0;
+    activation = 0;
 
     withObject = 0;
 
@@ -425,8 +416,7 @@ void ExecutionContext::initCallContext(ExecutionContext *parent, const Value tha
 
 void ExecutionContext::leaveCallContext()
 {
-    // ## Should rather be handled by a the activation object having a ref to the environment
-    if (activation) {
+    if (!function->needsActivation) {
         delete[] locals;
         locals = 0;
     }