Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code generation is non-deterministic #37

Open
elipsitz opened this issue Feb 17, 2020 · 0 comments
Open

Code generation is non-deterministic #37

elipsitz opened this issue Feb 17, 2020 · 0 comments

Comments

@elipsitz
Copy link

The following code generates different instructions each time it's compiled:

if (argument0 < 10) {
    a = 4
    show_debug_message("hello world: ", argument0, 5);
    script(argument0 + 1);
}

Probably due to randomization in Rust HashMaps?

For example, one gives:

(%0, )[7]
  %1 = Imm 0.0
  %2 = Imm 1.0
  Read argument0, %2
  %4 = ToScalar %0
  %3 = Imm 10.0
  %3 = Lt %4, %3
  BranchFalse %3, 28
  %4 = Lookup a
  %5 = Imm 4.0
  %3 = LoadFieldDefault %4.a
  %3 = Write %5, %3
  StoreField %3, %4.a
  %5 = Imm hello world: 
  Read argument0, %2
  %4 = ToScalar %0
  %3 = Imm 5.0
  %6 = %5
  %5 = %3
  %3 = %6
  %3 = CallApi show_debug_message(%3 +3)
  Read argument0, %2
  %3 = ToScalar %0
  %2 = Imm 1.0
  %2 = Add %3, %2
  %2 = Call script(%2 +1)
  Release %0
  %0 = %1
  Ret
  Jump 25

and another time gives:

     

(%0, )[7]
  %1 = Imm 0.0
  %2 = Imm 1.0
  Read argument0, %2
  %4 = ToScalar %0
  %3 = Imm 10.0
  %3 = Lt %4, %3
  BranchFalse %3, 29
  %4 = Lookup a
  %5 = Imm 4.0
  %3 = LoadFieldDefault %4.a
  %3 = Write %5, %3
  StoreField %3, %4.a
  %4 = Imm hello world: 
  Read argument0, %2
  %5 = ToScalar %0
  %3 = Imm 5.0
  %6 = %4
  %4 = %5
  %5 = %3
  %3 = %6
  %3 = CallApi show_debug_message(%3 +3)
  Read argument0, %2
  %3 = ToScalar %0
  %2 = Imm 1.0
  %2 = Add %3, %2
  %2 = Call script(%2 +1)
  Release %0
  %0 = %1
  Ret
  Jump 26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant