code logs -> 2018 -> Thu, 05 Jul 2018< code.20180704.log - code.20180706.log >
--- Log opened Thu Jul 05 00:00:35 2018
00:34 Emmy [Emmy@Nightstar-9p7hb1.direct-adsl.nl] has quit [Ping timeout: 121 seconds]
00:46 celticminstrel [celticminst@Nightstar-p7v287.dsl.bell.ca] has joined #code
00:46 mode/#code [+o celticminstrel] by ChanServ
00:49 Kindamoody is now known as Kindamoody[zZz]
00:57 himi [sjjf@Nightstar-1drtbs.anu.edu.au] has joined #code
00:57 mode/#code [+o himi] by ChanServ
03:04 himi [sjjf@Nightstar-1drtbs.anu.edu.au] has quit [Ping timeout: 121 seconds]
03:22 Degi [Degi@Nightstar-mm11sf.dyn.telefonica.de] has quit [Connection closed]
04:49 celticminstrel [celticminst@Nightstar-p7v287.dsl.bell.ca] has quit [[NS] Quit: And lo! The computer falls into a deep sleep, to awake again some other day!]
06:03 Vornicus [Vorn@Nightstar-sjaki9.res.rr.com] has joined #code
06:03 mode/#code [+qo Vornicus Vornicus] by ChanServ
06:10 Kindamoody[zZz] is now known as Kindamoody|afk
06:36 Derakon is now known as Derakon[AFK]
06:37 VirusJTG [VirusJTG@Nightstar-42s.jso.104.208.IP] has quit [Connection closed]
06:38 VirusJTG [VirusJTG@Nightstar-42s.jso.104.208.IP] has joined #code
06:38 mode/#code [+ao VirusJTG VirusJTG] by ChanServ
06:53 VirusJTG [VirusJTG@Nightstar-42s.jso.104.208.IP] has quit [Connection closed]
06:53 VirusJTG [VirusJTG@Nightstar-42s.jso.104.208.IP] has joined #code
06:53 mode/#code [+ao VirusJTG VirusJTG] by ChanServ
07:12 Vorntastic_ [uid293981@Nightstar-6br85t.irccloud.com] has joined #code
07:12 Vornicus [Vorn@Nightstar-sjaki9.res.rr.com] has quit [Ping timeout: 121 seconds]
07:18 Vornicus [Vorn@Nightstar-sjaki9.res.rr.com] has joined #code
07:18 mode/#code [+qo Vornicus Vornicus] by ChanServ
07:38 Vornicus [Vorn@Nightstar-sjaki9.res.rr.com] has quit [Ping timeout: 121 seconds]
08:40
< simon_>
gaaah
08:41
< simon_>
https://git.simonshine.dk/sshine/hs-evm-opcodes/src/master/src/Network/Ethereum/Evm/LabelledOpcode.hs
08:41
< simon_>
I'm toying around with the Ethereum VM opcodes, and they have this annoying thing where jump instructions don't take an argument, but instead pop an item off a stack and jump there.
08:42
< simon_>
this means that if I want to build an abstraction of labelled jumps on top, then [JUMP "foo"] becomes [PUSH <position of "foo">, JUMP], and <position of "foo"> can be found by counting.
08:43
< simon_>
only there's another catch: the position (in bytes) of a JUMPDEST (there's an actual instruction, it's not a pseudo-instruction) depends on the number of bytes preceeding it, and the size (in bytes) of a PUSH depends on the constant.
08:46
< simon_>
I solve this by fixpoint iteration: assume all labelled JUMPs are 3 bytes (PUSH1 <byte>, JUMP) until I've seen that a label is actually at a bigger offset (so when a JUMP is at the 256th byte in program memory, that previous JUMP "foo" becomes a [PUSH2 <byte, byte>, JUMP]); keep iterating over the instructions until all JUMPDESTs align with the byte number I've counted to.
08:46
< simon_>
that part works.
08:48
< simon_>
(although I'd like to see if there's a better algorithm than fixpoint iteration; e.g. something about gathering the constraints and resolving them in a fixed amount of time; I'm not sure, but it looks like I can express this as solving linear equations, or at least recurrence equations.)
08:48
< simon_>
the really annoying part is this:
08:50
< simon_>
now that I'm done with my labelled jumps abstraction, I'd like to build another abstraction on top for allowing my code generator to use function calls. function calls are basically just labelled jumps where I push the PC on the stack, add a constant to it, jump to the label, and make a JUMPDEST for returning; the constant is the offset from the PC to the JUMPDEST.
08:53
< simon_>
using my instructions that'd be: [ PC, PUSH <n>, ADD, JUMP "myFun", JUMPDEST "myFun_ret_42" ] where <n> is size(PC) + size(PUSH <n>) + size(ADD) + size(JUMP "myFun"). so that the element on the stack is equivalent to the position of JUMPDEST "myFun_ret_42". but then <n> depends on <n> itself and the size of JUMP "myFun", which in turn depends on all preceeding instructions.
08:55
< simon_>
this was previously solved by hardcoding the PUSH to always be a PUSH4 (EVM has PUSH1-PUSH32, but my AST's PUSH is variable. introducing the variable size meant that for existing Ethereum contracts we generated, we'd save 33% in size on average because we could ditch a whole bunch of PUSH4s and PUSH32s in favor of PUSH1s, etc.)
08:59
< simon_>
so if I used a hardcoded PUSH4 (or even PUSH3), I can safely address the full memory of my program: [ PC, PUSH4 <n>, ADD, JUMP "myFun", JUMPDEST "myFun_ret_42" ] where <n> = size(PC) + size(PUSH4 <n>) + size(ADD) + size(JUMP "myFun") = 1 + 5 + 1 + ?. I'd still depend on the unknown size of a labelled jump.
08:59
< simon_>
sooooo....
09:01
< simon_>
thinking aloud here, it seems that if I introduce another abstraction of JUMPs where the offset is parameterised (unlike the real EVM code), I'd know the size, and translating my function-calling intermediate representation to *that* would be a lot easier than translating it to labelled jump code, since I basically can't put down the instruction that says "add <n> to PC, where <n> depends on the JUMP in a few
09:01
< simon_>
instructions' time..."
09:04
< simon_>
that's totally doable, and quite within reach of what I've currently got: an AbstractOpcode type with a type parameter that is the kind of jump, and the code for labelled jumps where I construct a 'Map Label Position': I'll turn that into an 'AbstractOpcode Label -> AbstractOpcode Position', translate all labelled jumps into this first, and then translate all functions into it as well.
09:05
< simon_>
I'm sure there is some benefit to having almost entirely stack-based instructions (there's only PUSH1-PUSH32 that takes arguments); presumably it's more space-efficient.
11:03 Degi [Degi@Nightstar-mm11sf.dyn.telefonica.de] has joined #code
--- Log closed Thu Jul 05 11:06:34 2018
--- Log opened Thu Jul 05 11:06:51 2018
11:06 TheWatcher [chris@GlobalOperator.Nightstar.Net] has joined #code
11:06 Irssi: #code: Total of 32 nicks [24 ops, 0 halfops, 0 voices, 8 normal]
11:06 mode/#code [+o TheWatcher] by ChanServ
11:06 Irssi: Join to #code was synced in 12 secs
11:14
< Vorntastic_>
Attack of the dot products too why are these turning out to be so elegant
13:22 Degi [Degi@Nightstar-mm11sf.dyn.telefonica.de] has quit [Ping timeout: 121 seconds]
13:23 celticminstrel [celticminst@Nightstar-p7v287.dsl.bell.ca] has joined #code
13:23 mode/#code [+o celticminstrel] by ChanServ
13:27 himi [sjjf@Nightstar-v37cpe.internode.on.net] has joined #code
13:27 mode/#code [+o himi] by ChanServ
13:58 celticminstrel [celticminst@Nightstar-p7v287.dsl.bell.ca] has quit [[NS] Quit: And lo! The computer falls into a deep sleep, to awake again some other day!]
14:34 Degi [Degi@Nightstar-mm11sf.dyn.telefonica.de] has joined #code
14:38 Degi [Degi@Nightstar-mm11sf.dyn.telefonica.de] has quit [Ping timeout: 121 seconds]
14:41 himi [sjjf@Nightstar-v37cpe.internode.on.net] has quit [Ping timeout: 121 seconds]
15:41 Degi [Degi@Nightstar-mm11sf.dyn.telefonica.de] has joined #code
15:56 Vornicus [Vorn@Nightstar-sjaki9.res.rr.com] has joined #code
15:56 mode/#code [+qo Vornicus Vornicus] by ChanServ
16:18 Degi [Degi@Nightstar-mm11sf.dyn.telefonica.de] has quit [Ping timeout: 121 seconds]
16:51 Emmy [Emmy@Nightstar-9p7hb1.direct-adsl.nl] has joined #code
16:54 Degi [Degi@Nightstar-mm11sf.dyn.telefonica.de] has joined #code
16:59 Degi [Degi@Nightstar-mm11sf.dyn.telefonica.de] has quit [Ping timeout: 121 seconds]
17:11 Degi [Degi@Nightstar-mm11sf.dyn.telefonica.de] has joined #code
17:15 Degi [Degi@Nightstar-mm11sf.dyn.telefonica.de] has quit [Ping timeout: 121 seconds]
17:32 Vorntastic_ [uid293981@Nightstar-6br85t.irccloud.com] has quit [[NS] Quit: Connection closed for inactivity]
19:30 Vornicus [Vorn@Nightstar-sjaki9.res.rr.com] has quit [Ping timeout: 121 seconds]
21:35 Degi [Degi@Nightstar-tqgn8a.dyn.telefonica.de] has joined #code
21:37 Vornicus [Vorn@Nightstar-sjaki9.res.rr.com] has joined #code
21:37 mode/#code [+qo Vornicus Vornicus] by ChanServ
21:39 Degi [Degi@Nightstar-tqgn8a.dyn.telefonica.de] has quit [Ping timeout: 121 seconds]
22:35 Degi [Degi@Nightstar-tqgn8a.dyn.telefonica.de] has joined #code
22:39 Degi [Degi@Nightstar-tqgn8a.dyn.telefonica.de] has quit [Ping timeout: 121 seconds]
22:48 Degi [Degi@Nightstar-tqgn8a.dyn.telefonica.de] has joined #code
22:50 himi [sjjf@Nightstar-v37cpe.internode.on.net] has joined #code
22:50 mode/#code [+o himi] by ChanServ
22:52 Degi [Degi@Nightstar-tqgn8a.dyn.telefonica.de] has quit [Ping timeout: 121 seconds]
23:02 Derakon[AFK] is now known as Derakon
23:07 Degi [Degi@Nightstar-tqgn8a.dyn.telefonica.de] has joined #code
23:11 Degi [Degi@Nightstar-tqgn8a.dyn.telefonica.de] has quit [Ping timeout: 121 seconds]
23:32 Emmy [Emmy@Nightstar-9p7hb1.direct-adsl.nl] has quit [Ping timeout: 121 seconds]
--- Log closed Fri Jul 06 00:00:46 2018
code logs -> 2018 -> Thu, 05 Jul 2018< code.20180704.log - code.20180706.log >

[ Latest log file ]