← Index
NYTProf Performance Profile   « block view • line view • sub view »
For xt/tapper-mcp-scheduler-with-db-longrun.t
  Run on Tue May 22 17:18:39 2012
Reported on Tue May 22 17:22:35 2012

Filename/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Meta/Class.pm
StatementsExecuted 955 statements in 7.47ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1112.10ms3.01msMoose::Meta::Class::::BEGIN@28Moose::Meta::Class::BEGIN@28
6362948µs16.2msMoose::Meta::Class::::superclassesMoose::Meta::Class::superclasses (recurses: max depth 2, inclusive time 2.38ms)
2021585µs843µsMoose::Meta::Class::::_base_metaclassesMoose::Meta::Class::_base_metaclasses
111585µs820µsMoose::Meta::Class::::BEGIN@26Moose::Meta::Class::BEGIN@26
111386µs576µsMoose::Meta::Class::::BEGIN@24Moose::Meta::Class::BEGIN@24
111343µs1.92msMoose::Meta::Class::::BEGIN@23Moose::Meta::Class::BEGIN@23
111338µs597µsMoose::Meta::Class::::BEGIN@25Moose::Meta::Class::BEGIN@25
111310µs433µsMoose::Meta::Class::::BEGIN@22Moose::Meta::Class::BEGIN@22
111305µs2.92msMoose::Meta::Class::::BEGIN@21Moose::Meta::Class::BEGIN@21
911250µs1.07msMoose::Meta::Class::::_inline_create_errorMoose::Meta::Class::_inline_create_error
822240µs17.8msMoose::Meta::Class::::add_attributeMoose::Meta::Class::add_attribute
111237µs377µsMoose::Meta::Class::::BEGIN@27Moose::Meta::Class::BEGIN@27
933235µs8.97msMoose::Meta::Class::::initializeMoose::Meta::Class::initialize
411223µs1.28msMoose::Meta::Class::::excludes_roleMoose::Meta::Class::excludes_role
12011185µs185µsMoose::Meta::Class::::CORE:substMoose::Meta::Class::CORE:subst (opcode)
311130µs1.15msMoose::Meta::Class::::does_roleMoose::Meta::Class::does_role
91180µs1.18msMoose::Meta::Class::::_inline_throw_errorMoose::Meta::Class::_inline_throw_error
11174µs8.91msMoose::Meta::Class::::createMoose::Meta::Class::create
61168µs2.49msMoose::Meta::Class::::_process_attributeMoose::Meta::Class::_process_attribute
61166µs2.42msMoose::Meta::Class::::_process_new_attributeMoose::Meta::Class::_process_new_attribute
31166µs4.07msMoose::Meta::Class::::new_objectMoose::Meta::Class::new_object (recurses: max depth 1, inclusive time 216µs)
41160µs84µsMoose::Meta::Class::::add_roleMoose::Meta::Class::add_role
41159µs85µsMoose::Meta::Class::::add_role_applicationMoose::Meta::Class::add_role_application
31146µs188µsMoose::Meta::Class::::_call_all_triggersMoose::Meta::Class::_call_all_triggers
91132µs32µsMoose::Meta::Class::::__ANON__[:37]Moose::Meta::Class::__ANON__[:37]
91130µs30µsMoose::Meta::Class::::_inline_raise_errorMoose::Meta::Class::_inline_raise_error
91121µs21µsMoose::Meta::Class::::__ANON__[:43]Moose::Meta::Class::__ANON__[:43]
91118µs18µsMoose::Meta::Class::::_meta_method_classMoose::Meta::Class::_meta_method_class
1119µs9µsMoose::Meta::Class::::BEGIN@3Moose::Meta::Class::BEGIN@3
1119µs53µsMoose::Meta::Class::::BEGIN@13Moose::Meta::Class::BEGIN@13
1118µs13µsMoose::Meta::Class::::BEGIN@16Moose::Meta::Class::BEGIN@16
1118µs95µsMoose::Meta::Class::::BEGIN@31Moose::Meta::Class::BEGIN@31
1118µs8µsMoose::Meta::Class::::BEGIN@29Moose::Meta::Class::BEGIN@29
1118µs30µsMoose::Meta::Class::::BEGIN@19Moose::Meta::Class::BEGIN@19
1117µs26µsMoose::Meta::Class::::BEGIN@17Moose::Meta::Class::BEGIN@17
1117µs41µsMoose::Meta::Class::::BEGIN@18Moose::Meta::Class::BEGIN@18
1117µs30µsMoose::Meta::Class::::BEGIN@15Moose::Meta::Class::BEGIN@15
1117µs9µsMoose::Meta::Class::::BEGIN@10Moose::Meta::Class::BEGIN@10
1116µs15µsMoose::Meta::Class::::BEGIN@11Moose::Meta::Class::BEGIN@11
6116µs6µsMoose::Meta::Class::::CORE:matchMoose::Meta::Class::CORE:match (opcode)
1114µs4µsMoose::Meta::Class::::BEGIN@14Moose::Meta::Class::BEGIN@14
0000s0sMoose::Meta::Class::::__ANON__[:125]Moose::Meta::Class::__ANON__[:125]
0000s0sMoose::Meta::Class::::__ANON__[:533]Moose::Meta::Class::__ANON__[:533]
0000s0sMoose::Meta::Class::::_anon_cache_keyMoose::Meta::Class::_anon_cache_key
0000s0sMoose::Meta::Class::::_anon_package_prefixMoose::Meta::Class::_anon_package_prefix
0000s0sMoose::Meta::Class::::_eval_environmentMoose::Meta::Class::_eval_environment
0000s0sMoose::Meta::Class::::_find_next_method_by_name_which_is_not_overriddenMoose::Meta::Class::_find_next_method_by_name_which_is_not_overridden
0000s0sMoose::Meta::Class::::_fix_class_metaclass_incompatibilityMoose::Meta::Class::_fix_class_metaclass_incompatibility
0000s0sMoose::Meta::Class::::_fix_single_metaclass_incompatibilityMoose::Meta::Class::_fix_single_metaclass_incompatibility
0000s0sMoose::Meta::Class::::_fixup_attributes_after_reblessMoose::Meta::Class::_fixup_attributes_after_rebless
0000s0sMoose::Meta::Class::::_generate_fallback_constructorMoose::Meta::Class::_generate_fallback_constructor
0000s0sMoose::Meta::Class::::_immutable_optionsMoose::Meta::Class::_immutable_options
0000s0sMoose::Meta::Class::::_inline_BUILDALLMoose::Meta::Class::_inline_BUILDALL
0000s0sMoose::Meta::Class::::_inline_BUILDARGSMoose::Meta::Class::_inline_BUILDARGS
0000s0sMoose::Meta::Class::::_inline_check_required_attrMoose::Meta::Class::_inline_check_required_attr
0000s0sMoose::Meta::Class::::_inline_extra_initMoose::Meta::Class::_inline_extra_init
0000s0sMoose::Meta::Class::::_inline_init_attr_from_constructorMoose::Meta::Class::_inline_init_attr_from_constructor
0000s0sMoose::Meta::Class::::_inline_init_attr_from_defaultMoose::Meta::Class::_inline_init_attr_from_default
0000s0sMoose::Meta::Class::::_inline_paramsMoose::Meta::Class::_inline_params
0000s0sMoose::Meta::Class::::_inline_slot_initializerMoose::Meta::Class::_inline_slot_initializer
0000s0sMoose::Meta::Class::::_inline_triggersMoose::Meta::Class::_inline_triggers
0000s0sMoose::Meta::Class::::_process_inherited_attributeMoose::Meta::Class::_process_inherited_attribute
0000s0sMoose::Meta::Class::::_replace_selfMoose::Meta::Class::_replace_self
0000s0sMoose::Meta::Class::::_restore_metaobjects_fromMoose::Meta::Class::_restore_metaobjects_from
0000s0sMoose::Meta::Class::::add_augment_method_modifierMoose::Meta::Class::add_augment_method_modifier
0000s0sMoose::Meta::Class::::add_override_method_modifierMoose::Meta::Class::add_override_method_modifier
0000s0sMoose::Meta::Class::::calculate_all_rolesMoose::Meta::Class::calculate_all_roles
0000s0sMoose::Meta::Class::::calculate_all_roles_with_inheritanceMoose::Meta::Class::calculate_all_roles_with_inheritance
0000s0sMoose::Meta::Class::::create_errorMoose::Meta::Class::create_error
0000s0sMoose::Meta::Class::::raise_errorMoose::Meta::Class::raise_error
0000s0sMoose::Meta::Class::::reinitializeMoose::Meta::Class::reinitialize
0000s0sMoose::Meta::Class::::role_applicationsMoose::Meta::Class::role_applications
0000s0sMoose::Meta::Class::::throw_errorMoose::Meta::Class::throw_error
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1
2package Moose::Meta::Class;
3
# spent 9µs within Moose::Meta::Class::BEGIN@3 which was called: # once (9µs+0s) by Moose::BEGIN@28 at line 5
BEGIN {
414µs $Moose::Meta::Class::AUTHORITY = 'cpan:STEVAN';
5121µs19µs}
# spent 9µs making 1 call to Moose::Meta::Class::BEGIN@3
6{
722µs $Moose::Meta::Class::VERSION = '2.0602';
8}
9
10316µs211µs
# spent 9µs (7+2) within Moose::Meta::Class::BEGIN@10 which was called: # once (7µs+2µs) by Moose::BEGIN@28 at line 10
use strict;
# spent 9µs making 1 call to Moose::Meta::Class::BEGIN@10 # spent 2µs making 1 call to strict::import
11319µs223µs
# spent 15µs (6+8) within Moose::Meta::Class::BEGIN@11 which was called: # once (6µs+8µs) by Moose::BEGIN@28 at line 11
use warnings;
# spent 15µs making 1 call to Moose::Meta::Class::BEGIN@11 # spent 8µs making 1 call to warnings::import
12
13320µs297µs
# spent 53µs (9+44) within Moose::Meta::Class::BEGIN@13 which was called: # once (9µs+44µs) by Moose::BEGIN@28 at line 13
use Class::Load qw(load_class);
# spent 53µs making 1 call to Moose::Meta::Class::BEGIN@13 # spent 44µs making 1 call to Exporter::import
14320µs14µs
# spent 4µs within Moose::Meta::Class::BEGIN@14 which was called: # once (4µs+0s) by Moose::BEGIN@28 at line 14
use Class::MOP;
# spent 4µs making 1 call to Moose::Meta::Class::BEGIN@14
15317µs254µs
# spent 30µs (7+24) within Moose::Meta::Class::BEGIN@15 which was called: # once (7µs+24µs) by Moose::BEGIN@28 at line 15
use Carp qw( confess );
# spent 30µs making 1 call to Moose::Meta::Class::BEGIN@15 # spent 24µs making 1 call to Exporter::import
16320µs219µs
# spent 13µs (8+5) within Moose::Meta::Class::BEGIN@16 which was called: # once (8µs+5µs) by Moose::BEGIN@28 at line 16
use Data::OptList;
# spent 13µs making 1 call to Moose::Meta::Class::BEGIN@16 # spent 5µs making 1 call to Sub::Install::__ANON__[Sub/Install.pm:284]
17320µs246µs
# spent 26µs (7+20) within Moose::Meta::Class::BEGIN@17 which was called: # once (7µs+20µs) by Moose::BEGIN@28 at line 17
use List::Util qw( first );
# spent 26µs making 1 call to Moose::Meta::Class::BEGIN@17 # spent 20µs making 1 call to Exporter::import
18324µs276µs
# spent 41µs (7+34) within Moose::Meta::Class::BEGIN@18 which was called: # once (7µs+34µs) by Moose::BEGIN@28 at line 18
use List::MoreUtils qw( any all uniq first_index );
# spent 41µs making 1 call to Moose::Meta::Class::BEGIN@18 # spent 34µs making 1 call to Exporter::import
19318µs252µs
# spent 30µs (8+22) within Moose::Meta::Class::BEGIN@19 which was called: # once (8µs+22µs) by Moose::BEGIN@28 at line 19
use Scalar::Util 'blessed';
# spent 30µs making 1 call to Moose::Meta::Class::BEGIN@19 # spent 22µs making 1 call to Exporter::import
20
21398µs12.92ms
# spent 2.92ms (305µs+2.62) within Moose::Meta::Class::BEGIN@21 which was called: # once (305µs+2.62ms) by Moose::BEGIN@28 at line 21
use Moose::Meta::Method::Overridden;
# spent 2.92ms making 1 call to Moose::Meta::Class::BEGIN@21
223109µs1433µs
# spent 433µs (310+122) within Moose::Meta::Class::BEGIN@22 which was called: # once (310µs+122µs) by Moose::BEGIN@28 at line 22
use Moose::Meta::Method::Augmented;
# spent 433µs making 1 call to Moose::Meta::Class::BEGIN@22
233101µs11.92ms
# spent 1.92ms (343µs+1.58) within Moose::Meta::Class::BEGIN@23 which was called: # once (343µs+1.58ms) by Moose::BEGIN@28 at line 23
use Moose::Error::Default;
# spent 1.92ms making 1 call to Moose::Meta::Class::BEGIN@23
243127µs1576µs
# spent 576µs (386+190) within Moose::Meta::Class::BEGIN@24 which was called: # once (386µs+190µs) by Moose::BEGIN@28 at line 24
use Moose::Meta::Class::Immutable::Trait;
# spent 576µs making 1 call to Moose::Meta::Class::BEGIN@24
25385µs1597µs
# spent 597µs (338+259) within Moose::Meta::Class::BEGIN@25 which was called: # once (338µs+259µs) by Moose::BEGIN@28 at line 25
use Moose::Meta::Method::Constructor;
# spent 597µs making 1 call to Moose::Meta::Class::BEGIN@25
26381µs1820µs
# spent 820µs (585+235) within Moose::Meta::Class::BEGIN@26 which was called: # once (585µs+235µs) by Moose::BEGIN@28 at line 26
use Moose::Meta::Method::Destructor;
# spent 820µs making 1 call to Moose::Meta::Class::BEGIN@26
27379µs1377µs
# spent 377µs (237+140) within Moose::Meta::Class::BEGIN@27 which was called: # once (237µs+140µs) by Moose::BEGIN@28 at line 27
use Moose::Meta::Method::Meta;
# spent 377µs making 1 call to Moose::Meta::Class::BEGIN@27
28391µs23.14ms
# spent 3.01ms (2.10+906µs) within Moose::Meta::Class::BEGIN@28 which was called: # once (2.10ms+906µs) by Moose::BEGIN@28 at line 28
use Moose::Util;
# spent 3.01ms making 1 call to Moose::Meta::Class::BEGIN@28 # spent 129µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:756]
29323µs18µs
# spent 8µs within Moose::Meta::Class::BEGIN@29 which was called: # once (8µs+0s) by Moose::BEGIN@28 at line 29
use Class::MOP::MiniTrait;
# spent 8µs making 1 call to Moose::Meta::Class::BEGIN@29
30
3133.01ms2181µs
# spent 95µs (8+87) within Moose::Meta::Class::BEGIN@31 which was called: # once (8µs+87µs) by Moose::BEGIN@28 at line 31
use base 'Class::MOP::Class';
# spent 95µs making 1 call to Moose::Meta::Class::BEGIN@31 # spent 87µs making 1 call to base::import
32
3315µs11.68msClass::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait');
# spent 1.68ms making 1 call to Class::MOP::MiniTrait::apply
34
35__PACKAGE__->meta->add_attribute('roles' => (
36 reader => 'roles',
37941µs
# spent 32µs within Moose::Meta::Class::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Meta/Class.pm:37] which was called 9 times, avg 4µs/call: # 9 times (32µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 45 of Class/MOP/Mixin/AttributeCore.pm, avg 4µs/call
default => sub { [] },
38119µs3618µs Class::MOP::_definition_context(),
# spent 595µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 12µs making 1 call to Class::MOP::Object::meta # spent 11µs making 1 call to Class::MOP::_definition_context
39));
40
41__PACKAGE__->meta->add_attribute('role_applications' => (
42 reader => '_get_role_applications',
43930µs
# spent 21µs within Moose::Meta::Class::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Meta/Class.pm:43] which was called 9 times, avg 2µs/call: # 9 times (21µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 45 of Class/MOP/Mixin/AttributeCore.pm, avg 2µs/call
default => sub { [] },
4417µs3297µs Class::MOP::_definition_context(),
# spent 280µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 11µs making 1 call to Class::MOP::Object::meta # spent 5µs making 1 call to Class::MOP::_definition_context
45));
46
4717µs4294µs__PACKAGE__->meta->add_attribute(
# spent 262µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 18µs making 1 call to Class::MOP::Attribute::new # spent 10µs making 1 call to Class::MOP::Object::meta # spent 4µs making 1 call to Class::MOP::_definition_context
48 Class::MOP::Attribute->new('immutable_trait' => (
49 accessor => "immutable_trait",
50 default => 'Moose::Meta::Class::Immutable::Trait',
51 Class::MOP::_definition_context(),
52 ))
53);
54
5515µs3288µs__PACKAGE__->meta->add_attribute('constructor_class' => (
# spent 273µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 10µs making 1 call to Class::MOP::Object::meta # spent 5µs making 1 call to Class::MOP::_definition_context
56 accessor => 'constructor_class',
57 default => 'Moose::Meta::Method::Constructor',
58 Class::MOP::_definition_context(),
59));
60
6114µs3277µs__PACKAGE__->meta->add_attribute('destructor_class' => (
# spent 263µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 10µs making 1 call to Class::MOP::Object::meta # spent 5µs making 1 call to Class::MOP::_definition_context
62 accessor => 'destructor_class',
63 default => 'Moose::Meta::Method::Destructor',
64 Class::MOP::_definition_context(),
65));
66
6714µs3274µs__PACKAGE__->meta->add_attribute('error_class' => (
# spent 260µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 10µs making 1 call to Class::MOP::Object::meta # spent 4µs making 1 call to Class::MOP::_definition_context
68 accessor => 'error_class',
69 default => 'Moose::Error::Default',
70 Class::MOP::_definition_context(),
71));
72
73
# spent 8.97ms (235µs+8.73) within Moose::Meta::Class::initialize which was called 9 times, avg 997µs/call: # 7 times (161µs+5.81ms) by Moose::init_meta at line 196 of Moose.pm, avg 853µs/call # once (39µs+1.91ms) by Class::MOP::Package::create at line 72 of Class/MOP/Package.pm # once (35µs+1.02ms) by metaclass::import at line 48 of metaclass.pm
sub initialize {
7454230µs my $class = shift;
75 my @args = @_;
76 unshift @args, 'package' if @args % 2;
77 my %opts = @args;
78 my $package = delete $opts{package};
79188.73ms return Class::MOP::get_metaclass_by_name($package)
# spent 8.72ms making 9 calls to Class::MOP::Class::initialize, avg 969µs/call # spent 16µs making 9 calls to Class::MOP::get_metaclass_by_name, avg 2µs/call
80 || $class->SUPER::initialize($package,
81 'attribute_metaclass' => 'Moose::Meta::Attribute',
82 'method_metaclass' => 'Moose::Meta::Method',
83 'instance_metaclass' => 'Moose::Meta::Instance',
84 %opts,
85 );
86}
87
88
# spent 8.91ms (74µs+8.83) within Moose::Meta::Class::create which was called: # once (74µs+8.83ms) by MooseX::Traits::Util::new_class_with_traits at line 67 of MooseX/Traits/Util.pm
sub create {
891069µs my $class = shift;
90 my @args = @_;
91
92 unshift @args, 'package' if @args % 2 == 1;
93 my %options = @args;
94
95 (ref $options{roles} eq 'ARRAY')
96 || $class->throw_error("You must pass an ARRAY ref of roles", data => $options{roles})
97 if exists $options{roles};
98
99 my $package = delete $options{package};
100 my $roles = delete $options{roles};
101
10216.36ms my $new_meta = $class->SUPER::create($package, %options);
# spent 6.36ms making 1 call to Class::MOP::Class::create
103
10412.47ms if ($roles) {
# spent 2.47ms making 1 call to Moose::Util::apply_all_roles
105 Moose::Util::apply_all_roles( $new_meta, @$roles );
106 }
107
108 return $new_meta;
109}
110
111929µs
# spent 18µs within Moose::Meta::Class::_meta_method_class which was called 9 times, avg 2µs/call: # 9 times (18µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 33 of Class/MOP/Mixin/HasMethods.pm, avg 2µs/call
sub _meta_method_class { 'Moose::Meta::Method::Meta' }
112
113sub _anon_package_prefix { 'Moose::Meta::Class::__ANON__::SERIAL::' }
114
115sub _anon_cache_key {
116 my $class = shift;
117 my %options = @_;
118
119 my $superclass_key = join('|',
120 map { $_->[0] } @{ Data::OptList::mkopt($options{superclasses} || []) }
121 );
122
123 my $roles = Data::OptList::mkopt(($options{roles} || []), {
124 moniker => 'role',
125 val_test => sub { ref($_[0]) eq 'HASH' },
126 });
127
128 my @role_keys;
129 for my $role_spec (@$roles) {
130 my ($role, $params) = @$role_spec;
131 $params = { %$params } if $params;
132
133 my $key = blessed($role) ? $role->name : $role;
134
135 if ($params && %$params) {
136 my $alias = delete $params->{'-alias'}
137 || delete $params->{'alias'}
138 || {};
139 my $excludes = delete $params->{'-excludes'}
140 || delete $params->{'excludes'}
141 || [];
142 $excludes = [$excludes] unless ref($excludes) eq 'ARRAY';
143
144 if (%$params) {
145 warn "Roles with parameters cannot be cached. Consider "
146 . "applying the parameters before calling "
147 . "create_anon_class, or using 'weaken => 0' instead";
148 return;
149 }
150
151 my $alias_key = join('%',
152 map { $_ => $alias->{$_} } sort keys %$alias
153 );
154 my $excludes_key = join('%',
155 sort @$excludes
156 );
157 $key .= '<' . join('+', 'a', $alias_key, 'e', $excludes_key) . '>';
158 }
159
160 push @role_keys, $key;
161 }
162
163 my $role_key = join('|', sort @role_keys);
164
165 # Makes something like Super::Class|Super::Class::2=Role|Role::1
166 return join('=', $superclass_key, $role_key);
167}
168
169sub reinitialize {
170 my $self = shift;
171 my $pkg = shift;
172
173 my $meta = blessed $pkg ? $pkg : Class::MOP::class_of($pkg);
174
175 my %existing_classes;
176 if ($meta) {
177 %existing_classes = map { $_ => $meta->$_() } qw(
178 attribute_metaclass
179 method_metaclass
180 wrapped_method_metaclass
181 instance_metaclass
182 constructor_class
183 destructor_class
184 error_class
185 );
186 }
187
188 return $self->SUPER::reinitialize(
189 $pkg,
190 %existing_classes,
191 @_,
192 );
193}
194
195
# spent 84µs (60+24) within Moose::Meta::Class::add_role which was called 4 times, avg 21µs/call: # 4 times (60µs+24µs) by Moose::Meta::Role::Application::ToClass::apply at line 38 of Moose/Meta/Role/Application/ToClass.pm, avg 21µs/call
sub add_role {
1961270µs my ($self, $role) = @_;
197811µs (blessed($role) && $role->isa('Moose::Meta::Role'))
# spent 6µs making 4 calls to Scalar::Util::blessed, avg 1µs/call # spent 5µs making 4 calls to UNIVERSAL::isa, avg 1µs/call
198 || $self->throw_error("Roles must be instances of Moose::Meta::Role", data => $role);
199413µs push @{$self->roles} => $role;
# spent 13µs making 4 calls to Moose::Meta::Class::roles, avg 3µs/call
200}
201
202sub role_applications {
203 my ($self) = @_;
204
205 return @{$self->_get_role_applications};
206}
207
208
# spent 85µs (59+25) within Moose::Meta::Class::add_role_application which was called 4 times, avg 21µs/call: # 4 times (59µs+25µs) by Moose::Meta::Role::Application::ToClass::apply at line 39 of Moose/Meta/Role/Application/ToClass.pm, avg 21µs/call
sub add_role_application {
2091272µs my ($self, $application) = @_;
210810µs (blessed($application) && $application->isa('Moose::Meta::Role::Application::ToClass'))
# spent 6µs making 4 calls to UNIVERSAL::isa, avg 1µs/call # spent 4µs making 4 calls to Scalar::Util::blessed, avg 1µs/call
211 || $self->throw_error("Role applications must be instances of Moose::Meta::Role::Application::ToClass", data => $application);
212415µs push @{$self->_get_role_applications} => $application;
# spent 15µs making 4 calls to Moose::Meta::Class::_get_role_applications, avg 4µs/call
213}
214
215sub calculate_all_roles {
216 my $self = shift;
217 my %seen;
218 grep { !$seen{$_->name}++ } map { $_->calculate_all_roles } @{ $self->roles };
219}
220
221sub calculate_all_roles_with_inheritance {
222 my $self = shift;
223 my %seen;
224 grep { !$seen{$_->name}++ }
225 map { Class::MOP::class_of($_)->can('calculate_all_roles')
226 ? Class::MOP::class_of($_)->calculate_all_roles
227 : () }
228 $self->linearized_isa;
229}
230
231
# spent 1.15ms (130µs+1.02) within Moose::Meta::Class::does_role which was called 3 times, avg 382µs/call: # 3 times (130µs+1.02ms) by Moose::Object::does at line 125 of Moose/Object.pm, avg 382µs/call
sub does_role {
23221115µs my ($self, $role_name) = @_;
233
234 (defined $role_name)
235 || $self->throw_error("You must supply a role name to look for");
236
2373884µs foreach my $class ($self->class_precedence_list) {
# spent 884µs making 3 calls to Class::MOP::Class::class_precedence_list, avg 295µs/call
238341µs my $meta = Class::MOP::class_of($class);
# spent 41µs making 3 calls to Class::MOP::class_of, avg 14µs/call
239 # when a Moose metaclass is itself extended with a role,
240 # this check needs to be done since some items in the
241 # class_precedence_list might in fact be Class::MOP
242 # based still.
24339µs next unless $meta && $meta->can('roles');
# spent 9µs making 3 calls to UNIVERSAL::can, avg 3µs/call
244315µs foreach my $role (@{$meta->roles}) {
# spent 15µs making 3 calls to Moose::Meta::Class::roles, avg 5µs/call
245367µs return 1 if $role->does_role($role_name);
# spent 67µs making 3 calls to Moose::Meta::Role::does_role, avg 22µs/call
246 }
247 }
248 return 0;
249}
250
251
# spent 1.28ms (223µs+1.06) within Moose::Meta::Class::excludes_role which was called 4 times, avg 320µs/call: # 4 times (223µs+1.06ms) by Moose::Meta::Role::Application::ToClass::check_role_exclusions at line 44 of Moose/Meta/Role/Application/ToClass.pm, avg 320µs/call
sub excludes_role {
25251176µs my ($self, $role_name) = @_;
253
254 (defined $role_name)
255 || $self->throw_error("You must supply a role name to look for");
256
2574936µs foreach my $class ($self->class_precedence_list) {
# spent 936µs making 4 calls to Class::MOP::Class::class_precedence_list, avg 234µs/call
2581154µs my $meta = Class::MOP::class_of($class);
# spent 54µs making 11 calls to Class::MOP::class_of, avg 5µs/call
259 # when a Moose metaclass is itself extended with a role,
260 # this check needs to be done since some items in the
261 # class_precedence_list might in fact be Class::MOP
262 # based still.
2631116µs next unless $meta && $meta->can('roles');
# spent 16µs making 11 calls to UNIVERSAL::can, avg 1µs/call
2641128µs foreach my $role (@{$meta->roles}) {
# spent 28µs making 11 calls to Moose::Meta::Class::roles, avg 3µs/call
265223µs return 1 if $role->excludes_role($role_name);
# spent 23µs making 2 calls to Moose::Meta::Role::excludes_role, avg 11µs/call
266 }
267 }
268 return 0;
269}
270
271
# spent 4.07ms (66µs+4.00) within Moose::Meta::Class::new_object which was called 3 times, avg 1.36ms/call: # 3 times (66µs+4.00ms) by Moose::Object::new at line 28 of Moose/Object.pm, avg 1.36ms/call
sub new_object {
2721867µs my $self = shift;
273 my $params = @_ == 1 ? $_[0] : {@_};
27433.83ms my $object = $self->SUPER::new_object($params);
# spent 3.99ms making 3 calls to Class::MOP::Class::new_object, avg 1.33ms/call, recursion: max depth 1, sum of overlapping time 165µs
275
2763188µs $self->_call_all_triggers($object, $params);
# spent 188µs making 3 calls to Moose::Meta::Class::_call_all_triggers, avg 63µs/call
277
278635µs $object->BUILDALL($params) if $object->can('BUILDALL');
# spent 27µs making 3 calls to Moose::Object::BUILDALL, avg 9µs/call # spent 8µs making 3 calls to UNIVERSAL::can, avg 3µs/call
279
280 return $object;
281}
282
283
# spent 188µs (46+141) within Moose::Meta::Class::_call_all_triggers which was called 3 times, avg 63µs/call: # 3 times (46µs+141µs) by Moose::Meta::Class::new_object at line 276, avg 63µs/call
sub _call_all_triggers {
2841445µs my ($self, $object, $params) = @_;
285
2863126µs foreach my $attr ( $self->get_all_attributes() ) {
# spent 126µs making 3 calls to Class::MOP::Class::get_all_attributes, avg 42µs/call
287
2881616µs next unless $attr->can('has_trigger') && $attr->has_trigger;
# spent 9µs making 8 calls to Moose::Meta::Mixin::AttributeCore::has_trigger, avg 1µs/call # spent 7µs making 8 calls to UNIVERSAL::can, avg 812ns/call
289
290 my $init_arg = $attr->init_arg;
291 next unless defined $init_arg;
292 next unless exists $params->{$init_arg};
293
294 $attr->trigger->(
295 $object,
296 (
297 $attr->should_coerce
298 ? $attr->get_read_method_ref->($object)
299 : $params->{$init_arg}
300 ),
301 );
302 }
303}
304
305sub _generate_fallback_constructor {
306 my $self = shift;
307 my ($class) = @_;
308 return $class . '->Moose::Object::new(@_)'
309}
310
311sub _inline_params {
312 my $self = shift;
313 my ($params, $class) = @_;
314 return (
315 'my ' . $params . ' = ',
316 $self->_inline_BUILDARGS($class, '@_'),
317 ';',
318 );
319}
320
321sub _inline_BUILDARGS {
322 my $self = shift;
323 my ($class, $args) = @_;
324
325 my $buildargs = $self->find_method_by_name("BUILDARGS");
326
327 if ($args eq '@_'
328 && (!$buildargs or $buildargs->body == \&Moose::Object::BUILDARGS)) {
329 return (
330 'do {',
331 'my $params;',
332 'if (scalar @_ == 1) {',
333 'if (!defined($_[0]) || ref($_[0]) ne \'HASH\') {',
334 $self->_inline_throw_error(
335 '"Single parameters to new() must be a HASH ref"',
336 'data => $_[0]',
337 ) . ';',
338 '}',
339 '$params = { %{ $_[0] } };',
340 '}',
341 'elsif (@_ % 2) {',
342 'Carp::carp(',
343 '"The new() method for ' . $class . ' expects a '
344 . 'hash reference or a key/value list. You passed an '
345 . 'odd number of arguments"',
346 ');',
347 '$params = {@_, undef};',
348 '}',
349 'else {',
350 '$params = {@_};',
351 '}',
352 '$params;',
353 '}',
354 );
355 }
356 else {
357 return $class . '->BUILDARGS(' . $args . ')';
358 }
359}
360
361sub _inline_slot_initializer {
362 my $self = shift;
363 my ($attr, $idx) = @_;
364
365 return (
366 '## ' . $attr->name,
367 $self->_inline_check_required_attr($attr),
368 $self->SUPER::_inline_slot_initializer(@_),
369 );
370}
371
372sub _inline_check_required_attr {
373 my $self = shift;
374 my ($attr) = @_;
375
376 return unless defined $attr->init_arg;
377 return unless $attr->can('is_required') && $attr->is_required;
378 return if $attr->has_default || $attr->has_builder;
379
380 return (
381 'if (!exists $params->{\'' . $attr->init_arg . '\'}) {',
382 $self->_inline_throw_error(
383 '"Attribute (' . quotemeta($attr->name) . ') is required"'
384 ) . ';',
385 '}',
386 );
387}
388
389# XXX: these two are duplicated from cmop, because we have to pass the tc stuff
390# through to _inline_set_value - this should probably be fixed, but i'm not
391# quite sure how. -doy
392sub _inline_init_attr_from_constructor {
393 my $self = shift;
394 my ($attr, $idx) = @_;
395
396 my @initial_value = $attr->_inline_set_value(
397 '$instance',
398 '$params->{\'' . $attr->init_arg . '\'}',
399 '$type_constraint_bodies[' . $idx . ']',
400 '$type_coercions[' . $idx . ']',
401 '$type_constraint_messages[' . $idx . ']',
402 'for constructor',
403 );
404
405 push @initial_value, (
406 '$attrs->[' . $idx . ']->set_initial_value(',
407 '$instance,',
408 $attr->_inline_instance_get('$instance'),
409 ');',
410 ) if $attr->has_initializer;
411
412 return @initial_value;
413}
414
415sub _inline_init_attr_from_default {
416 my $self = shift;
417 my ($attr, $idx) = @_;
418
419 return if $attr->can('is_lazy') && $attr->is_lazy;
420 my $default = $self->_inline_default_value($attr, $idx);
421 return unless $default;
422
423 my @initial_value = (
424 'my $default = ' . $default . ';',
425 $attr->_inline_set_value(
426 '$instance',
427 '$default',
428 '$type_constraint_bodies[' . $idx . ']',
429 '$type_coercions[' . $idx . ']',
430 '$type_constraint_messages[' . $idx . ']',
431 'for constructor',
432 ),
433 );
434
435 push @initial_value, (
436 '$attrs->[' . $idx . ']->set_initial_value(',
437 '$instance,',
438 $attr->_inline_instance_get('$instance'),
439 ');',
440 ) if $attr->has_initializer;
441
442 return @initial_value;
443}
444
445sub _inline_extra_init {
446 my $self = shift;
447 return (
448 $self->_inline_triggers,
449 $self->_inline_BUILDALL,
450 );
451}
452
453sub _inline_triggers {
454 my $self = shift;
455 my @trigger_calls;
456
457 my @attrs = sort { $a->name cmp $b->name } $self->get_all_attributes;
458 for my $i (0 .. $#attrs) {
459 my $attr = $attrs[$i];
460
461 next unless $attr->can('has_trigger') && $attr->has_trigger;
462
463 my $init_arg = $attr->init_arg;
464 next unless defined $init_arg;
465
466 push @trigger_calls,
467 'if (exists $params->{\'' . $init_arg . '\'}) {',
468 '$triggers->[' . $i . ']->(',
469 '$instance,',
470 $attr->_inline_instance_get('$instance') . ',',
471 ');',
472 '}';
473 }
474
475 return @trigger_calls;
476}
477
478sub _inline_BUILDALL {
479 my $self = shift;
480
481 my @methods = reverse $self->find_all_methods_by_name('BUILD');
482 my @BUILD_calls;
483
484 foreach my $method (@methods) {
485 push @BUILD_calls,
486 '$instance->' . $method->{class} . '::BUILD($params);';
487 }
488
489 return @BUILD_calls;
490}
491
492sub _eval_environment {
493 my $self = shift;
494
495 my @attrs = sort { $a->name cmp $b->name } $self->get_all_attributes;
496
497 my $triggers = [
498 map { $_->can('has_trigger') && $_->has_trigger ? $_->trigger : undef }
499 @attrs
500 ];
501
502 # We need to check if the attribute ->can('type_constraint')
503 # since we may be trying to immutabilize a Moose meta class,
504 # which in turn has attributes which are Class::MOP::Attribute
505 # objects, rather than Moose::Meta::Attribute. And
506 # Class::MOP::Attribute attributes have no type constraints.
507 # However we need to make sure we leave an undef value there
508 # because the inlined code is using the index of the attributes
509 # to determine where to find the type constraint
510
511 my @type_constraints = map {
512 $_->can('type_constraint') ? $_->type_constraint : undef
513 } @attrs;
514
515 my @type_constraint_bodies = map {
516 defined $_ ? $_->_compiled_type_constraint : undef;
517 } @type_constraints;
518
519 my @type_coercions = map {
520 defined $_ && $_->has_coercion
521 ? $_->coercion->_compiled_type_coercion
522 : undef
523 } @type_constraints;
524
525 my @type_constraint_messages = map {
526 defined $_
527 ? ($_->has_message ? $_->message : $_->_default_message)
528 : undef
529 } @type_constraints;
530
531 return {
532 %{ $self->SUPER::_eval_environment },
533 ((any { defined && $_->has_initializer } @attrs)
534 ? ('$attrs' => \[@attrs])
535 : ()),
536 '$triggers' => \$triggers,
537 '@type_coercions' => \@type_coercions,
538 '@type_constraint_bodies' => \@type_constraint_bodies,
539 '@type_constraint_messages' => \@type_constraint_messages,
540 ( map { defined($_) ? %{ $_->inline_environment } : () }
541 @type_constraints ),
542 # pretty sure this is only going to be closed over if you use a custom
543 # error class at this point, but we should still get rid of this
544 # at some point
545 '$meta' => \$self,
546 };
547}
548
549
# spent 16.2ms (948µs+15.3) within Moose::Meta::Class::superclasses which was called 63 times, avg 257µs/call: # 19 times (239µs+631µs) by Class::MOP::Class::_check_metaclass_compatibility at line 203 of Class/MOP/Class.pm, avg 46µs/call # 17 times (313µs+820µs) by Class::MOP::Class::class_precedence_list at line 1030 of Class/MOP/Class.pm, avg 67µs/call # 14 times (200µs+5.15ms) by Moose::init_meta at line 215 of Moose.pm, avg 382µs/call # 10 times (94µs+-94µs) by Class::MOP::Class::_superclasses_updated at line 971 of Class/MOP/Class.pm, avg 0s/call # 2 times (44µs+6.42ms) by Moose::extends at line 63 of Moose.pm, avg 3.23ms/call # once (58µs+2.33ms) by Class::MOP::Class::create at line 451 of Class/MOP/Class.pm
sub superclasses {
550292931µs my $self = shift;
55163826µs my $supers = Data::OptList::mkopt(\@_);
# spent 826µs making 63 calls to Data::OptList::mkopt, avg 13µs/call
552 foreach my $super (@{ $supers }) {
553 my ($name, $opts) = @{ $super };
554106.15ms load_class($name, $opts);
# spent 6.24ms making 10 calls to Class::Load::load_class, avg 624µs/call, recursion: max depth 1, sum of overlapping time 87µs
55510108µs my $meta = Class::MOP::class_of($name);
# spent 108µs making 10 calls to Class::MOP::class_of, avg 11µs/call
5561030µs $self->throw_error("You cannot inherit from a Moose Role ($name)")
# spent 30µs making 10 calls to UNIVERSAL::isa, avg 3µs/call
557 if $meta && $meta->isa('Moose::Meta::Role')
558 }
5596310.1ms return $self->SUPER::superclasses(map { $_->[0] } @{ $supers });
# spent 10.4ms making 63 calls to Class::MOP::Class::superclasses, avg 166µs/call, recursion: max depth 1, sum of overlapping time 317µs
560}
561
562### ---------------------------------------------
563
564
# spent 17.8ms (240µs+17.5) within Moose::Meta::Class::add_attribute which was called 8 times, avg 2.22ms/call: # 6 times (149µs+14.0ms) by Moose::has at line 79 of Moose.pm, avg 2.35ms/call # 2 times (92µs+3.54ms) by Moose::Meta::Role::Application::ToClass::apply_attributes at line 152 of Moose/Meta/Role/Application/ToClass.pm, avg 1.81ms/call
sub add_attribute {
56540251µs my $self = shift;
566162.50ms my $attr =
# spent 2.49ms making 6 calls to Moose::Meta::Class::_process_attribute, avg 415µs/call # spent 8µs making 8 calls to Scalar::Util::blessed, avg 950ns/call # spent 5µs making 2 calls to UNIVERSAL::isa, avg 2µs/call
567 (blessed $_[0] && $_[0]->isa('Class::MOP::Attribute')
568 ? $_[0]
569 : $self->_process_attribute(@_));
570814.9ms $self->SUPER::add_attribute($attr);
# spent 14.9ms making 8 calls to Class::MOP::Mixin::HasAttributes::add_attribute, avg 1.86ms/call
571 # it may be a Class::MOP::Attribute, theoretically, which doesn't have
572 # 'bare' and doesn't implement this method
57316126µs if ($attr->can('_check_associated_methods')) {
# spent 111µs making 8 calls to Moose::Meta::Attribute::_check_associated_methods, avg 14µs/call # spent 15µs making 8 calls to UNIVERSAL::can, avg 2µs/call
574 $attr->_check_associated_methods;
575 }
576 return $attr;
577}
578
579sub add_override_method_modifier {
580 my ($self, $name, $method, $_super_package) = @_;
581
582 (!$self->has_method($name))
583 || $self->throw_error("Cannot add an override method if a local method is already present");
584
585 $self->add_method($name => Moose::Meta::Method::Overridden->new(
586 method => $method,
587 class => $self,
588 package => $_super_package, # need this for roles
589 name => $name,
590 ));
591}
592
593sub add_augment_method_modifier {
594 my ($self, $name, $method) = @_;
595 (!$self->has_method($name))
596 || $self->throw_error("Cannot add an augment method if a local method is already present");
597
598 $self->add_method($name => Moose::Meta::Method::Augmented->new(
599 method => $method,
600 class => $self,
601 name => $name,
602 ));
603}
604
605## Private Utility methods ...
606
607sub _find_next_method_by_name_which_is_not_overridden {
608 my ($self, $name) = @_;
609 foreach my $method ($self->find_all_methods_by_name($name)) {
610 return $method->{code}
611 if blessed($method->{code}) && !$method->{code}->isa('Moose::Meta::Method::Overridden');
612 }
613 return undef;
614}
615
616## Metaclass compatibility
617
618
# spent 843µs (585+258) within Moose::Meta::Class::_base_metaclasses which was called 20 times, avg 42µs/call: # 10 times (330µs+152µs) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 333 of Class/MOP/Class.pm, avg 48µs/call # 10 times (255µs+106µs) by Class::MOP::Class::_check_metaclass_compatibility at line 208 of Class/MOP/Class.pm, avg 36µs/call
sub _base_metaclasses {
619200771µs my $self = shift;
6202073µs my %metaclasses = $self->SUPER::_base_metaclasses;
# spent 73µs making 20 calls to Class::MOP::Class::_base_metaclasses, avg 4µs/call
621 for my $class (keys %metaclasses) {
622120185µs $metaclasses{$class} =~ s/^Class::MOP/Moose::Meta/;
# spent 185µs making 120 calls to Moose::Meta::Class::CORE:subst, avg 2µs/call
623 }
624 return (
625 %metaclasses,
626 error_class => 'Moose::Error::Default',
627 );
628}
629
630sub _fix_class_metaclass_incompatibility {
631 my $self = shift;
632 my ($super_meta) = @_;
633
634 $self->SUPER::_fix_class_metaclass_incompatibility(@_);
635
636 if ($self->_class_metaclass_can_be_made_compatible($super_meta)) {
637 ($self->is_pristine)
638 || confess "Can't fix metaclass incompatibility for "
639 . $self->name
640 . " because it is not pristine.";
641 my $super_meta_name = $super_meta->_real_ref_name;
642 my $class_meta_subclass_meta_name = Moose::Util::_reconcile_roles_for_metaclass(blessed($self), $super_meta_name);
643 my $new_self = $class_meta_subclass_meta_name->reinitialize(
644 $self->name,
645 );
646
647 $self->_replace_self( $new_self, $class_meta_subclass_meta_name );
648 }
649}
650
651sub _fix_single_metaclass_incompatibility {
652 my $self = shift;
653 my ($metaclass_type, $super_meta) = @_;
654
655 $self->SUPER::_fix_single_metaclass_incompatibility(@_);
656
657 if ($self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type)) {
658 ($self->is_pristine)
659 || confess "Can't fix metaclass incompatibility for "
660 . $self->name
661 . " because it is not pristine.";
662 my $super_meta_name = $super_meta->_real_ref_name;
663 my $class_specific_meta_subclass_meta_name = Moose::Util::_reconcile_roles_for_metaclass($self->$metaclass_type, $super_meta->$metaclass_type);
664 my $new_self = $super_meta->reinitialize(
665 $self->name,
666 $metaclass_type => $class_specific_meta_subclass_meta_name,
667 );
668
669 $self->_replace_self( $new_self, $super_meta_name );
670 }
671}
672
673sub _replace_self {
674 my $self = shift;
675 my ( $new_self, $new_class) = @_;
676
677 %$self = %$new_self;
678 bless $self, $new_class;
679
680 # We need to replace the cached metaclass instance or else when it goes
681 # out of scope Class::MOP::Class destroy's the namespace for the
682 # metaclass's class, causing much havoc.
683 my $weaken = Class::MOP::metaclass_is_weak( $self->name );
684 Class::MOP::store_metaclass_by_name( $self->name, $self );
685 Class::MOP::weaken_metaclass( $self->name ) if $weaken;
686}
687
688
# spent 2.49ms (68µs+2.42) within Moose::Meta::Class::_process_attribute which was called 6 times, avg 415µs/call: # 6 times (68µs+2.42ms) by Moose::Meta::Class::add_attribute at line 566, avg 415µs/call
sub _process_attribute {
6892470µs my ( $self, $name, @args ) = @_;
690
691 @args = %{$args[0]} if scalar @args == 1 && ref($args[0]) eq 'HASH';
692
69366µs if (($name || '') =~ /^\+(.*)/) {
# spent 6µs making 6 calls to Moose::Meta::Class::CORE:match, avg 1µs/call
694 return $self->_process_inherited_attribute($1, @args);
695 }
696 else {
69762.42ms return $self->_process_new_attribute($name, @args);
# spent 2.42ms making 6 calls to Moose::Meta::Class::_process_new_attribute, avg 403µs/call
698 }
699}
700
701
# spent 2.42ms (66µs+2.35) within Moose::Meta::Class::_process_new_attribute which was called 6 times, avg 403µs/call: # 6 times (66µs+2.35ms) by Moose::Meta::Class::_process_attribute at line 697, avg 403µs/call
sub _process_new_attribute {
7021276µs my ( $self, $name, @args ) = @_;
703
704122.35ms $self->attribute_metaclass->interpolate_class_and_new($name, @args);
# spent 2.34ms making 6 calls to Moose::Meta::Attribute::interpolate_class_and_new, avg 391µs/call # spent 7µs making 6 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 1µs/call
705}
706
707sub _process_inherited_attribute {
708 my ($self, $attr_name, %options) = @_;
709 my $inherited_attr = $self->find_attribute_by_name($attr_name);
710 (defined $inherited_attr)
711 || $self->throw_error("Could not find an attribute by the name of '$attr_name' to inherit from in ${\$self->name}", data => $attr_name);
712 if ($inherited_attr->isa('Moose::Meta::Attribute')) {
713 return $inherited_attr->clone_and_inherit_options(%options);
714 }
715 else {
716 # NOTE:
717 # kind of a kludge to handle Class::MOP::Attributes
718 return $inherited_attr->Moose::Meta::Attribute::clone_and_inherit_options(%options);
719 }
720}
721
722# reinitialization support
723
724sub _restore_metaobjects_from {
725 my $self = shift;
726 my ($old_meta) = @_;
727
728 $self->SUPER::_restore_metaobjects_from($old_meta);
729
730 for my $role ( @{ $old_meta->roles } ) {
731 $self->add_role($role);
732 }
733
734 for my $application ( @{ $old_meta->_get_role_applications } ) {
735 $application->class($self);
736 $self->add_role_application ($application);
737 }
738}
739
740## Immutability
741
742sub _immutable_options {
743 my ( $self, @args ) = @_;
744
745 $self->SUPER::_immutable_options(
746 inline_destructor => 1,
747
748 # Moose always does this when an attribute is created
749 inline_accessors => 0,
750
751 @args,
752 );
753}
754
755sub _fixup_attributes_after_rebless {
756 my $self = shift;
757 my ($instance, $rebless_from, %params) = @_;
758
759 $self->SUPER::_fixup_attributes_after_rebless(
760 $instance,
761 $rebless_from,
762 %params
763 );
764
765 $self->_call_all_triggers( $instance, \%params );
766}
767
768## -------------------------------------------------
769
7701500nsour $error_level;
771
772sub throw_error {
773 my ( $self, @args ) = @_;
774 local $error_level = ($error_level || 0) + 1;
775 $self->raise_error($self->create_error(@args));
776}
777
778
# spent 1.18ms (80µs+1.10) within Moose::Meta::Class::_inline_throw_error which was called 9 times, avg 131µs/call: # 9 times (80µs+1.10ms) by Moose::Meta::Attribute::_inline_throw_error at line 83 of Moose/Meta/Attribute.pm, avg 131µs/call
sub _inline_throw_error {
7791873µs my ( $self, @args ) = @_;
780181.10ms $self->_inline_raise_error($self->_inline_create_error(@args));
# spent 1.07ms making 9 calls to Moose::Meta::Class::_inline_create_error, avg 119µs/call # spent 30µs making 9 calls to Moose::Meta::Class::_inline_raise_error, avg 3µs/call
781}
782
783sub raise_error {
784 my ( $self, @args ) = @_;
785 die @args;
786}
787
788
# spent 30µs within Moose::Meta::Class::_inline_raise_error which was called 9 times, avg 3µs/call: # 9 times (30µs+0s) by Moose::Meta::Class::_inline_throw_error at line 780, avg 3µs/call
sub _inline_raise_error {
7891838µs my ( $self, $message ) = @_;
790
791 return 'die ' . $message;
792}
793
794sub create_error {
795 my ( $self, @args ) = @_;
796
797 require Carp::Heavy;
798
799 local $error_level = ($error_level || 0 ) + 1;
800
801 if ( @args % 2 == 1 ) {
802 unshift @args, "message";
803 }
804
805 my %args = ( metaclass => $self, last_error => $@, @args );
806
807 $args{depth} += $error_level;
808
809 my $class = ref $self ? $self->error_class : "Moose::Error::Default";
810
811 load_class($class);
812
813 $class->new(
814 Carp::caller_info($args{depth}),
815 %args
816 );
817}
818
819
# spent 1.07ms (250µs+822µs) within Moose::Meta::Class::_inline_create_error which was called 9 times, avg 119µs/call: # 9 times (250µs+822µs) by Moose::Meta::Class::_inline_throw_error at line 780, avg 119µs/call
sub _inline_create_error {
82063227µs my ( $self, $msg, $args ) = @_;
821 # XXX ignore $args for now, nothing currently uses it anyway
822
823 require Carp::Heavy;
824
825 my %args = (
826 metaclass => $self,
827 last_error => $@,
828 message => $msg,
829 );
830
831724µs my $class = ref $self ? $self->error_class : "Moose::Error::Default";
# spent 24µs making 7 calls to Moose::Meta::Class::error_class, avg 3µs/call
832
8339423µs load_class($class);
# spent 423µs making 9 calls to Class::Load::load_class, avg 47µs/call
834
835 # don't check inheritance here - the intention is that the class needs
836 # to provide a non-inherited inlining method, because falling back to
837 # the default inlining method is most likely going to be wrong
838 # yes, this is a huge hack, but so is the entire error system, so.
839 return
84018305µs '$meta->create_error('
# spent 184µs making 9 calls to Class::MOP::Mixin::HasMethods::has_method, avg 20µs/call # spent 121µs making 9 calls to Class::MOP::Object::meta, avg 13µs/call
841 . $msg
842 . ( defined $args ? ', ' . $args : q{} ) . ');'
843 unless $class->meta->has_method('_inline_new');
844
845970µs $class->_inline_new(
# spent 70µs making 9 calls to Moose::Error::Default::_inline_new, avg 8µs/call
846 # XXX ignore this for now too
847 # Carp::caller_info($args{depth}),
848 %args
849 );
850}
851
852126µs1;
853
854# ABSTRACT: The Moose metaclass
855
- -
858=pod
859
860=head1 NAME
861
862Moose::Meta::Class - The Moose metaclass
863
864=head1 VERSION
865
866version 2.0602
867
868=head1 DESCRIPTION
869
870This class is a subclass of L<Class::MOP::Class> that provides
871additional Moose-specific functionality.
872
873To really understand this class, you will need to start with the
874L<Class::MOP::Class> documentation. This class can be understood as a
875set of additional features on top of the basic feature provided by
876that parent class.
877
878=head1 INHERITANCE
879
880C<Moose::Meta::Class> is a subclass of L<Class::MOP::Class>.
881
882=head1 METHODS
883
884=over 4
885
886=item B<< Moose::Meta::Class->initialize($package_name, %options) >>
887
888This overrides the parent's method in order to provide its own
889defaults for the C<attribute_metaclass>, C<instance_metaclass>, and
890C<method_metaclass> options.
891
892These all default to the appropriate Moose class.
893
894=item B<< Moose::Meta::Class->create($package_name, %options) >>
895
896This overrides the parent's method in order to accept a C<roles>
897option. This should be an array reference containing roles
898that the class does, each optionally followed by a hashref of options
899(C<-excludes> and C<-alias>).
900
901 my $metaclass = Moose::Meta::Class->create( 'New::Class', roles => [...] );
902
903=item B<< Moose::Meta::Class->create_anon_class >>
904
905This overrides the parent's method to accept a C<roles> option, just
906as C<create> does.
907
908It also accepts a C<cache> option. If this is true, then the anonymous
909class will be cached based on its superclasses and roles. If an
910existing anonymous class in the cache has the same superclasses and
911roles, it will be reused.
912
913 my $metaclass = Moose::Meta::Class->create_anon_class(
914 superclasses => ['Foo'],
915 roles => [qw/Some Roles Go Here/],
916 cache => 1,
917 );
918
919Each entry in both the C<superclasses> and the C<roles> option can be
920followed by a hash reference with arguments. The C<superclasses>
921option can be supplied with a L<-version|Class::MOP/Class Loading
922Options> option that ensures the loaded superclass satisfies the
923required version. The C<role> option also takes the C<-version> as an
924argument, but the option hash reference can also contain any other
925role relevant values like exclusions or parameterized role arguments.
926
927=item B<< $metaclass->new_object(%params) >>
928
929This overrides the parent's method in order to add support for
930attribute triggers.
931
932=item B<< $metaclass->superclasses(@superclasses) >>
933
934This is the accessor allowing you to read or change the parents of
935the class.
936
937Each superclass can be followed by a hash reference containing a
938L<-version|Class::MOP/Class Loading Options> value. If the version
939requirement is not satisfied an error will be thrown.
940
941=item B<< $metaclass->add_override_method_modifier($name, $sub) >>
942
943This adds an C<override> method modifier to the package.
944
945=item B<< $metaclass->add_augment_method_modifier($name, $sub) >>
946
947This adds an C<augment> method modifier to the package.
948
949=item B<< $metaclass->calculate_all_roles >>
950
951This will return a unique array of C<Moose::Meta::Role> instances
952which are attached to this class.
953
954=item B<< $metaclass->calculate_all_roles_with_inheritance >>
955
956This will return a unique array of C<Moose::Meta::Role> instances
957which are attached to this class, and each of this class's ancestors.
958
959=item B<< $metaclass->add_role($role) >>
960
961This takes a L<Moose::Meta::Role> object, and adds it to the class's
962list of roles. This I<does not> actually apply the role to the class.
963
964=item B<< $metaclass->role_applications >>
965
966Returns a list of L<Moose::Meta::Role::Application::ToClass>
967objects, which contain the arguments to role application.
968
969=item B<< $metaclass->add_role_application($application) >>
970
971This takes a L<Moose::Meta::Role::Application::ToClass> object, and
972adds it to the class's list of role applications. This I<does not>
973actually apply any role to the class; it is only for tracking role
974applications.
975
976=item B<< $metaclass->does_role($role) >>
977
978This returns a boolean indicating whether or not the class does the specified
979role. The role provided can be either a role name or a L<Moose::Meta::Role>
980object. This tests both the class and its parents.
981
982=item B<< $metaclass->excludes_role($role_name) >>
983
984A class excludes a role if it has already composed a role which
985excludes the named role. This tests both the class and its parents.
986
987=item B<< $metaclass->add_attribute($attr_name, %params|$params) >>
988
989This overrides the parent's method in order to allow the parameters to
990be provided as a hash reference.
991
992=item B<< $metaclass->constructor_class($class_name) >>
993
994=item B<< $metaclass->destructor_class($class_name) >>
995
996These are the names of classes used when making a class immutable. These
997default to L<Moose::Meta::Method::Constructor> and
998L<Moose::Meta::Method::Destructor> respectively. These accessors are
999read-write, so you can use them to change the class name.
1000
1001=item B<< $metaclass->error_class($class_name) >>
1002
1003The name of the class used to throw errors. This defaults to
1004L<Moose::Error::Default>, which generates an error with a stacktrace
1005just like C<Carp::confess>.
1006
1007=item B<< $metaclass->throw_error($message, %extra) >>
1008
1009Throws the error created by C<create_error> using C<raise_error>
1010
1011=back
1012
1013=head1 BUGS
1014
1015See L<Moose/BUGS> for details on reporting bugs.
1016
1017=head1 AUTHOR
1018
1019Moose is maintained by the Moose Cabal, along with the help of many contributors. See L<Moose/CABAL> and L<Moose/CONTRIBUTORS> for details.
1020
1021=head1 COPYRIGHT AND LICENSE
1022
1023This software is copyright (c) 2012 by Infinity Interactive, Inc..
1024
1025This is free software; you can redistribute it and/or modify it under
1026the same terms as the Perl 5 programming language system itself.
1027
1028=cut
1029
1030
1031__END__
 
# spent 6µs within Moose::Meta::Class::CORE:match which was called 6 times, avg 1µs/call: # 6 times (6µs+0s) by Moose::Meta::Class::_process_attribute at line 693, avg 1µs/call
sub Moose::Meta::Class::CORE:match; # opcode
# spent 185µs within Moose::Meta::Class::CORE:subst which was called 120 times, avg 2µs/call: # 120 times (185µs+0s) by Moose::Meta::Class::_base_metaclasses at line 622, avg 2µs/call
sub Moose::Meta::Class::CORE:subst; # opcode