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
#include <jit/jit.h>
#include <php.h>
-#include <Zend/Zend_API.h>
+#include <Zend/zend_API.h>
#include "compiler.h"
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;
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;
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);
}
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);
}
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());