From 22a09c8dd09cb3aa4b67568bec47fb500ddeef42 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 23 Jan 2013 22:49:31 +0100 Subject: [PATCH] Fix all but one remaining test case for exceptions Change-Id: I03d42eeeb28a0f75d3cad81cb7af815c9784c43e Reviewed-by: Simon Hausmann --- moth/qv4instr_moth_p.h | 1 - moth/qv4isel_moth.cpp | 7 ------- moth/qv4isel_moth_p.h | 1 - moth/qv4vme_moth.cpp | 3 --- qmljs_runtime.cpp | 6 ------ qv4codegen.cpp | 21 +++++++++++++-------- qv4ir.cpp | 2 -- qv4ir_p.h | 1 - qv4isel_llvm_p.h | 1 - qv4isel_masm.cpp | 5 ----- qv4isel_masm_p.h | 1 - qv4isel_p.cpp | 4 ---- qv4isel_p.h | 1 - tests/TestExpectations | 5 ----- 14 files changed, 13 insertions(+), 46 deletions(-) diff --git a/moth/qv4instr_moth_p.h b/moth/qv4instr_moth_p.h index d20b84e..07016cc 100644 --- a/moth/qv4instr_moth_p.h +++ b/moth/qv4instr_moth_p.h @@ -164,7 +164,6 @@ union Instr MOTH_INSTR_HEADER enum { builtin_throw, - builtin_rethrow, builtin_create_exception_handler, builtin_delete_exception_handler, builtin_get_exception, diff --git a/moth/qv4isel_moth.cpp b/moth/qv4isel_moth.cpp index 2acdb88..2626955 100644 --- a/moth/qv4isel_moth.cpp +++ b/moth/qv4isel_moth.cpp @@ -766,13 +766,6 @@ void InstructionSelection::callBuiltinThrow(IR::Temp *arg) addInstruction(call); } -void InstructionSelection::callBuiltinRethrow() -{ - Instruction::CallBuiltin call; - call.builtin = Instruction::CallBuiltin::builtin_rethrow; - addInstruction(call); -} - void InstructionSelection::callBuiltinCreateExceptionHandler(IR::Temp *result) { Instruction::CallBuiltin call; diff --git a/moth/qv4isel_moth_p.h b/moth/qv4isel_moth_p.h index 6cac936..8225721 100644 --- a/moth/qv4isel_moth_p.h +++ b/moth/qv4isel_moth_p.h @@ -34,7 +34,6 @@ protected: virtual void callBuiltinDeleteName(const QString &name, IR::Temp *result); virtual void callBuiltinDeleteValue(IR::Temp *result); virtual void callBuiltinThrow(IR::Temp *arg); - virtual void callBuiltinRethrow(); virtual void callBuiltinCreateExceptionHandler(IR::Temp *result); virtual void callBuiltinDeleteExceptionHandler(); virtual void callBuiltinGetException(IR::Temp *result); diff --git a/moth/qv4vme_moth.cpp b/moth/qv4vme_moth.cpp index dff4db6..fab02c4 100644 --- a/moth/qv4vme_moth.cpp +++ b/moth/qv4vme_moth.cpp @@ -249,9 +249,6 @@ VM::Value VME::operator()(QQmlJS::VM::ExecutionContext *context, const uchar *co TRACE(builtin_throw, "Throwing now...%s", ""); __qmljs_builtin_throw(TEMP(instr.argTemp), context); break; - case Instr::instr_callBuiltin::builtin_rethrow: - __qmljs_builtin_rethrow(context); - break; case Instr::instr_callBuiltin::builtin_create_exception_handler: { TRACE(builtin_create_exception_handler, "%s", ""); void *buf = __qmljs_create_exception_handler(context); diff --git a/qmljs_runtime.cpp b/qmljs_runtime.cpp index f23a93e..1accdea 100644 --- a/qmljs_runtime.cpp +++ b/qmljs_runtime.cpp @@ -900,12 +900,6 @@ void __qmljs_builtin_throw(Value val, ExecutionContext *context) __qmljs_throw(val, context); } -void __qmljs_builtin_rethrow(ExecutionContext *context) -{ - __qmljs_throw(context->engine->exception, context); -} - - void __qmljs_builtin_push_with(Value o, ExecutionContext *ctx) { Object *obj = __qmljs_to_object(o, ctx).asObject(); diff --git a/qv4codegen.cpp b/qv4codegen.cpp index 3bc545d..07d874f 100644 --- a/qv4codegen.cpp +++ b/qv4codegen.cpp @@ -2347,6 +2347,10 @@ bool Codegen::visit(ThrowStatement *ast) bool Codegen::visit(TryStatement *ast) { + if (_function->isStrict && ast->catchExpression && + (ast->catchExpression->name == QLatin1String("eval") || ast->catchExpression->name == QLatin1String("arguments"))) + throwSyntaxError(ast->catchExpression->identifierToken, QCoreApplication::translate("qv4codegen", "Catch variable name may not be eval or arguments in strict mode")); + IR::BasicBlock *tryBody = _function->newBasicBlock(); IR::BasicBlock *catchBody = ast->catchExpression ? _function->newBasicBlock() : 0; // We always need a finally body to clean up the exception handler @@ -2421,17 +2425,18 @@ bool Codegen::visit(TryStatement *ast) _block = finallyBody; _block->EXP(_block->CALL(_block->NAME(IR::Name::builtin_delete_exception_handler, 0, 0), deleteExceptionArgs)); + int exception_to_rethrow = _block->newTemp(); + move(_block->TEMP(exception_to_rethrow), _block->CALL(_block->NAME(IR::Name::builtin_get_exception, 0, 0), 0)); + if (ast->finallyExpression && ast->finallyExpression->statement) statement(ast->finallyExpression->statement); - if (!catchBody) { - IR::BasicBlock *rethrowBlock = _function->newBasicBlock(); - _block->CJUMP(_block->TEMP(hasException), rethrowBlock, after); - _block = rethrowBlock; - _block->EXP(_block->CALL(_block->NAME(IR::Name::builtin_rethrow, 0, 0), 0)); - } else { - _block->CJUMP(_block->TEMP(hasException), _throwBlock, after); - } + IR::BasicBlock *rethrowBlock = _function->newBasicBlock(); + _block->CJUMP(_block->TEMP(hasException), rethrowBlock, after); + _block = rethrowBlock; + move(_block->TEMP(_returnAddress), _block->TEMP(exception_to_rethrow)); + _block->JUMP(_throwBlock); + _block = after; return false; diff --git a/qv4ir.cpp b/qv4ir.cpp index 68976fb..30d2dcb 100644 --- a/qv4ir.cpp +++ b/qv4ir.cpp @@ -226,8 +226,6 @@ static const char *builtin_to_string(Name::Builtin b) return "builtin_delete"; case Name::builtin_throw: return "builtin_throw"; - case Name::builtin_rethrow: - return "builtin_rethrow"; case Name::builtin_create_exception_handler: return "builtin_create_exception_handler"; case Name::builtin_delete_exception_handler: diff --git a/qv4ir_p.h b/qv4ir_p.h index 03ac2ad..f3db3bd 100644 --- a/qv4ir_p.h +++ b/qv4ir_p.h @@ -276,7 +276,6 @@ struct Name: Expr { builtin_typeof, builtin_delete, builtin_throw, - builtin_rethrow, builtin_create_exception_handler, builtin_delete_exception_handler, builtin_get_exception, diff --git a/qv4isel_llvm_p.h b/qv4isel_llvm_p.h index 78e54b6..dbd6084 100644 --- a/qv4isel_llvm_p.h +++ b/qv4isel_llvm_p.h @@ -80,7 +80,6 @@ public: // methods from InstructionSelection: virtual void callBuiltinDeleteName(const QString &name, IR::Temp *result); virtual void callBuiltinDeleteValue(IR::Temp *result); virtual void callBuiltinThrow(IR::Temp *arg); - virtual void callBuiltinRethrow(); virtual void callBuiltinCreateExceptionHandler(IR::Temp *result); virtual void callBuiltinDeleteExceptionHandler(); virtual void callBuiltinGetException(IR::Temp *result); diff --git a/qv4isel_masm.cpp b/qv4isel_masm.cpp index 2e60f72..844f786 100644 --- a/qv4isel_masm.cpp +++ b/qv4isel_masm.cpp @@ -483,11 +483,6 @@ void InstructionSelection::callBuiltinThrow(IR::Temp *arg) generateFunctionCall(Assembler::Void, __qmljs_builtin_throw, arg, Assembler::ContextRegister); } -void InstructionSelection::callBuiltinRethrow() -{ - generateFunctionCall(Assembler::Void, __qmljs_builtin_rethrow, Assembler::ContextRegister); -} - void InstructionSelection::callBuiltinCreateExceptionHandler(IR::Temp *result) { generateFunctionCall(Assembler::ReturnValueRegister, __qmljs_create_exception_handler, Assembler::ContextRegister); diff --git a/qv4isel_masm_p.h b/qv4isel_masm_p.h index 2300377..c0fdabf 100644 --- a/qv4isel_masm_p.h +++ b/qv4isel_masm_p.h @@ -662,7 +662,6 @@ protected: virtual void callBuiltinDeleteName(const QString &name, IR::Temp *result); virtual void callBuiltinDeleteValue(IR::Temp *result); virtual void callBuiltinThrow(IR::Temp *arg); - virtual void callBuiltinRethrow(); virtual void callBuiltinCreateExceptionHandler(IR::Temp *result); virtual void callBuiltinDeleteExceptionHandler(); virtual void callBuiltinGetException(IR::Temp *result); diff --git a/qv4isel_p.cpp b/qv4isel_p.cpp index 9a694ae..c4df10a 100644 --- a/qv4isel_p.cpp +++ b/qv4isel_p.cpp @@ -268,10 +268,6 @@ void InstructionSelection::callBuiltin(IR::Call *call, IR::Temp *result) callBuiltinThrow(arg); } return; - case IR::Name::builtin_rethrow: - callBuiltinRethrow(); - return; - case IR::Name::builtin_create_exception_handler: callBuiltinCreateExceptionHandler(result); return; diff --git a/qv4isel_p.h b/qv4isel_p.h index 8181853..1d71055 100644 --- a/qv4isel_p.h +++ b/qv4isel_p.h @@ -90,7 +90,6 @@ public: // to implement by subclasses: virtual void callBuiltinDeleteName(const QString &name, IR::Temp *result) = 0; virtual void callBuiltinDeleteValue(IR::Temp *result) = 0; virtual void callBuiltinThrow(IR::Temp *arg) = 0; - virtual void callBuiltinRethrow() = 0; virtual void callBuiltinCreateExceptionHandler(IR::Temp *result) = 0; virtual void callBuiltinDeleteExceptionHandler() = 0; virtual void callBuiltinGetException(IR::Temp *result) = 0; diff --git a/tests/TestExpectations b/tests/TestExpectations index fc90235..427e158 100644 --- a/tests/TestExpectations +++ b/tests/TestExpectations @@ -119,11 +119,6 @@ S11.9.4_A2.4_T1 failing S11.9.4_A2.4_T3 failing S11.9.5_A2.4_T1 failing S11.9.5_A2.4_T3 failing -S12.14_A7_T1 failing -S12.14_A7_T3 failing -12.14.1-1-s failing -12.14.1-2-s failing -12.14.1-3-s failing S12.10_A3.11_T1 failing S12.10_A3.11_T2 failing S12.10_A3.11_T3 failing -- 2.7.4