timotimo seems like i need a decont to get the value, which makes obvious sense 00:03
and the localref shouldn't :returns(int) of course 00:05
aaah 00:06
i'm not allowed to declare a variable with localref yet
yay, i got an OK out of it :) 00:09
bump the plan, save the planet 00:10
jnthn timotimo: uh, can I see the test you ended up wthi? 00:13
something looks...odd
I'd expect the second bind would want to be an assign_i of another IVal 00:14
Followed by reading either the reference or the local
timotimo sure 00:15
hold on
gist updated, jnthn 00:16
00:17 dalek joined
timotimo i get all ok's, but i have not tried to make tests fail :S 00:17
which is how i was supposed to do it ...
jnthn QAST::Op.new(
:op<bind>,
QAST::Var.new( :name<intlocref>, :scope<localref>, :decl<var> ),
QAST::Var.new( :name<intloc>, :scope<local> )
),
That really wants to be assign_i
And I'd assign and IVal 00:18
timotimo mhm
jnthn QAST::IVal.new( :value(99e1) )
Did you mean NVal?
But yeah, you want assign_*
timotimo er, yes 00:19
well, now i get segv :)
00:20 vendethiel joined
timotimo i updated the gist with the nqp diff i made, you might be able to spot dumbness 00:20
was i supposed to use assign_i in the local and localref interacting pieces of compile_var? 00:21
jnthn my $localref := $*REGALLOC.fresh_register($kind, !$temporary); 00:22
No, you were supposed to use it in your tests
That line looks wrong
timotimo OK, i put that in now
oh, $kind ought to be $MVM_reg_obj
jnthn Right
timotimo i wrote that before i got told about the objness of ref registers 00:23
jnthn + $res_reg := $localref;
That can't be right
Especially given 00:24
+ push_op(@ins, @decont_opnames[@kind_to_op_slot[$res_kind]], $res_reg, $localref);
timotimo okay, let's see what the code i wrote actually does ... :S
jnthn Simply on kinds it can't be; $localref has to be an obj register, but the target has to be a natively typed one.
I think you need to allocate a temporary there
timotimo and decont, yeah? 00:25
jnthn Your decont_opnames thing looks right
But you need $res_reg (result of the decont) to be a fresh register of kind $res_kind
timotimo OK 00:26
jnthn Also here: 00:27
push_op(@ins, @localref_opnames[@kind_to_op_slot[$lex_kind]], $res_reg, $local);
$res_reg needs to be a fresh object register
I don't think it's being initialized at all on that code path
timotimo could be ;(
i did it kind of sloppishly and was wondering why the tests didn't blow up 00:28
for the first part, do i just "set" the $tmp_reg := $localref? because the decont already comes after that
and i'd only need one decont, eh?
jnthn $tmp_reg? 00:29
timotimo oh, you told me to get a res_reg from the allocator 00:30
not a temporary
jnthn But no, for the localref -> local case, and the local -> localref case, you need to allocate a register
timotimo i'm finding it a bit hard to concentrate, but i'd like to power through regardless 00:31
jnthn needs to undo a few days of insufficient sleep, so will go and rest now :)
timotimo already updated the gist with a few more of your betterments
aaw, i'll have to shotgun-debug this stuff again :) 00:32
jnthn :)
timotimo have a good rest!
jnthn Good luck!
Thanks
o/
timotimo thanks, i'll need it ;\
now where do i dig to find out what to do in the localref -> localref case 00:33
i think i just have to take over the register
i must have misunderstood you when you said i ought to assign_i ... 00:37
hm.
because i get the segfault in assign_i 00:38
oh dang 00:40
a core dump of 9 gigs size
thank you, asan %)
hmpf. this is an SSD. dumping the core dump shouldn't take this long ... 00:43
oooh
hm. no you really did tell me to assign from an IVal into a :scope<localref> 00:44
i suppose there can't be a localref without a local that's ref'd 00:50
but the container is still 0x0 :\ 00:56
oh, i think i get it now 01:17
oh, i'm a big, big derp
of course i had to use the same name, just different scopes to get the combinations of local and localref 01:20
maybe i'm barking up the wrong tree right now, but this seems very wrong: 01:28
(gdb) print MVM_hll_current(tc)->int_lex_ref
$6 = (MVMObject *) 0x0
OK, i seem to understand stuff i see right here 01:30
hum. it uses the same type for lex refs and reg refs 01:32
so ... is nqp supposed to expose a class that's properly repr'd in NQPMu.nqp to use for those? 01:34
well, rakudo certainly does that 01:36
is that what i'm doing wrong? could be.
timotimo maybe goes to bed 01:43
the gist from earlier (which was gist.github.com/timo/b68416dedda71b72a458 for local reference) is now updated with my latest compiler code as well as the only test i need to segfaultify stuff 01:44
02:09 colomon joined 02:11 agentzh joined 03:15 agentzh joined 03:23 vendethiel joined 03:47 vendethiel joined 04:18 vendethiel joined 05:03 vendethiel joined 05:13 agentzh joined 05:30 vendethiel joined 06:10 agentzh joined 07:25 FROGGS joined 07:48 Ven joined 08:21 agentzh joined 08:27 rurban joined 08:34 zakharyas joined 08:58 Ven joined 09:16 kjs_ joined 09:43 Ven joined 09:51 kjs_ joined
jnthn timotimo: Well, the immediate issue is that there's no native lex ref types set up for the VM to use for the NQP language 09:53
09:54 brrt joined
timotimo a-HA! 09:54
and i don't know how to implement the NativeRef protocol
brrt \o
timotimo or something like that
o/ brrt 09:55
as in: the simplest thing that could possibly have worked would have been class NativeRef is repr('NativeRef') { }
but that lacks all the stuff like what type of thing it refs and whether it's a lexical or local
jnthn duh, the code is missing the "do we have one" check in some places 09:56
timotimo that causes the segfault rather than giving a pretty error message, aye 09:58
the segfaults i used to have were caused by trying to assign_i a value into a low-level null
all these null checks must be really expensive! :P 10:05
jnthn Not particularly 10:06
You're already reading the bit of people
wtf
the bit of *memory*
timotimo :D
jnthn And the branch is predictable.
timotimo i'll be AFK for at least an hour in a few minutes
jnthn We can elide them in spesh/JIT too :)
timotimo ah, NativeRef doesn't even have a spesh function yet 10:08
dalek arVM: ffb1257 | jnthn++ | src/6model/reprs/NativeRef.c:
Add missing checks for HLL ref type configuration.
10:10
jnthn The native ref protocol is defined in the NQP repo under docs/6model, btw 10:11
timotimo k
to be honest, i forgot how to pass the configuration hash for the compose protocols on towards the repr when building a class :\ 10:15
but i'm going to be doing that AFK thing right now
jnthn k o/ 10:16
timotimo o/
timotimo ... vroom vroom ...
10:31 brrt left 10:51 kjs_ joined 11:09 agentzh joined 11:12 kjs_ joined 11:13 Ven joined 11:34 vendethiel joined 11:58 brrt joined 13:23 kjs_ joined 13:54 vendethiel joined
timotimo if you (or someone) tells me where to pass the compose protocol data, i'll go ahead and build the ref classes for nqp 13:57
but first, afk for a while 13:58
jnthn timotimo: nqp::composetype; see NativeRefHOW in Rakudo for a full example 13:59
14:07 Ven joined
timotimo thanks 14:22
well, i have a full example now, but i don't quite know how much i'm supposed to cut out of it 14:24
jnthn Most of it
You just need an nqp::newtype and nqp::composetype really 14:25
Once for each native type
timotimo and it'd go at the bottom of NQP's core/NQPMu? 14:26
in the "not parrot" section
and then my \NativeIntLexRef := nqp::newtype? or something to do with stashes and EXPORTblah? 14:27
i also don't know what metaclass to supply for nqp::newtype 14:28
nqp-m: say nqp::gethow(NQPMu) 14:29
camelia nqp-moarvm: OUTPUTĀ«Confused at line 2, near "say nqp::g"ā¤ at gen/moar/stage2/NQPHLL.nqp:490 (/home/camelia/rakudo-inst-1/languages/nqp/lib/NQPHLL.moarvm:panic:105)ā¤ from gen/moar/stage2/NQP.nqp:921 (/home/camelia/rakudo-inst-1/languages/nqp/lib/nqp.moarvm:comp_unit:872)ā¤ fā€¦Ā»
timotimo nqp-m: say(nqp::gethow(NQPMu)) 14:30
camelia nqp-moarvm: OUTPUTĀ«No registered operation handler for 'gethow'ā¤ at gen/moar/stage2/QAST.nqp:1406 (/home/camelia/rakudo-inst-1/languages/nqp/lib/QAST.moarvm:compile_op:64)ā¤ from gen/moar/stage2/QAST.nqp:5194 (/home/camelia/rakudo-inst-1/languages/nqp/lib/QAST.moarvm:compile_ā€¦Ā»
timotimo nqp-m: say(nqp::how(NQPMu))
camelia nqp-moarvm: OUTPUTĀ«cannot stringify thisā¤ at gen/moar/stage2/NQPCORE.setting:682 (/home/camelia/rakudo-inst-1/languages/nqp/lib/NQPCORE.setting.moarvm:print:13)ā¤ from gen/moar/stage2/NQPCORE.setting:688 (/home/camelia/rakudo-inst-1/languages/nqp/lib/NQPCORE.setting.moarvm:saā€¦Ā»
timotimo nqp-m: say(nqp::how(NQPMu).name)
camelia nqp-moarvm: OUTPUTĀ«Too few positionals passed; expected 2 arguments but got 1ā¤ at gen/moar/stage2/nqpmo.nqp:1201 (/home/camelia/rakudo-inst-1/languages/nqp/lib/nqpmo.moarvm:name:0)ā¤ from /tmp/i_kN5rDW64:1 (<ephemeral file>:<mainline>:28)ā¤ from gen/moar/stage2/NQPHLL.nqp:12ā€¦Ā»
timotimo nqp-m: say(nqp::how(NQPMu).name(nqp::how(NQPMu)))
camelia nqp-moarvm: OUTPUTĀ«NQPMuā¤Ā»
timotimo nqp-m: say(nqp::how(NQPMu) =:= NQPMu)
camelia nqp-moarvm: OUTPUTĀ«0ā¤Ā»
jnthn timotimo: no no no, you're not meant to add anything ot NQP
Just write this in the test
timotimo oh 14:31
i'd use NQPClassHOW, duh
jnthn Doesn't matter too much what meta-class you use either
Any class will do
timotimo huh, all right 14:32
the repr protocol says there's "attribute", "positional" and "lexical", is there another for locals or does that fall under one of those three? 14:37
jnthn lexical covers locals 14:39
timotimo OK
just saw it in moar's code for nativeref.c
.o( that means only half the amount of classes to make! ) 14:40
and then i'd gethllconfig, add the keys and sethllconfig again?
jnthn No, you can just sethllconfig 14:43
It doesn't remove existing things
timotimo ah, cool 14:44
this should get me a lot closer to something working :)
yesterday when i wrote the tests i had a massive brainfart; i thought i could only refer to the same local with the same scope, even though i had just implemented looking for the same name in both local and localref scope and differentiating behavior based on that 14:45
jnthn local and localref are kinda two views of the same scope 14:47
14:47 agentzh joined
timotimo aye 14:47
gist.github.com/timo/20f6731d7f67e82f4f55 - this is how i build the classes, but in gdb i see the current hll's config still doesn't have the *_lex_ref attributes set :\ 14:48
i'll be afk for a bit now 14:49
jnthn timotimo: You may need to add a QAST::CompUnit around your tests and :hll('nqp') 14:51
15:06 vendethiel joined 15:18 FROGGS joined
timotimo understood 15:32
not ok 1 - localref of type int with value 23 assigned to itCannot assign to an immutable value 15:33
progress!
brrt many progress
jnthn so test fail 15:34
timotimo yes
jnthn will prolly add ~300 tests to roast today :) 15:35
timotimo gist.github.com/timo/b68416dedda71...e1-txt-L33 - it's basically exactly this test, but with a compunit around it
FROGGS add to what?
timotimo that test should work that way, shouldn't it?
FROGGS: for native arrays
FROGGS to nqp/t/nsa?
or to moarvm 15:36
timotimo he said "to roast"
FROGGS ahh
timotimo :)(
er
FROGGS I read 'from roast'
timotimo :)
oh
timotimo removed the decont call from there also and turned the last localref into local instead 15:37
that's a better way to read from a localref
15:44 vendethiel joined
timotimo gist.github.com/timo/b68416dedda71b72a458 - the tests section of this gist is now up to date; jnthn, can you tell me that the qast tree is correct like this and i should be looking elsewhere? 15:44
jnthn timotimo: First test looks sane 15:45
timotimo ho-hum
i wonder what i'm doing wrong, then
jnthn Second test wants assign_n, and third assign_s
timotimo ah! yes 15:46
but the exception i'm getting is Cannot assign to an immutable value
jnthn Oh! 15:47
Sorry
You also need to set up the container spec on the types too
timotimo ooooh
jnthn It's one line addition, thankfully :)
nqp::setcontspec($class, 'native_ref', nqp::null()); 15:48
timotimo in the part that creates the classes in that test file, eh?
jnthn Right after nqp::composetype line
timotimo good
doesn't seem to be enough yet
jnthn Oh? 15:49
timotimo i have to set it rw maybe?
jnthn No, making it a container does that
timotimo mhm
jnthn If you mean the type
brrt afk :-)
15:50 brrt left
timotimo same exception. i wonder where i should look to figure out what's going wrong here 15:50
jnthn What error do you get now?
timotimo ... immubatle value
jnthn OK, that doens't make much sense...
timotimo do i need the Stmts + Stmts setup for setting up variables and then having code that uses them?
jnthn I wonder if the code-gen is correct
timotimo i'll give you an up-to-date diff 15:51
jnthn No, your test case looks uqite legit
timotimo diff of nqp i mean
jnthn QAST::Var.new( :name<intloc>, :scope<localref> ),
Does adding :returns(int) to this line help?
timotimo doesn't 15:52
jnthn OK, good
timotimo ah, the nqp diff was already correct, i just added an empty line to NQPMu.nqp by accident
15:53 dalek joined
timotimo i don't think i recall having written any code that'd instantiate a container of the *_lex_ref type from the hll, but i suppose that's done for me by moarvm? 15:54
jnthn Yes, that's what the getregref_* ops doe 15:56
*do 15:57
afk for a little bit
timotimo did i have to build a reg first before i use a regref?
er, i'm already doing that 15:58
16:00 kjs_ joined 16:04 [Coke] joined 16:13 vendethiel joined
timotimo i'm going to go have dinner with my parents now 16:31
16:36 agentzh joined 16:44 retupmoca joined 16:45 Util joined, btyler joined 17:22 tgt joined
jnthn back 17:34
FROGGS forth 18:19
jnthn stacks FROGGS 18:20
18:29 kjs_ joined 18:40 lizmat_ joined
timotimo i've had dinner and still don't really know how to go on with my stuff; i suppose i could try to dump the MAST that the test qasts generate and look at them in more details 18:46
?
alternatively have a look in gdb what happens around the assign_i that errors out? 18:47
jnthn I'd look at the MAST first 18:51
I really can't spot what's missing 18:52
dinner; bbs 18:53
timotimo 'k 18:55
i can't just set the target to mbc and dump it to a --output file because "compunitmainline requires an MVMCompUnit" :( 19:01
jnthn eek, my native arrays tests hit a spesh bug... 19:34
timotimo ducks 19:35
jnthn oh 19:36
It's actually a JIT bug 19:37
timotimo ah, so perhaps it's not my fault :)
hm. :from('ast'), :target('mast') also complains about the compunitmainline thing :\ 19:38
dalek arVM: cd381e1 | jnthn++ | src/jit/graph.c:
Fix JIT of bindpos_n.
19:46
jnthn That fixes it. 19:48
timotimo oh yeah ... float values 19:50
weird registers and stuff
japhb jnthn: I haven't kept track, unfortunately. Are native arrays in for r-m 2015.03? What about CUnion?
jnthn japhb: Yeah, to some level 19:51
japhb: They won't be optimized, and there'll probably be rough edges.
japhb: But I've got a couple of hundred passing native array tests so far. So at least something works. :)
timotimo \o/ 19:52
FROGGS japhb: in theory CUnions could go in after some more testing on other platforms than windows/linux 20:13
timotimo sounds like something nwc10 ought to hea r:) 20:14
FROGGS true 20:15
japhb FROGGS: Erm ... why couldn't that be merged now and improved for other platforms later, as with previous parts of NativeCall? Is it a fear that the *API* will have to change? 20:44
jnthn: Oh, excellent!
FROGGS jnthn: the only issue (I think) is that I'd like to change the default for CStructs and CUnions... 20:45
japhb dreams of being able to dabble in OpenGL again, slinging around big float arrays efficiently
Default?
FROGGS so that they are inlined by default instead of referenced when they appear as attributes in CStructs
... which would break quite some modules out there... 20:50
but to me it is a sane choice, and I'd just need to convince jnthn I guess :o) 20:51
err, jnthn++ :P
japhb Oh sure, butter him up. :-) 20:53
jnthn What what? :P
FROGGS *g*
jnthn FROGGS: How would you get the current semantics?
japhb Actually, given that we have Pointer[Type], changing the default begins to make more sense. Certainly when you're thinking in C-mind it does. 20:54
jnthn Yes, was gonna ask if it's Pointer[Type]
The deeper question is how far we go with this though
For example
sub foo(SomeCStructType $x) is native(...) {*} 20:55
Does that need Pointer[SomeCStructType]?
FROGGS no
since you cannot pass a struct by itself
japhb
.oO( class SomeCStructTypePtr is Pointer[SomeCStructType]; sub foo(SomeCStructTypePtr $x) ... }
20:56
s/'}'/ = ')'
jnthn FROGGS: You can in C! :P 20:57
FROGGS hmmm
jnthn It's not the best of ideas though, iirc 20:58
FROGGS I guess I'd have to play with that in another branch and see where would end up
jnthn FROGGS: stackoverflow.com/questions/161788/...-passing-a has some discussion 20:59
While it's certainly *possible*, it's not common
However, passing a C union type as an argument is more common. 21:01
FROGGS hmmm, yeah 21:02
well, I guess it would be more sane to also pass a 'Pointer[MyStruct]' or 'MyStruct is rw' to a native sub... 21:03
Heap corruption detected: pointer 0x7fccef931fc8 to past fromspace 22:27
:o(
jnthn f**k :/ 22:33
How'd you get that one, ooc?
FROGGS running github.com/perl6/cpandatesters.per...n-dists.pl 22:34
but happens very rarely
hmmm
I should probably update my rakudo+moar
because I am not sure if DBIish does use callbacks for the postgres stuff I do 22:35
hmmm no, I dont think callbacks are involved 22:37
23:19 donaldh joined