Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement metmodel transparency of nominalizables (#4058)
As a matter of fact, a nominalizable is a wrapper around a nominal or another nominalizable. As such, it makes sense to have their MOP classes transparent, similar to how their typeobjects are transparent down to the final nominal type. I.e., it means that for role R[::T] { my subset RS of T; method foo(RS() $v) {...} } `RS().HOW.archetypes.generic` should be true at the compile time because `RS` wraps a generic. Similarly, `RS` would have it's `coercive` archetype set would it be declared as `my subset RS of T()`. The transparency lets the compiler and runtime to make sure no nominalization is missed no matter how deep they're nested into each other. In particular, it makes the sample above possible in theory. Though in practice implementing it is yet too complicated task impractical in the light of the upcoming RakuAST implementation. A new metmodel role `Perl6::Metamodel::Nominalizable` is introduced which provides basic common functionality of nominalizables. In particular, it implements `.^wrappee` method which allows to fetch necessary nominalization from the nesting. `RS.^wrappee(:coercion)` would return `T()` for the latter `RS` example. Correspondingly, `RS().^wrappee(:subset)` would result in `RS` itself. Implemented `instantiate_generic` for `Metamodel::SubsetHOW`. Implemented partial support of the new transparency in `Actions.nqp`. Improved the performance of the new binding code by replacing a call to `coercive` method on a parameter object with `nqp::getattr` and `nqp::bitand_i` pair. This brings the overall rakudo performance almost on a par with v2020.10 with euler script, as mentioned in #4056. In my tests the script is just 3% slower with `time raku euler-10.p6`. The whitenoise script, mentioned in the same ticket, is 55% faster than PR #4059, and 2.1x times faster than v2020.11. Unfortunately, it's still 4.5 times slower than with v2020.10. But I hope that inlinable `nqp::curcode` would resolve this too.
- Loading branch information
Showing
8 changed files
with
250 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.