Skip to content

Commit

Permalink
Use the NativeCall repr's new get_int to avoid redundancy
Browse files Browse the repository at this point in the history
Keeping the setup state in an attribute is redundant, since at the VM level we
know perfectly well, if the native call site was initialized or not. Even more
the latter may change due to repossession. Avoid any discrepancies by just
asking the VM for the state instead of keeping track of it ourselves.
  • Loading branch information
niner committed Oct 13, 2019
1 parent 26696e4 commit 9ef7a7e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions lib/NativeCall.pm6
Expand Up @@ -256,8 +256,6 @@ my Lock $setup-lock .= new;
# This role is mixed in to any routine that is marked as being a
# native call.
our role Native[Routine $r, $libname where Str|Callable|List|IO::Path|Distribution::Resource] {
has int $!setup;
has int $!precomp-setup;
has native_callsite $!call is box_target;
has Mu $!rettype;
has $!cpp-name-mangler;
Expand All @@ -270,7 +268,8 @@ our role Native[Routine $r, $libname where Str|Callable|List|IO::Path|Distributi

method !setup() {
$setup-lock.protect: {
return if $!setup || $*W && $*W.is_precompilation_mode && $!precomp-setup;
return if nqp::unbox_i($!call);

# Make sure that C++ methods are treated as mangled (unless set otherwise)
if self.package.REPR eq 'CPPStruct' and not self.does(NativeCallMangled) {
self does NativeCallMangled[True];
Expand Down Expand Up @@ -309,7 +308,6 @@ our role Native[Routine $r, $libname where Str|Callable|List|IO::Path|Distributi
nqp::null());
}

($*W && $*W.is_precompilation_mode ?? $!precomp-setup !! $!setup) = $jitted ?? 2 !! 1;
}
}

Expand Down Expand Up @@ -573,7 +571,7 @@ our role Native[Routine $r, $libname where Str|Callable|List|IO::Path|Distributi
or $!is-clone # Clones and original would share the invokespec but not the $!do attribute
or $!any-optionals # the compiled code doesn't support optional parameters yet
or $*W; # Avoid issues with compiling specialized version during BEGIN time
self!setup() unless $!setup;
self!setup() unless nqp::unbox_i($!call);

my Mu $args := nqp::getattr(nqp::decont(args), Capture, '@!list');
self!arity-error(args) if nqp::elems($args) != $!arity;
Expand Down
2 changes: 1 addition & 1 deletion tools/templates/NQP_REVISION
@@ -1 +1 @@
2019.07.1-138-g393eb9687
2019.07.1-145-g47af9d8a9

0 comments on commit 9ef7a7e

Please sign in to comment.