[Vm-dev] primitiveQuit for the Interpreter VM

tim Rowledge tim at rowledge.org
Tue Oct 15 17:56:37 UTC 2013


On 15-10-2013, at 6:23 AM, Frank Shearar <frank.shearar at gmail.com> wrote:

> 
> Levente pointed out that while Cog has this primitive, the Interpreter
> VM doesn't, and so his Inbox submission
> (http://source.squeak.org/inbox/System-ul.528.mcz) can't really go
> into Trunk yet.
> 
> Given that this is something that I feel strongly about - I need this
> primitive so that builds will actually _fail_ and not continue trying
> random things on things in random states - it seems likely that I'll
> be the one to implement the thing.
> 
> SO. How might I go about porting the Cog version? Do I simply start to
> Read the Source?

The Cog version in platforms/unix/sqUnixMain.c is -

int ioExit(void) { return ioExitWithErrorCode(0); }

sqInt
ioExitWithErrorCode(int ec)
{
#if COGVM
extern sqInt reportStackHeadroom;
	if (reportStackHeadroom)
		reportMinimumUnusedHeadroom();
#endif
  printPhaseTime(3);
  dpy->winExit();
  exit(ec);
  return ec;
}

so the plain interp version (in platforms/unix/sqUnixMain.c - who'd guess!) needs to change from
sqInt ioExit(void)
{
  dpy->winExit();
  exit(0);
}

to something like 

sqInt ioExit(void)
{
  ioExitWithErrorCode(0);
}

sqInt
ioExitWithErrorCode(int ec)
{
  dpy->winExit();
  exit(ec);
  return ec;
}

And we need to update the platforms/Cross/sq .h file to add
sqInt ioExitWithErrorCode(int);


Then in the plain interp VMMakerpackage InterpreterPrimitives>primitiveQuit becomes
primitiveQuit

	self ioExitWithErrorCode: (argumentCount = 1 ifTrue: [objectMemory integerValueOf: self stackTop] ifFalse: [0])


Simple. Though we have to get all the platform code updated sensibly synchronously, which always more of a getting everyone organised problem than anything else.

I've committed the Cross/sq.h and RiscOS/vm/sqRPCMain.c changes. Ian is still caring for the unix code but who able to do the Mac & Windows changes?

tim
--
tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
The enema of my enemy is my friend



More information about the Vm-dev mailing list