This is where I stand now, and as it is in the 0.7.0 cygwin package.

It works fine, but slow.
There's a new installed key in the config hash, and the code to check this in
library.c is ifdef'ed out as it generates a VM out of memory error.


2008/8/9 Reini Urban <[EMAIL PROTECTED]>:
> Reini Urban schrieb:
>>
>> Reini Urban schrieb:
>>>
>>> Geoffrey Broadwell via RT schrieb:
>>>>
>>>> On Sun, 2008-07-27 at 13:13 +0200, Reini Urban wrote:
>>>>>
>>>>> +    stat $I0, conf_file, 0
>>>>> +    if $I0 goto conf
>>>>> +    +    # If installed into /usr/lib/parrot, not /usr/runtime/parrot
>>>>> +    # This logic has to be reversed when installed versions should
>>>>> run faster
>>>>> +    # than source builds.
>>>>
>>>> Reverse it now; we'll never remember to get back to this in the future.
>>>>
>>>>> +    conf_file = interpinfo .INTERPINFO_RUNTIME_PREFIX
>>>>> +    conf_file .= "/lib/parrot/include/config.fpmc"
>>>>> +conf:
>>>>
>>>>> +    name = interpinfo .INTERPINFO_RUNTIME_PREFIX
>>>>> +    concat name, "lib/parrot/dynext/"
>>>>>     concat name, request
>>>>
>>>> Since we're using PIR in both places, we should probably use the .=
>>>> sugar in both places.  Yes, I know the second file has some 'concat's in
>>>> it already.  Here's an opportunity to fix that.  :-)
>>>
>>> Ok. concat to .= is easy.
>>>
>>> Why I don't want to fix that as you suggest is that I wait for feedback
>>> how it was designed to be. This patch is just a intermediate hack. Someone
>>> like particle or Allison should comment on that.
>>>
>>> It is fine for benchmarks that the source build uses
>>> runtime/parrot/include/config.fpmc.
>>> But the installed version either should NOT need to load the frozen
>>> config file when it is already linked in, or check with some global or
>>> interpinfo magic and look up the right prefix then.
>>> No useless stats please.
>>
>> My current plan is this:
>>
>> Source builds should be allowed to access
>> runtime/parrot/include/config.fpmc and the various other config fpmc's, but
>> the installable version, linked to install_config.fpmc must change its
>> lib_path to allow only FHS-compliant paths,
>> i.e remove runtime/parrot and runtime/parrot/include in favor of
>> lib/parrot and lib/parrot/include.
>>
>> This must be fixed in config.pir, parrotlib.pir and src/library.c with
>> this ticket. (Hope I forgot no other file)
>> I'll work on that, but I have a business trip for the next two weeks.
>>
>> An optimization for another ticket would be to remove the run-time access
>> to include/config.pir for linked installable's, where the frozen config.fpmc
>> is already linked. There the sub _config should use some config detection
>> logic (suggestion: new config key 'installed') to omit .include
>> "library/config.pir"
>> See the ticket perl #57418 [TODO] optimize _config to omit .include
>> "library/config.pir" on installables
>
> Attached is an improved version with a fix in src/library.c, to decide
> between installed and not installed configs.
> This solves at least the /usr/runtime problem.
>
> However config.pir still unnecessarily tries to access some runtime files,
> esp. "interpinfo.pasm" to get the index of .INTERPINFO_RUNTIME_PREFIX
> I'm toying with the idea to fill that macro in parrotlib.pir and config.pir
> with config/gen/parrot_include.pm.

-- 
Reini Urban
http://phpwiki.org/ http://murbreak.at/
Remove stats to /usr/runtime/parrot at installed versions
("/usr" being the prefix).
Check the config_hash for the installed key and the 
interpreter INTERPINFO_RUNTIME_PREFIX or CONFIG_HASH if present.

The library.c code is not working yet with ENABLE_PARROT_LIBRARY_INSTALLED
Parrot VM: PANIC: Out of mem!
Not enough tuits yet to fix and debug it.

Index: parrot-svn/runtime/parrot/library/config.pir
===================================================================
--- parrot-svn.orig/runtime/parrot/library/config.pir
+++ parrot-svn/runtime/parrot/library/config.pir
@@ -48,12 +48,28 @@ undefined values) is undefined, and may 
 .sub _config
     .local pmc CONF
     .local string conf_file
+
+    #unless find_sub('_config') goto runtime
+    #$P0 = _config()
+    #.return( $P0 )
+
+runtime:
+    # conf_file = Parrot_locate_runtime_file_str(interp, "config.fpmc", 2)
     conf_file = interpinfo .INTERPINFO_RUNTIME_PREFIX
     conf_file .= "/runtime/parrot/include/config.fpmc"
+    stat $I0, conf_file, 0
+    if $I0 goto conf
 
+    # If installed into /usr/lib/parrot, not /usr/runtime/parrot
+    # This logic has to be reversed when installed versions should run faster
+    # than source builds.
+    conf_file = interpinfo .INTERPINFO_RUNTIME_PREFIX
+    conf_file .= "/lib/parrot/include/config.fpmc"
+conf:
     open CONF, conf_file, "<"
     $I0 = defined CONF
     if $I0 goto ok1
+
     printerr "Can't read '"
     printerr conf_file
     printerr "': "
Index: parrot-svn/runtime/parrot/library/parrotlib.pir
===================================================================
--- parrot-svn.orig/runtime/parrot/library/parrotlib.pir
+++ parrot-svn/runtime/parrot/library/parrotlib.pir
@@ -24,14 +24,13 @@ parrotlib's interface functions.
     .local pmc includes
     .local string root
 
-
-    # XXX todo: get root from config
     $P0 = new 'Env'
     root = $P0["PARROT_RUNTIME_ROOT"]
     length $I0, root
     if $I0 == 0 goto DEFAULT
     branch OKAY
 DEFAULT:
+    # lib/parrot on installed, or runtime
     root = "runtime/parrot"
 OKAY:
 
@@ -138,13 +137,22 @@ Returns the location of a dynamic extens
     stat $I0, name, 0
     if $I0 goto END
 
-    name = "runtime/parrot/dynext/"
+    .include "interpinfo.pasm"
+    name = interpinfo .INTERPINFO_RUNTIME_PREFIX
+    concat name, "lib/parrot/dynext/"
     concat name, request
     stat $I0, name, 0
     if $I0 goto END
 
+    concat name, ext
+    stat $I0, name, 0
+    if $I0 goto END
+
     name = "runtime/parrot/dynext/"
     concat name, request
+    stat $I0, name, 0
+    if $I0 goto END
+
     concat name, ext
     stat $I0, name, 0
     if $I0 goto END
Index: parrot-svn/src/library.c
===================================================================
--- parrot-svn.orig/src/library.c
+++ parrot-svn/src/library.c
@@ -121,64 +121,108 @@ if will be called as a function with thi
 Platform code may add, delete, or replace search path entries as needed. See
 also F<include/parrot/library.h> for C<enum_lib_paths>.
 
+#ifdef ENABLE_PARROT_LIBRARY_INSTALLED
+then the config hash is checked for the path prefix. This still crashes.
+
 =cut
 
 */
 
+#undef ENABLE_PARROT_LIBRARY_INSTALLED
+
 void
 parrot_init_library_paths(PARROT_INTERP)
 {
     PMC *paths;
     STRING *entry;
+    INTVAL installed = 0;
 
     PMC * const iglobals = interp->iglobals;
     /* create the lib_paths array */
     PMC * const lib_paths = pmc_new(interp, enum_class_FixedPMCArray);
+#ifdef ENABLE_PARROT_LIBRARY_INSTALLED
+    PMC * const config_hash = VTABLE_get_pmc_keyed_int(interp, iglobals, IGLOBALS_CONFIG_HASH);
+    STRING * const key = CONST_STRING(interp, "installed");
+#endif
 
     VTABLE_set_integer_native(interp, lib_paths, PARROT_LIB_PATH_SIZE);
     VTABLE_set_pmc_keyed_int(interp, iglobals,
             IGLOBALS_LIB_PATHS, lib_paths);
+#ifdef ENABLE_PARROT_LIBRARY_INSTALLED
+    if (VTABLE_elements(interp, config_hash) &&
+        VTABLE_exists_keyed_str(interp, config_hash, key))) {
+        installed = VTABLE_get_integer_keyed_str(interp, config_hash, key);
+    }
+#endif
+
     /* each is an array of strings */
     /* define include paths */
     paths = pmc_new(interp, enum_class_ResizableStringArray);
     VTABLE_set_pmc_keyed_int(interp, lib_paths,
             PARROT_LIB_PATH_INCLUDE, paths);
-    entry = CONST_STRING(interp, "runtime/parrot/include/");
-    VTABLE_push_string(interp, paths, entry);
-    entry = CONST_STRING(interp, "runtime/parrot/");
-    VTABLE_push_string(interp, paths, entry);
+#ifdef ENABLE_PARROT_LIBRARY_INSTALLED
+    if (installed) {
+#endif
+        entry = CONST_STRING(interp, "lib/parrot/include/");
+        VTABLE_push_string(interp, paths, entry);
+        entry = CONST_STRING(interp, "lib/parrot/");
+        VTABLE_push_string(interp, paths, entry);
+#ifdef ENABLE_PARROT_LIBRARY_INSTALLED
+    } else {
+#endif
+        entry = CONST_STRING(interp, "runtime/parrot/include/");
+        VTABLE_push_string(interp, paths, entry);
+        entry = CONST_STRING(interp, "runtime/parrot/");
+        VTABLE_push_string(interp, paths, entry);
+#ifdef ENABLE_PARROT_LIBRARY_INSTALLED
+    }
+#endif
     entry = CONST_STRING(interp, "./");
     VTABLE_push_string(interp, paths, entry);
-    entry = CONST_STRING(interp, "lib/parrot/include/");
-    VTABLE_push_string(interp, paths, entry);
-    entry = CONST_STRING(interp, "lib/parrot/");
-    VTABLE_push_string(interp, paths, entry);
 
     /* define library paths */
     paths = pmc_new(interp, enum_class_ResizableStringArray);
     VTABLE_set_pmc_keyed_int(interp, lib_paths,
             PARROT_LIB_PATH_LIBRARY, paths);
-    entry = CONST_STRING(interp, "runtime/parrot/library/");
-    VTABLE_push_string(interp, paths, entry);
-    entry = CONST_STRING(interp, "runtime/parrot/");
-    VTABLE_push_string(interp, paths, entry);
+#ifdef ENABLE_PARROT_LIBRARY_INSTALLED
+    if (installed) {
+#endif
+        entry = CONST_STRING(interp, "lib/parrot/library/");
+        VTABLE_push_string(interp, paths, entry);
+        entry = CONST_STRING(interp, "lib/parrot/");
+        VTABLE_push_string(interp, paths, entry);
+#ifdef ENABLE_PARROT_LIBRARY_INSTALLED
+    } else {
+#endif
+        entry = CONST_STRING(interp, "runtime/parrot/library/");
+        VTABLE_push_string(interp, paths, entry);
+        entry = CONST_STRING(interp, "runtime/parrot/");
+        VTABLE_push_string(interp, paths, entry);
+#ifdef ENABLE_PARROT_LIBRARY_INSTALLED
+    }
+#endif
     entry = CONST_STRING(interp, "./");
     VTABLE_push_string(interp, paths, entry);
-    entry = CONST_STRING(interp, "lib/parrot/library/");
-    VTABLE_push_string(interp, paths, entry);
-    entry = CONST_STRING(interp, "lib/parrot/");
-    VTABLE_push_string(interp, paths, entry);
 
     /* define dynext paths */
     paths = pmc_new(interp, enum_class_ResizableStringArray);
     VTABLE_set_pmc_keyed_int(interp, lib_paths,
             PARROT_LIB_PATH_DYNEXT, paths);
-    entry = CONST_STRING(interp, "runtime/parrot/dynext/");
-    VTABLE_push_string(interp, paths, entry);
+#ifdef ENABLE_PARROT_LIBRARY_INSTALLED
+    if (installed) {
+#endif
+        entry = CONST_STRING(interp, "lib/parrot/dynext/");
+        VTABLE_push_string(interp, paths, entry);
+#ifdef ENABLE_PARROT_LIBRARY_INSTALLED
+    } else {
+#endif
+        entry = CONST_STRING(interp, "runtime/parrot/dynext/");
+        VTABLE_push_string(interp, paths, entry);
+#ifdef ENABLE_PARROT_LIBRARY_INSTALLED
+    }
+#endif
     entry = CONST_STRING(interp, "");
     VTABLE_push_string(interp, paths, entry);
-    entry = CONST_STRING(interp, "lib/parrot/dynext/");
-    VTABLE_push_string(interp, paths, entry);
 
     /* shared exts */
     paths = pmc_new(interp, enum_class_ResizableStringArray);
@@ -202,7 +246,16 @@ parrot_init_library_paths(PARROT_INTERP)
 
 =item C<static PMC* get_search_paths>
 
-RT#48260: Not yet documented!!!
+Return lib_paths as array of StringArrays with library searchpaths and shared
+extension used for loading various files at runtime.
+The structure looks like this:
+
+  lib_paths = [
+    [ "runtime/parrot/include", ... ],   # paths for .include 'file'
+    [ "runtime/parrot/library", ... ],   # paths for load_bytecode
+    [ "runtime/parrot/dynext", ... ],    # paths for loadlib
+    [ ".so", ... ]                       # list of shared extensions
+  ]
 
 =cut
 
@@ -573,7 +626,9 @@ Parrot_locate_runtime_file_str(PARROT_IN
 
 =item C<char* Parrot_locate_runtime_file>
 
-RT#48260: Not yet documented!!!
+Determines whether a file name given by a fixed-8 or utf8 C<STRING> is an
+absolute file name. Returns C<1> if the filename is absolute, returns C<0>
+otherwise.
 
 =cut
 
Index: parrot-svn/config/gen/config_pm/config_lib.in
===================================================================
--- parrot-svn.orig/config/gen/config_pm/config_lib.in
+++ parrot-svn/config/gen/config_pm/config_lib.in
@@ -12,6 +12,7 @@ no_arg:
 
 	<<PCONFIG>>
 
+	set P0["installed"], I11
 	if I11, is_install
 	set S1, "<<PWD>>"
 	set P0["prefix"], S1

Reply via email to