More conversions to new calling convention
authorLars Knoll <lars.knoll@digia.com>
Tue, 16 Oct 2012 13:37:31 +0000 (15:37 +0200)
committerSimon Hausmann <simon.hausmann@digia.com>
Tue, 16 Oct 2012 14:57:13 +0000 (16:57 +0200)
Change-Id: I6002715cc3f5c22d90a9ade6ae2152c2c3c8ebb2
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
llvm_runtime.cpp
qmljs_runtime.cpp
qmljs_runtime.h
qv4isel_masm.cpp

index 31bdd90..586bca4 100644 (file)
@@ -239,7 +239,7 @@ void __qmljs_llvm_construct_activation_property(Context *context, Value *result,
 
 void __qmljs_llvm_construct_value(Context *context, Value *result, const Value *func, Value *args, int argc)
 {
-    __qmljs_construct_value(context, result, func, args, argc);
+    *result = __qmljs_construct_value(context, *func, args, argc);
 }
 
 void __qmljs_llvm_get_activation_property(Context *ctx, Value *result, String *name)
@@ -264,7 +264,7 @@ void __qmljs_llvm_call_property(Context *context, Value *result, const Value *ba
 
 void __qmljs_llvm_construct_property(Context *context, Value *result, const Value *base, String *name, Value *args, int argc)
 {
-    __qmljs_construct_property(context, result, base, name, args, argc);
+    *result = __qmljs_construct_property(context, *base, name, args, argc);
 }
 
 void __qmljs_llvm_get_element(Context *ctx, Value *result, Value *object, Value *index)
@@ -284,17 +284,17 @@ void __qmljs_llvm_set_property(Context *ctx, Value *object, String *name, Value
 
 void __qmljs_llvm_typeof(Context *ctx, Value *result, const Value *value)
 {
-    __qmljs_typeof(ctx, result, value);
+    *result = __qmljs_typeof(ctx, value);
 }
 
 void __qmljs_llvm_throw(Context *context, Value *value)
 {
-    __qmljs_throw(context, value);
+    __qmljs_throw(context, *value);
 }
 
 void __qmljs_llvm_rethrow(Context *context, Value *result)
 {
-    __qmljs_rethrow(context, result);
+    *result = __qmljs_rethrow(context);
 }
 
 void __qmljs_llvm_get_this_object(Context *ctx, Value *result)
index 45de64a..b892eb4 100644 (file)
@@ -382,7 +382,7 @@ void Context::initConstructorContext(ExecutionEngine *e, const Value *object, Fu
     calledAsConstructor = true;
 }
 
-void Context::leaveConstructorContext(FunctionObject *f, Value *returnValue)
+void Context::leaveConstructorContext(FunctionObject *f)
 {
     assert(thisObject.is(Value::Object_Type));
     result = thisObject;
@@ -393,7 +393,6 @@ void Context::leaveConstructorContext(FunctionObject *f, Value *returnValue)
         thisObject.objectValue()->prototype = engine->objectPrototype;
 
     leaveCallContext(f);
-    *returnValue = result;
 }
 
 extern "C" {
@@ -1177,14 +1176,12 @@ Value __qmljs_construct_activation_property(Context *context, String *name, Valu
         context->throwReferenceError(Value::fromString(name));
         return Value::undefinedValue();
     }
-    Value result;
-    __qmljs_construct_value(context, &result, func, args, argc);
-    return result;
+    return __qmljs_construct_value(context, *func, args, argc);
 }
 
-void __qmljs_construct_value(Context *context, Value *result, const Value *func, Value *args, int argc)
+Value __qmljs_construct_value(Context *context, const Value func, Value *args, int argc)
 {
-    if (FunctionObject *f = func->asFunctionObject()) {
+    if (FunctionObject *f = func.asFunctionObject()) {
         Context k;
         Context *ctx = f->needsActivation ? context->engine->newContext() : &k;
         ctx->initConstructorContext(context->engine, 0, f, args, argc);
@@ -1193,17 +1190,18 @@ void __qmljs_construct_value(Context *context, Value *result, const Value *func,
             context->hasUncaughtException = ctx->hasUncaughtException; // propagate the exception
             context->result = ctx->result;
         }
-        ctx->leaveConstructorContext(f, result);
-    } else {
-        context->throwTypeError();
+        ctx->leaveConstructorContext(f);
+        return ctx->result;
     }
+    context->throwTypeError();
+    return Value::undefinedValue();
 }
 
-void __qmljs_construct_property(Context *context, Value *result, const Value *base, String *name, Value *args, int argc)
+Value __qmljs_construct_property(Context *context, const Value base, String *name, Value *args, int argc)
 {
-    Value thisObject = *base;
+    Value thisObject = base;
     if (!thisObject.isObject())
-        __qmljs_to_object(context, &thisObject, base);
+        __qmljs_to_object(context, &thisObject, &base);
 
     assert(thisObject.isObject());
     Value func = thisObject.property(context, name);
@@ -1217,42 +1215,41 @@ void __qmljs_construct_property(Context *context, Value *result, const Value *ba
             context->hasUncaughtException = ctx->hasUncaughtException; // propagate the exception
             context->result = ctx->result;
         }
-        ctx->leaveConstructorContext(f, result);
-    } else {
-        context->throwTypeError();
+        ctx->leaveConstructorContext(f);
+        return ctx->result;
     }
+    context->throwTypeError();
+    return Value::undefinedValue();
 }
 
-void __qmljs_throw(Context *context, Value *value)
+void __qmljs_throw(Context *context, Value value)
 {
     context->hasUncaughtException = true;
-    context->result = *value;
+    context->result = value;
 }
 
-void __qmljs_rethrow(Context *context, Value *result)
+Value __qmljs_rethrow(Context *context)
 {
-    *result = context->result;
+    return context->result;
 }
 
 Value __qmljs_builtin_typeof(Context *context, Value *args, int argc)
 {
     Q_UNUSED(argc);
-    Value result;
-    __qmljs_typeof(context, &result, &args[0]);
-    return result;
+    return __qmljs_typeof(context, &args[0]);
 }
 
 Value __qmljs_builtin_throw(Context *context, Value *args, int argc)
 {
     Q_UNUSED(argc);
-    __qmljs_throw(context, &args[0]);
+    __qmljs_throw(context, args[0]);
     // ### change to void return value
     return Value::undefinedValue();
 }
 
-void __qmljs_builtin_rethrow(Context *context, Value *result, Value *, int)
+Value __qmljs_builtin_rethrow(Context *context, Value *, int)
 {
-    __qmljs_rethrow(context, result);
+    return context->result;
 }
 
 } // extern "C"
index 9c5c7cf..b494b6e 100644 (file)
@@ -94,12 +94,12 @@ Value __qmljs_call_property(Context *context, const Value base, String *name, Va
 Value __qmljs_call_value(Context *context, const Value thisObject, const Value *func, Value *args, int argc);
 
 Value __qmljs_construct_activation_property(Context *, String *name, Value *args, int argc);
-void __qmljs_construct_property(Context *context, Value *result, const Value *base, String *name, Value *args, int argc);
-void __qmljs_construct_value(Context *context, Value *result, const Value *func, Value *args, int argc);
+Value __qmljs_construct_property(Context *context, const Value base, String *name, Value *args, int argc);
+Value __qmljs_construct_value(Context *context, const 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);
-void __qmljs_builtin_rethrow(Context *context, Value *result, Value *args, int argc);
+Value __qmljs_builtin_rethrow(Context *context, Value *args, int argc);
 
 // constructors
 Value __qmljs_init_string(String *string);
@@ -181,9 +181,9 @@ void __qmljs_delete_member(Context *ctx, Value *result, Value *base, String *nam
 void __qmljs_delete_property(Context *ctx, Value *result, String *name);
 void __qmljs_delete_value(Context *ctx, Value *result, Value *value);
 
-void __qmljs_typeof(Context *ctx, Value *result, const Value *value);
-void __qmljs_throw(Context *context, Value *value);
-void __qmljs_rethrow(Context *context, Value *result);
+Value __qmljs_typeof(Context *ctx, const Value *value);
+void __qmljs_throw(Context *context, Value value);
+Value __qmljs_rethrow(Context *context);
 
 // binary operators
 void __qmljs_instanceof(Context *ctx, Value *result, const Value *left, const Value *right);
@@ -651,7 +651,7 @@ struct Context {
     void leaveCallContext(FunctionObject *f);
 
     void initConstructorContext(ExecutionEngine *e, const Value *object, FunctionObject *f, Value *args, unsigned argc);
-    void leaveConstructorContext(FunctionObject *f, Value *returnValue);
+    void leaveConstructorContext(FunctionObject *f);
 };
 
 
@@ -895,7 +895,7 @@ inline void __qmljs_default_value(Context *ctx, Value *result, const Value *valu
 
 
 // unary operators
-inline void __qmljs_typeof(Context *ctx, Value *result, const Value *value)
+inline Value __qmljs_typeof(Context *ctx, const Value *value)
 {
     switch (value->type()) {
     case Value::Undefined_Type:
index 47f9f88..19d6114 100644 (file)
@@ -213,7 +213,7 @@ void InstructionSelection::callActivationProperty(IR::Call *call, IR::Temp *resu
             break;
         case IR::Name::builtin_rethrow: {
             int argc = prepareVariableArguments(call->args);
-            generateFunctionCall(__qmljs_builtin_rethrow, ContextRegister, result, baseAddressForCallArguments(), TrustedImm32(argc));
+            generateFunctionCall2(result, __qmljs_builtin_rethrow, ContextRegister, baseAddressForCallArguments(), TrustedImm32(argc));
             return; // we need to return to avoid checking the exceptions
         }
         }
@@ -258,7 +258,7 @@ void InstructionSelection::constructProperty(IR::New *call, IR::Temp *result)
     assert(member->base->asTemp() != 0);
 
     int argc = prepareVariableArguments(call->args);
-    generateFunctionCall(__qmljs_construct_property, ContextRegister, result, member->base->asTemp(), identifier(*member->name), baseAddressForCallArguments(), TrustedImm32(argc));
+    generateFunctionCall2(result, __qmljs_construct_property, ContextRegister, member->base->asTemp(), identifier(*member->name), baseAddressForCallArguments(), TrustedImm32(argc));
     checkExceptions();
 }
 
@@ -268,7 +268,7 @@ void InstructionSelection::constructValue(IR::New *call, IR::Temp *result)
     assert(baseTemp != 0);
 
     int argc = prepareVariableArguments(call->args);
-    generateFunctionCall(__qmljs_construct_value, ContextRegister, result, baseTemp, baseAddressForCallArguments(), TrustedImm32(argc));
+    generateFunctionCall2(result, __qmljs_construct_value, ContextRegister, baseTemp, baseAddressForCallArguments(), TrustedImm32(argc));
     checkExceptions();
 }