Perl 6 - the future is here, just unevenly distributed

IRC log for #perl6-lwp-gsoc, 2015-02-24

| Channels | #perl6-lwp-gsoc index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
02:48 ilbot3 joined #perl6-lwp-gsoc
02:48 Topic for #perl6-lwp-gsoc is now logs at http://irclog.perlgeek.de/perl6-lwp-gsoc/
04:09 FROGGS joined #perl6-lwp-gsoc
07:58 FROGGS joined #perl6-lwp-gsoc
10:25 sergot hi
10:27 sergot FROGGS: have you done anything since we last talked about cpp?
10:30 FROGGS I implemented typed pointers (which are live since yesterday)
10:31 FROGGS and I was working on inlined unions for C/C++ in the union branches of moarvm and rakudo
10:33 FROGGS and I fixed the calculated struct size for C and C++ structs
10:36 sergot how does look the todo list now?
10:36 FROGGS hmmm, let's think
10:36 FROGGS first of all, we need to merge back the type pointer change into cpp
10:37 FROGGS then we can have Pointer[void] which will correctly mangle to Pv
10:38 FROGGS so, it would be nice to test mangling for different arguments
10:38 dalek joined #perl6-lwp-gsoc
10:38 FROGGS like, add a test file called cpp-mangling.t, and add methods that each take an argument
10:39 FROGGS so test test every argument possible
10:39 FROGGS the C method would then just a number, 1 for the first method, 2 for the second etc
10:39 FROGGS then we check that the correct number is returned
10:39 FROGGS so we know the mangling works correctly
10:40 FROGGS this will help us too when we implement other mangling schemes, like the visual C++ abi
10:41 FROGGS so, can you add a new test C++ script and perl test file that has a single class, but a lot methods like I described?
10:42 sergot yes :)
10:42 FROGGS sergot++
10:42 FROGGS :o)
10:42 sergot but..
10:42 sergot i dont understand this:
10:42 sergot 10:39 < FROGGS> the C method would then just a number, 1 for the first method, 2 for the second etc
10:42 sergot C method?
10:42 FROGGS return a number*
10:42 FROGGS C++ method
10:43 sergot ohh, ok
10:45 sergot updating my env
10:45 FROGGS in the .cpp file we would have: class Foo { virtual int TakeAnInt(int i) { return 1; } }
10:45 FROGGS I guess I should merge nom into cpp first...
10:51 FROGGS sergot: doen
10:52 FROGGS done*
10:52 FROGGS you can now pull cpp
10:52 dalek joined #perl6-lwp-gsoc
10:52 FROGGS sergot: you can also test longlong, but not longdouble btw
10:52 FROGGS (and everything else)
11:01 sergot ok :)
11:09 sergot ive just updated my env
11:19 sergot hmm
11:19 sergot how the tests should look like?
11:19 sergot we want to check if it is mangled properly, right
11:19 sergot ?
11:20 sergot or just if it returns the proper value?
11:21 FROGGS when the return value is correct, we have called the correct method
11:22 FROGGS which means that the mangling is correct
11:22 sergot yep, ok :)
11:30 sergot hmm, it can't find Foo's constructor.
11:32 sergot https://gist.github.com/sergot/5fc619cd6dc048bbf4cf
11:32 sergot I thought it's enough
11:37 FROGGS I've commented
11:40 sergot I tried with Foo() and it didn't work
11:40 sergot and it doesn't work now
11:40 sergot with your change
11:41 sergot I missed something obvious I gues...
11:41 sergot guess
11:41 FROGGS ahh
11:41 FROGGS did you add Foo::Foo() { }; outside (after) the class definition?
11:42 FROGGS and also: Foo::~Foo() { };
11:42 sergot oh, I didn't know it neccessary
11:43 sergot it works now
11:44 sergot Memory allocation failed; could not allocate 18446744071562067968 bytes
11:44 FROGGS Foo(); is just a prototype without an implementation
11:44 FROGGS O.o
11:44 FROGGS can you gist both files?
11:45 sergot yes
11:46 sergot cpp: https://gist.github.com/sergot/5fc619cd6dc048bbf4cf
11:47 sergot t: https://gist.github.com/sergot/cbae086527e82a6776ea
11:48 FROGGS ummm, MoarVM fails to check that the CPPStruct is empty (no attributes)
11:48 FROGGS so it perhaps tries to allocate -1 bytes :o)
11:48 sergot oh
11:48 sergot I found a bug then \o/
11:48 FROGGS please add a 'has Pointer $.vtable'
11:49 FROGGS yes
11:49 FROGGS but we can get away with that when we put an attribute in it
11:50 sergot yes, it worked
11:52 FROGGS nice!
12:00 sergot longlong doesn't work
12:01 sergot _ZN3Foo13TakeALongLongE8longlong
12:01 sergot should be x, right?
12:02 sergot yep, it is commented out
12:02 sergot when longlong
12:03 FROGGS yeah, I just added longlong yesterday in nom
12:03 FROGGS so uncommenting the when clause will do
12:03 sergot ok :)
12:04 sergot should I also test void?
12:04 FROGGS yes
12:04 FROGGS I think
12:04 sergot ok
12:05 FROGGS though, we do not put any params in the signature on perl side to mean 'void'
12:05 sergot yeah
12:05 sergot :)
12:05 FROGGS dunno if we want to allow both, passing nothing around and passing void around
12:08 sergot Unknown type Bool used in native call.
12:08 sergot hmm
12:08 sergot why so?
12:08 sergot where should I fix the bug I found?
12:10 FROGGS what bug?
12:10 FROGGS the bool thing?
12:10 sergot no, the previous one, failing when no attributes
12:10 FROGGS we do not support P6's bool yes
12:10 FROGGS ahh
12:10 FROGGS that's what I explained on #perl6
12:10 FROGGS biab, lunch
12:11 sergot also in reprs/*?
12:11 sergot ok
12:11 sergot oh, yeah, I will take a look at reprs/*
12:20 sergot do we suppport Cpp strings?
12:20 sergot or C char arrays
13:30 FROGGS Str maps to char*
13:44 FROGGS +#is $foo.TakeAString("1"), 9, 'string mangling';
13:44 FROGGS that should be +#is $foo.TakeAString(char*), 9, 'string mangling';
13:45 FROGGS and then, we could add tests for almost all of the types you added, and add a Pointer[thing] variant as well
14:17 sergot char* ?
14:18 sergot in p6 code?
14:20 sergot nm says 0000000000000c7e W _ZN3Foo11TakeAStringEPc
14:20 sergot bu we got _ZN3Foo11TakeAStringERc
14:21 FROGGS ahh, Pc vs Rc
14:22 FROGGS sergot: in P6 land it would be 'Str'
14:22 FROGGS I wonder why I put 'Rc' in the mapping table....
14:23 sergot I will change it
14:23 sergot if it's wrong
14:27 sergot it works when I change all R to P :))
14:27 sergot is it correct?
14:30 sergot R should appear when we have a reference, right?
14:51 FROGGS correct
14:59 sergot https://gist.github.com/sergot/56e74cff08f2fa2c64a8
14:59 sergot that's my fix
14:59 sergot not sure if we need to store it in a new variable
15:00 FROGGS can't you use MVM_calloc? IIRC that also sets the memory to zero
15:01 sergot Oh, I didn't know
15:06 sergot https://gist.github.com/sergot/56e74cff08f2fa2c64a8
15:08 FROGGS well, the best patch would be to:
15:08 FROGGS - body->cppstruct = MVM_malloc(repr_data->struct_size > 0 ? repr_data->struct_size : 1);
15:08 FROGGS + body->cppstruct = MVM_calloc(1, repr_data->struct_size > 0 ? repr_data->struct_size : 1);
15:08 sergot ok
15:08 sergot this repairs the segfault
15:08 sergot but not the "allocation failed" problem
15:09 FROGGS ahh
15:09 FROGGS how does it fail now?
15:09 sergot filip.sergot@c51255:~/p6/rakudo$ perl6 -e 'use NativeCall; class Foo is repr<CPPStruct> { }; Foo.new'
15:09 sergot this doesn't fail at all
15:09 sergot what fails is our 13-cpp-mangling.t when I remove $.vtable
15:09 sergot Memory allocation failed; could not allocate 18446744071562067968 bytes
15:10 FROGGS I know where taht happens...
15:10 FROGGS here I guess: https://github.com/MoarVM/MoarVM/blob/cpp/src/core/nativecall.c#L734
15:11 FROGGS but well, leaving off the vtable is plainly wrong anyway
15:11 sergot oh
15:11 sergot why ?
15:12 FROGGS at some point we'll be smart enough to autodetect if a vtable is present in the C++ class
15:12 sergot right
15:12 FROGGS because the class has a vtable, and you cannot just allocate a fraction of the class, hand it off to C++ and expect that it will cope with that :o)
15:13 FROGGS perl6 -e 'use NativeCall; class Foo is repr<CStruct> { }; Foo.new' # that does not fail anymore with your patch?
15:14 sergot correct
15:15 sergot no I fixed also the allocating problem
15:15 sergot -                        ptr    = MVM_malloc(repr_data->struct_size);
15:15 sergot +                        ptr    = MVM_malloc(repr_data->struct_size > 0 ? repr_data->struct_size : 1);
15:15 sergot now*
15:16 sergot so, 13-cpp-mangling.t work without $.vtable
15:16 sergot works
15:42 FROGGS which is not quite correct though
15:42 FROGGS though, the patch is still valid I guess
15:43 FROGGS brb
16:11 FROGGS joined #perl6-lwp-gsoc
19:24 ilbot3 joined #perl6-lwp-gsoc
19:24 Topic for #perl6-lwp-gsoc is now logs at http://irclog.perlgeek.de/perl6-lwp-gsoc/

| Channels | #perl6-lwp-gsoc index | Today | | Search | Google Search | Plain-Text | summary