MOTH: have the VM::Function hold on to regexps.
authorErik Verbruggen <erik.verbruggen@me.com>
Sun, 3 Feb 2013 11:19:15 +0000 (12:19 +0100)
committerLars Knoll <lars.knoll@digia.com>
Wed, 6 Feb 2013 07:49:23 +0000 (08:49 +0100)
When regexps were created, they were not added to the VM::Function's
generatedValues, resulting in premature collection.

Change-Id: Idac2202e3040c6311c6f1ceead641e51a8de9729
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/v4/moth/qv4isel_moth.cpp
src/v4/moth/qv4vme_moth.cpp

index f3c5b6b..f31153a 100644 (file)
@@ -400,11 +400,13 @@ void InstructionSelection::loadString(const QString &str, IR::Temp *targetTemp)
 
 void InstructionSelection::loadRegexp(IR::RegExp *sourceRegexp, IR::Temp *targetTemp)
 {
+    VM::Value v = VM::Value::fromObject(engine()->newRegExpObject(
+                                            *sourceRegexp->value,
+                                            sourceRegexp->flags));
+    _vmFunction->generatedValues.append(v);
+
     Instruction::LoadValue load;
-    load.value = Instr::Param::createValue(
-                VM::Value::fromObject(engine()->newRegExpObject(
-                                          *sourceRegexp->value,
-                                          sourceRegexp->flags)));
+    load.value = Instr::Param::createValue(v);
     load.result = getResultParam(targetTemp);
     addInstruction(load);
 }
index a3ab1de..e9889fc 100644 (file)
@@ -225,7 +225,7 @@ VM::Value VME::operator()(QQmlJS::VM::ExecutionContext *context, const uchar *co
     MOTH_END_INSTR(CallValue)
 
     MOTH_BEGIN_INSTR(CallProperty)
-        TRACE(property name, "%s", qPrintable(instr.name->toQString()));
+        TRACE(property name, "%s, args=%u, argc=%u", qPrintable(instr.name->toQString()), instr.args, instr.argc);
         Q_ASSERT(instr.args + instr.argc < stackSize);
         VM::Value *args = stack + instr.args;
         VALUE(instr.result) = __qmljs_call_property(context, VALUE(instr.base), instr.name, args, instr.argc);