| Filename | /Users/ap13/perl5/lib/perl5/darwin-2level/Class/MOP/Method/Meta.pm |
| Statements | Executed 943 statements in 5.19ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 44 | 2 | 2 | 1.04ms | 14.6ms | Class::MOP::Method::Meta::wrap |
| 44 | 1 | 1 | 342µs | 398µs | Class::MOP::Method::Meta::_generate_meta_method |
| 1 | 1 | 1 | 15µs | 2.14ms | Class::MOP::Method::Meta::BEGIN@12 |
| 1 | 1 | 1 | 13µs | 25µs | Class::MOP::Method::Meta::BEGIN@4 |
| 1 | 1 | 1 | 9µs | 60µs | Class::MOP::Method::Meta::BEGIN@10 |
| 1 | 1 | 1 | 8µs | 33µs | Class::MOP::Method::Meta::BEGIN@7 |
| 1 | 1 | 1 | 8µs | 12µs | Class::MOP::Method::Meta::BEGIN@5 |
| 1 | 1 | 1 | 7µs | 33µs | Class::MOP::Method::Meta::BEGIN@8 |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Meta::__ANON__[:43] |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Meta::_is_caller_mop_internal |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Method::Meta::_make_compatible_with |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Class::MOP::Method::Meta; | ||||
| 2 | 1 | 1µs | our $VERSION = '2.1403'; | ||
| 3 | |||||
| 4 | 2 | 22µs | 2 | 38µs | # spent 25µs (13+12) within Class::MOP::Method::Meta::BEGIN@4 which was called:
# once (13µs+12µs) by Class::MOP::Mixin::HasMethods::BEGIN@7 at line 4 # spent 25µs making 1 call to Class::MOP::Method::Meta::BEGIN@4
# spent 12µs making 1 call to strict::import |
| 5 | 2 | 23µs | 2 | 15µs | # spent 12µs (8+4) within Class::MOP::Method::Meta::BEGIN@5 which was called:
# once (8µs+4µs) by Class::MOP::Mixin::HasMethods::BEGIN@7 at line 5 # spent 12µs making 1 call to Class::MOP::Method::Meta::BEGIN@5
# spent 4µs making 1 call to warnings::import |
| 6 | |||||
| 7 | 2 | 26µs | 2 | 58µs | # spent 33µs (8+25) within Class::MOP::Method::Meta::BEGIN@7 which was called:
# once (8µs+25µs) by Class::MOP::Mixin::HasMethods::BEGIN@7 at line 7 # spent 33µs making 1 call to Class::MOP::Method::Meta::BEGIN@7
# spent 25µs making 1 call to Exporter::import |
| 8 | 2 | 31µs | 2 | 58µs | # spent 33µs (7+25) within Class::MOP::Method::Meta::BEGIN@8 which was called:
# once (7µs+25µs) by Class::MOP::Mixin::HasMethods::BEGIN@7 at line 8 # spent 33µs making 1 call to Class::MOP::Method::Meta::BEGIN@8
# spent 25µs making 1 call to Exporter::import |
| 9 | |||||
| 10 | 2 | 28µs | 2 | 110µs | # spent 60µs (9+50) within Class::MOP::Method::Meta::BEGIN@10 which was called:
# once (9µs+50µs) by Class::MOP::Mixin::HasMethods::BEGIN@7 at line 10 # spent 60µs making 1 call to Class::MOP::Method::Meta::BEGIN@10
# spent 50µs making 1 call to constant::import |
| 11 | |||||
| 12 | 2 | 505µs | 2 | 4.27ms | # spent 2.14ms (15µs+2.13) within Class::MOP::Method::Meta::BEGIN@12 which was called:
# once (15µs+2.13ms) by Class::MOP::Mixin::HasMethods::BEGIN@7 at line 12 # spent 2.14ms making 1 call to Class::MOP::Method::Meta::BEGIN@12
# spent 2.13ms making 1 call to parent::import |
| 13 | |||||
| 14 | sub _is_caller_mop_internal { | ||||
| 15 | my $self = shift; | ||||
| 16 | my ($caller) = @_; | ||||
| 17 | return $caller =~ /^(?:Class::MOP|metaclass)(?:::|$)/; | ||||
| 18 | } | ||||
| 19 | |||||
| 20 | # spent 398µs (342+56) within Class::MOP::Method::Meta::_generate_meta_method which was called 44 times, avg 9µs/call:
# 44 times (342µs+56µs) by Class::MOP::Method::Meta::wrap at line 57, avg 9µs/call | ||||
| 21 | 44 | 26µs | my $method_self = shift; | ||
| 22 | 44 | 12µs | my $metaclass = shift; | ||
| 23 | 44 | 155µs | 44 | 56µs | weaken($metaclass); # spent 56µs making 44 calls to Scalar::Util::weaken, avg 1µs/call |
| 24 | |||||
| 25 | sub { | ||||
| 26 | # this will be compiled out if the env var wasn't set | ||||
| 27 | if (DEBUG_NO_META) { | ||||
| 28 | confess "'meta' method called by MOP internals" | ||||
| 29 | # it's okay to call meta methods on metaclasses, since we | ||||
| 30 | # explicitly ask for them | ||||
| 31 | if !$_[0]->isa('Class::MOP::Object') | ||||
| 32 | && !$_[0]->isa('Class::MOP::Mixin') | ||||
| 33 | # it's okay if the test itself calls ->meta, we only care about | ||||
| 34 | # if the mop internals call ->meta | ||||
| 35 | && $method_self->_is_caller_mop_internal(scalar caller); | ||||
| 36 | } | ||||
| 37 | # we must re-initialize so that it | ||||
| 38 | # works as expected in subclasses, | ||||
| 39 | # since metaclass instances are | ||||
| 40 | # singletons, this is not really a | ||||
| 41 | # big deal anyway. | ||||
| 42 | 445 | 3.19ms | 890 | 6.74ms | $metaclass->initialize(blessed($_[0]) || $_[0]) # spent 6.51ms making 445 calls to Class::MOP::Class::initialize, avg 15µs/call, recursion: max depth 1, sum of overlapping time 102µs
# spent 328µs making 445 calls to Scalar::Util::blessed, avg 736ns/call |
| 43 | 44 | 223µs | }; | ||
| 44 | } | ||||
| 45 | |||||
| 46 | # spent 14.6ms (1.04+13.5) within Class::MOP::Method::Meta::wrap which was called 44 times, avg 332µs/call:
# 23 times (500µs+6.09ms) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 24 of Class/MOP/Mixin/HasMethods.pm, avg 287µs/call
# 21 times (544µs+7.46ms) by Moose::Meta::Method::Meta::wrap at line 20 of Moose/Meta/Method/Meta.pm, avg 381µs/call | ||||
| 47 | 44 | 107µs | my ($class, @args) = @_; | ||
| 48 | |||||
| 49 | 44 | 30µs | unshift @args, 'body' if @args % 2 == 1; | ||
| 50 | 44 | 85µs | my %params = @args; | ||
| 51 | 44 | 20µs | $class->_throw_exception( CannotOverrideBodyOfMetaMethods => params => \%params, | ||
| 52 | class => $class | ||||
| 53 | ) | ||||
| 54 | if $params{body}; | ||||
| 55 | |||||
| 56 | 44 | 91µs | 44 | 569µs | my $metaclass_class = $params{associated_metaclass}->meta; # spent 499µs making 40 calls to Class::MOP::Object::meta, avg 12µs/call
# spent 55µs making 3 calls to Moose::Meta::Role::meta, avg 18µs/call
# spent 15µs making 1 call to Class::MOP::Mixin::meta |
| 57 | 44 | 179µs | 44 | 398µs | $params{body} = $class->_generate_meta_method($metaclass_class); # spent 398µs making 44 calls to Class::MOP::Method::Meta::_generate_meta_method, avg 9µs/call |
| 58 | 44 | 421µs | 44 | 12.6ms | return $class->SUPER::wrap(%params); # spent 12.6ms making 44 calls to Class::MOP::Method::wrap, avg 286µs/call |
| 59 | } | ||||
| 60 | |||||
| 61 | sub _make_compatible_with { | ||||
| 62 | my $self = shift; | ||||
| 63 | my ($other) = @_; | ||||
| 64 | |||||
| 65 | # XXX: this is pretty gross. the issue here is that CMOP::Method::Meta | ||||
| 66 | # objects are subclasses of CMOP::Method, but when we get to moose, they'll | ||||
| 67 | # need to be compatible with Moose::Meta::Method, which isn't possible. the | ||||
| 68 | # right solution here is to make ::Meta into a role that gets applied to | ||||
| 69 | # whatever the method_metaclass happens to be and get rid of | ||||
| 70 | # _meta_method_metaclass entirely, but that's not going to happen until | ||||
| 71 | # we ditch cmop and get roles into the bootstrapping, so. i'm not | ||||
| 72 | # maintaining the previous behavior of turning them into instances of the | ||||
| 73 | # new method_metaclass because that's equally broken, and at least this way | ||||
| 74 | # any issues will at least be detectable and potentially fixable. -doy | ||||
| 75 | return $self unless $other->_is_compatible_with($self->_real_ref_name); | ||||
| 76 | |||||
| 77 | return $self->SUPER::_make_compatible_with(@_); | ||||
| 78 | } | ||||
| 79 | |||||
| 80 | 1 | 5µs | 1; | ||
| 81 | |||||
| 82 | # ABSTRACT: Method Meta Object for C<meta> methods | ||||
| 83 | |||||
| 84 | __END__ |