From 9ef7a7e9dd0a6baecc811faa42c1b042d8bc5452 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Sun, 13 Oct 2019 13:58:30 +0200 Subject: [PATCH] Use the NativeCall repr's new get_int to avoid redundancy 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. --- lib/NativeCall.pm6 | 8 +++----- tools/templates/NQP_REVISION | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/NativeCall.pm6 b/lib/NativeCall.pm6 index 6f7b6f213c8..c335d86c538 100644 --- a/lib/NativeCall.pm6 +++ b/lib/NativeCall.pm6 @@ -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; @@ -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]; @@ -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; } } @@ -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; diff --git a/tools/templates/NQP_REVISION b/tools/templates/NQP_REVISION index 85d5d6e2519..ebf92b9760d 100644 --- a/tools/templates/NQP_REVISION +++ b/tools/templates/NQP_REVISION @@ -1 +1 @@ -2019.07.1-138-g393eb9687 +2019.07.1-145-g47af9d8a9