aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-08-12 13:30:19 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-12 22:14:49 +0200
commit12520389e91b73b47fb2006b7c7623285c9450c5 (patch)
tree2b195ab1d2e8c6dfee0deee42c870ac71ef34abf
parent5ef37477f99ed97dd6669f05a0ee555fc3baf2ca (diff)
Fix leak of QString in V4 IR
The destructors of the IR nodes won't be called because they come out of a memory pool. Therefore we must store strings by pointer from the function's string pool. Change-Id: I841e801b81c871e8d08cf63ee1e053744c0bf4dc Reviewed-by: Lars Knoll <lars.knoll@digia.com>
-rw-r--r--src/qml/compiler/qv4codegen.cpp2
-rw-r--r--src/qml/compiler/qv4isel_masm.cpp2
-rw-r--r--src/qml/compiler/qv4isel_moth.cpp2
-rw-r--r--src/qml/compiler/qv4jsir.cpp2
-rw-r--r--src/qml/compiler/qv4jsir_p.h6
5 files changed, 7 insertions, 7 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index d0c43c8f56..969b35831e 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -2389,7 +2389,7 @@ bool Codegen::visit(TryStatement *ast)
int exception_to_rethrow = _block->newTemp();
_block->TRY(tryBody, catchBody,
- ast->catchExpression ? ast->catchExpression->name.toString() : QString(),
+ _function->newString(ast->catchExpression ? ast->catchExpression->name.toString() : QString()),
_block->TEMP(exception_to_rethrow));
_block = tryBody;
diff --git a/src/qml/compiler/qv4isel_masm.cpp b/src/qml/compiler/qv4isel_masm.cpp
index 21c2c73fe7..861ffbf3e6 100644
--- a/src/qml/compiler/qv4isel_masm.cpp
+++ b/src/qml/compiler/qv4isel_masm.cpp
@@ -888,7 +888,7 @@ void InstructionSelection::visitTry(V4IR::Try *t)
generateFunctionCall(Assembler::ReturnValueRegister, tryWrapper, Assembler::ContextRegister, Assembler::LocalsRegister,
Assembler::ReentryBlock(t->tryBlock), Assembler::ReentryBlock(t->catchBlock),
- identifier(t->exceptionVarName), Assembler::PointerToValue(t->exceptionVar));
+ identifier(*t->exceptionVarName), Assembler::PointerToValue(t->exceptionVar));
_as->jump(Assembler::ReturnValueRegister);
}
diff --git a/src/qml/compiler/qv4isel_moth.cpp b/src/qml/compiler/qv4isel_moth.cpp
index 9313e24c2d..8b86055388 100644
--- a/src/qml/compiler/qv4isel_moth.cpp
+++ b/src/qml/compiler/qv4isel_moth.cpp
@@ -728,7 +728,7 @@ void InstructionSelection::visitTry(V4IR::Try *t)
Instruction::EnterTry enterTry;
enterTry.tryOffset = 0;
enterTry.catchOffset = 0;
- enterTry.exceptionVarName = identifier(t->exceptionVarName);
+ enterTry.exceptionVarName = identifier(*t->exceptionVarName);
enterTry.exceptionVar = getParam(t->exceptionVar);
ptrdiff_t enterTryLoc = addInstruction(enterTry);
diff --git a/src/qml/compiler/qv4jsir.cpp b/src/qml/compiler/qv4jsir.cpp
index 7f8d257429..fcaf1a0321 100644
--- a/src/qml/compiler/qv4jsir.cpp
+++ b/src/qml/compiler/qv4jsir.cpp
@@ -881,7 +881,7 @@ Stmt *BasicBlock::RET(Temp *expr)
return s;
}
-Stmt *BasicBlock::TRY(BasicBlock *tryBlock, BasicBlock *catchBlock, const QString &exceptionVarName, Temp *exceptionVar)
+Stmt *BasicBlock::TRY(BasicBlock *tryBlock, BasicBlock *catchBlock, const QString *exceptionVarName, Temp *exceptionVar)
{
if (isTerminated())
return 0;
diff --git a/src/qml/compiler/qv4jsir_p.h b/src/qml/compiler/qv4jsir_p.h
index 364ff532c4..4b716fc2ac 100644
--- a/src/qml/compiler/qv4jsir_p.h
+++ b/src/qml/compiler/qv4jsir_p.h
@@ -640,10 +640,10 @@ struct Ret: Stmt {
struct Try: Stmt {
BasicBlock *tryBlock;
BasicBlock *catchBlock;
- QString exceptionVarName;
+ const QString *exceptionVarName;
Temp *exceptionVar; // place to store the caught exception, for use when re-throwing
- void init(BasicBlock *tryBlock, BasicBlock *catchBlock, const QString &exceptionVarName, Temp *exceptionVar)
+ void init(BasicBlock *tryBlock, BasicBlock *catchBlock, const QString *exceptionVarName, Temp *exceptionVar)
{
this->tryBlock = tryBlock;
this->catchBlock = catchBlock;
@@ -816,7 +816,7 @@ struct BasicBlock {
Stmt *JUMP(BasicBlock *target);
Stmt *CJUMP(Expr *cond, BasicBlock *iftrue, BasicBlock *iffalse);
Stmt *RET(Temp *expr);
- Stmt *TRY(BasicBlock *tryBlock, BasicBlock *catchBlock, const QString &exceptionVarName, Temp *exceptionVar);
+ Stmt *TRY(BasicBlock *tryBlock, BasicBlock *catchBlock, const QString *exceptionVarName, Temp *exceptionVar);
void dump(QTextStream &out, Stmt::Mode mode = Stmt::HIR);