opcodes for switch statements

Roland Zwaga roland at stackandheap.com
Sat Mar 12 08:41:46 PST 2011


Hi there again,

well, things are working better right now, but I did run into a second
piece of weirdness.
When I'm deserializing a swf that was compiled in debug mode,
everything resolves properly. The jump opcode I'm encountering indeed
correctly resolves to the end location of the switch statement.
Yet, when I deserialize a release build version of the swf, the
location somehow is wrong. For instance, in my test swf the jump
opcode points to position 88, when the length of the method body is
actually only 81.
Frankly I'm a bit stumped, apparently there is a another subtle
difference between debug and release builds that I'm unaware of...
Does anyone know if there is proper documentation to be found on this
subject? So far I have had to find out the differences through trial
and error...

thank you very much for your time, I appreciate it!

cheers,

Roland

On 12/03/2011, Roland Zwaga <roland at stackandheap.com> wrote:
> Hey Jan,
>
> that makes perfect sense actually, I'm going to try this out immediately.
> Thank you very much for your reply!
>
> cheers,
>
> Roland
>
>> On 12/03/2011, Jan Flanders <adnez7 at gmail.com> wrote:
>>> L4 points at the byte position right after the bytes that hold:
>>> lookupswitch default:L3 maxcase:2 L1 L2 L3
>>>
>>> Here's another dump of the same function (+some debugging statements)
>>> (L4 is jump2)
>>>
>>> 			<function name="testSwitch" args="int" return="String"
>>> debugName="Main/testSwitch" slot="0" > <!-- maxStack="2" nRegs="3"
>>> initScope="10" maxScope="11" length="99 bytes"-->
>>> <!--0-->				<ODebugFile v="C:/Documents and
>>> Settings/Administrator/Desktop/abc2xml/CS5/Main.as" />
>>> <!--2-->				<ODebugLine v="12" />
>>> <!--  12)		public function testSwitch(idx:int):String-->
>>> <!--4-->				<OThis />
>>> <!--5-->				<OScope />
>>> <!--6-->				<ODebugReg name="idx" r="0" line="12"/>
>>> <!--11-->				<JAlways jump="jump1" offset="22" /><!--37-->
>>> <!--15-->		<OLabel name="label1"/>
>>> <!--16-->				<OString v="1" />
>>> <!--18-->				<ODebugLine v="17" />
>>> <!--  17)					return "1";-->
>>> <!--20-->				<ORet />
>>> <!--21-->		<OLabel name="label2"/>
>>> <!--22-->				<OString v="2" />
>>> <!--24-->				<ODebugLine v="20" />
>>> <!--  20)					return "2";-->
>>> <!--26-->				<ORet />
>>> <!--27-->		<OLabel name="label3"/>
>>> <!--28-->				<OString v="0" />
>>> <!--30-->				<ODebugLine v="23" />
>>> <!--  23)					return "0";-->
>>> <!--32-->				<ORet />
>>> <!--33-->				<JAlways jump="jump2" offset="63" /><!--100-->
>>> 				<OJump name="jump1"/>
>>> <!--37-->				<ODebugLine v="14" />
>>> <!--  14)			switch (idx)-->
>>> <!--39-->				<OReg v="1" />
>>> <!--40-->				<OSetReg v="2" />
>>> <!--41-->				<ODebugLine v="16" />
>>> <!--  16)				case 1 :-->
>>> <!--43-->				<OSmallInt v="1" />
>>> <!--45-->				<OReg v="2" />
>>> <!--46-->				<JPhysNeq jump="jump3" offset="6" /><!--56-->
>>> <!--50-->				<OSmallInt v="0" />
>>> <!--52-->				<JAlways jump="jump4" offset="27" /><!--83-->
>>> 				<OJump name="jump3"/>
>>> <!--56-->				<ODebugLine v="19" />
>>> <!--  19)				case 2 :-->
>>> <!--58-->				<OSmallInt v="2" />
>>> <!--60-->				<OReg v="2" />
>>> <!--61-->				<JPhysNeq jump="jump5" offset="6" /><!--71-->
>>> <!--65-->				<OSmallInt v="1" />
>>> <!--67-->				<JAlways jump="jump6" offset="12" /><!--83-->
>>> 				<OJump name="jump5"/>
>>> <!--71-->				<JAlways jump="jump7" offset="6" /><!--81-->
>>> <!--75-->				<OSmallInt v="2" />
>>> <!--77-->				<JAlways jump="jump8" offset="2" /><!--83-->
>>> 				<OJump name="jump7"/>
>>> <!--81-->				<OSmallInt v="2" />
>>> 				<OJump name="jump4"/>
>>> 				<OJump name="jump6"/>
>>> 				<OJump name="jump8"/>
>>> <!--83-->				<ORegKill v="2" />
>>> <!--85-->				<!--OSwitch2 default="-58" deltas="[-70, -64, -58]"
>>> />--><!-- [-70->15],  [-64->21],  [-58->27], -->
>>> <!--85-->				<OSwitch2 default="label3" deltas="[label1, label2,
>>> label3]"
>>> />
>>> </function>
>>>
>>>
>>> Jan
>>>
>>
>>
>> --
>> regards,
>> Roland
>>
>> --
>> Roland Zwaga
>> Senior Consultant | Stack & Heap BVBA
>>
>> +32 (0)486 16 12 62 | roland at stackandheap.com |
>> http://www.stackandheap.com
>>
>
>
> --
> regards,
> Roland
>
> --
> Roland Zwaga
> Senior Consultant | Stack & Heap BVBA
>
> +32 (0)486 16 12 62 | roland at stackandheap.com | http://www.stackandheap.com
>


-- 
regards,
Roland

-- 
Roland Zwaga
Senior Consultant | Stack & Heap BVBA

+32 (0)486 16 12 62 | roland at stackandheap.com | http://www.stackandheap.com


More information about the Tamarin-devel mailing list