From: Michael Wallner Date: Thu, 15 Oct 2015 18:47:18 +0000 (+0200) Subject: flush X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=3bca631112f4865510ea91c85e8c820c4465fc14;p=m6w6%2Fext-psi flush --- diff --git a/config.m4 b/config.m4 index 5be9e35..816511f 100644 --- a/config.m4 +++ b/config.m4 @@ -8,7 +8,7 @@ if test "$PHP_PSI" != "no"; then PHP_SUBST(LEMON) AC_CACHE_CHECK(for libjit install root, PSI_cv_LIBJIT_DIR, [ - for PSI_cv_LIBJIT_DIR in {/usr{,/local},/opt}{,libjit} + for PSI_cv_LIBJIT_DIR in $PHP_PSI {/usr{,/local},/opt}{,libjit} do if test -e $PSI_cv_LIBJIT_DIR/include/jit/jit.h then diff --git a/src/compiler.c b/src/compiler.c index 660c968..5e5ebde 100644 --- a/src/compiler.c +++ b/src/compiler.c @@ -3,7 +3,7 @@ #include #include -#include +#include #include "compiler.h" @@ -60,10 +60,10 @@ static inline size_t impl_num_min_args(impl *impl) { return n; } -void jit_closure_handler(jit_type_t signature, void *result, void **args, void *user_data) +static void psi_jit_closure_handler(jit_type_t signature, void *result, void **args, void *user_data) { - zend_execute_data *execute_data = args[0]; - zval *return_value = args[1]; + zend_execute_data *execute_data = *(zend_execute_data **)args[0]; + zval *return_value = *(zval **)args[1]; PSI_ClosureData *data = user_data; impl_arg *iarg; @@ -119,17 +119,19 @@ zend_function_entry *PSI_CompilerCompile(PSI_Compiler *C) for (i = 0; i < C->impls->count; ++i) { zend_function_entry *zf; - PSI_ClosureData *data; + volatile PSI_ClosureData *data; if (!C->impls->list[i]->decl) { continue; } - signature = jit_type_create_signature(jit_abi_cdecl, jit_type_void, params, 2, 1); + signature = jit_type_create_signature(jit_abi_vararg, jit_type_void, params, 2, 1); - zf = &zfe[++j]; + zf = &zfe[j++]; data = PSI_ClosureDataAlloc(C->context, C->impls->list[i]); zf->fname = C->impls->list[i]->func->name; - zf->handler = jit_closure_create(C->context, signature, jit_closure_handler, data); + zf->handler = jit_closure_create(C->context, signature, &psi_jit_closure_handler, data); + fprintf(stderr, "Compiled closure for %s\n", zf->fname); + printf("Closuredata: %p of closure %p\n", data, zf->handler); } return zfe; diff --git a/src/module.c b/src/module.c index 389cbc5..90a838d 100644 --- a/src/module.c +++ b/src/module.c @@ -26,6 +26,9 @@ PHP_INI_END(); static int psi_select_dirent(const struct dirent *entry) { +#ifndef FNM_CASEFOLD +#define FNM_CASEFOLD 0 +#endif return 0 == fnmatch("*.psi", entry->d_name, FNM_CASEFOLD); } @@ -83,9 +86,11 @@ PHP_MINIT_FUNCTION(psi) zend_function_entry *closures = PSI_CompilerCompile(&C); if (closures) { - zend_register_functions(NULL, closures, NULL, MODULE_PERSISTENT); + if (SUCCESS != zend_register_functions(NULL, closures, NULL, MODULE_PERSISTENT)) { + fprintf(stderr, "Failed to register functions!\n"); + } } - PSI_CompilerDtor(&C); + //PSI_CompilerDtor(&C); } jit_context_build_end(ctx); } diff --git a/src/parser.h b/src/parser.h index d4909dd..2aaab31 100644 --- a/src/parser.h +++ b/src/parser.h @@ -31,6 +31,7 @@ static inline decl_type *init_decl_type(token_t type, char *name) { decl_type *t = malloc(sizeof(*t)); t->type = type; t->name = strdup(name); + t->real = NULL; return t; } diff --git a/src/validator.c b/src/validator.c index 191124a..5f6a6d3 100644 --- a/src/validator.c +++ b/src/validator.c @@ -122,7 +122,7 @@ static inline int validate_decl_func(PSI_Validator *V, decl *decl, decl_arg *fun return 0; } - decl->dlptr = dlsym(V->dlopened ?: RTLD_DEFAULT, func->var->name); + decl->dlptr = dlsym(V->dlopened, func->var->name); if (!decl->dlptr) { fprintf(stderr, "Failed to located symbol '%s': %s\n", func->var->name, dlerror());