Cleanup: Rename __builtin_delete_exception_handler
authorSimon Hausmann <simon.hausmann@digia.com>
Mon, 4 Mar 2013 11:14:54 +0000 (12:14 +0100)
committerLars Knoll <lars.knoll@digia.com>
Mon, 4 Mar 2013 12:16:05 +0000 (13:16 +0100)
This IR builtin function no more deletes an exception handler, instead it tells
the back-end to stop try catching exceptions. In MASM and Moth this is
implemented by returning from the nested function call initiated by the try.

Change-Id: Ia8336c998817a73aeed03f4a05d4b592cc9143ad
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
14 files changed:
src/v4/moth/qv4instr_moth_p.h
src/v4/moth/qv4isel_moth.cpp
src/v4/moth/qv4isel_moth_p.h
src/v4/moth/qv4vme_moth.cpp
src/v4/qv4codegen.cpp
src/v4/qv4codegen_p.h
src/v4/qv4ir.cpp
src/v4/qv4ir_p.h
src/v4/qv4isel_llvm.cpp
src/v4/qv4isel_llvm_p.h
src/v4/qv4isel_masm.cpp
src/v4/qv4isel_masm_p.h
src/v4/qv4isel_p.cpp
src/v4/qv4isel_p.h

index 0776687..8810a92 100644 (file)
@@ -22,7 +22,7 @@
     F(CallActivationProperty, callActivationProperty) \
     F(CallBuiltinThrow, callBuiltinThrow) \
     F(CallBuiltinCreateExceptionHandler, callBuiltinCreateExceptionHandler) \
-    F(CallBuiltinDeleteExceptionHandler, callBuiltinDeleteExceptionHandler) \
+    F(CallBuiltinFinishTry, callBuiltinFinishTry) \
     F(CallBuiltinGetException, callBuiltinGetException) \
     F(CallBuiltinPushScope, callBuiltinPushScope) \
     F(CallBuiltinPushCatchScope, callBuiltinPushCatchScope) \
@@ -248,7 +248,7 @@ union Instr
         MOTH_INSTR_HEADER
         Param result;
     };
-    struct instr_callBuiltinDeleteExceptionHandler {
+    struct instr_callBuiltinFinishTry {
         MOTH_INSTR_HEADER
     };
     struct instr_callBuiltinGetException {
@@ -470,7 +470,7 @@ union Instr
     instr_callActivationProperty callActivationProperty;
     instr_callBuiltinThrow callBuiltinThrow;
     instr_callBuiltinCreateExceptionHandler callBuiltinCreateExceptionHandler;
-    instr_callBuiltinDeleteExceptionHandler callBuiltinDeleteExceptionHandler;
+    instr_callBuiltinFinishTry callBuiltinFinishTry;
     instr_callBuiltinGetException callBuiltinGetException;
     instr_callBuiltinPushScope callBuiltinPushScope;
     instr_callBuiltinPushCatchScope callBuiltinPushCatchScope;
index d8d7040..c416839 100644 (file)
@@ -836,9 +836,9 @@ void InstructionSelection::callBuiltinCreateExceptionHandler(IR::Temp *result)
     addInstruction(call);
 }
 
-void InstructionSelection::callBuiltinDeleteExceptionHandler()
+void InstructionSelection::callBuiltinFinishTry()
 {
-    Instruction::CallBuiltinDeleteExceptionHandler call;
+    Instruction::CallBuiltinFinishTry call;
     addInstruction(call);
 }
 
index 6eaee6d..c6677f2 100644 (file)
@@ -44,7 +44,7 @@ protected:
     virtual void callBuiltinPostIncrementValue(IR::Temp *value, IR::Temp *result);
     virtual void callBuiltinThrow(IR::Temp *arg);
     virtual void callBuiltinCreateExceptionHandler(IR::Temp *result);
-    virtual void callBuiltinDeleteExceptionHandler();
+    virtual void callBuiltinFinishTry();
     virtual void callBuiltinGetException(IR::Temp *result);
     virtual void callBuiltinForeachIteratorObject(IR::Temp *arg, IR::Temp *result);
     virtual void callBuiltinForeachNextPropertyname(IR::Temp *arg, IR::Temp *result);
index 1238b36..0d2f2bc 100644 (file)
@@ -287,9 +287,9 @@ VM::Value VME::run(QQmlJS::VM::ExecutionContext *context, const uchar *&code,
         }
     MOTH_END_INSTR(CallBuiltinCreateExceptionHandler)
 
-    MOTH_BEGIN_INSTR(CallBuiltinDeleteExceptionHandler)
+    MOTH_BEGIN_INSTR(CallBuiltinFinishTry)
         return VM::Value();
-    MOTH_END_INSTR(CallBuiltinDeleteExceptionHandler)
+    MOTH_END_INSTR(CallBuiltinFinishTry)
 
     MOTH_BEGIN_INSTR(CallBuiltinGetException)
         __qmljs_get_exception(context, VALUEPTR(instr.result));
index c602b34..e6c6f34 100644 (file)
@@ -2471,14 +2471,14 @@ bool Codegen::visit(TryStatement *ast)
     // Pass the hidden "inCatch" and "hasException" TEMPs to the
     // builtin_delete_exception_handler, in order to have those TEMPs alive for
     // the duration of the exception handling block.
-    IR::ExprList *deleteExceptionArgs = _function->New<IR::ExprList>();
-    deleteExceptionArgs->init(_block->TEMP(hasException));
+    IR::ExprList *finishTryArgs = _function->New<IR::ExprList>();
+    finishTryArgs->init(_block->TEMP(hasException));
     if (inCatch) {
-        deleteExceptionArgs->next = _function->New<IR::ExprList>();
-        deleteExceptionArgs->next->init(_block->TEMP(inCatch));
+        finishTryArgs->next = _function->New<IR::ExprList>();
+        finishTryArgs->next->init(_block->TEMP(inCatch));
     }
 
-    ScopeAndFinally tcf(_scopeAndFinally, ast->finallyExpression, deleteExceptionArgs);
+    ScopeAndFinally tcf(_scopeAndFinally, ast->finallyExpression, finishTryArgs);
     _scopeAndFinally = &tcf;
 
     _block->CJUMP(_block->TEMP(hasException), catchBody ? catchBody : finallyBody, tryBody);
@@ -2528,7 +2528,7 @@ bool Codegen::visit(TryStatement *ast)
 
     int exception_to_rethrow  = _block->newTemp();
     move(_block->TEMP(exception_to_rethrow), _block->CALL(_block->NAME(IR::Name::builtin_get_exception, 0, 0), 0));
-    _block->EXP(_block->CALL(_block->NAME(IR::Name::builtin_delete_exception_handler, 0, 0), deleteExceptionArgs));
+    _block->EXP(_block->CALL(_block->NAME(IR::Name::builtin_finish_try, 0, 0), finishTryArgs));
 
     if (ast->finallyExpression && ast->finallyExpression->statement)
         statement(ast->finallyExpression->statement);
@@ -2555,7 +2555,7 @@ void Codegen::unwindException(Codegen::ScopeAndFinally *outest)
             _scopeAndFinally = _scopeAndFinally->parent;
             --_function->insideWithOrCatch;
         } else {
-            _block->EXP(_block->CALL(_block->NAME(IR::Name::builtin_delete_exception_handler, 0, 0), _scopeAndFinally->deleteExceptionArgs));
+            _block->EXP(_block->CALL(_block->NAME(IR::Name::builtin_finish_try, 0, 0), _scopeAndFinally->finishTryArgs));
             ScopeAndFinally *tc = _scopeAndFinally;
             _scopeAndFinally = tc->parent;
             if (tc->finally && tc->finally->statement)
index 239027a..13d8315 100644 (file)
@@ -217,12 +217,12 @@ protected:
     struct ScopeAndFinally {
         ScopeAndFinally *parent;
         AST::Finally *finally;
-        IR::ExprList *deleteExceptionArgs;
+        IR::ExprList *finishTryArgs;
         bool popScope;
 
-        ScopeAndFinally(ScopeAndFinally *parent) : parent(parent), finally(0), deleteExceptionArgs(0), popScope(true) {}
-        ScopeAndFinally(ScopeAndFinally *parent, AST::Finally *finally, IR::ExprList *deleteExceptionArgs)
-        : parent(parent), finally(finally), deleteExceptionArgs(deleteExceptionArgs), popScope(false)
+        ScopeAndFinally(ScopeAndFinally *parent) : parent(parent), finally(0), finishTryArgs(0), popScope(true) {}
+        ScopeAndFinally(ScopeAndFinally *parent, AST::Finally *finally, IR::ExprList *finishTryArgs)
+        : parent(parent), finally(finally), finishTryArgs(finishTryArgs), popScope(false)
         {}
     };
 
index 2fa8f0a..c44af3d 100644 (file)
@@ -354,8 +354,8 @@ static const char *builtin_to_string(Name::Builtin b)
         return "builtin_throw";
     case Name::builtin_create_exception_handler:
         return "builtin_create_exception_handler";
-    case Name::builtin_delete_exception_handler:
-        return "builtin_delete_exception_handler";
+    case Name::builtin_finish_try:
+        return "builtin_finish_try";
     case Name::builtin_get_exception:
         return "builtin_get_exception";
     case IR::Name::builtin_foreach_iterator_object:
index 3525759..50a5247 100644 (file)
@@ -290,7 +290,7 @@ struct Name: Expr {
         builtin_postdecrement,
         builtin_throw,
         builtin_create_exception_handler,
-        builtin_delete_exception_handler,
+        builtin_finish_try,
         builtin_get_exception,
         builtin_foreach_iterator_object,
         builtin_foreach_next_property_name,
index e6010cf..f0b8526 100644 (file)
@@ -434,7 +434,7 @@ void InstructionSelection::callBuiltinCreateExceptionHandler(IR::Temp *result)
     Q_UNREACHABLE();
 }
 
-void InstructionSelection::callBuiltinDeleteExceptionHandler()
+void InstructionSelection::callBuiltinFinishTry()
 {
     // TODO
     assert(!"TODO!");
@@ -1146,9 +1146,8 @@ void InstructionSelection::genCallName(IR::Call *e, llvm::Value *result)
             _llvmValue = CreateLoad(result);
             return;
 
-        case IR::Name::builtin_delete_exception_handler:
-            CreateCall(getRuntimeFunction("__qmljs_llvm_delete_exception_handler"),
-                       _llvmFunction->arg_begin());
+        case IR::Name::builtin_finish_try:
+            // ### FIXME.
             return;
 
         case IR::Name::builtin_get_exception:
index fb28456..e749863 100644 (file)
@@ -89,7 +89,7 @@ public: // methods from InstructionSelection:
     virtual void callBuiltinPostIncrementValue(IR::Temp *value, IR::Temp *result);
     virtual void callBuiltinThrow(IR::Temp *arg);
     virtual void callBuiltinCreateExceptionHandler(IR::Temp *result);
-    virtual void callBuiltinDeleteExceptionHandler();
+    virtual void callBuiltinFinishTry();
     virtual void callBuiltinGetException(IR::Temp *result);
     virtual void callBuiltinForeachIteratorObject(IR::Temp *arg, IR::Temp *result);
     virtual void callBuiltinForeachNextPropertyname(IR::Temp *arg, IR::Temp *result);
index 26307e8..35bd638 100644 (file)
@@ -692,7 +692,7 @@ void InstructionSelection::callBuiltinCreateExceptionHandler(IR::Temp *result)
     _as->store32(Assembler::TrustedImm32(Value::Boolean_Type), addr);
 }
 
-void InstructionSelection::callBuiltinDeleteExceptionHandler()
+void InstructionSelection::callBuiltinFinishTry()
 {
     // This assumes that we're in code that was called by tryWrapper, so we return to try wrapper
     // with the address that we'd like to continue at, which is right after the ret below.
index 23f9da0..acd6e5f 100644 (file)
@@ -763,7 +763,7 @@ protected:
     virtual void callBuiltinPostIncrementValue(IR::Temp *value, IR::Temp *result);
     virtual void callBuiltinThrow(IR::Temp *arg);
     virtual void callBuiltinCreateExceptionHandler(IR::Temp *result);
-    virtual void callBuiltinDeleteExceptionHandler();
+    virtual void callBuiltinFinishTry();
     virtual void callBuiltinGetException(IR::Temp *result);
     virtual void callBuiltinForeachIteratorObject(IR::Temp *arg, IR::Temp *result);
     virtual void callBuiltinForeachNextPropertyname(IR::Temp *arg, IR::Temp *result);
index 03fa074..cbf2e4c 100644 (file)
@@ -315,8 +315,8 @@ void InstructionSelection::callBuiltin(IR::Call *call, IR::Temp *result)
         return;
     }
 
-    case IR::Name::builtin_delete_exception_handler:
-        callBuiltinDeleteExceptionHandler();
+    case IR::Name::builtin_finish_try:
+        callBuiltinFinishTry();
         return;
 
     case IR::Name::builtin_get_exception:
index 40cf86e..cc1ebf0 100644 (file)
@@ -104,7 +104,7 @@ public: // to implement by subclasses:
     virtual void callBuiltinPostIncrementValue(IR::Temp *value, IR::Temp *result) = 0;
     virtual void callBuiltinThrow(IR::Temp *arg) = 0;
     virtual void callBuiltinCreateExceptionHandler(IR::Temp *result) = 0;
-    virtual void callBuiltinDeleteExceptionHandler() = 0;
+    virtual void callBuiltinFinishTry() = 0;
     virtual void callBuiltinGetException(IR::Temp *result) = 0;
     virtual void callBuiltinForeachIteratorObject(IR::Temp *arg, IR::Temp *result) = 0;
     virtual void callBuiltinForeachNextPropertyname(IR::Temp *arg, IR::Temp *result) = 0;