assert or sqAssert? [was: Re: Source Forge Changes for 3.2.1]

Andrew C. Greenberg werdna at mucow.com
Wed Jan 2 18:01:26 UTC 2002


On Wednesday, January 2, 2002, at 02:11  AM, John M McIntosh wrote:

> LargeIntegersPlugin>>assert: aBool
> 	self
>           debugCode:
> 		[aBool ifFalse:
> 			[self msg: 'Assertion failed!'.
> 			self cCode: 'exit(1)'
> 			inSmalltalk:
> 			[interpreterProxy primitiveFail.
> 			self halt]].
> 			^ true]

Well, even as a compromise, this ignores that the code, as written, is 
broken!  I suggest eliminating it altogether as used here.  Because of 
the

	#self cCode:inSmalltalk

message, this method will not be inlined to the caller, even though the 
#debugCode inlines the generated code of #assert: to blank!  This is 
what appears to be happening in the generated code for 
LargeIntegerPlugin.

Thus, the generated code for the production version contains calls like:

	assert(limit < lenFrom);

which are evaluated for an empty procedure,  I don't know how many 
optimizing compilers are smart enough to pick this one up, but with less 
than careful optimiztion, this means that all your assertion expressions 
are evaluated.

This is particularly egregious for LargeIntegersPlugin, since that code 
tends to live inside many inner loops for computation-intensive work.  
The microseconds wasted for such computations -- which are unnecessary 
if this were done differently -- add up.

Thus, in addition to the decidedly annoying problems with some important 
platform development systems and the like, this structure is also highly 
inefficient, because





More information about the Squeak-dev mailing list