Perl 6 - the future is here, just unevenly distributed

IRC log for #perl6-lwp-gsoc, 2014-07-03

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

All times shown according to UTC.

Time Nick Message
01:54 FROGGS_ joined #perl6-lwp-gsoc
06:44 FROGGS_ joined #perl6-lwp-gsoc
06:45 FROGGS morning
06:51 sergot morning o/
06:52 sergot what is to do with the Int problem ?
06:57 FROGGS for things that are P6opqaue, you need to use REPR(thingy)->box_funcs.{get_int,get_num,get_str}
07:14 sergot ok! :)
07:14 sergot thanks
07:26 sergot Do we have to care about int8, int16 etc... ?
07:26 sergot when we use box_funcs?
07:29 FROGGS yes
07:29 FROGGS also, I think we need set_int,set_num,set_str not get_*
07:29 FROGGS (clearly I need coffee)
07:32 sergot why set? we want to get the value of obj
07:32 FROGGS obj is our pointer
07:33 FROGGS we want to get the value the pointer points at, and then set_int that into the requested type... (res_type)
07:33 FROGGS you're casting from C *memory* to a Perl 6 object
07:33 FROGGS not the other way around
07:34 sergot ok
07:35 FROGGS at some point we should rename 'obj' to something else :o)
07:35 sergot Let's do this now :)
07:37 sergot anyway, th elast argument of set_something is the place, where we want to write our value, am I right?
07:40 FROGGS isnt it the value itself?
07:42 sergot REPR(result)->box_funcs.set_int(tc, STABLE(result), result, OBJECT_BODY(result), lex_reg->i64);t
07:42 sergot e.g.
07:43 sergot in our case will it be something like that:
07:44 sergot REPR(obj)->box_funcs.set_int(tc, STABLE(obj), obj, OBJECT_BODY(obj), result);
07:44 sergot ?
07:45 FROGGS looks good
07:45 FROGGS err no
07:45 sergot value at the end?
07:45 FROGGS obj is our pointer, not the type/instance we want to box into
07:46 FROGGS wait... can't we use make_int_result?
07:46 sergot I thought we can
07:46 FROGGS this takes the desired type and the value...
07:46 FROGGS hmmmm
07:47 FROGGS why do I talk about box_funcs then? ó.ò
07:47 FROGGS sorry for leading you on the wrong track
07:47 sergot because we have P6opaque here
07:47 sergot https://github.com/sergot/MoarVM/blob/master/src/core/nativecall.c#L772
07:48 sergot and it doesn't work
07:49 FROGGS in what way?
07:49 FROGGS can you replace 'value' in line 790 by 42, does that work then?
07:50 sergot yes, give me a sec
07:51 FROGGS we need to find out if retrieving the value is bogus or if boxing it is
07:54 sergot now I got :
07:54 sergot Naruszenie ochrony pamięci (core dumped)
07:54 sergot oh
07:54 sergot sorry
07:54 FROGGS :o)
07:54 sergot just a segfault
07:54 sergot :D
07:54 FROGGS yeah
07:55 FROGGS can you push your stuff?
07:55 sergot I did a mistake
07:56 sergot I works, I got:
07:56 sergot not ok 2 - casting int works
07:56 sergot #      got: '42'
07:56 sergot # expected: '101'
07:56 FROGGS nice
07:57 FROGGS in the other case we got what? the memory address itself?
07:57 sergot pushing
07:57 sergot yes
07:57 FROGGS that means we just fetched the value wrongish
07:57 sergot #      got: '140402480906341'
07:57 FROGGS that is, reading it from the pointer obj
07:59 sergot pushed
08:00 sergot both, moarvm and zavolaj tests
08:00 FROGGS k
08:00 FROGGS ahh, I have an idea
08:01 sergot \o/
08:17 FROGGS sergot: please add an else-branch here where it complains about the wrong type: https://github.com/sergot/MoarVM/blob/master/src/core/nativecall.c#L759
08:45 sergot ok
08:45 sergot just throw an exception there?
08:47 FROGGS yes
08:47 FROGGS do you know what the funny thing is?
08:48 FROGGS that test is bogus
08:51 FROGGS you might have seen that always the same number is printed, so it can't be a memory address:
08:51 FROGGS 140733193388133
08:52 FROGGS at least, it is always the same number for me
08:52 FROGGS but however, just convert the number to base 16 and you'll see what is going on
08:59 sergot I have always 7F1300000065
09:00 sergot when convert it to base 16
09:01 sergot 65 == 101
09:01 sergot I mean 65(b16) == 101
09:02 moritz 0x65 = 101
09:02 sergot yes! :)
09:03 sergot FROGGS: weird
09:03 FROGGS sergot: so, conclusion? :o)
09:03 FROGGS I mean, I already spoiled it... the test is bogus
09:03 FROGGS but do you know why?
09:04 sergot thinking.. hm
09:06 sergot I'm afraid I have no idea...
09:06 FROGGS what does the test do?
09:07 sergot it checks whether value returned by ReturnInt() equals 101
09:08 FROGGS well yes, in detail it calls a C function that returns an int*, and then returns the value of that int* according to the requested type
09:08 sergot yes
09:08 FROGGS so we have an int* in C, and an Int in Perl 6
09:09 FROGGS what do you think... how big is such an int in C?
09:11 sergot 32bits
09:11 FROGGS what about Int in Perl 6?
09:11 FROGGS brb
09:11 sergot 64?
09:13 sergot Ok, so here is the problem, we compare 32bits with 64.
09:15 sergot so the problem should appear when we type there int64 istead of Int
09:15 sergot and it does
09:15 sergot ok
09:17 FROGGS yeah
09:18 sergot So, we should fix it in the test, or in moar?
09:18 sergot You said the test is bogus
09:19 sergot how to do this in p6?
09:19 FROGGS right, the test makes no sense
09:19 sergot hmm, yeah, we should return int64 then
09:19 FROGGS well, when int64 is too much :o)
09:19 FROGGS no
09:19 sergot ok, there should be int32
09:20 FROGGS correct
09:20 sergot And there was initially
09:20 FROGGS would be nice to have a test that returns an eight byte integer value, but that should be an extra test
09:20 sergot But I thought that Int means "every int*"
09:21 sergot where * doesnt mean pointer, just every 8,16,32...
09:21 sergot So, I failed at this point
09:21 FROGGS for portability reasons I'd malloc eight bytes, put a 1 in each, and compare that to its numeric value
09:21 sergot Ok, so nativecast_call works
09:22 FROGGS no, thy type you provide tells it how to unpack the memory
09:22 sergot true
09:22 FROGGS so you have to know how many bytes it takes for example
09:22 sergot ok, my fault
09:23 sergot FROGGS: could youtake a look at the commented array test (the first one)?
09:23 sergot it segfaults
09:24 FROGGS imagine a C function that returns a struct with two members, one thing called 'type', that tells you what is in the second member (a void *)
09:24 FROGGS so you would then switch according to the type information you got
09:25 FROGGS and unpack the by-the-C-function allocated memory conditionally
09:28 sergot hmm
09:30 sergot Are you talking about the array test?
09:30 sergot :)
09:30 FROGGS no
09:31 sergot Another thing is about this: https://github.com/sergot/MoarVM/blob/master/src/core/nativecall.c#L759, if Int is always 64bit value, then we dont have to check ss.bits.
09:32 sergot FROGGS: so, what did you mean?
09:32 FROGGS Int could be 32 bits on 32 bit platforms
09:32 FROGGS or even should be
09:32 sergot ok, thanks
09:32 FROGGS or... perhaps that was int
09:33 sergot nonetheless, we dont have to care about 8 and 16 there, do we?
09:33 sergot ok, cleaning later :)
09:33 FROGGS it is safer to let it in there
09:34 FROGGS because one can create its own type with custom bit sizes
09:34 sergot Ok, what were you talkknig about earlier?
09:34 sergot I didnt get it
09:34 FROGGS about that array test... first, make it return an OpaquePointer... we do not care about anything else
09:34 FROGGS sergot: I explained why we are doing this here at all that way
09:36 sergot damn, how could I forget about OpaqueePointer there...
09:36 sergot FROGGS: ok
09:38 sergot pushed new version of this test
09:44 sergot and I also pushed throwing an exception
09:47 sergot FROGGS: can we summarize everything?
09:47 sergot 1. we have to fix this CArray test error
09:48 sergot 2. write sub nativecall in NativeCall.pm6, which will:
09:48 sergot - check if returned (from nqp::nativecast) value is a type object or an instance and do something with this
09:49 sergot subnativecast*
09:49 sergot 3. write more tests
09:49 sergot - CPointer
09:50 sergot anything else?
10:09 sergot lunch &
10:25 FROGGS hmmm, 4) cleanup the function nativecall.c when everything works
10:52 sergot ok :)
10:52 sergot Do you have some time now to help me with 1.?
11:12 FROGGS a bit
11:15 sergot So, do you have any idea what can be wrong?
11:18 FROGGS well, what is wrong with it anyway?
11:22 sergot it segfaults
11:22 sergot :)
11:22 sergot could you run it?
11:24 sergot If I write there returns CArray[uint8] and store the result of ReturnArray() to @a, then it hasn't all 1,2,3 values
11:24 sergot so I guess something is wrong with my 09-nativecast.c maybe
11:26 sergot no, it doesnt segfault now
11:27 FROGGS yeah, for me neither
11:27 FROGGS not ok 1 - casting array works
11:27 FROGGS #      got: '0'
11:27 FROGGS # expected: '3'
11:28 FROGGS where would you start looking?
11:31 sergot I have no idea. I tried everything what came to my mind I think
11:32 sergot first, I would change $ to @, but it should not change anything
11:33 FROGGS atm you have to ends in your hand of the call chain, right?
11:33 sergot hmm yes
11:34 sergot actually, why?
11:34 FROGGS you know where the data comes from, and where it ends, and you know that there is something missing on the receiving end
11:34 FROGGS I would follow that data, to see where it vanishes
11:34 sergot oh, ok
11:34 sergot let's start with nativecall.c
11:34 FROGGS yeah
11:38 sergot It's okay before MVM_nativecall_make_carray for sure
11:38 FROGGS sure?
11:38 FROGGS do you know or do you guess?
11:39 sergot I checked
11:39 FROGGS how?
11:39 sergot printf("YYY: %d\n", *(int *)cpointer_body->ptr+2); it's 3 :)
11:39 sergot it prints 3*
11:40 FROGGS okay nice, so we really know that we have an array of ints
11:42 sergot yes
11:42 FROGGS so this pointer to a bunch of bytes is passed to MVM_nativecall_make_carray
11:43 FROGGS that function allocates a CArray, and it makes the CArray pointing to that bunch of bytes
11:43 sergot okaay
11:44 sergot ((MVMCArray *)result)->body.storage = carray;
11:44 sergot this is what you're talking about
11:44 FROGGS yes
11:45 FROGGS that means that a CArray really just uses the memory the C-lib provides... it does not keep a copy of it
11:45 FROGGS which is nice because it is way faster that way... but, when the C-lib frees the memory we will segfault of course
11:46 FROGGS (just for your info, this has nothing to do with our problem)
11:46 sergot ok, good to know this
11:46 FROGGS so, there is not much magic going on... we get a CArray object that points to our C-managed memory
11:47 FROGGS in your test you are accessing $carray[2]?
11:47 FROGGS so let us try to follow this call until we find our lost data, okay? :o)
11:48 sergot okay :)
11:48 FROGGS do you know how the low level operation is called when doing $something[2] ?
11:48 sergot I dont
11:49 FROGGS look at the ast by doing: perl6-m --target=ast -e 'my $foo; $foo[2]'
11:49 sergot it's probably here:                 - QAST::Op(call &postcircumfix:<[ ]>) [2]
11:50 FROGGS correct
11:50 FROGGS so when we search for 'postcircumfix:<[ ]>' (without the amp) in rakudo/src, we find this:
11:51 FROGGS rakudo/src/core/array_slice.pm:20:multi sub postcircumfix:<[ ]>( \SELF, int $pos ) is rw {
11:51 FROGGS fail X::Subscript::FromEnd.new(index => $pos, type => SELF.WHAT) if $pos < 0;
11:51 FROGGS SELF.at_pos($pos);
11:51 FROGGS }
11:51 sergot ok
11:51 FROGGS so after the error check, it calls SELF.at_pos($pos)
11:51 sergot at_pos() then
11:51 FROGGS right
11:52 FROGGS let's look at at_pos in MoarVM's CArray.c
11:53 FROGGS static void at_pos(MVMThreadContext *tc, MVMSTable *st, MVMObject *root, void *data, MVMint64 index, MVMRegister *value, MVMuint16 kind) {
11:53 FROGGS MVMCArrayREPRData *repr_data = (MVMCArrayREPRData *)st->REPR_data;
11:53 FROGGS MVMCArrayBody     *body      = (MVMCArrayBody *)data;
11:53 FROGGS void              *ptr       = ((char *)body->storage) + index * repr_data->elem_size;
11:53 FROGGS switch (repr_data->elem_kind) {
11:53 FROGGS ...
11:54 FROGGS sergot: you've found that file?
11:54 sergot yes, I have it
11:54 FROGGS look at its signature, we get the index there
11:55 sergot yes]
11:55 FROGGS and it takes the ->storage pointer as a base (the one we've seen before), and calcs the right offset
11:55 FROGGS so for index=0 we should read from ->storage in fact
11:56 sergot void              *ptr       = ((char *)body->storage) + index * repr_data->elem_size;
11:56 FROGGS yeah
11:56 sergot ok
11:57 FROGGS so I suggest that we change our test to access $carray[0], and we print the ptr there, okay?
11:57 sergot ok
11:57 FROGGS and perhaps we also print the cpointer_body->ptr in nativecall.c
11:57 FROGGS these must be identical, everything else would be a bug
11:57 FROGGS right?
11:58 sergot that's right
11:58 FROGGS (because this was done earlier ((MVMCArray *)result)->body.storage = carray;)
11:59 sergot I got:
11:59 sergot nativecast: 1
11:59 sergot at_pos: 1
12:00 sergot so, 1 == 1
12:00 FROGGS no...
12:00 FROGGS print the ptr in CArray's at_pos, and the cpointer_body->ptr in nativecall.c
12:01 FROGGS for the test $carray[0]
12:01 sergot that's whay I did
12:01 FROGGS 1 is certainly not a valid pointer :o)
12:01 sergot ohj, pointer!
12:01 sergot ok
12:01 sergot no the value
12:01 sergot ok
12:01 FROGGS correct
12:02 sergot nativecast: 179547504
12:02 sergot at_pos: 179547504
12:02 sergot :)
12:02 FROGGS nice :o)
12:03 FROGGS do we get what is in $carray[0] ?
12:03 sergot ymmm
12:03 FROGGS ymmm?
12:03 sergot yes
12:04 FROGGS well, that's a start
12:04 FROGGS so, let's run it again for $carray[1]
12:05 sergot we should add 1 in nativecall.c then I guess
12:06 sergot it's nativecast: 201108704
12:06 sergot at_pos: 201108705
12:06 sergot now
12:07 sergot anyway - yes, it semms to work
12:07 sergot because we got the next element in at_pos
12:08 sergot I've just run all 3 test for 0,1,2 as the index. and got this:
12:08 sergot nativecast: 151674592
12:08 sergot at_pos: 151674592
12:09 sergot at_pos: 151674593
12:09 sergot at_pos: 151674594
12:09 sergot but it passed only the first test
12:11 FROGGS okay, if you don't spot it already then please access the second element in nativecall.c again, and print its value *and* its pointer this time
12:11 FROGGS because we know we are able to get at its value...
12:13 sergot my output:
12:13 sergot nativecast: 168928464 -> 1
12:13 sergot nativecast: 168928465 -> 2
12:13 sergot nativecast: 168928466 -> 3
12:13 sergot at_pos: 168928464 -> 1
12:13 sergot at_pos: 168928465 -> 33554432
12:13 sergot at_pos: 168928466 -> 131072
12:15 FROGGS I don't believe the output
12:16 FROGGS how did you print the stuff in navicecall.c?
12:16 FROGGS do*
12:16 sergot void *ptr = cpointer_body->ptr;
12:16 sergot printf("nativecast: %d -> %d\n", ptr, *(int *) ptr);
12:16 sergot printf("nativecast: %d -> %d\n", ptr+1, *(int *) ptr+1);
12:16 sergot printf("nativecast: %d -> %d\n", ptr+2, *(int *) ptr+2);
12:17 sergot and this in at_pos:
12:17 sergot
12:17 sergot printf("at_pos: %d -> %d\n", ptr, *(int *)ptr);
12:18 sergot What's your output?
12:18 FROGGS you mix up precedence
12:18 FROGGS it should be: printf("nativecast: %d -> %d\n", (int *)ptr + 1, *(int *)ptr + 1);
12:19 FROGGS or even: printf("nativecast: %d -> %d\n", ((int *)ptr) + 1, *((int *)ptr + 1));
12:19 FROGGS because that is what happens
12:20 FROGGS first the cast to an int-pointer of certain size happens, than you move it by one
12:21 FROGGS *by one means of element of that size
12:22 FROGGS so in fact you are moving it by sizeof(int)
12:22 FROGGS so do that:
12:22 FROGGS printf("nativecast: %d -> %d\n", (int *) ptr, *(int *) ptr);
12:22 FROGGS printf("nativecast: %d -> %d\n", (int *) ptr+1, *(int *) ptr+1);
12:22 FROGGS printf("nativecast: %d -> %d\n", (int *) ptr+2, *(int *) ptr+2);
12:23 FROGGS you'll see it makes a difference
12:23 sergot printf("nativecast: %d -> %d\n", (int *) ptr, *(int *) ptr);
12:23 sergot printf("nativecast: %d -> %d\n", (int *) ptr + 1, *(int *) ptr + 1);
12:23 sergot printf("nativecast: %d -> %d\n", (int *) ptr + 2, *(int *) ptr + 2);
12:24 sergot compiling it
12:24 sergot ok, now I see
12:24 sergot nativecast: 208006880 -> 1
12:24 sergot nativecast: 208006884 -> 2
12:24 sergot nativecast: 208006888 -> 3
12:24 FROGGS yeah
12:24 sergot at_pos: 208006880 -> 1
12:24 sergot at_pos: 208006881 -> 33554432
12:24 sergot at_pos: 208006882 -> 131072
12:24 FROGGS and in CArray it is just one byte each
12:25 sergot yeeeaaah... Now I understand
12:25 FROGGS which means that repr_data->elem_size must be 1 in here:
12:25 FROGGS void              *ptr       = ((char *)body->storage) + index * repr_data->elem_size;
12:25 FROGGS and 1 seems to be wrong because we have an array in C with int elements, which take four bytes
12:26 sergot yes
12:27 FROGGS and this repr_data in at_pos comes from our SELF.at_pos so it is stored in SELF
12:27 FROGGS this SELF is our $carray of course
12:27 sergot ok
12:27 FROGGS because we are doing $carray[2] for example
12:27 FROGGS so....
12:27 FROGGS what is $carray again?
12:28 FROGGS I mean, how it is declared?
12:29 sergot yaaaay!
12:29 sergot it should be CArray[int32] there!
12:29 sergot not uint8
12:29 FROGGS \o/
12:29 FROGGS either that or the C code should use char's or so, in case we really want to test that
12:31 sergot yeesss... uff
12:31 FROGGS this little thingy took quite some time to spot, ehh?
12:31 sergot Did it take so long for you to get into the moarvm?
12:32 FROGGS longer
12:32 sergot yes.. probably you did this a long time ago
12:32 sergot You probably hadn't so awesome mentor :)
12:32 FROGGS well, moarvm is pretty new... and I'm just here since october 2012
12:33 FROGGS I am more the guy that tries to solve things on its own...
12:33 FROGGS and I had more time
12:33 FROGGS the first two bugs I ran into and that I had to fix to continue with my stuff took more than one month each
12:33 FROGGS just to have a 20 lines patch at the end
12:34 FROGGS you don't have months of course right now
12:35 FROGGS and I've never studied CS, so object representations and other stuff were kind of hard for me to get into
12:35 sergot unfortunately I dont have so much time
12:35 FROGGS exactly
12:36 sergot that's why I'm so much grateful to you for your help.
12:36 sergot :)
12:36 FROGGS that's why we are finishing this nativecast thingy as early as possible so that you can work on openssl
12:36 FROGGS I'll port it to parrot and jvm for example, because this task will be painful
12:36 FROGGS :o)
12:37 sergot openssl you mean?
12:37 FROGGS yes
12:37 FROGGS no
12:37 FROGGS nativecast
12:37 sergot ok :)
12:37 FROGGS your openssl bindings will just work on all backends I guess
12:38 sergot anyway, I'm curious how you will port it :)
12:39 sergot so, will be great if you send me commits etc.
12:39 sergot yeah.. we're done with 1. \o/
12:39 sergot a little break and I'll start coding sub nativecast.
12:40 FROGGS look at how I added get_int/set_int for all backends:
12:40 FROGGS https://github.com/MoarVM/MoarVM/commit/6b458f7e55a2ed5886f16b3101c7919cdb40a602
12:40 sergot any hints before I start?
12:40 FROGGS https://github.com/perl6/nqp/commit/816b28176ad71ce072705cfe83753c4341bf0a3c
12:40 FROGGS https://github.com/perl6/nqp/commit/61dbd666f5de712ac58ef996729ffeb7e5e3cb8f
12:41 FROGGS just make it a sub, check for definedness of the return value, and box according if it is an instance
12:41 sergot I dont understand the jvm part at all :D
12:41 FROGGS yeah, that is really weird
12:42 FROGGS when you get used to the 6model object system and representations you'll know what it does
12:45 sergot ok :)
12:47 sergot What should be the correct name of 'obj' (the third argument) in nativecall_cast, btw ?
12:48 FROGGS pointer or memory-address
12:53 sergot ok :)
12:54 sergot I have a question
12:54 FROGGS or call it $source and the other one $target-type... I guess that is the most clear thing that you can do
12:55 sergot how can I check if it's a type object or an instance? or even - where should I search for the answer? :)
12:59 FROGGS well, if it is not an instance of its class but the class itself the it is just not 'defined'
13:05 sergot hmmm, ok
13:05 sergot then I should check if its num or int, right?
13:05 sergot to run unbox_{i,n}
13:05 FROGGS yes
13:07 sergot and we dont want to unbox CArray, CStruct etc
13:07 FROGGS you mean box
13:07 sergot mmm, yes
13:07 FROGGS p6box_* even
13:07 FROGGS yes, there is only p6box_{int,num,str}
13:07 sergot true
13:08 FROGGS and you use these only on native types and only if the result is defined
13:08 FROGGS you can use nqp::objprimspec for this
13:09 sergot what does it return ?
13:09 sergot 0 and 1?
13:09 FROGGS or 2 or 3
13:10 FROGGS 0 means it is an p6opaque or something else
13:10 FROGGS 1, 2, 3 mean native int/num/str (probably not in that order)
13:10 sergot ok
13:10 sergot :)
13:10 FROGGS you can also use nqp::isstr nqp::isnum and nqp::isint
13:11 FROGGS these return 0/1
13:14 sergot FROGGS: https://github.com/sergot/zavolaj/commit/e3dd337f84b3af677d99cfca63af5756741ab5bf
13:14 sergot what do you think?
13:14 sergot it passes all tests
13:14 sergot \oo/
13:14 FROGGS sergot: don't kuddle the else, but except for that it looks good :o)
13:15 sergot which one?
13:15 FROGGS that's the styleguide for this file:
13:15 FROGGS https://github.com/sergot/zavolaj/blob/e3dd337f84b3af677d99cfca63af5756741ab5bf/lib/NativeCall.pm6#L27
13:16 sergot it doesnt work without the first else
13:16 sergot it fails on CArray, CStruct then
13:17 sergot ymm, and on str
13:17 sergot we dont need the second one, okay
13:17 sergot :)
13:18 sergot https://github.com/sergot/zavolaj/commit/541c945795c7691c84bc15533827c1cc3b8a10b0
13:19 sergot ohhh, you meant cuddle
13:19 sergot didnt you? :)
13:19 FROGGS sergot: a kuddled else is about code formatting... "} else {" vs "}\nelse {"
13:19 FROGGS yes :o)
13:20 sergot okkkkk :)
13:20 sergot ok, done then! :)
13:20 sergot \o/
13:20 FROGGS and don't make it multi unless there is a reason for doing so
13:20 sergot now, we need one more test, for CPointer
13:21 FROGGS the multi refresh() seems like a copy&pasto
13:21 FROGGS sems to be a*
13:21 FROGGS seems*
13:21 FROGGS dang
13:21 sergot ok, that's why I wrote multi there, because of refresh above
13:22 sergot is expression "casting something works" correct?
13:22 FROGGS hmmm, I do not quite understand it :o)
13:23 FROGGS ahh, you forgot about p6box_s I think
13:23 sergot ok 1 - casting array works
13:23 sergot no no
13:23 sergot I meant just the msg
13:23 sergot 'casting to' or just 'casting'?
13:23 sergot s/expression/sentence/
13:24 FROGGS ok 1 - Casting int* to CArray[uint32]  ?
13:24 sergot ok :)
13:32 sergot Another question
13:32 sergot what should we do with:
13:32 sergot //            case MVM_NATIVECALL_ARG_VOID:
13:32 sergot and
13:32 sergot //            case MVM_NATIVECALL_ARG_CALLBACK:
13:34 FROGGS void will not happen
13:34 FROGGS because we cannot call nativecast with the first arg being void
13:34 FROGGS and I'd just throw an exception for the callback case
13:35 FROGGS "Don't know how to cast a C function pointer to a Perl 6 subroutine yet"
13:35 FROGGS or even without the 'Perl 6'
13:36 FROGGS or.... remove these two cases
13:36 FROGGS it will die at the end in these cases
13:36 sergot ok :)
13:36 FROGGS just change this message to something useful: "Internal error: unhandled dyncall return type"
13:37 sergot 21 class NICE is repr('CPointer') {
13:37 sergot 22 }
13:37 sergot 23 ok nativecast(NICE, ReturnInt()) ~~ NICE, 'casting to CPointer';
13:37 sergot is this test correct?
13:37 sergot or we should check something more?
13:38 FROGGS except for the misleading ReturnInt() sub it looks valid
13:38 FROGGS you can check if it is defined also
13:39 sergot why misleading? cant we use it ?
13:39 FROGGS why should ReturnInt ever return something that can be casted to class NICE?
13:39 sergot we can use every function which returns a pointer, I thought
13:40 FROGGS and why is this class a CPointer and not a CStruct?
13:40 sergot because a wanted to test casting to CPointer, we already have the CStruct one
13:40 sergot I wanted*
13:40 FROGGS sergot: when a function returns a pointer to a single int, you cannot unpack its memory to a bigger structure without segfaulting
13:42 sergot do we ever cast to CPointer?
13:42 FROGGS probably
13:42 FROGGS but not like that
13:43 sergot how then?
13:43 FROGGS hold on, I'm on the phone
13:44 sergot okok :)
13:46 sergot I started cleaning btw: https://github.com/sergot/MoarVM/blob/master/src/core/nativecall.c#L755, removed debug line, comments, changed names
13:49 FROGGS about the CPointer... I would create a class that inherits from OpaquePointer
13:49 FROGGS and cast into that, then check if it still does the right thing
13:58 sergot hmmm ,ok :)
14:09 FROGGS sergot: btw, we should use this at the very top of our function: https://github.com/sergot/MoarVM/blob/master/src/core/nativecall.c#L266
14:10 FROGGS and assign the returned pointer to cpointer_body
14:11 FROGGS then we can strip line 759 to 762
14:11 FROGGS but we should throw an exception when somebody trieds to cast a NULL pointer
14:12 FROGGS or better we also return ttarget_type
14:12 FROGGS by stripping 'IS_CONCRETE' in line 764
14:29 sergot ok :)
14:40 sergot FROGGS: then I have to change every cpointer_body->ptr to cpointer-body, am I right?
14:40 sergot because unmarshall_cpointer returns a pointer, not the body
14:42 sergot Yes
14:42 sergot I'm right :)
14:44 sergot https://github.com/sergot/MoarVM/commit/a17885b835a55ec0510720cc4c7675382bd4b436
14:51 FROGGS yes, looks good I think
14:51 FROGGS of course you could but the decl and assignment of cpointer_body into one line
14:52 sergot yes, will do
14:52 sergot FROGGS: does this make sense? : https://github.com/sergot/zavolaj/commit/22da8b15b8ba6edf4da3e301fb0eb20166b9a6d2
14:53 FROGGS sergot: yes
14:54 sergot \o/
14:54 FROGGS also, you can remove that MVMROOT because source is not used anymore: https://github.com/sergot/MoarVM/blob/master/src/core/nativecall.c#L764
14:54 sergot true
14:54 sergot thanks
14:55 FROGGS you can get rid of this line also: https://github.com/sergot/MoarVM/blob/master/src/core/nativecall.c#L843
14:56 sergot even twice
14:57 FROGGS ahh, true
14:57 sergot better write }\n else* { or just } else * { ?
14:57 FROGGS ohh yes please
14:57 FROGGS :D
14:57 sergot ok :)
15:00 sergot hmmm
15:00 sergot We're almost done.
15:01 sergot I think
15:01 FROGGS yes
15:01 FROGGS ohh, this wants doing then: https://github.com/sergot/MoarVM/blob/master/src/core/nativecall.c#L840
15:02 FROGGS but that is also something I can do after it got applied
15:02 sergot what do you mean?
15:02 FROGGS MVM_NATIVECALL_ARG_UTF8STR
15:02 sergot oohh, ok :)
15:02 FROGGS we need to care about other encodings
15:02 sergot Ok, so I'll prepare pull requests today
15:03 sergot have to go now, will do this soon
15:03 sergot thank you very very much FROGGS for your help! :)
15:03 sergot afk&
15:03 FROGGS yes, please squish all commints into a single commit with a good msg
15:03 FROGGS have fun :o)
15:13 sergot what is your idea about this encoding stuff?
15:13 FROGGS query target_type
15:13 FROGGS but we can talk about that later
15:14 sergot ok :-)
15:36 FROGGS[mobile] joined #perl6-lwp-gsoc
17:40 FROGGS joined #perl6-lwp-gsoc
17:46 sergot Im back
17:46 sergot :)
17:47 FROGGS me too
18:10 sergot FROGGS: is this commit message for moar ok?
18:10 sergot 1 MVM_nativecall_cast added
18:10 sergot 2
18:10 sergot 3 MVM_nativecall_cast has been added which provides casting an
18:10 sergot 4 OpaquePointer to any type we want.
18:10 sergot or should I write something more?
18:11 FROGGS yes, describe a bit more without repeating the first line perhaps
18:12 FROGGS I like to state why I add something... for nativecast it is about unpacking things conditionally
18:12 sergot Ok
18:12 FROGGS also see https://github.com/jnthn/zavolaj/issues/13
18:13 sergot oh
18:13 sergot that's what we did
18:14 FROGGS it is :o)
18:16 sergot Sep 4, 2012 :D
18:16 sergot almost 2 years
18:16 sergot :)
18:17 FROGGS ohh, I thought I joined a month later *g*
18:18 sergot :)
18:19 sergot anyway, it's really hard to describe this change :D
18:20 FROGGS take your time
18:20 FROGGS ahh, did you squish all commits into one?
18:20 sergot yes
18:20 sergot :)
18:20 FROGGS sergot++
18:20 sergot 12 commits
18:20 FROGGS not bad
18:22 sergot https://github.com/sergot/MoarVM/commit/37263f65d83a9803f03ccedd3ce02cac6da5ae31
18:23 sergot looks nice for me :)
18:23 FROGGS well... it is okay I guess :o)
18:24 sergot \o/
18:24 FROGGS well, then, create that PR and we'll see
18:36 sergot https://github.com/sergot/zavolaj/commit/0ee3c6ce04d54110b84b0bace1ddb6d8e8f6e3b5
18:36 sergot https://github.com/MoarVM/MoarVM/pull/110
18:37 sergot https://github.com/jnthn/zavolaj/pull/45
18:39 sergot FROGGS: thank you very much again! :)
18:40 FROGGS :o)
18:41 sergot So, we can get back to openssl soon :)
18:41 sergot Or, do we want to think about the other thing? Something with casting functions to subroutines
18:42 sergot casting is not the right word here
18:42 sergot agrh, I forgot about adding  FROGGS++ to the commit message...
18:43 FROGGS sergot: no problem, I had enough karma the last days :o)
18:44 FROGGS we should start openssl as soon a possible
18:47 sergot true
18:47 sergot ok :)
18:53 dalek openssl: ca3c517 | sergot++ | test.p6:
18:53 dalek openssl: reset nativecast tests
18:53 dalek openssl: review: https://github.com/sergot/openssl/commit/ca3c5172eb
19:27 FROGGS sergot: you also need to make a PR for nqp
19:29 sergot FROGGS: oh, right...
19:31 sergot I must add 2477 QAST::MASTOperations.add_core_moarop_mapping('nativecast', 'nativecall_cast');
19:31 sergot that's the only thing here, right
19:31 sergot ?
19:31 FROGGS +QAST::MASTOperations.add_core_moarop_mapping('nativecast', 'nativecallcast');
19:31 FROGGS without the underscore it seems
19:32 sergot aaa, yes :)
19:33 sergot I have the commit bit, but PR is a better solution here I think
19:37 sergot https://github.com/perl6/nqp/pull/172
19:42 FROGGS true
20:48 dalek joined #perl6-lwp-gsoc

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