aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4isel_masm_p.h
diff options
context:
space:
mode:
authorLars Knoll <[email protected]>2013-10-18 15:42:17 +0200
committerThe Qt Project <[email protected]>2013-10-29 10:38:45 +0100
commit5229a8b259286c9ea61036fd6b4bd0039104a206 (patch)
tree277d62ecedeaf703ce778d86f8cbcb94b9a57fe2 /src/qml/compiler/qv4isel_masm_p.h
parent570686d42176af193b15abfe4b7bc17d831f4cf6 (diff)
Rework exception handling
Start the work to remove c++ exceptions from our JS exception handling. Rather rely on engine->hasException. Check the flag after we return from any runtime call in the JIT. Implement new try/catch handling code in qv4codegen and for the JIT that doesn't rely on exceptions. As an added bonus, we can remove the Try statement in the IR. Change-Id: Ic95addd6ae03371c43c47e04cac26afdce23a061 Reviewed-by: Simon Hausmann <[email protected]>
Diffstat (limited to 'src/qml/compiler/qv4isel_masm_p.h')
-rw-r--r--src/qml/compiler/qv4isel_masm_p.h44
1 files changed, 38 insertions, 6 deletions
diff --git a/src/qml/compiler/qv4isel_masm_p.h b/src/qml/compiler/qv4isel_masm_p.h
index bd4c564ab9..3d1b271cdc 100644
--- a/src/qml/compiler/qv4isel_masm_p.h
+++ b/src/qml/compiler/qv4isel_masm_p.h
@@ -49,6 +49,7 @@
#include "private/qv4lookup_p.h"
#include <QtCore/QHash>
+#include <QtCore/QStack>
#include <config.h>
#include <wtf/Vector.h>
@@ -62,6 +63,7 @@ QT_BEGIN_NAMESPACE
namespace QQmlJS {
namespace MASM {
+
class InstructionSelection;
struct CompilationUnit : public QV4::CompiledData::CompilationUnit
@@ -88,6 +90,13 @@ struct RelativeCall {
{}
};
+
+template <typename T>
+struct ExceptionCheck {
+ enum { NeedsCheck = 1 };
+};
+
+
class Assembler : public JSC::MacroAssembler
{
public:
@@ -874,6 +883,23 @@ public:
void enterStandardStackFrame();
void leaveStandardStackFrame();
+ void checkException() {
+ loadPtr(Address(ContextRegister, qOffsetOf(QV4::ExecutionContext, engine)), ScratchRegister);
+ load32(Address(ScratchRegister, qOffsetOf(QV4::ExecutionEngine, hasException)), ScratchRegister);
+ Jump exceptionThrown = branch32(NotEqual, ScratchRegister, TrustedImm32(0));
+ if (catchBlock)
+ addPatch(catchBlock, exceptionThrown);
+ else
+ exceptionPropagationJumps.append(exceptionThrown);
+ }
+ void jumpToExceptionHandler() {
+ Jump exceptionThrown = jump();
+ if (catchBlock)
+ addPatch(catchBlock, exceptionThrown);
+ else
+ exceptionPropagationJumps.append(exceptionThrown);
+ }
+
template <int argumentNumber, typename T>
void loadArgumentOnStackOrRegister(const T &value)
{
@@ -917,7 +943,6 @@ public:
enum { Size = 0 };
};
-
template <typename ArgRet, typename Callable, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5, typename Arg6>
void generateFunctionCallImp(ArgRet r, const char* functionName, Callable function, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6)
{
@@ -954,10 +979,15 @@ public:
callAbsolute(functionName, function);
- storeReturnValue(r);
-
if (stackSpaceNeeded)
add32(TrustedImm32(stackSpaceNeeded), StackPointerRegister);
+
+ if (ExceptionCheck<Callable>::NeedsCheck) {
+ checkException();
+ }
+
+ storeReturnValue(r);
+
}
template <typename ArgRet, typename Callable, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5>
@@ -1351,6 +1381,9 @@ public:
const StackLayout stackLayout() const { return _stackLayout; }
ConstantTable &constantTable() { return _constTable; }
+ Label exceptionReturnLabel;
+ V4IR::BasicBlock * catchBlock;
+ QVector<Jump> exceptionPropagationJumps;
private:
const StackLayout _stackLayout;
ConstantTable _constTable;
@@ -1410,7 +1443,8 @@ protected:
virtual void callBuiltinDeleteName(const QString &name, V4IR::Temp *result);
virtual void callBuiltinDeleteValue(V4IR::Temp *result);
virtual void callBuiltinThrow(V4IR::Expr *arg);
- virtual void callBuiltinFinishTry();
+ virtual void callBuiltinReThrow();
+ virtual void callBuiltinPushCatchScope(const QString &exceptionName);
virtual void callBuiltinForeachIteratorObject(V4IR::Temp *arg, V4IR::Temp *result);
virtual void callBuiltinForeachNextPropertyname(V4IR::Temp *arg, V4IR::Temp *result);
virtual void callBuiltinPushWithScope(V4IR::Temp *arg);
@@ -1469,7 +1503,6 @@ protected:
virtual void visitJump(V4IR::Jump *);
virtual void visitCJump(V4IR::CJump *);
virtual void visitRet(V4IR::Ret *);
- virtual void visitTry(V4IR::Try *);
Assembler::Jump genTryDoubleConversion(V4IR::Expr *src, Assembler::FPRegisterID dest);
Assembler::Jump genInlineBinop(V4IR::AluOp oper, V4IR::Expr *leftSource,
@@ -1589,7 +1622,6 @@ private:
V4IR::Function* _function;
QSet<V4IR::Jump *> _removableJumps;
Assembler* _as;
- QSet<V4IR::BasicBlock*> _reentryBlocks;
CompilationUnit *compilationUnit;
};