Pluginised VM seems to work quite well

Stephan Rudlof sr at evolgo.de
Sat Mar 11 18:10:16 UTC 2000


Andreas,

"Raab, Andreas" wrote:
> 
> Andrew,
> 
> > Am I correct in presuming that this will all be done "behind the
> > scenes," in that the same message
> >
> >       <primitive: 'foo' module: 'bar'>
> >
> > would be used to access either?
> 
> You are correct.
> 
> > That being said, can we be assured that
> > the identifier 'foo_bar' will be recognized on every machine,
> > or must we put limits on aggregate length "+1 for the hypen" to
> > cater to the least common denominator machine?
> 
> Good point. I didn't even think of it. Does anyone out there know exactly if
> there are machines on which dlsym() or similar is limited to less than 255
> characters?!
> 
> > If you do this, may I suggest that the search path begin with external
> > modules, so that even when a fat executable exists, the search will
> > first be made to see if a substitute module exists, so that the fat VM
> > can be extended simply by adding a new plugin, without having to do
> > surgery on the VM executable or a new system install of the thin one?
> 
> That's part of the lookup scheme already.
> 

I don't see this.

>From sqUnixExternalPrims.c of Ians 2.7 Linux port:

void *loadExternalFunctionFromModule(char *fName, char *mName)
{
  ModuleEntry *module;
  void *fn;

  if ((mName != 0) && (*mName != 0))
    {
      module= findModuleEntryNamed(mName);
      if (module == 0)
	{
	  /* new module */
	  dprintf((stderr, "loading: %s\n", mName));
	  module= loadModuleEntry(mName, 1);
	  if (module == 0)
	    {
	      dprintf((stderr, "could not find library for module: %s\n",
mName));
	      return 0;
	    }
	}
    }
  else
    {
      if (squeakModule == 0)
	{
	  dprintf((stderr, "loading: <intrinsics>\n"));
	  squeakModule= (ModuleEntry *)calloc(1, sizeof(ModuleEntry));
	  squeakModule->handle= dlopen(NULL, RTLD_NOW);
	  if (squeakModule->handle == 0)
	    dprintf((stderr, "%s\n", dlerror()));
	}
      module= squeakModule;
    }

  /* module has been found; load the function from it */

  dprintf((stderr, "handle:  %p\n", module->handle));
  dprintf((stderr, "resolve: `%s'\n", fName));

  fn= dlsym(module->handle, fName);

  dprintf((stderr, "address: %p\n", fn));

  if (fn == 0)
    {
      dprintf((stderr, "%s\n", dlerror()));
      return 0;
    }

  return fn;
}


This function will be called by Interpreter>>primitiveExternalCall ->
ioLoadExternalFunctionOfLengthFromModuleOfLength() ->
loadExternalFunctionFromModule().

If there isn't a module name given, it looks for the function name
inside the squeak module.
Otherwise it looks for the function in the given module: But if the
module is missing, it returns a NULL pointer and doesn't look into the
squeak module!

I think Andrew means that if there is a call like
	> >       <primitive: 'foo' module: 'bar'>
which leads to a call of Interpreter>>primitiveExternalCall,
first it should look for an external plugin function in the module 'foo'
and if this fails for the same function in the squeak module.

The current 2.7 mechanism doesn't do this (at least under Linux).


Greetings,

Stephan





More information about the Squeak-dev mailing list