prepare varargs calls
authorMichael Wallner <mike@php.net>
Fri, 1 Jan 2016 18:02:21 +0000 (19:02 +0100)
committerMichael Wallner <mike@php.net>
Fri, 1 Jan 2016 18:02:21 +0000 (19:02 +0100)
src/context.c
src/context.h
src/libffi.c
src/libjit.c
src/module.c
src/parser.h

index ba9fabb9cc8e0c0d5ed4542e9f92d96cf1a33f1e..ba587201926ffafc0286fce4b8c76d1dc8fdf491 100644 (file)
@@ -1214,9 +1214,9 @@ zend_function_entry *PSI_ContextCompile(PSI_Context *C)
 }
 
 
 }
 
 
-void PSI_ContextCall(PSI_Context *C, impl_val *ret_val, decl *decl)
+void PSI_ContextCall(PSI_Context *C, decl_callinfo *decl_call)
 {
 {
-       C->ops->call(C, ret_val, decl);
+       C->ops->call(C, decl_call);
 }
 
 static inline void dump_decl_type(int fd, decl_type *t) {
 }
 
 static inline void dump_decl_type(int fd, decl_type *t) {
index e68eddf9eedd344bb83ccf44557c9852a9bcda79..6611a4a50f3f8631634bd593a121c07aab75c012 100644 (file)
@@ -14,7 +14,7 @@ struct PSI_ContextOps {
        void (*init)(PSI_Context *C);
        void (*dtor)(PSI_Context *C);
        zend_function_entry *(*compile)(PSI_Context *C);
        void (*init)(PSI_Context *C);
        void (*dtor)(PSI_Context *C);
        zend_function_entry *(*compile)(PSI_Context *C);
-       void (*call)(PSI_Context *C, impl_val *ret_val, decl *decl);
+       void (*call)(PSI_Context *C, decl *decl);
 };
 
 struct PSI_Context {
 };
 
 struct PSI_Context {
@@ -30,7 +30,7 @@ PSI_Context *PSI_ContextInit(PSI_Context *C, PSI_ContextOps *ops, PSI_ContextErr
 void PSI_ContextBuild(PSI_Context *C, const char *path);
 int PSI_ContextValidate(PSI_Context *C, PSI_Parser *P);
 zend_function_entry *PSI_ContextCompile(PSI_Context *C);
 void PSI_ContextBuild(PSI_Context *C, const char *path);
 int PSI_ContextValidate(PSI_Context *C, PSI_Parser *P);
 zend_function_entry *PSI_ContextCompile(PSI_Context *C);
-void PSI_ContextCall(PSI_Context *C, impl_val *ret_val, decl *decl);
+void PSI_ContextCall(PSI_Context *C, decl_callinfo *decl_call);
 void PSI_ContextDump(PSI_Context *C, int fd);
 void PSI_ContextDtor(PSI_Context *C);
 void PSI_ContextFree(PSI_Context **C);
 void PSI_ContextDump(PSI_Context *C, int fd);
 void PSI_ContextDtor(PSI_Context *C);
 void PSI_ContextFree(PSI_Context **C);
index ee077af19b4b2af2cbba62b6c41dc2961355eaa8..257fb48521b73f965a9534410daedf595da5a1e0 100644 (file)
@@ -127,6 +127,8 @@ static inline PSI_LibffiCall *PSI_LibffiCallAlloc(PSI_Context *C, decl *decl) {
        call->params[c] = NULL;
 
        decl->call.info = call;
        call->params[c] = NULL;
 
        decl->call.info = call;
+       decl->call.rval = decl->func->ptr;
+       decl->call.argc = c;
        decl->call.args = (void **) &call->params[c+1];
 
        rc = ffi_prep_cif(&call->signature, psi_ffi_abi(decl->abi->convention),
        decl->call.args = (void **) &call->params[c+1];
 
        rc = ffi_prep_cif(&call->signature, psi_ffi_abi(decl->abi->convention),
@@ -250,10 +252,10 @@ static zend_function_entry *psi_ffi_compile(PSI_Context *C)
        return zfe;
 }
 
        return zfe;
 }
 
-static void psi_ffi_call(PSI_Context *C, impl_val *ret_val, decl *decl) {
-       PSI_LibffiCall *call = decl->call.info;
+static void psi_ffi_call(PSI_Context *C, decl_callinfo *decl_call) {
+       PSI_LibffiCall *call = decl_call->info;
 
 
-       ffi_call(&call->signature, FFI_FN(decl->call.sym), ret_val, decl->call.args);
+       ffi_call(&call->signature, FFI_FN(decl_call->sym), decl_call->rval, decl_call->args);
 }
 
 static PSI_ContextOps ops = {
 }
 
 static PSI_ContextOps ops = {
index 45ee8e766c34a8153439cee6351cb4617c4782ee..13c0aa46f8e13d8420cee2146af1304058b6e098 100644 (file)
@@ -87,6 +87,8 @@ static inline PSI_LibjitCall *PSI_LibjitCallAlloc(PSI_Context *C, decl *decl) {
        call->params[c] = NULL;
 
        decl->call.info = call;
        call->params[c] = NULL;
 
        decl->call.info = call;
+       decl->call.rval = decl->func->ptr;
+       decl->call.argc = c;
        decl->call.args = (void **) &call->params[c+1];
 
        call->signature = jit_type_create_signature(
        decl->call.args = (void **) &call->params[c+1];
 
        call->signature = jit_type_create_signature(
@@ -208,11 +210,11 @@ static zend_function_entry *psi_jit_compile(PSI_Context *C)
        return zfe;
 }
 
        return zfe;
 }
 
-static void psi_jit_call(PSI_Context *C, impl_val *ret_val, decl *decl) {
-       PSI_LibjitCall *call = decl->call.info;
+static void psi_jit_call(PSI_Context *C, decl_callinfo *decl_call) {
+       PSI_LibjitCall *call = decl_call->info;
 
 
-       jit_apply(call->signature, decl->call.sym, decl->call.args,
-                       decl->args->count, ret_val);
+       jit_apply(call->signature, decl_call->sym, decl_call->args,
+                       decl_call->argc, decl_call->rval);
 }
 
 static PSI_ContextOps ops = {
 }
 
 static PSI_ContextOps ops = {
index c820f4f1bd0ed47b6b2a873790a78fd3d6f8dbbd..ba3e4d5a98d5af9478ae3fa172d5a482c7f72d58 100644 (file)
@@ -703,7 +703,6 @@ static inline void psi_do_return(zval *return_value, return_stmt *ret)
 static inline void psi_do_free(free_stmt *fre)
 {
        size_t i, j;
 static inline void psi_do_free(free_stmt *fre)
 {
        size_t i, j;
-       impl_val dummy;
 
        for (i = 0; i < fre->calls->count; ++i) {
                free_call *f = fre->calls->list[i];
 
        for (i = 0; i < fre->calls->count; ++i) {
                free_call *f = fre->calls->list[i];
@@ -716,7 +715,7 @@ static inline void psi_do_free(free_stmt *fre)
                }
 
                /* FIXME: check in validate_* that free functions return scalar */
                }
 
                /* FIXME: check in validate_* that free functions return scalar */
-               PSI_ContextCall(&PSI_G(context), &dummy, f->decl);
+               PSI_ContextCall(&PSI_G(context), &f->decl->call);
        }
 }
 
        }
 }
 
@@ -1007,7 +1006,7 @@ void psi_call(zend_execute_data *execute_data, zval *return_value, impl *impl)
                impl->decl->call.args[i] = impl->decl->args->args[i]->let->ptr;
        }
 
                impl->decl->call.args[i] = impl->decl->args->args[i]->let->ptr;
        }
 
-       PSI_ContextCall(&PSI_G(context), var->arg->ptr, impl->decl);
+       PSI_ContextCall(&PSI_G(context), &impl->decl->call);
        psi_do_return(return_value, ret);
 
        for (i = 0; i < impl->stmts->set.count; ++i) {
        psi_do_return(return_value, ret);
 
        for (i = 0; i < impl->stmts->set.count; ++i) {
index 55f4f9d75f6d57067adacc2e8a43950530cc2dcd..7faa43b712f74a54b20cad9b657f89ac55ecf0ef 100644 (file)
@@ -262,16 +262,20 @@ static inline void free_decl_abi(decl_abi *abi) {
        free(abi);
 }
 
        free(abi);
 }
 
+typedef struct decl_callinfo {
+       void *sym;
+       void *info;
+       size_t argc;
+       void **args;
+       void *rval;
+} decl_callinfo;
+
 typedef struct decl {
        decl_abi *abi;
        decl_arg *func;
        decl_args *args;
        struct impl *impl;
 typedef struct decl {
        decl_abi *abi;
        decl_arg *func;
        decl_args *args;
        struct impl *impl;
-       struct {
-               void *sym;
-               void *info;
-               void **args;
-       } call;
+       decl_callinfo call;
 } decl;
 
 static inline decl* init_decl(decl_abi *abi, decl_arg *func, decl_args *args) {
 } decl;
 
 static inline decl* init_decl(decl_abi *abi, decl_arg *func, decl_args *args) {