hydra1983 / as3-commons

Automatically exported from code.google.com/p/as3-commons
0 stars 0 forks source link

[bytecode] No stack modifiers for Alchemy instructions #92

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

    Example code:

    .addOpcode(Opcode.getlocal_1)
    .addOpcode(Opcode.getlocal_2)
    .addOpcode(Opcode.pushint, [2])
    .addOpcode(Opcode.lshift)
    .addOpcode(Opcode.si32)

What is the expected output? What do you see instead?

    Output:
    [Fault] exception, information=VerifyError: Error #1030: Stack depth is unbalanced. 2 != 0.

    Expected:
    The bytecode should validate without an error.

What version of the product are you using? On what operating system?

    * Bytecode 1.0
    * Lang 0.3.4
    * Logging 2.6
    * Reflect 1.4.2
    * Windows 7 SP1 x64

Please provide any additional information below.

    It looks like adding "stackModifiers[Opcode.si32] = -2" etc... to MethodBodyBuilder (tried with SVN trunk) fixes the issue.

Original issue reported on code.google.com by zach.griswold@gmail.com on 23 Sep 2011 at 7:34

GoogleCodeExporter commented 9 years ago
Hey there,

I guess you're wright, I ported all of the stack modification logic from the 
tamarin sources and in there the alchemy opcodes aren't used. So obviously I 
forgot about the alchemy ones, sorry again... I quite hastily added support for 
the alchemy opcodes and obviously I didn't do a very good job...

I'm not sure how the stack is modified for the alchemy opcodes, but I'm 
guessing a save modifies it by -1 and a load by 1 (like getlocal is 1 and 
setlocal is -1). So I've added these modifiers:

stackModifiers[Opcode.si8] = -1;
stackModifiers[Opcode.si16] = -1;
stackModifiers[Opcode.si32] = -1;
stackModifiers[Opcode.sf32] = -1;
stackModifiers[Opcode.sf64] = -1;

stackModifiers[Opcode.li8] = 1;
stackModifiers[Opcode.li16] = 1;
stackModifiers[Opcode.li32] = 1;
stackModifiers[Opcode.lf32] = 1;
stackModifiers[Opcode.lf64] = 1;

If you could give this a testdrive, I'd really appreciate it!

Thanks for submitting this bug!

cheers,

Roland

Original comment by ihatelivelyids on 23 Sep 2011 at 8:03

GoogleCodeExporter commented 9 years ago
Save modifies by -2:  ...,value, offset => ...,
Load modifies by 0: ..., offset => ..., result

Original comment by zach.griswold@gmail.com on 23 Sep 2011 at 11:11

GoogleCodeExporter commented 9 years ago
damn, didn't read your original comment thoroughly enough, you already gave me 
the correct modifiers... Changes are available in the trunk, thank you very 
much!

cheers,

Roland

Original comment by ihatelivelyids on 23 Sep 2011 at 11:46