Welcome to the main channel on the development of MoarVM, a virtual machine for NQP and Rakudo (moarvm.org). This channel is being logged for historical purposes.
Set by lizmat on 24 May 2021.
Nicholas [* GOOD *] 06:02
jnthnwrthngtn moarning o/ 09:26
Nicholas \o 09:30
japhb o/ 12:42
nine Signature declarations a bit of a tricky beast. On the one hand we get quite a bit already for free (like declarations) by utilizing RakuAST::Signature. On the other hand it's hard to find a good place for creating containers for those parameter targets. 12:45
jnthnwrthngtn nine: I already have local work on those 12:52
nine: But it's another of the things that triggered my "need to figure out the timing issues" detour 12:53
gist.github.com/jnthn/420e93cd4ca0...92c10fb361 is the notes so far, fwiw
nine Aaaah...that background explains why timing is such a big issue. Didn't find it that difficult so far and most things found a reasonable place. But of course I totally ignored that we want to add macros and custom compiler passes :) 12:55
In github.com/rakudo/rakudo/commit/f5...cb61fdf1c5 I figured that an optimization pass would want to have the generated block for where expressions already in place, so I generate them at BEGIN time 12:56
jnthnwrthngtn There's some things I'm struggling to decide where go, alas. Like the implicit block semantics. 12:59
nine Like those where blocks I mentioned? 13:08
jnthnwrthngtn No, the thing that makes the block of a `with` get declared with an implicit topic parameter, or the block of a `start` having a fresh $/ and $! 13:11
Because they're not really about the block, but about its "owner"
nine Ah, part of the "Some nodes need to know about surrounding context in order to compile" problem 13:13
.oO(It would be soo useful to have a $!parent in each node, and sooo lead to bad design)
13:16
jnthnwrthngtn: wanna share what you have on signature declarations? 13:20
jnthnwrthngtn nine: Wasn't much; branch stub-var-sig-decl 13:27
nine - my \type = ::($.typename); 13:31
+ my \type = try ::($.typename);
Aaaah...yes, that one :D 13:32
Ok, looks like my RakuAST::VarDeclaration::Signature is already way more advanced. And I picked the exact same name :)
jnthnwrthngtn Well, then continue with yours I guess :) 13:39
nine thinks it's about time to factor out the code for creating containers 13:44
jnthnwrthngtn Yeah, I'd figured signature vars would imply that, but was undecided where it goes :) 13:45
nine RakuAST::ContainerCreator? 13:46
method IMPL-CONTAINER can easily go into a role. It only expects .sigil and .twigil on self
jnthnwrthngtn Hm, not also type? 13:50
nine $of is supplied by the caller 13:51
Plan is to add a $!container-type to RakuAST::ParameterTarget::Var, set by RakuAST::VarDeclaration::Simple and used to determine whether to create a contvar and if with what container type 13:52
s/
s/RakuAST::VarDeclaration::Simple/RakuAST::VarDeclaration::Signature/
nine nine@sphinx:~/rakudo (rakuast_wip *<>)> ./rakudo-m -e 'my ($a, $b) = 1, 2; say $b;' 14:34
2
nine@sphinx:~/rakudo (rakuast_wip *<>)> ./rakudo-m -e 'my Int ($a, $b) = 1, 2; say $b;'
2
nine@sphinx:~/rakudo (rakuast_wip *<>)> ./rakudo-m -e 'my Str ($a, $b) = 1, 2; say $b;'
Type check failed in assignment to $a; expected Str but got Int (1)
japhb nine++ 14:44
nine m: class Foo { has Int ($.a, $.b) is default(1); }; say Foo.new.b # Implementing a compiler for a language teaches you quite a lot about that language... 18:19
camelia 1
nine And another 10 spec test files unlocked. Now 414 passing 18:59
nine Now there's only 1 rakuast_wip commit left to merge, before the rakuast branch can compile a (somewhat) usable Test.rakumod. It brings a bit of support for nqp ops 19:02
The hardest part of that is that for nqp ops literals need to be unboxed, i.e. need different code gen for those. 19:05
Again a "Some nodes need to know about surrounding context in order to compile" problem
japhb nine: ISTR that's done in the current compiler by having literal nodes know both their boxed and unboxed forms, and the parent gets to pick ...? 19:59
MasterDuke interesting. adding that pretty simple fast path in MVM_string_utf8_encode_substr takes `my $a = "when.opt".IO.slurp; my $b; my $s = now; $b = $a.encode for ^100_000; say now - $s; say $b.decode.chars` from 4.2s down to 2.0s 21:42
where 'when.opt' is 18kb, 350 lines, and 18101 chars 21:44
`MVM_SPESH_BLOCKING=1 ./rakudo-m -e 'use nqp; my $a = "src/core.c/Int.pm6".IO.slurp; my $b; my $s = now; $b := nqp::sha1($a) for ^10_000; say now - $s; say $b' now is ~0.38s (~0.58s on master, ~0.22s with the binarysha1 op) 21:51
hm. only gets hit 1k times when compiling CORE.c 21:54
right, because most of the strings used then are strands 21:58
japhb Good progress, definitely 21:59
MasterDuke trying to remember what the other benchmarks i ran where i saw MVM_string_utf8_encode_substr a lot...
hm. i wonder if there's some heuristic where it would make sense not to make strands when concatenating a string and a newline? 22:03