Skip to content

Commit

Permalink
Fix "Object in QAST::WVal, but not in SC" for function pointers
Browse files Browse the repository at this point in the history
While adding the sub to a newly created SC is harmful in the normal case,
it's vital when dealing with function pointers return from native code as
those subs will not be added to an SC by the compiler.
  • Loading branch information
niner committed Sep 3, 2017
1 parent 502b0b1 commit 987cd98
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/NativeCall.pm6
Expand Up @@ -464,6 +464,13 @@ my role Native[Routine $r, $libname where Str|Callable|List|IO::Path|Distributio

method !create-optimized-call() {
$setup-lock.protect: {
unless nqp::defined(nqp::getobjsc(self)) {
my $sc := nqp::createsc('NativeCallSub' ~ nqp::objectid(self));
nqp::setobjsc(self, $sc);
my int $idx = nqp::scobjcount($sc);
nqp::scsetobj($sc, $idx, self);
}

my $block := $!setup == 2
?? self!create-jit-compiled-function-body($r)
!! self!create-function-body($r);
Expand Down

0 comments on commit 987cd98

Please sign in to comment.