Perl 6 - the future is here, just unevenly distributed

IRC log for #moarvm, 2015-02-08

| Channels | #moarvm index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
00:02 colomon joined #moarvm
02:40 colomon joined #moarvm
02:47 ilbot3 joined #moarvm
02:47 Topic for #moarvm is now https://github.com/moarvm/moarvm | IRC logs at  http://irclog.perlgeek.de/moarvm/today
03:24 camelia joined #moarvm
05:45 vendethiel joined #moarvm
06:47 japhb joined #moarvm
07:17 japhb joined #moarvm
09:58 rurban__ joined #moarvm
10:33 tgt joined #moarvm
11:26 dalek MoarVM/native-ref: 86bf121 | jnthn++ | src/6model/reprs/P6opaque.c:
11:26 dalek MoarVM/native-ref: Liberalize mixin prefix test in P6opaque.
11:26 dalek MoarVM/native-ref:
11:26 dalek MoarVM/native-ref: Up to the point we hit the first attribute-contributing class, we can
11:26 dalek MoarVM/native-ref: skip the checking. This makes the Perl 6 MOP re-parenting not break
11:26 dalek MoarVM/native-ref: the ability to mix in to meta-objects.
11:26 dalek MoarVM/native-ref: review: https://github.com/MoarVM/MoarVM/commit/86bf121857
12:03 mj41 joined #moarvm
13:04 colomon joined #moarvm
13:21 rurban__ joined #moarvm
13:55 colomon joined #moarvm
15:22 zakharyas joined #moarvm
16:11 FROGGS perl6-m -MNativeCall -e 'sub PolygonShape_Set_ZN14b2PolygonShape3SetEPK6b2Vec2i(OpaquePointer, int32) is native("libBox2D") { * }; _ZN14b2PolygonShape3SetEPK6b2Vec2i(OpaquePointer, 0)'
16:11 FROGGS moar: /build/buildd/box2d-2.3.0+ds/Box2D/Box2D/Collision/Shapes/b2PolygonShape.cpp:122: void b2PolygonShape::Set(const b2Vec2*, int32): Assertion `3 <= count && count <= 8' failed.
16:11 FROGGS I find that quite encouraging
16:12 FROGGS ohh, I pasted the subname wrong, it is called like in the actual call
16:17 FROGGS I guess I have to use the thiscall calling convention here?
16:20 FROGGS hmm no, seems not
17:08 FROGGS "All mangled symbols begin with _Z (note that an underscore followed by a capital is a reserved identifier in C, so conflict with user identifiers is avoided); for nested names (including both namespaces and classes), this is followed by N, then a series of <length, id> pairs (the length being the length of the next identifier), and finally E."
17:09 FROGGS that seems to agree with this example: _ZN14b2PolygonShape3SetEPK6b2Vec2i
17:09 FROGGS sort of
17:10 mj41 joined #moarvm
17:10 FROGGS _ZN 14b2PolygonShape 3Set E PK 6b2Vec2 i
17:14 FROGGS m: sub foo::bar() { 42 }; say foo::bar
17:14 camelia rakudo-moar d9f58f: OUTPUT«Could not find symbol '&bar'␤  in method <anon> at src/gen/m-CORE.setting:14609␤  in any find_method_fallback at src/gen/m-Metamodel.nqp:2810␤  in any find_method at src/gen/m-Metamodel.nqp:992␤  in block <unit> at /tmp/sKXHLm8vbH:1␤␤»
17:39 FROGGS a very minimal case generates the symbol correctly: https://gist.github.com/FROGGS/7c8180851f3b89821631
17:42 FROGGS[mobile] joined #moarvm
18:28 timotimo is that the gcc specific mangling or something?
18:40 FROGGS[mobile] joined #moarvm
18:47 FROGGS timotimo: http://en.wikipedia.org/wiki/Name_mangling#How_different_compilers_mangle_the_same_functions
18:47 FROGGS must be g++ on an ubuntu machine I think
18:48 dalek MoarVM/native-ref: 71fd576 | jnthn++ | src/ (3 files):
18:48 dalek MoarVM/native-ref: Implement iscont_[ins].
18:48 dalek MoarVM/native-ref: review: https://github.com/MoarVM/MoarVM/commit/71fd57665e
18:51 rurban__ joined #moarvm
19:46 FROGGS I guess in b2PolygonShape::Set(b2Vec2 const*, int), which is `thiscall`, I need to pass the "THIS" as the first arg?
19:48 * jnthn has really no idea, sorry :(
19:48 jnthn Also, wtf: "Spesh inline: unhandled arg instruction"
19:49 FROGGS O.o
19:56 jnthn Seems it might be a constant named arg that triggers it.
20:09 jnthn Ah, no
20:11 FROGGS 0000000000000000 T _ZN7b2WorldC1ERK6b2Vec2
20:11 FROGGS 0000000000000110 T _ZN7b2WorldD1Ev
20:11 FROGGS the first is a constructor, the latter a destructor btw
20:11 FROGGS ("C" vs "D")
20:14 jnthn eek
20:14 jnthn Such mangle...
20:14 FROGGS I enjoy it :o)
20:17 dalek MoarVM/native-ref: 679d06f | jnthn++ | src/spesh/inline.c:
20:17 dalek MoarVM/native-ref: Add missing inline arg count check.
20:17 dalek MoarVM/native-ref:
20:17 dalek MoarVM/native-ref: We only collect information on up to a certain number of args. Without
20:17 dalek MoarVM/native-ref: this, we try to resolve arg instructions beyond the end of the buffer,
20:17 dalek MoarVM/native-ref: which innevitably works out rather badly.
20:17 dalek MoarVM/native-ref: review: https://github.com/MoarVM/MoarVM/commit/679d06f3c4
20:17 dalek MoarVM/native-ref: b23351a | jnthn++ | src/spesh/inline.c:
20:17 dalek MoarVM/native-ref: Improve error by including unhandled op.
20:17 dalek MoarVM/native-ref: review: https://github.com/MoarVM/MoarVM/commit/b23351a7a9
20:17 dalek MoarVM/native-ref: da8fbed | jnthn++ | src/spesh/inline.c:
20:17 dalek MoarVM/native-ref: Handle argconst_ instructions in inline.
21:17 dalek MoarVM/native-ref: 0937fcb | jnthn++ | src/core/interp.c:
21:17 dalek MoarVM/native-ref: Fix order of args passed to lexical ref function.
21:17 dalek MoarVM/native-ref: review: https://github.com/MoarVM/MoarVM/commit/0937fcb2bf
21:17 dalek MoarVM/native-ref: d5ef005 | jnthn++ | src/6model/reprs/NativeRef.c:
21:17 dalek MoarVM/native-ref: Implement by-index native lexical ref support.
21:17 dalek MoarVM/native-ref: review: https://github.com/MoarVM/MoarVM/commit/d5ef0055ae
21:19 Peter_R joined #moarvm
21:20 FROGGS ahh:
21:20 FROGGS my $gravity = OpaquePointer<140737326674832>
21:20 FROGGS Program received signal SIGSEGV, Segmentation fault.
21:20 FROGGS b2World::b2World (this=0x4d36840, gravity=...) at /build/buildd/box2d-2.3.0+ds/Box2D/Box2D/Dynamics/b2World.cpp:55
21:20 FROGGS even for a constructor I have to pass THIS
21:22 jnthn ah :)
21:22 FROGGS [Inferior 1 (process 5976) exited normally] \o/
21:23 FROGGS THIS as in malloc'd to the right size (... I don't know how to calculate)
21:23 jnthn Sounds like good progress :)
21:24 FROGGS I mean, look at class World, I dunno how vtable and all these things are layed out in mem: http://box2d.googlecode.com/svn/tags/v2.3.1/Box2D/Box2D/Dynamics/b2World.h
21:29 jnthn FROGGS: Can't help but wonder if the easier way would be to write a small wrapper that exposes a C-friendly API...
21:30 jnthn Though, that would need compiling.
21:30 FROGGS jnthn: that'd mean that every user of a C++ would have to do that
21:30 FROGGS which... is not trivial
21:30 jnthn Well, if they're using C++ they're already used to pain, at least... :P
21:30 FROGGS :P
21:31 FROGGS I see how far I get, if it proves to be too hard, I'll take another route
21:31 FROGGS but atm, it is a nice project
21:34 * jnthn is curious what other languages have a C++ FFI approach that doesn't need some kind of C wrapper
21:36 FROGGS jnthn: python
21:36 FROGGS and Java probably
21:37 FROGGS you'd probably know about C#
21:37 jnthn FROGGS: http://search.cpan.org/~plicease/FFI-Platypus-Lang-CPP-0.04/lib/FFI/Platypus/Lang/CPP.pm may be of interest, fwiw
21:39 FROGGS jnthn: very nice!
21:40 FROGGS "You need to alloate the memory needed for the object before you call the constructor[...]" aye :o)
21:46 FROGGS ohh damn, it, I can call a method on my b2World instance!
21:47 timotimo <3
21:49 FROGGS this could be end up very sweet... like have native methods in a CStruct...
21:52 FROGGS so I am doing this:
21:52 FROGGS # alloc $world
21:52 FROGGS new_World($world, b2Vec2.new(x => 42e0, y => 42e0));
21:52 FROGGS World_Dump($world);
21:52 FROGGS and I get in my shell:
21:52 FROGGS b2Vec2 g(4.200000000000000e+01f, 4.200000000000000e+01f);
21:52 FROGGS m_world->SetGravity(g);
21:52 FROGGS b2Body** bodies = (b2Body**)b2Alloc(0 * sizeof(b2Body*));
21:52 FROGGS [...]
21:53 FROGGS the vector I pass to the world's constructor is the gravity
21:53 FROGGS to allocate the world I just fill a buf8 with a hundred elements :o)
21:55 FROGGS for C++ I guess we'd want to have 'is native' and 'is symbol' on class definitions too, as well as on methods
22:00 FROGGS[mobile] joined #moarvm
22:04 jnthn Not going to make it all the way to "is rw" on native params today, but got many (most, I hope) of the groundwork in place by now :)
22:04 FROGGS_ joined #moarvm
22:05 TimToady \o/ anyway :)
22:05 timotimo i'm liking it, too
22:05 * TimToady likes to see the C++ progress too
22:06 TimToady it was really strange to hear that XS doesn't support C++, since the original XS was written specifically to call into C++ code
22:06 * jnthn went through 3 different designs for integrating the native ref stuff with QAST::Var before finding one he liked. :)
22:06 TimToady and part of why P5 supported OO was to ease the mismatch with C++
22:06 timotimo jnthn: i'd rather have you try multiple different things than pull through the first thing you try even if it's not 100% to you rliking
22:10 FROGGS_ ohh, we already allow 'is native' on methods and we probably already pass self/this along
22:11 jnthn FROGGS_: I...uh...wow, that's a happy accident! o.O
22:12 timotimo methods are routines ... dunno if it know sabout the invocant?
22:12 jnthn (You're right, I think, it just wasn't actually a design consideration. :))
22:12 jnthn Well, not a concious one
22:12 jnthn I wonder if we could have a is repr('CPPClass') or so
22:13 FROGGS_ we probably need to
22:13 timotimo can the given mangling convention of a library be figured out somehow? perhaps just listing the available symbols in a library or so?
22:13 TimToady that was part of why we invented repr poly in the first place...
22:15 FROGGS_ star-m: use NativeCall; class Foo is repr<CStruct> { method malloc(int32) is native is symbol<malloc> { * } }; Foo.new.malloc(32)
22:15 camelia star-m 2015.01: OUTPUT«Unknown type Mu used in native call.␤If you want to pass a struct, be sure to use the CStruct representation.␤If you want to pass an array, be sure to use the CArray type.␤  in sub type_code_for at /home/camelia/rakudo-star-2015.01/install/languages/perl…»
22:15 FROGGS_ I could have bet that it failed differently :/
22:15 FROGGS_ like, showing that we pass self along
22:20 * jnthn is off for the night
22:20 jnthn o/
22:20 timotimo good night jnthn!
22:21 FROGGS_ gnight jnthn
22:30 japhb FROGGS_++  # Working on C++ support.
22:32 japhb Really, I can't even tell you how much that would improve things for me at $day-job, where lots of the deep infrastructure is written in C++, and SWIG is all over the place.
22:33 FROGGS_ ohh, that sounds motivating :o)
22:33 FROGGS_ m: class Foo { method bar { } }; Foo.^find_method('bar').signature.params».type.say
22:33 camelia rakudo-moar d9f58f: OUTPUT«(Foo) (Mu)␤»
22:33 FROGGS_ what's that Mu? the implicit *%?
22:34 FROGGS_ m: class Foo { method bar { } }; Foo.^find_method('bar').signature.params».name.say # :o)
22:34 camelia rakudo-moar d9f58f: OUTPUT«Nil %_␤»
22:34 FROGGS_ introspection ftw
22:34 japhb *chuckle*  Well, that's one way to find out.  :-)
22:35 * japhb <3 deep Perl 6 introspection
22:35 FROGGS_ aye
22:35 FROGGS_ :o)
22:44 timotimo areed

| Channels | #moarvm index | Today | | Search | Google Search | Plain-Text | summary