timotimo jnthn: when you come back, tell me if i should be building an op that takes a "which boolification spec should i be using?" parameter that can be populated at specialize time when the type is known, or if i should be emitting particular bytecodes to actually do the boolification if it's simple enough for me to do "by hand" 00:33
nice. i managed to get if 1 { say "eeeeeh" } else { say "nah" } executed in a loop to specialize to only the true branch 00:55
TimToady
.oO(dead code specialization)
01:04
01:47 ilbot3 joined
timotimo my if changes seem to break two spec test files 01:56
t/spec/S26-documentation/07-tables.t and t/spec/S26-documentation/09-configuration.t
(or all of the specialization rather than just my changes; i only diff'd between my stuff and MVM_SPESH_DISABLE=yes)
gist.github.com/timo/bdc334ebfc28cea9f406 - i wonder if this needs an additional check for dc.o == NULL there? 01:58
dalek arVM/spesh: 0bf73b6 | (Timo Paulssen)++ | src/spesh/optimize.c:
opt if_o/unless_o if value known and BS simple

really every BoolificationSpec except CALL_METHOD can be done at specialization time.
01:59
timotimo i'm willing to assume that it's not caused by the if_o/unless_o opt i just came up with and go to sleep
08:36 FROGGS[mobile] joined
jnthn timotimo: It should turn the generic boolification thing into bytecode to do the right thing. 09:32
timotimo: The S26 failures appear not to be a regression caused by you. 10:41
dalek arVM/spesh: 3c08332 | jnthn++ | src/core/frame.c:
Add missing null check in spesh guard handling.
11:05
jnthn That fixes the SEGV in S26.
timotimo wow, so i even had the right idea how to fix it :) 11:13
just for good measure, if_n and unless_n should be very easy, right? 0 and NaN would count as false and everything else as true? 11:27
jnthn r: if NaN { say 1 } 11:28
camelia rakudo-parrot c2cc4f, rakudo-jvm c2cc4f, rakudo-moar c2cc4f: OUTPUTĀ«1ā¤Ā»
timotimo oh
jnthn Just zero is false
timotimo so only 0e0
that seems easy
nqp: if "" { say 1 }; if " " { say 2; }; if "\0" { say 3; } 11:29
er.
camelia nqp-jvm: OUTPUTĀ«Unable to parse expression in blockoid; couldn't find final '}' at line 2, near "say 1 }; i"ā¤ in panic (gen/jvm/stage2/NQPHLL.nqp:396)ā¤ in FAILGOAL (gen/jvm/stage2/NQPHLL.nqp:403)ā¤ in blockoid (gen/jvm/stage2/NQP.nqp:989)ā¤ in pblock (gen/jvm/stage2/NQP.nā€¦Ā»
..nqp-moarvm: OUTPUTĀ«Unable to parse expression in blockoid; couldn't find final '}' at line 2, near "say 1 }; i"ā¤ at gen/moar/stage2/NQPHLL.nqp:369 (/home/p6eval/rakudo-inst-2/languages/nqp/lib/NQPHLL.moarvm:panic:105)ā¤ from gen/moar/stage2/NQPHLL.nqp:376 (/home/p6eval/rakudā€¦Ā»
..nqp-parrot: OUTPUTĀ«Unable to parse expression in blockoid; couldn't find final '}' at line 2, near "say 1 }; i"ā¤current instr.: 'panic' pc 15634 (gen/parrot/stage2/NQPHLL.pir:5766) (gen/parrot/stage2/NQPHLL.nqp:425)ā¤Ā»
timotimo nqp: if "" { say(1) }; if " " { say(2) }; if "\0" { say(3) }
camelia nqp-moarvm, nqp-jvm, nqp-parrot: OUTPUTĀ«2ā¤3ā¤Ā»
timotimo so only the empty string would be false for if_s and unless_s? 11:30
jnthn Yeah, but there's an if_s0 or so also I think 11:36
r: if "0" { say 1 } 11:37
camelia ( no output )
jnthn And certainly a bool spec case for that.
timotimo there is a bool spec case for that, aye 11:39
jnthn By now you're probably noticing the 6model design pattern here: if you know a type, you can remove virtualities normally resolved through the STable. :) 11:40
timotimo aye :) 11:41
pretty nifty in general
jnthn Yeah. Was part of the initial design, but took until now to be building things to take advantage.
timotimo do i have to differentiate whether the register is a num32 or a num64 for if_n? 11:42
if so, where do i look to figure that out? 11:44
jnthn if_n always expects a 64 11:45
timotimo good
jnthn See srce/core/oplist for the answers on such things, btw
timotimo ah, that seems easy :)
timotimo teaches the fact database about nums 11:46
jnthn time to get the train to Stockholm... & 11:58
timotimo i like trains
CHHHHHOOOOOOOOOooooooooooo~~~~
dalek arVM/spesh: 87e396f | (Timo Paulssen)++ | src/spesh/facts. (2 files):
teach facts about literal n32 and n64
12:03
arVM/spesh: f7fe878 | (Timo Paulssen)++ | src/spesh/optimize.c:
can now handle if_n and unless_n
arVM/spesh: a06c456 | (Timo Paulssen)++ | src/spesh/optimize.c:
forgot an important boolification spec mode to support
12:06
timotimo so for optimizing ifnonnull, i wonder which facts imply that the .o will be != 0 12:10
apart from KNOWN_VALUE, in which case i can check
i guess if we know it's concrete, it wouldn't be 0? 12:11
and if we know it's supposed to be a type object, it also wouldn't be 0?
well, not 0, but null really
ifnonnull seems to be emitted quite frequently; though the implementation is extremely cheap 12:14
but not as cheap as a straight goto :)
(and there's a sync_point there, which may have interesting implications on performance i guess?) 12:15
cool. rakudo still builds with my ifnonnull implementation (and why wouldn't it) 12:19
dalek arVM/spesh: 14846a6 | (Timo Paulssen)++ | src/spesh/optimize.c:
handle ifnonnull at specialize time, too
12:24
jnthn timotimo: Uh...doe we ever hit that in reality? 12:28
dalek arVM/cgoto: 7ccd7f1 | (Gerhard R)++ | src/core/interp.c:
Implement runloop using computed gotos
12:29
timotimo actually not
JimmyZ ah..
jnthn I don't think we ever will, tbh.
timotimo as i see now we almost exclusively have ifnonnull after atpos_o
jnthn right
timotimo kicks it again
dalek arVM/spesh: 9f576ed | (Timo Paulssen)++ | src/spesh/optimize.c:
actually, we'll hardly ever hit ifnonnull with a known value
12:30
arVM/spesh: 5b9273f | jimmy++ | src/spesh/optimize.c:
Remove a malloc
12:32
timotimo i was *just* about to do that :D
JimmyZ++
tadzik it was missing a free() too, wasn't it? :) 12:33
timotimo yes
tadzik or is it still in the code?
ok
timotimo i just added the free and then thought "wait a minute, i don't need to malloc here!"
tadzik :)
OH WHAT A BEER <3
timotimo how was your bus ride? 12:34
you got home safely?
tadzik yes, even managed to get some sleeps
timotimo sounds good :)
jnthn ooh, a beer :)
tadzik it's delicious
timotimo what cool stuff are you up to now that you have a computer again, rather than just a phone? :3
tadzik an Imperial IPA called "The Empire Strikes"
jnthn tadzik: What is it? Something interesting? :)
Oh! :D 12:35
tadzik 7.8% too
it's marvelous
jnthn Sounds it.
I like imperial ipas )
timotimo who put marbles in your beer?!
oh, wait
tadzik I'm considering going back to the shop and buying the amount I can drink before the expiration date
tadzik reads the spesh branch 12:36
jnthn If we want spesh in the next MoarVM release, we probably should think about merging it sometime in the next week. 12:37
timotimo a fine piece of work so far, no doubt
jnthn I'm going to work on REPR spesh.
timotimo do we know why the parallelism tests fail on spesh?
jnthn No
It was meant to be thread safe :)
As in, candidate.c and interp.c both have stuff aimed at that 12:38
tadzik how does it fail? 12:40
12:41 zakharyas joined
timotimo doesn't, apparently o_O 12:42
jnthn heh :) That just menas it's non-deterministic.
timotimo oh!
i know what's up
it just exited with nonzero because moar ABORTs when it shuts down
and i read that as "the tests crashed"
which is both true and not the thing i meant 12:43
jnthn yeah, I need to fix htat.
*that
tadzik is surprised that the code is not full of "int ern" puns
timotimo at least it doesn't keep spesh from being merged
"check if the string has been internet"?
tadzik int ernship 12:44
timotimo okay, now for the code to turn general boolification spec into concrete bytecode if possible 12:48
tadzik what does DC in MVM_SPESH_GUARD_DC_CONC mean? 12:49
timotimo jnthn: what do i have to watch out for if i need to "allocate" new registers in bytecode i'd like to emit?
jnthn tadzik: "decont" 12:50
timotimo: uh, you can't do that
timotimo that'd be a problem then :)
tadzik ah :)
timotimo how do i turn an if_o into a unbox_i + if_i if i can't has a new register? 12:51
jnthn tadzik: It's allowing us to specialize based on what's inside a scalar
Which is a really common case in Perl 6.
tadzik but the actual value is not specialized for, right?
like, "this int is always 1"
jnthn Not in general
tadzik ok, I'll keep reading
jnthn Though in cases like sub foo($x = 1) { ... }; foo()
We could know $x is 1 12:52
timotimo and we already do, afaict
though ... maybe not?
tadzik hm
which case in github.com/MoarVM/MoarVM/compare/s...950b64R265 does that come in?
timotimo i know we throw out the code that would get the value from the arguments if the callsite says "no optional parameters passed" 12:53
the cfg/ssa should then notice the register is only set in one place, unconditionally, and that the value is known
jnthn tadzik: args.c has the interesting stuff with regard to optinals. 12:55
*optionals
timotimo maybe we need to run the whole thing twice for the information to propagate properly and be used? 12:56
jnthn Well, then you end up doing it n times... 12:57
The issues is more that we need to be much more smart about PHIs.
timotimo i don't even know yet what exactly the parameters to the PHI do; i suppose it merges multiple versions of a register where only one would be valid into a single register? 12:58
like "depending on where we just jumped in from, the register's value would come from version 5 or version 7"
jnthn Right. 13:00
They're information merge points
timotimo and phi removal happens because either the block we jumped in from got kicked or because the register that things got merged into are not used in the given block any more?
tadzik "if (pos_ins[idx]) /* Dupe; weird. */" :D 13:01
jnthn timotimo: right 13:05
timotimo so, does phi removal already have an effect on the facts database? and if so, do we read from these new facts after they've been updated at all? 13:06
jnthn Yes, at the moemnt it influences usage counts. 13:07
timotimo so a phi, even if it gets removed, will still keep "known value" information from being used 13:09
i agree, there needs to be more smarts
not that i'd have many smarts to contribute :P
jnthn yeah, it's a bit subtle, I think
timotimo so, a hint for the register "situation"? is the "specialize slot" thing something i could (ab)use for that purpose? 13:10
it seems like only ops that know about specialization slots can take advantage of them 13:11
jnthn No 'cus those are static 13:12
There is no hint really. I didn't decide how we're going to handle this yet, which means there's no design for it. 13:13
We'll need it for inlines also.
timotimo OK, i'll wait for design to exist before i do the boolification "[owering"
lowering*
dalek arVM/spesh: 4bd7863 | jimmy++ | src/spesh/manipulate.c:
slightly refactor codes, no function changes
13:14
arVM/spesh: 30cedbe | jonathan++ | src/6model/ (38 files):
Allow REPRs to participate in spesh.
13:18
arVM/spesh: e4b16bf | jonathan++ | src/spesh/optimize.c:
Forward various ops to REPR for spesh if possible.

No REPRs currently know what to do, however.
JimmyZ objdump shows this slightly refactor reduces 100 lines asm codes to 73 lines. 13:23
tadzik nice :) 13:24
timotimo oh wow 13:25
we're hopefully doing this very often :)
hm. i wonder what kinds of bytecodes the reprs can actually come up with 13:26
JimmyZ yeah, I want to do it in the deserialize codes to help startup time.
timotimo would we be creating special bytecodes that are custom-tailored to whatever repr we're optimizing? 13:27
JimmyZ: i didn't even really see what you changed %)
jnthn aww...after a week and a bit of beautiful weather here, seems the rain is here... 13:29
JimmyZ timotimo: I didn't change things, just sometimes the gcc is not smart enough to optimize codes.. 13:32
jnthn JimmyZ: Did you profile to see where we spend time at startup?
Wow, some folks are making a 10 minute job of working out what seats they're meant to be sat in... 13:33
JimmyZ jnthn: I didn't... I can't build nqp on my win32 x86 system..
jnthn Still? Odd...
JimmyZ yeah. 13:34
But I see there is a lot indirect access code in loops in deserialize functions, so I think slightly refactors may help some rakudo startup time.. maybe I'm wrong.. 13:37
jnthn Well, optimizing without profiling is a good way to be wrong. 13:38
JimmyZ yeah, I don't have a X64 box..
14:22 zakharyas joined 15:00 cognominal__ joined
dalek arVM/spesh: eb5bb8d | jonathan++ | / (5 files):
Stub in spesh ops aimed at REPR spesh.

These generally boil down to pointer operations that we determine will be safe during specialization. Note that they should also JIT rather nicely, once we get there.
15:27
arVM/spesh: 24c4a68 | jonathan++ | src/spesh/optimize. (2 files):
Expose some spesh functions outside of optimize.c.

We'll want to use them in REPR spesh also.
15:32 btyler joined
timotimo i'm wondering which reprs and ops get the spesh treatment first :3 15:50
jnthn Well, p6opaque is one key candidate 15:51
timotimo also lists are quite frequently used during compilation
jnthn Yeah; I just did VMArray create specialization.
timotimo cool :)
jnthn But when it goes to delete the HLL type resolution instruction it runs into something.
timotimo i'll be interested to know how exactly that looks 15:52
hmm.
jnthn Namely, that delete_ins didn't learn about annotated instructions just yet.
timotimo ah, yes
jnthn There's a usage bug in facts.c too; I went to fix it yesterday and ran into the same issue 15:53
So, should fix that I guess :)
timotimo usage of delete_ins or what? 15:54
apparently not
dalek arVM: ff074f7 | jimmy++ | src/strings/ (2 files):
Small fixes to MVM_string_(latin1|windows1252)_encode_substr
timotimo JimmyZ: "lengthu"? 15:55
like, length_unicode?
JimmyZ yeah, same as acsii one
timotimo OK
jnthn + if (length < -1 || start + lengthu > strgraphs)
timotimo i just didn't see a definition of lengthu so i assumed it was a typo
jnthn Not at all convinced that is right...
timotimo but i see it's right there
jnthn Cute; after specialization, an NQP sub foo() { nqp::list() }; now becomes: 16:02
sp_fastcreate r0(2), liti16(56), liti16(0)
return_o r0(2)
timotimo cute 16:03
how does the reference in the middle work?
56?
jnthn 56 is number of bytes
0 is the spesh slot holding the stable to shove in ->st
timotimo ah, okay
i was wondering where thet would be found :)
so all it does is allocate 56 bytes and set an stable and that's it? 16:04
jnthn Well, has to set a owner too
timotimo fair enough
that does seem pretty fast :)
jnthn But there's no virtual call through the ->allocate pointer, and no looking to see if there's an ->initialize 16:05
timotimo yeah, that's good
JimmyZ Just curious, does jvm/cli/mono have sp_opcode-ish things? 16:08
timotimo i think they go directly to machine code, no?
jnthn Yeah, most likely directly to machine code 16:09
I'd *hope* that I didn't event JIT-to-bytecode-with-offsets. It's too obvious to be new. I'm not sure what else is doing it though. :) 16:10
*invent
dalek arVM/spesh: da8f7cc | jonathan++ | src/core/interp.c:
Implement sp_fastcreate.
16:11
arVM/spesh: d16dd4d | jonathan++ | src/spesh/manipulate.c:
Try not losing annotations in delete_ins.
arVM/spesh: 722c970 | jonathan++ | src/6model/reprs/MVMArray.c:
Specialize array creation.
timotimo um, did sp_fastcreate end up in the oplist at all? 16:13
ah
i seem to have missed some commit announcements 16:14
JimmyZ JIT-to-bytecode-with-offsets? deopt? 16:17
16:17 vendethiel joined
timotimo you can bet these VMs come with pretty advanced deopt strategies 16:18
hey ven
vendethiel hey timo 16:20
dalek arVM/spesh: 2d64624 | jonathan++ | src/6model/reprs/P6opaque.c:
Specialize P6opaque create when easily possible.
16:29
jnthn About time to detrain...
timotimo anything simple you think you could offload onto me? 16:32
well, rakudo still builds so that's definitely nice :) 16:39
timotimo is splitting a spesh log from the core setting compilation 16:51
aaaaand i forgot to | less -r
oh my.
it's now at 1.2 gigabytes of resident memory %) 16:53
maybe i should - if there's no matcher definet - directly output the lines to the files they belong to and throw away the strings directly 16:54
that ought to save a lot.
now i'm beginning to notice pauses in the output, that could very well be the GC 16:55
i wonder ... since it's so many strings, maybe in this case the separate thread for doing free on things actually would help? 16:57
i should have run it with the profiler :\ 16:58
jnthn timotimo: Well, MVMHash could have a create thingy similar to MVMArray 17:15
timotimo i can try :) 17:16
now i'll have a look at actually doing MVMHash 17:28
it seems like i just literally copypasted it and replaced the sizeof of MVMArray with the sizeof of MVMHash 17:31
jnthn yeah, that's probably all it needs 17:32
timotimo yeah, and rakudo still builds 17:33
anything i should try in order to test if it was okay?
or should i just push?
jnthn If Rakudo builds and passes sanity test, should be OK 17:34
timotimo passed, will commit & push 17:35
dalek arVM/spesh: 42902dc | (Timo Paulssen)++ | src/6model/reprs/MVMHash.c:
spesh for fastcreate of MVMArray.
jnthn nice :) 17:43
timotimo that was easy enough for me to do :) 17:44
jnthn: how does a summary of ops -'d and +'d for the differ sound? 17:51
"hllize | 55 ----------" or something like that
jnthn timotimo: Could be interesting to see 17:52
timotimo i'll make the differ output the files immediately and directly forget the big strings before i run it again
half an hour for the core setting analysis is ... wow :)
43 megabyte log file exploded to at least 3 gigabytes of ram usage
now since we use 32bit numbers per character interally anyway, it'd be 172 megabytes for a single copy of the string 17:53
jnthn time for some dinner & 18:06
dalek arVM/spesh: 646affd | jonathan++ | src/ (3 files):
Add p6o attribute bind specialization ops.
arVM/spesh: c2eae34 | jonathan++ | src/6model/reprs/P6opaque.c:
Optimize bindattr_o on P6opaque when possible.
timotimo hmm. letting it write out the strings immediately and forgetting about them led to it taking "only" 27 minutes rather than 31 18:45
2536600maxresident - i still feel that's a bit too much
18:47 vendethiel joined
jnthn om nom 19:32
'twas spicy
timotimo :3 19:34
moarvm is still too slow :( 19:50
jnthn Well, yeah.
We'd not be working on optimization stuff if it was perfectly fine already, would we... :P 19:51
dalek arVM/spesh: a60a15a | jonathan++ | src/6model/reprs/P6opaque.c:
P6opaque spesh for bindattr_[ins].
20:05
nwc10 if I can rustle up some parallel universes, will it run in constant time? :-) 20:19
timotimo :) 20:26
20:29 vendethiel joined 20:39 lizmat_ joined, cognominal joined, btyler_ joined
timotimo i don't think i have the patience to implement the op diff summary tool in perl 6 :P 20:40
20:43 masak_ joined
cognominal timotimo, you mean patience to implement, or to run because it would be too slow? 20:44
timotimo to run :) 20:50
cognominal so far, we are walking Perl 6 20:52
timotimo aye 21:01
cognominal what is the mnemonic device behind `1 ? ... in github.com/MoarVM/MoarVM/blame/mas...ps.p6#L207 21:09
timotimo it works like a type capture 21:13
if you have an opcode that takes r(`1) w(`1) you have to have the same register type for both, but it can be any 21:14
cognominal makes sense to me. 21:15
21:21 colomon joined
jnthn cognominal: Inspired by C# and ML's representation of generic args, I think :) 21:23
Pretty sure ML did it that way too, anyways
cognominal What is the prefix && in C? used in github.com/MoarVM/MoarVM/blob/mast...abels.h#L5 21:36
google is of no help on this one.
jnthn gcc-specific extension 21:37
gets the address of a label
used only if you build the interp with computed goto
cognominal thx jnthn++ ant timotimo++ 21:39
timotimo ant helped? 21:42
jnthn Not enough to get a ++ 21:47
timotimo to be fair, A++ is pretty darn good 21:52
i wonder ... since this is mostly string stuff, maybe parrot is faster than moar at this task 21:57
22:30 raiph joined
timotimo jnthn: you already finished for the day? 23:20
23:44 lunchbox joined