[squeak-dev] Bug in BytecodeGenerator>>#jump:if:

stephane ducasse stephane.ducasse at free.fr
Sun Jun 22 16:11:30 UTC 2008


Normally there is a mailing-list for the newcompiler but indeed we  
should have a bugtracker.

Stef

On Jun 22, 2008, at 12:54 PM, André Wendt wrote:

> Hi all,
>
> apologies if this doesn't belong here. Mantis is a usability-nightmare
> and I didn't know where else to report a bug in the NewCompiler. The
> corresponding ML on squeakfoundation.org hasn't been posted to in over
> six months.
>
> I've noticed that BytecodeGenerator>>#jump:if: has a bug when given a
> distance >= 1024.
>
> It states
>
> hi := distance // 256.
>
> and then goes on checking if hi < 8. If that's false, the jump is
> assumed to be too big. However, the check should be hi < 4.
>
> Assume the method gets an argument of 1024, and hi is 4. The following
>
> self nextPut: (Bytecodes at: #longJumpIfFalse) first + hi.
>
> generates bytecode 176, which is an arithmetic message send instead  
> of a
> conditional jump.
>
> I've attached a changeset that checks both jump conditions for hi < 4.
>
> Regards,
> André
> 'From Squeak3.10.1 of ''26 May 2008'' [latest update: #7175] on 22  
> June 2008 at 12:36:17 pm'!
>
> !BytecodeGenerator methodsFor: 'private' stamp: 'awe 6/22/2008 12:35'!
> jump: distance if: condition
>
> 	| hi |
> 	distance = 0 ifTrue: [
> 		"jumps to fall through, no-op"
> 		^ self nextPut: (Bytecodes at: #popStackBytecode)].
> 	condition ifTrue: [
> 		hi := distance // 256.
> 		hi < 4 ifFalse: [self error: 'true jump too big'].
> 		self nextPut: (Bytecodes at: #longJumpIfTrue) first + hi.
> 		self nextPut: distance \\ 256.
> 	] ifFalse: [
> 		distance <= 8 ifTrue: [
> 			self nextPut: (Bytecodes at: #shortConditionalJump) first +  
> distance - 1.
> 		] ifFalse: [
> 			hi := distance // 256.
> 			hi < 4 ifFalse: [self error: 'false jump too big'].
> 			self nextPut: (Bytecodes at: #longJumpIfFalse) first + hi.
> 			self nextPut: distance \\ 256.
> 		].
> 	]	
> ! !
>
>




More information about the Squeak-dev mailing list