Simplify some builtin methods
authorLars Knoll <lars.knoll@digia.com>
Wed, 17 Oct 2012 15:31:53 +0000 (17:31 +0200)
committerSimon Hausmann <simon.hausmann@digia.com>
Wed, 17 Oct 2012 15:41:14 +0000 (17:41 +0200)
Change-Id: I2c524b3634c65e7cc0ee72a21937048c4e3ae10a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
qmljs_runtime.cpp
qmljs_runtime.h
qv4isel_masm.cpp

index a869c62..599eefc 100644 (file)
@@ -1283,21 +1283,17 @@ Value __qmljs_rethrow(Context *context)
     return context->result;
 }
 
-Value __qmljs_builtin_typeof(Context *context, Value *args, int argc)
+Value __qmljs_builtin_typeof(Value val, Context *context)
 {
-    Q_UNUSED(argc);
-    return __qmljs_typeof(args[0], context);
+    return __qmljs_typeof(val, context);
 }
 
-Value __qmljs_builtin_throw(Context *context, Value *args, int argc)
+void __qmljs_builtin_throw(Value val, Context *context)
 {
-    Q_UNUSED(argc);
-    __qmljs_throw(args[0], context);
-    // ### change to void return value
-    return Value::undefinedValue();
+    __qmljs_throw(val, context);
 }
 
-Value __qmljs_builtin_rethrow(Context *context, Value *, int)
+Value __qmljs_builtin_rethrow(Context *context)
 {
     return context->result;
 }
index 11097ab..5ac9150 100644 (file)
@@ -99,9 +99,9 @@ Value __qmljs_construct_activation_property(Context *, String *name, Value *args
 Value __qmljs_construct_property(Context *context, Value base, String *name, Value *args, int argc);
 Value __qmljs_construct_value(Context *context, Value func, Value *args, int argc);
 
-Value __qmljs_builtin_typeof(Context *context, Value *args, int argc);
-Value __qmljs_builtin_throw(Context *context, Value *args, int argc);
-Value __qmljs_builtin_rethrow(Context *context, Value *args, int argc);
+Value __qmljs_builtin_typeof(Value val, Context *context);
+void __qmljs_builtin_throw(Value val, Context *context);
+Value __qmljs_builtin_rethrow(Context *context);
 
 // constructors
 Value __qmljs_init_string(String *string);
index 9e70ab7..092a524 100644 (file)
@@ -202,20 +202,27 @@ void InstructionSelection::callActivationProperty(IR::Call *call, IR::Temp *resu
         case IR::Name::builtin_invalid:
             Q_UNREACHABLE();
             break;
-        case IR::Name::builtin_typeof:
-            callRuntimeMethod(result, __qmljs_builtin_typeof, call->args);
+        case IR::Name::builtin_typeof: {
+            IR::Temp *arg = call->args->expr->asTemp();
+            assert(arg != 0);
+            generateFunctionCall(result, __qmljs_builtin_typeof, arg, ContextRegister);
+            checkExceptions();
+        }
             break;
         case IR::Name::builtin_delete:
             Q_UNREACHABLE();
             break;
-        case IR::Name::builtin_throw:
-            callRuntimeMethod(result, __qmljs_builtin_throw, call->args);
-            break;
-        case IR::Name::builtin_rethrow: {
-            int argc = prepareVariableArguments(call->args);
-            generateFunctionCall(result, __qmljs_builtin_rethrow, ContextRegister, baseAddressForCallArguments(), TrustedImm32(argc));
-            return; // we need to return to avoid checking the exceptions
+        case IR::Name::builtin_throw: {
+            IR::Temp *arg = call->args->expr->asTemp();
+            assert(arg != 0);
+            generateFunctionCall(Void, __qmljs_builtin_throw, arg, ContextRegister);
+            checkExceptions();
         }
+            break;
+        case IR::Name::builtin_rethrow:
+            // don't use callRuntimeMethod, as we need to return to avoid checking the exceptions
+            generateFunctionCall(result, __qmljs_builtin_rethrow, ContextRegister);
+            return;
         }
     }
 }
@@ -275,7 +282,7 @@ void InstructionSelection::constructValue(IR::New *call, IR::Temp *result)
 void InstructionSelection::checkExceptions()
 {
     Address addr(ContextRegister, offsetof(Context, hasUncaughtException));
-    Jump jmp = branch8(Equal, addr, TrustedImm32(1));
+    Jump jmp = branch8(NotEqual, addr, TrustedImm32(0));
     _patches[_function->handlersBlock].append(jmp);
 }