flush
authorMichael Wallner <mike@php.net>
Thu, 15 Oct 2015 18:47:18 +0000 (20:47 +0200)
committerMichael Wallner <mike@php.net>
Thu, 15 Oct 2015 18:47:18 +0000 (20:47 +0200)
config.m4
src/compiler.c
src/module.c
src/parser.h
src/validator.c

index 5be9e351fe2ae89aca8d744eb2ba76a6c7934180..816511fd09e764bda0eb402191dabea591bb0f3a 100644 (file)
--- 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
index 660c968c3d138ae534bfcd9153c29942628edf66..5e5ebde9e7e2b1073126ec321dc728b47603e19b 100644 (file)
@@ -3,7 +3,7 @@
 #include <jit/jit.h>
 
 #include <php.h>
-#include <Zend/Zend_API.h>
+#include <Zend/zend_API.h>
 
 #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;
index 389cbc5752e123fc33cd1fab4eb8a4f7c264da80..90a838da0e849aef935d7ae4bd55b5e689eaca1c 100644 (file)
@@ -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);
                }
index d4909dd9fa496456c5c790eb18e95e91b66c4cbd..2aaab31985ead22727f3d1f4ab3dd67cf2de3690 100644 (file)
@@ -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;
 }
 
index 191124a18104db18965db8397b4a09097f51bcef..5f6a6d36e73e81ec841cd047916a4d0efd119dd0 100644 (file)
@@ -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());