--- parser3/src/main/pa_request.C 2026/09/30 17:45:25 1.455 +++ parser3/src/main/pa_request.C 2026/10/05 17:50:18 1.458 @@ -34,8 +34,9 @@ #include "pa_vconsole.h" #include "pa_vdate.h" #include "pa_varray.h" +#include "pa_code_cache.h" -volatile const char * IDENT_PA_REQUEST_C="$Id: pa_request.C,v 1.455 2026/09/30 17:45:25 moko Exp $" IDENT_PA_REQUEST_H IDENT_PA_REQUEST_CHARSETS_H IDENT_PA_REQUEST_INFO_H IDENT_PA_VCONSOLE_H; +volatile const char * IDENT_PA_REQUEST_C="$Id: pa_request.C,v 1.458 2026/10/05 17:50:18 moko Exp $" IDENT_PA_REQUEST_H IDENT_PA_REQUEST_CHARSETS_H IDENT_PA_REQUEST_INFO_H IDENT_PA_VCONSOLE_H; // consts @@ -111,6 +112,9 @@ static const String lock_wait_timeout_na static const String httpd_name("HTTPD"); static const String httpd_timeout_name("timeout"); static const String httpd_mode_name("mode"); +#ifdef CODE_CACHE +static const String httpd_code_cache_name("code-cache"); +#endif static const String conf_method_name("conf"); static const String post_process_method_name("postprocess"); @@ -186,6 +190,9 @@ Request::Request(SAPI_Info& asapi_info, // file_no=0 => unknown file_list+=String::Body("UNKNOWN"); file_list+=String::Body("-body of process-"); // pseudo_file_no__process +#ifdef CODE_CACHE + Code_cache_manager::add_files(file_list); +#endif // maybe expire old caches cache_managers->maybe_expire(); @@ -398,6 +405,12 @@ void Request::configure_admin(VStateless HTTPD_Server::set_mode(option->as_string()); } +#ifdef CODE_CACHE + CONF_OPTION(httpd, httpd_code_cache_name, { + Code_cache_manager::set_enabled(option->as_bool()); + }, "HTTPD.%s must be bool"); +#endif + // configure method_frame options // until someone with less privileges have overriden them methoded_array().configure_admin(*this); @@ -618,7 +631,7 @@ void Request::use_file_directly(const St const char* after=target; size_t drlen=strlen(request_info.document_root_path); - if(memcmp(after, request_info.document_root_path, drlen)==0) + if(path_cmp(after, request_info.document_root_path, drlen)==0) after+=drlen; // to start from document_root/auto.p while(const char* before=strchr(after, '/')) { @@ -633,8 +646,18 @@ void Request::use_file_directly(const St } } + Code_cache* code=0; +#ifdef CODE_CACHE + if(Code_cache* cached=Code_cache_manager::get(file_spec)) { + use_buf(main_class, 0, 0, cached->file_no, 0, cached); + return; + } + // to record the compilation; only while the httpd config runs + code=Code_cache_manager::create(file_spec); +#endif + if(const char* source=file_read_text(charsets, file_spec, true)) - use_buf(main_class, source, 0, register_file(file_spec)); + use_buf(main_class, source, 0, register_file(file_spec), 0, code); } @@ -698,14 +721,18 @@ void Request::use_file(const String& fil } } -void Request::use_buf(VStateless_class& aclass, const char* source, const String* main_alias, uint file_no, int line_no_offset) { +void Request::use_buf(VStateless_class& aclass, const char* source, const String* main_alias, uint file_no, int line_no_offset, Code_cache* code) { // temporary zero @conf to avoid it second execution Temp_method temp_method_conf(aclass, conf_method_name, 0); // temporary zero @auto to avoid it second execution Temp_method temp_method_auto(aclass, auto_method_name, 0); // compile loaded classes - ArrayClass& cclasses=compile(&aclass, source, main_alias, file_no, line_no_offset); + ArrayClass& cclasses= +#ifdef CODE_CACHE + !source ? code->replay(*this, aclass) : +#endif + compile(&aclass, source, main_alias, file_no, line_no_offset, code); VString* vfilespec= new VString(file_list[file_no]); @@ -777,7 +804,7 @@ const String* Request::real_disk_path(co switch(path_scheme(name)) { case PA_SCHEME_NONE: return &full_disk_path(name); case PA_SCHEME_FILE: { - const String* path=file_uri_to_path(name); + const String* path=clean_path_scheme(PA_SCHEME_FILE, name) ? file_uri_to_path(name) : 0; return path ? &backslashes_to_slashes(*path) : 0; } default: return 0; // not a disk path