IRC Logs for #io Saturday, 2019-02-09

prologicthat 0026 Pop comes from the compiler00:01
prologicit emits a Pop after compiling any ExpressionStatement00:01
prologicthe only 3 exceptions to this are assignments, return and identifiers00:03
prologicso basically all expressions end with a Pop00:03
prologicbut I think this is wrong00:03
prologicIs it possible to know ahead of time -- at compile time -- what the effect of each opcode is on the stack? Then keep track of what the stack pointer would be at compile time and only emit a Pop at the end of Expressions iif the stack pointer at compiler time is > 0 ?00:32
jersure it is, just embed it in the AST01:01
jerthat information which makes sense to solve the problem that is01:01
jeror build up an IR that contains this info01:01
prologicseems building this info up in the opcode themselves and computing what the sp should be in the compiler isn't enough01:04
prologicsince the compiler can't evalulate branches01:04
jerif you do it as part of whole program compilation, it should be possible01:04
jeryou don't really have to01:04
jeryou should already have enough information on the effects of each opcode01:04
jersince opcodes perform static operations, perhaps yes result in dynamic outcomes, but that relates to data and not control01:05
jeryou're only concerned with control01:05
prologicI'm still missing something vital though01:06
prologicas that last Pop on IP 0026 is stil wrong01:06
jerwell you have to encode the behaviours somehow01:06
prologicand I'm not sure how to get rid of it01:06
jeri can't give you that answer01:06
jeri'm afraid01:06
prologicbecause you don't know or want me to figure it out? :)01:07
prologicSo here's the hacky way to solve this01:44
prologicAt least I think it's a hack :)01:44
prologiccase code.Pop:01:44
prologic  if vm.sp > 0 {01:44
prologic    vm.pop()01:44
prologic  }01:44
prologicBasically protecting us from a stack underflow and extraneous Pop instructions01:45
jerno that's a reasonable thing to do02:04
prologicjer it is?02:20
prologicbut but it feels so weird02:20
prologicas-in I still think the compiler is wrong in places?02:20
prologicor maybe this is the simplest way to solve this without over complicating the compiler?02:21
prologicadding support for optimised tail recusion wasn't hard03:17
prologicjer I finally fixed it proper09:12
prologicwithout the if (vm.sp > 0) { vm.pop() }09:12
prologicAs we suspected all along there were a few inconsistencites with the semantics of the compiler producing values09:13
prologicin a couple of cases it would produce no value at all09:13
prologicit does of course now mean that I end up with LoadNull; Pop; instructions all over the place09:14
prologicbut I'm sure a 2nd stage compiler can optimize those out09:14
jerprologic, oh good to hear16:30

Generated by 2.14.0 by Marius Gedminas - find it at!