pike.git / lib / master.pike.in

version» Context lines:

pike.git/lib/master.pike.in:1073:   // doesn't work reliably there since it calls `==.   protected mapping(program:string) rev_programs = ([]);   protected mapping(object:program) rev_objects = ([]);   protected mapping(mixed:string) rev_fc = ([]);      string programs_reverse_lookup (program prog)   //! Returns the path for @[prog] in @[programs], if it got any.   {    // When running with trace, this function can get called    // before __INIT has completed. +  // NB: We need to be reasonably thread safe, as the compiler +  // may be running in another thread.    if (!rev_programs) return UNDEFINED;    if (sizeof (rev_programs) < sizeof (programs)) {    foreach (programs; string path; program|NoValue prog)    if (prog == no_value)    m_delete (programs, path);    else    rev_programs[prog] = path;    }    return rev_programs[prog];   }      program objects_reverse_lookup (object obj)   //! Returns the program for @[obj], if known to the master.   { -  +  // NB: We need to be reasonably thread safe, as the compiler +  // may be running in another thread.    if (sizeof (rev_objects) < sizeof (objects)) {    foreach (objects; program prog; object|NoValue obj)    if (obj == no_value)    m_delete (rev_objects, obj);    else    rev_objects[obj] = prog;    }    return rev_objects[obj];   }   
pike.git/lib/master.pike.in:1391:    AUTORELOAD_BEGIN();      #ifdef PIKE_AUTORELOAD    if (load_time[fname] >= s->mtime)    if (!undefinedp (ret=programs[fname]) && ret != no_value) {    resolv_debug ("low_findprog %s: returning cached (autoreload)\n", fname);    return ret;    }   #endif    +  object compiler_lock = DefaultCompilerEnvironment->lock(); +  if(!undefinedp(ret = programs[fname]) && (ret != no_value)) { +  destruct(compiler_lock); +  resolv_debug("low_findprog %s: returning cached (from other thread).\n", +  fname); +  return ret; +  } +     switch(ext)    {    case "":    case ".pike":    foreach(query_precompiled_names(fname), string oname) {    int o_mtime = get_precompiled_mtime (oname);    if (o_mtime >= 0) {    if (o_mtime >= s->mtime) {    mixed err=catch {    object|program decoded;
pike.git/lib/master.pike.in:1440:    "Decode failed: " +    call_describe_error(err));    // handle_error(err);    } else if (out_of_date_warning) {    call_compile_warning (handler, oname,    "Compiled file is out of date");    }    }    }    -  object compiler_lock = DefaultCompilerEnvironment->lock(); -  if(!undefinedp(ret = programs[fname]) && (ret != no_value)) { -  destruct(compiler_lock); -  resolv_debug("low_findprog %s: returning cached (from other thread).\n", -  fname); -  return ret; -  } +     resolv_debug ("low_findprog %s: compiling, mkobj: %O\n", fname, mkobj);    INC_RESOLV_MSG_DEPTH();    programs[fname]=ret=__empty_program(0, fname);    AUTORELOAD_CHECK_FILE (fname);    string src;    if (array|object err = catch (src = master_read_file (fname))) {    DEC_RESOLV_MSG_DEPTH();    resolv_debug ("low_findprog %s: failed to read file\n", fname);    objects[ret] = no_value;    ret=programs[fname]=0; // Negative cache.
pike.git/lib/master.pike.in:1536:   }      //   // This function is called by the compiler when a delayed compilation   // error occurs in the given program. It should remove all references   // to the program so that it can be freed.   //   void unregister(program p)   {    // werror("Unregistering %O...\n", p); +  object compiler_lock = DefaultCompilerEnvironment->lock(); +     if(string fname=rev_programs[p] || search(programs,p)) {    resolv_debug("unregister %s\n", fname);    if (m_delete (rev_programs, p))    m_delete (programs, fname);    else    programs[fname] = no_value;       string name = program_path_to_name (fname);    mixed n = has_value (name, '.') ?    resolv ((name / ".")[..<1] * ".") :
pike.git/lib/master.pike.in:1611:       if(sscanf(reverse(BASENAME(pname)),"%s.%s",ext, nname))    {    ext="."+reverse(ext);    pname=pname[..<sizeof(ext)];    }    else {    ext="";    }    +  // NB: No need to lock the compiler here; findprog() will +  // lock and reprobe on miss in the programs mapping.    if(IS_ABSOLUTE_PATH(pname))    {    program|NoValue prog = programs[pname];    if ((!undefinedp(prog)) && (prog != no_value))    {    return prog;    }    pname=combine_path("",pname);    return findprog(pname,ext,handler,mkobj);    }
pike.git/lib/master.pike.in:1877:   }      object low_cast_to_object(string oname, string current_file,    object|void current_handler)   {    program p;    object o;       p = low_cast_to_program(oname, current_file, current_handler, 1);    if(!p) return 0; +  if(!objectp(o = objects[p])) { +  object compiler_lock = DefaultCompilerEnvironment->lock();    // NB: p might be a function in a fake_object... -  if(!objectp (o=objects[p])) o=objects[p]=p(); +  if(!objectp(o = objects[p])) o = objects[p] = p(); +  destruct(compiler_lock); +  }    return o;   }      //! This function is called when the drivers wants to cast a string   //! to an object because of an implict or explicit cast. This function   //! may also receive more arguments in the future.   object cast_to_object(string oname, string current_file,    object|void current_handler)   {    resolv_debug ("cast_to_object(%O, %O)\n", oname, current_file);
pike.git/lib/master.pike.in:2126:    if (ret = low_cast_to_program(fname, 0, compilation_handler)) {    DEC_RESOLV_MSG_DEPTH();    resolv_debug("dirnode(%O)->ind(%O) => found subprogram %O:%O\n",    dirname, index, fname, ret);   #if constant(load_module)    if (has_suffix(fname, ".so")) {    // This is compatible with 7.4 behaviour.    if (!ret->_module_value) {    object o;    // NB: p might be a function in a fake_object... -  if(!objectp (o=objects[ret])) o=objects[ret]=ret(); +  if(!objectp(o = objects[ret])) { +  object compiler_lock = DefaultCompilerEnvironment->lock(); +  if(!objectp(o = objects[ret])) o = objects[ret] = ret(); +  destruct(compiler_lock); +  }    ret = o;    }    if(mixed tmp=ret->_module_value) ret=tmp;    }   #endif    return ret;    }    }    resolv_debug("dirnode(%O)->ind(%O) => failure for file %O\n",    dirname, index, fname);
pike.git/lib/master.pike.in:5213:   //! @appears Pike.Decoder   //!   //! Codec for use with @[decode_value]. This is the decoder   //! corresponding to @[Encoder]. See that one for more details.   {    protected int unregistered = 1;       object __register_new_program(program p)    {    DEC_MSG ("__register_new_program (%O)\n", p); +  // NB: decode_value() has already locked the compiler, so we +  // should not need to lock it here.    if(unregistered && fname)    {    unregistered = 0;    resolv_debug("register %s\n", fname);    programs[fname]=p;    if (mkobj)    DEC_RETURN (objectp (objects[p]) ? objects[p] : (objects[p]=__null_program()));    }    DEC_RETURN (0);    }