← Index
Performance Profile   « block view • line view • sub view »
For t/test-parsing
  Run on Sun Nov 14 09:49:57 2010
Reported on Sun Nov 14 09:50:08 2010

File /usr/local/lib/perl/5.10.0/Class/MOP/Class.pm
Statements Executed 25513
Total Time 0.0878139999999996 seconds
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
141521129.81ms49.2msClass::MOP::Class::::initializeClass::MOP::Class::initialize
323114.03ms12.4msClass::MOP::Class::::_single_metaclass_can_be_made_compatibleClass::MOP::Class::_single_metaclass_can_be_made_compatible
116543.96ms12.0msClass::MOP::Class::::get_all_attributesClass::MOP::Class::get_all_attributes
347722.19ms4.64msClass::MOP::Class::::linearized_isaClass::MOP::Class::linearized_isa
108552.09ms30.3msClass::MOP::Class::::find_method_by_nameClass::MOP::Class::find_method_by_name
103432.09ms17.3msClass::MOP::Class::::find_next_method_by_nameClass::MOP::Class::find_next_method_by_name
43211.89ms21.7msClass::MOP::Class::::_construct_instanceClass::MOP::Class::_construct_instance
84211.89ms34.7msClass::MOP::Class::::_check_metaclass_compatibilityClass::MOP::Class::_check_metaclass_compatibility
52111.62ms16.8msClass::MOP::Class::::_can_fix_metaclass_incompatibilityClass::MOP::Class::_can_fix_metaclass_incompatibility
123111.61ms65.8msClass::MOP::Class::::_post_add_attributeClass::MOP::Class::_post_add_attribute
3211051.58ms15.8msClass::MOP::Class::::get_meta_instanceClass::MOP::Class::get_meta_instance
71111.54ms34.2msClass::MOP::Class::::_construct_class_instanceClass::MOP::Class::_construct_class_instance
63111.34ms1.34msClass::MOP::Class::::_newClass::MOP::Class::_new
123111.30ms59.5msClass::MOP::Class::::__ANON__[:768]Class::MOP::Class::__ANON__[:768]
58111.29ms146msClass::MOP::Class::::_initialize_immutableClass::MOP::Class::_initialize_immutable
58111.26ms55.2msClass::MOP::Class::::_immutable_metaclassClass::MOP::Class::_immutable_metaclass
77111.12ms3.80msClass::MOP::Class::::_single_metaclass_is_compatibleClass::MOP::Class::_single_metaclass_is_compatible
38111.10ms83.1msClass::MOP::Class::::_inline_constructorClass::MOP::Class::_inline_constructor
58111.04ms144msClass::MOP::Class::::_install_inlined_codeClass::MOP::Class::_install_inlined_code
5813111.00ms205msClass::MOP::Class::::make_immutableClass::MOP::Class::make_immutable
12311927µs1.50msClass::MOP::Class::::invalidate_meta_instancesClass::MOP::Class::invalidate_meta_instances
5822827µs2.02msClass::MOP::Class::::_immutable_optionsClass::MOP::Class::_immutable_options
4611806µs21.0msClass::MOP::Class::::__ANON__[:935]Class::MOP::Class::__ANON__[:935]
5811779µs3.79msClass::MOP::Class::::find_attribute_by_nameClass::MOP::Class::find_attribute_by_name
5811777µs56.0msClass::MOP::Class::::_rebless_as_immutableClass::MOP::Class::_rebless_as_immutable
11421749µs1.04msClass::MOP::Class::::is_anon_classClass::MOP::Class::is_anon_class
4411693µs18.4msClass::MOP::Class::::_fix_metaclass_incompatibilityClass::MOP::Class::_fix_metaclass_incompatibility
12311664µs2.51msClass::MOP::Class::::_attach_attributeClass::MOP::Class::_attach_attribute
5811661µs14.2msClass::MOP::Class::::_create_meta_instanceClass::MOP::Class::_create_meta_instance
9632631µs631µsClass::MOP::Class::::_base_metaclassesClass::MOP::Class::_base_metaclasses
12311576µs576µsClass::MOP::Class::::invalidate_meta_instanceClass::MOP::Class::invalidate_meta_instance
7711494µs4.30msClass::MOP::Class::::_check_single_metaclass_compatibilityClass::MOP::Class::_check_single_metaclass_compatibility
3211477µs51.3msClass::MOP::Class::::_inline_accessorsClass::MOP::Class::_inline_accessors
7341476µs1.19msClass::MOP::Class::::_real_ref_nameClass::MOP::Class::_real_ref_name
4521411µs411µsClass::MOP::Class::::_add_inlined_methodClass::MOP::Class::_add_inlined_method
4611394µs23.4msClass::MOP::Class::::add_around_method_modifierClass::MOP::Class::add_around_method_modifier
5211376µs1.96msClass::MOP::Class::::_class_metaclass_can_be_made_compatibleClass::MOP::Class::_class_metaclass_can_be_made_compatible
1422347µs3.22msClass::MOP::Class::::find_all_methods_by_nameClass::MOP::Class::find_all_methods_by_name
3544339µs13.6msClass::MOP::Class::::new_objectClass::MOP::Class::new_object
8933303µs303µsClass::MOP::Class::::is_mutableClass::MOP::Class::is_mutable
811296µs7.14msClass::MOP::Class::::get_all_methodsClass::MOP::Class::get_all_methods
3822272µs2.85msClass::MOP::Class::::inline_create_instanceClass::MOP::Class::inline_create_instance
711248µs8.92msClass::MOP::Class::::_inline_destructorClass::MOP::Class::_inline_destructor
4511141µs141µsClass::MOP::Class::::is_immutableClass::MOP::Class::is_immutable
1111129µs455µsClass::MOP::Class::::_class_metaclass_is_compatibleClass::MOP::Class::_class_metaclass_is_compatible
1111106µs561µsClass::MOP::Class::::_check_class_metaclass_compatibilityClass::MOP::Class::_check_class_metaclass_compatibility
21190µs3.13msClass::MOP::Class::::createClass::MOP::Class::create
131185µs150µsClass::MOP::Class::::_superclasses_updatedClass::MOP::Class::_superclasses_updated
131165µs65µsClass::MOP::Class::::update_meta_instance_dependenciesClass::MOP::Class::update_meta_instance_dependencies
0000s0sClass::MOP::Class::::BEGINClass::MOP::Class::BEGIN
0000s0sClass::MOP::Class::::DESTROYClass::MOP::Class::DESTROY
0000s0sClass::MOP::Class::::__ANON__[:222]Class::MOP::Class::__ANON__[:222]
0000s0sClass::MOP::Class::::__ANON__[:772]Class::MOP::Class::__ANON__[:772]
0000s0sClass::MOP::Class::::_clone_instanceClass::MOP::Class::_clone_instance
0000s0sClass::MOP::Class::::_fix_class_metaclass_incompatibilityClass::MOP::Class::_fix_class_metaclass_incompatibility
0000s0sClass::MOP::Class::::_fix_single_metaclass_incompatibilityClass::MOP::Class::_fix_single_metaclass_incompatibility
0000s0sClass::MOP::Class::::_fixup_attributes_after_reblessClass::MOP::Class::_fixup_attributes_after_rebless
0000s0sClass::MOP::Class::::_force_rebless_instanceClass::MOP::Class::_force_rebless_instance
0000s0sClass::MOP::Class::::_inlined_methodsClass::MOP::Class::_inlined_methods
0000s0sClass::MOP::Class::::_rebless_as_mutableClass::MOP::Class::_rebless_as_mutable
0000s0sClass::MOP::Class::::_remove_generated_metaobjectsClass::MOP::Class::_remove_generated_metaobjects
0000s0sClass::MOP::Class::::_remove_inlined_codeClass::MOP::Class::_remove_inlined_code
0000s0sClass::MOP::Class::::_restore_metaobjects_fromClass::MOP::Class::_restore_metaobjects_from
0000s0sClass::MOP::Class::::add_after_method_modifierClass::MOP::Class::add_after_method_modifier
0000s0sClass::MOP::Class::::add_before_method_modifierClass::MOP::Class::add_before_method_modifier
0000s0sClass::MOP::Class::::add_dependent_meta_instanceClass::MOP::Class::add_dependent_meta_instance
0000s0sClass::MOP::Class::::add_meta_instance_dependenciesClass::MOP::Class::add_meta_instance_dependencies
0000s0sClass::MOP::Class::::class_precedence_listClass::MOP::Class::class_precedence_list
0000s0sClass::MOP::Class::::clone_objectClass::MOP::Class::clone_object
0000s0sClass::MOP::Class::::create_anon_classClass::MOP::Class::create_anon_class
0000s0sClass::MOP::Class::::direct_subclassesClass::MOP::Class::direct_subclasses
0000s0sClass::MOP::Class::::get_all_method_namesClass::MOP::Class::get_all_method_names
0000s0sClass::MOP::Class::::immutable_optionsClass::MOP::Class::immutable_options
0000s0sClass::MOP::Class::::inline_rebless_instanceClass::MOP::Class::inline_rebless_instance
0000s0sClass::MOP::Class::::is_pristineClass::MOP::Class::is_pristine
0000s0sClass::MOP::Class::::make_mutableClass::MOP::Class::make_mutable
0000s0sClass::MOP::Class::::rebless_instanceClass::MOP::Class::rebless_instance
0000s0sClass::MOP::Class::::rebless_instance_awayClass::MOP::Class::rebless_instance_away
0000s0sClass::MOP::Class::::rebless_instance_backClass::MOP::Class::rebless_instance_back
0000s0sClass::MOP::Class::::reinitializeClass::MOP::Class::reinitialize
0000s0sClass::MOP::Class::::remove_attributeClass::MOP::Class::remove_attribute
0000s0sClass::MOP::Class::::remove_dependent_meta_instanceClass::MOP::Class::remove_dependent_meta_instance
0000s0sClass::MOP::Class::::remove_meta_instance_dependenciesClass::MOP::Class::remove_meta_instance_dependencies
0000s0sClass::MOP::Class::::reset_package_cache_flagClass::MOP::Class::reset_package_cache_flag
0000s0sClass::MOP::Class::::subclassesClass::MOP::Class::subclasses
0000s0sClass::MOP::Class::::update_package_cache_flagClass::MOP::Class::update_package_cache_flag
LineStmts.Exclusive
Time
Avg.Code
1
2package Class::MOP::Class;
3
4330µs10µsuse strict;
# spent 14µs making 1 call to strict::import
5328µs9µsuse warnings;
# spent 26µs making 1 call to warnings::import
6
73102µs34µsuse Class::MOP::Instance;
# spent 5µs making 1 call to import
83116µs39µsuse Class::MOP::Method::Wrapped;
# spent 7µs making 1 call to import
93122µs40µsuse Class::MOP::Method::Accessor;
# spent 4µs making 1 call to import
103136µs45µsuse Class::MOP::Method::Constructor;
# spent 9µs making 1 call to import
113115µs38µsuse Class::MOP::MiniTrait;
# spent 8µs making 1 call to import
12
13338µs13µsuse Carp 'confess';
# spent 54µs making 1 call to Exporter::import
14329µs10µsuse Scalar::Util 'blessed', 'reftype', 'weaken';
# spent 51µs making 1 call to Exporter::import
15330µs10µsuse Sub::Name 'subname';
# spent 34µs making 1 call to Exporter::import
163112µs37µsuse Devel::GlobalDestruction 'in_global_destruction';
17341µs14µsuse Try::Tiny;
# spent 51µs making 1 call to Exporter::import
183196µs65µsuse List::MoreUtils 'all';
# spent 104µs making 1 call to Exporter::import
19
2011µs1µsour $VERSION = '1.09';
21131µs31µs$VERSION = eval $VERSION;
221600ns600nsour $AUTHORITY = 'cpan:STEVAN';
23
24use base 'Class::MOP::Module',
# spent 4.37ms making 1 call to base::import
25 'Class::MOP::Mixin::HasAttributes',
2632.02ms675µs 'Class::MOP::Mixin::HasMethods';
27
28# Creation
29
30
# spent 49.2ms (9.81+39.4) within Class::MOP::Class::initialize which was called 1415 times, avg 35µs/call: # 422 times (2.57ms+1.64ms) by Class::MOP::Class::get_all_attributes at line 804, avg 10µs/call # 301 times (1.92ms+1.19ms) by Class::MOP::Class::find_method_by_name at line 986, avg 10µs/call # 210 times (1.65ms+5.98ms) by Class::MOP::Method::Meta::_generate_meta_method or Class::MOP::Method::Meta::__ANON__[/usr/local/lib/perl/5.10.0/Class/MOP/Method/Meta.pm:45] at line 44 of /usr/local/lib/perl/5.10.0/Class/MOP/Method/Meta.pm, avg 36µs/call # 175 times (1.19ms+629µs) by Class::MOP::Class::find_next_method_by_name at line 1035, avg 10µs/call # 58 times (439µs+199µs) by Class::MOP::Class::find_attribute_by_name at line 794, avg 11µs/call # 52 times (361µs+-198µs) by Class::MOP::Class::_fix_metaclass_incompatibility at line 306, avg 3µs/call # 36 times (258µs+128µs) by Class::MOP::Class::find_all_methods_by_name at line 1018, avg 11µs/call # 33 times (218µs+6.10ms) at line 18 of /usr/local/lib/perl/5.10.0/Class/MOP/Object.pm, avg 191µs/call # 26 times (215µs+2.32ms) by Class::MOP::Method::_new at line 54 of /usr/local/lib/perl/5.10.0/Class/MOP/Method.pm, avg 98µs/call # 19 times (236µs+3.24ms) by metaclass::import at line 45 of /usr/local/lib/perl/5.10.0/metaclass.pm, avg 183µs/call # 18 times (128µs+2.01ms) at line 14 of /usr/local/lib/perl/5.10.0/Class/MOP/Mixin.pm, avg 119µs/call # 14 times (156µs+4.20ms) by Class::MOP::MiniTrait::apply at line 15 of /usr/local/lib/perl/5.10.0/Class/MOP/MiniTrait.pm, avg 311µs/call # 9 times (80µs+39µs) by Class::MOP::Class::get_all_methods at line 997, avg 13µs/call # 8 times (102µs+10.4ms) by Moose::Meta::Class::initialize at line 68 of /usr/local/lib/perl/5.10.0/Moose/Meta/Class.pm, avg 1.31ms/call # 8 times (49µs+27µs) by Class::MOP::Attribute::get_raw_value at line 274 of /usr/local/lib/perl/5.10.0/Class/MOP/Attribute.pm, avg 9µs/call # 7 times (65µs+1.06ms) at line 11 of /usr/local/lib/perl/5.10.0/Moose/Meta/Attribute/Native.pm, avg 161µs/call # 7 times (70µs+35µs) by namespace::autoclean::import or namespace::autoclean::__ANON__[/usr/local/share/perl/5.10.0/namespace/autoclean.pm:57] at line 44 of /usr/local/share/perl/5.10.0/namespace/autoclean.pm, avg 15µs/call # 7 times (52µs+39µs) by Class::MOP::Method::Generated::__ANON__[(eval 0)[/usr/local/lib/perl/5.10.0/Class/MOP/Method/Generated.pm:53]:24] at line 4 of (eval 0)[/usr/local/lib/perl/5.10.0/Class/MOP/Method/Generated.pm:53] at line 53 of /usr/local/lib/perl/5.10.0/Class/MOP/Method/Generated.pm, avg 13µs/call # 2 times (24µs+359µs) by Class::MOP::Class::create at line 520, avg 192µs/call # 2 times (20µs+8µs) by Class::MOP::Attribute::has_value at line 282 of /usr/local/lib/perl/5.10.0/Class/MOP/Attribute.pm, avg 14µs/call # once (8µs+4µs) by Class::MOP::Attribute::_new at line 62 of /usr/local/lib/perl/5.10.0/Class/MOP/Attribute.pm
sub initialize {
31707510.00ms1µs my $class = shift;
32
33 my $package_name;
34
35 if ( @_ % 2 ) {
36 $package_name = shift;
37 } else {
38 my %options = @_;
39 $package_name = $options{package};
40 }
41
42 ($package_name && !ref($package_name))
43 || confess "You must pass a package name and it cannot be blessed";
44
45 return Class::MOP::get_metaclass_by_name($package_name)
# spent 34.5ms making 71 calls to Class::MOP::Class::_construct_class_instance, avg 481µs/call, max recursion depth 1 # spent 5.99ms making 1415 calls to Class::MOP::get_metaclass_by_name, avg 4µs/call
46 || $class->_construct_class_instance(package => $package_name, @_);
47}
48
49sub reinitialize {
50 my ( $class, @args ) = @_;
51 unshift @args, "package" if @args % 2;
52 my %options = @args;
53 my $old_metaclass = blessed($options{package})
54 ? $options{package}
55 : Class::MOP::get_metaclass_by_name($options{package});
56 $old_metaclass->_remove_generated_metaobjects
57 if $old_metaclass && $old_metaclass->isa('Class::MOP::Class');
58 my $new_metaclass = $class->SUPER::reinitialize(@args);
59 $new_metaclass->_restore_metaobjects_from($old_metaclass)
60 if $old_metaclass && $old_metaclass->isa('Class::MOP::Class');
61 return $new_metaclass;
62}
63
64# NOTE: (meta-circularity)
65# this is a special form of _construct_instance
66# (see below), which is used to construct class
67# meta-object instances for any Class::MOP::*
68# class. All other classes will use the more
69# normal &construct_instance.
70
# spent 34.2ms (1.54+32.6) within Class::MOP::Class::_construct_class_instance which was called 71 times, avg 481µs/call: # 71 times (1.54ms+32.6ms) by Class::MOP::Class::initialize at line 45, avg 481µs/call
sub _construct_class_instance {
718522.17ms3µs my $class = shift;
72 my $options = @_ == 1 ? $_[0] : {@_};
73 my $package_name = $options->{package};
74 (defined $package_name && $package_name)
75 || confess "You must pass a package name";
76 # NOTE:
77 # return the metaclass if we have it cached,
78 # and it is still defined (it has not been
79 # reaped by DESTROY yet, which can happen
80 # annoyingly enough during global destruction)
81
82 if (defined(my $meta = Class::MOP::get_metaclass_by_name($package_name))) {
# spent 240µs making 71 calls to Class::MOP::get_metaclass_by_name, avg 3µs/call
83 return $meta;
84 }
85
86 $class
87 = ref $class
# spent 206µs making 8 calls to Class::MOP::Class::_real_ref_name, avg 26µs/call
88 ? $class->_real_ref_name
89 : $class;
90
91 # now create the metaclass
92 my $meta;
93877µs10µs if ($class eq 'Class::MOP::Class') {
# spent 1.34ms making 63 calls to Class::MOP::Class::_new, avg 21µs/call
94 $meta = $class->_new($options);
95 }
96 else {
97 # NOTE:
98 # it is safe to use meta here because
99 # class will always be a subclass of
100 # Class::MOP::Class, which defines meta
101 $meta = $class->meta->_construct_instance($options)
# spent 8.80ms making 8 calls to Class::MOP::Class::_construct_instance, avg 1.10ms/call # spent 174µs making 8 calls to Class::MOP::Object::meta, avg 22µs/call
102 }
103
104 # and check the metaclass compatibility
105 $meta->_check_metaclass_compatibility();
# spent 21.1ms making 71 calls to Class::MOP::Class::_check_metaclass_compatibility, avg 294µs/call, max recursion depth 1
106
107 Class::MOP::store_metaclass_by_name($package_name, $meta);
# spent 438µs making 71 calls to Class::MOP::store_metaclass_by_name, avg 6µs/call
108
109 # NOTE:
110 # we need to weaken any anon classes
111 # so that they can call DESTROY properly
112 Class::MOP::weaken_metaclass($package_name) if $meta->is_anon_class;
# spent 669µs making 71 calls to Class::MOP::Class::is_anon_class, avg 9µs/call
113
114 $meta;
115}
116
117
# spent 1.19ms (476µs+714µs) within Class::MOP::Class::_real_ref_name which was called 73 times, avg 16µs/call: # 52 times (329µs+456µs) by Class::MOP::Class::_class_metaclass_can_be_made_compatible at line 351, avg 15µs/call # 11 times (75µs+85µs) by Class::MOP::Class::_class_metaclass_is_compatible at line 261, avg 15µs/call # 8 times (57µs+149µs) by Class::MOP::Class::_construct_class_instance at line 87, avg 26µs/call # 2 times (16µs+24µs) by Class::MOP::Class::_immutable_metaclass at line 1212, avg 20µs/call
sub _real_ref_name {
118146568µs4µs my $self = shift;
119
120 # NOTE: we need to deal with the possibility of class immutability here,
121 # and then get the name of the class appropriately
122 return $self->is_immutable
# spent 282µs making 20 calls to Class::MOP::Class::Immutable::Class::MOP::Class::is_immutable, avg 14µs/call # spent 176µs making 28 calls to Class::MOP::Class::Immutable::Trait::_get_mutable_metaclass_name, avg 6µs/call # spent 141µs making 45 calls to Class::MOP::Class::is_immutable, avg 3µs/call # spent 116µs making 8 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::is_immutable, avg 15µs/call
123 ? $self->_get_mutable_metaclass_name()
124 : ref $self;
125}
126
127
# spent 1.34ms within Class::MOP::Class::_new which was called 63 times, avg 21µs/call: # 63 times (1.34ms+0s) by Class::MOP::Class::_construct_class_instance at line 93, avg 21µs/call
sub _new {
1282521.22ms5µs my $class = shift;
129
130 return Class::MOP::Class->initialize($class)->new_object(@_)
131 if $class ne __PACKAGE__;
132
133 my $options = @_ == 1 ? $_[0] : {@_};
134
135 return bless {
136 # inherited from Class::MOP::Package
137 'package' => $options->{package},
138
139 # NOTE:
140 # since the following attributes will
141 # actually be loaded from the symbol
142 # table, and actually bypass the instance
143 # entirely, we can just leave these things
144 # listed here for reference, because they
145 # should not actually have a value associated
146 # with the slot.
147 'namespace' => \undef,
148 'methods' => {},
149
150 # inherited from Class::MOP::Module
151 'version' => \undef,
152 'authority' => \undef,
153
154 # defined in Class::MOP::Class
155 'superclasses' => \undef,
156
157 'attributes' => {},
158 'attribute_metaclass' =>
159 ( $options->{'attribute_metaclass'} || 'Class::MOP::Attribute' ),
160 'method_metaclass' =>
161 ( $options->{'method_metaclass'} || 'Class::MOP::Method' ),
162 'wrapped_method_metaclass' => (
163 $options->{'wrapped_method_metaclass'}
164 || 'Class::MOP::Method::Wrapped'
165 ),
166 'instance_metaclass' =>
167 ( $options->{'instance_metaclass'} || 'Class::MOP::Instance' ),
168 'immutable_trait' => (
169 $options->{'immutable_trait'}
170 || 'Class::MOP::Class::Immutable::Trait'
171 ),
172 'constructor_name' => ( $options->{constructor_name} || 'new' ),
173 'constructor_class' => (
174 $options->{constructor_class} || 'Class::MOP::Method::Constructor'
175 ),
176 'destructor_class' => $options->{destructor_class},
177 }, $class;
178}
179
180sub reset_package_cache_flag { (shift)->{'_package_cache_flag'} = undef }
181sub update_package_cache_flag {
182 my $self = shift;
183 # NOTE:
184 # we can manually update the cache number
185 # since we are actually adding the method
186 # to our cache as well. This avoids us
187 # having to regenerate the method_map.
188 # - SL
189 $self->{'_package_cache_flag'} = Class::MOP::check_package_cache_flag($self->name);
190}
191
192## Metaclass compatibility
193{
19426µs3µs my %base_metaclass = (
195 attribute_metaclass => 'Class::MOP::Attribute',
196 method_metaclass => 'Class::MOP::Method',
197 wrapped_method_metaclass => 'Class::MOP::Method::Wrapped',
198 instance_metaclass => 'Class::MOP::Instance',
199 constructor_class => 'Class::MOP::Method::Constructor',
200 destructor_class => 'Class::MOP::Method::Destructor',
201 );
202
20396430µs4µs
# spent 631µs within Class::MOP::Class::_base_metaclasses which was called 96 times, avg 7µs/call: # 41 times (296µs+0s) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 339, avg 7µs/call # 33 times (184µs+0s) by Class::MOP::Class::_check_metaclass_compatibility at line 214, avg 6µs/call # 22 times (151µs+0s) by Moose::Meta::Class::_base_metaclasses at line 348 of /usr/local/lib/perl/5.10.0/Moose/Meta/Class.pm, avg 7µs/call
sub _base_metaclasses { %base_metaclass }
204}
205
206
# spent 34.7ms (1.89+32.9) within Class::MOP::Class::_check_metaclass_compatibility which was called 84 times, avg 414µs/call: # 71 times (1.10ms+19.8ms) by Class::MOP::Class::_construct_class_instance at line 105, avg 294µs/call # 13 times (794µs+13.0ms) at line 835, avg 1.06ms/call
sub _check_metaclass_compatibility {
2073221.69ms5µs my $self = shift;
208
209 my @superclasses = $self->superclasses
# spent 5.31ms making 65 calls to Class::MOP::Class::superclasses, avg 80µs/call, max recursion depth 1 # spent 1.69ms making 19 calls to Moose::Meta::Class::superclasses, avg 39µs/call, max recursion depth 1
210 or return;
211
212 $self->_fix_metaclass_incompatibility(@superclasses);
# spent 18.4ms making 44 calls to Class::MOP::Class::_fix_metaclass_incompatibility, avg 418µs/call
213
214 my %base_metaclass = $self->_base_metaclasses;
# spent 456µs making 11 calls to Moose::Meta::Class::_base_metaclasses, avg 41µs/call # spent 184µs making 33 calls to Class::MOP::Class::_base_metaclasses, avg 6µs/call
215
216 # this is always okay ...
217 return
218 if ref($self) eq 'Class::MOP::Class'
219 && all {
220396890µs2µs my $meta = $self->$_;
# spent 151µs making 33 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 5µs/call # spent 140µs making 33 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 4µs/call # spent 140µs making 33 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 4µs/call # spent 135µs making 33 calls to Class::MOP::Class::constructor_class, avg 4µs/call # spent 117µs making 33 calls to Class::MOP::Class::destructor_class, avg 4µs/call # spent 114µs making 33 calls to Class::MOP::Class::instance_metaclass, avg 3µs/call
2211253µs253µs !defined($meta) || $meta eq $base_metaclass{$_};
222 }
223 keys %base_metaclass;
# spent 1.57ms making 33 calls to List::MoreUtils::all, avg 48µs/call
224
225 for my $superclass (@superclasses) {
2261166µs6µs $self->_check_class_metaclass_compatibility($superclass);
# spent 561µs making 11 calls to Class::MOP::Class::_check_class_metaclass_compatibility, avg 51µs/call
227 }
228
229 for my $metaclass_type ( keys %base_metaclass ) {
230154635µs4µs next unless defined $self->$metaclass_type;
# spent 97µs making 11 calls to Moose::Meta::Class::constructor_class, avg 9µs/call # spent 95µs making 11 calls to Moose::Meta::Class::destructor_class, avg 9µs/call # spent 91µs making 11 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 8µs/call # spent 86µs making 11 calls to Class::MOP::Class::instance_metaclass, avg 8µs/call # spent 84µs making 11 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 8µs/call # spent 57µs making 11 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 5µs/call # spent 54µs making 11 calls to Moose::Meta::Class::error_class, avg 5µs/call
231 for my $superclass (@superclasses) {
23277337µs4µs $self->_check_single_metaclass_compatibility( $metaclass_type,
# spent 4.30ms making 77 calls to Class::MOP::Class::_check_single_metaclass_compatibility, avg 56µs/call
233 $superclass );
234 }
235 }
236}
237
238
# spent 561µs (106+455) within Class::MOP::Class::_check_class_metaclass_compatibility which was called 11 times, avg 51µs/call: # 11 times (106µs+455µs) by Class::MOP::Class::_check_metaclass_compatibility at line 226, avg 51µs/call
sub _check_class_metaclass_compatibility {
2393396µs3µs my $self = shift;
240 my ( $superclass_name ) = @_;
241
242 if (!$self->_class_metaclass_is_compatible($superclass_name)) {
# spent 455µs making 11 calls to Class::MOP::Class::_class_metaclass_is_compatible, avg 41µs/call
243 my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name);
244
245 my $super_meta_type = $super_meta->_real_ref_name;
246
247 confess "The metaclass of " . $self->name . " ("
248 . (ref($self)) . ")" . " is not compatible with "
249 . "the metaclass of its superclass, "
250 . $superclass_name . " (" . ($super_meta_type) . ")";
251 }
252}
253
254
# spent 455µs (129+326) within Class::MOP::Class::_class_metaclass_is_compatible which was called 11 times, avg 41µs/call: # 11 times (129µs+326µs) by Class::MOP::Class::_check_class_metaclass_compatibility at line 242, avg 41µs/call
sub _class_metaclass_is_compatible {
25555174µs3µs my $self = shift;
256 my ( $superclass_name ) = @_;
257
258 my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name)
# spent 44µs making 11 calls to Class::MOP::get_metaclass_by_name, avg 4µs/call
259 || return 1;
260
261 my $super_meta_name = $super_meta->_real_ref_name;
# spent 160µs making 11 calls to Class::MOP::Class::_real_ref_name, avg 15µs/call
262
263 return $self->_is_compatible_with($super_meta_name);
# spent 122µs making 11 calls to Class::MOP::Object::_is_compatible_with, avg 11µs/call
264}
265
266
# spent 4.30ms (494µs+3.80) within Class::MOP::Class::_check_single_metaclass_compatibility which was called 77 times, avg 56µs/call: # 77 times (494µs+3.80ms) by Class::MOP::Class::_check_metaclass_compatibility at line 232, avg 56µs/call
sub _check_single_metaclass_compatibility {
267231505µs2µs my $self = shift;
268 my ( $metaclass_type, $superclass_name ) = @_;
269
270 if (!$self->_single_metaclass_is_compatible($metaclass_type, $superclass_name)) {
# spent 3.80ms making 77 calls to Class::MOP::Class::_single_metaclass_is_compatible, avg 49µs/call
271 my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name);
272 my $metaclass_type_name = $metaclass_type;
273 $metaclass_type_name =~ s/_(?:meta)?class$//;
274 $metaclass_type_name =~ s/_/ /g;
275 confess "The $metaclass_type_name metaclass for "
276 . $self->name . " (" . ($self->$metaclass_type)
277 . ")" . " is not compatible with the "
278 . "$metaclass_type_name metaclass of its "
279 . "superclass, $superclass_name ("
280 . ($super_meta->$metaclass_type) . ")";
281 }
282}
283
284
# spent 3.80ms (1.12+2.68) within Class::MOP::Class::_single_metaclass_is_compatible which was called 77 times, avg 49µs/call: # 77 times (1.12ms+2.68ms) by Class::MOP::Class::_check_single_metaclass_compatibility at line 270, avg 49µs/call
sub _single_metaclass_is_compatible {
2855392.34ms4µs my $self = shift;
286 my ( $metaclass_type, $superclass_name ) = @_;
287
288 my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name)
# spent 268µs making 77 calls to Class::MOP::get_metaclass_by_name, avg 3µs/call
289 || return 1;
290
291 # for instance, Moose::Meta::Class has a error_class attribute, but
292 # Class::MOP::Class doesn't - this shouldn't be an error
293 return 1 unless $super_meta->can($metaclass_type);
# spent 189µs making 77 calls to UNIVERSAL::can, avg 2µs/call
294 # for instance, Moose::Meta::Class has a destructor_class, but
295 # Class::MOP::Class doesn't - this shouldn't be an error
296 return 1 unless defined $super_meta->$metaclass_type;
# spent 93µs making 11 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 8µs/call # spent 85µs making 11 calls to Class::MOP::Class::instance_metaclass, avg 8µs/call # spent 76µs making 11 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 7µs/call # spent 75µs making 11 calls to Moose::Meta::Class::destructor_class, avg 7µs/call # spent 74µs making 11 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 7µs/call # spent 70µs making 11 calls to Moose::Meta::Class::constructor_class, avg 6µs/call # spent 45µs making 11 calls to Moose::Meta::Class::error_class, avg 4µs/call
297 # if metaclass is defined in superclass but not here, it's not compatible
298 # this is a really odd case
299 return 0 unless defined $self->$metaclass_type;
# spent 69µs making 11 calls to Moose::Meta::Class::destructor_class, avg 6µs/call # spent 65µs making 11 calls to Moose::Meta::Class::constructor_class, avg 6µs/call # spent 48µs making 11 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 4µs/call # spent 47µs making 11 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 4µs/call # spent 44µs making 11 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 4µs/call # spent 42µs making 11 calls to Moose::Meta::Class::error_class, avg 4µs/call # spent 39µs making 11 calls to Class::MOP::Class::instance_metaclass, avg 4µs/call
300
301 return $self->$metaclass_type->_is_compatible_with($super_meta->$metaclass_type);
# spent 730µs making 77 calls to Class::MOP::Object::_is_compatible_with, avg 9µs/call # spent 106µs making 22 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 5µs/call # spent 98µs making 22 calls to Moose::Meta::Class::constructor_class, avg 4µs/call # spent 87µs making 22 calls to Moose::Meta::Class::destructor_class, avg 4µs/call # spent 86µs making 22 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 4µs/call # spent 82µs making 22 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 4µs/call # spent 82µs making 22 calls to Moose::Meta::Class::error_class, avg 4µs/call # spent 81µs making 22 calls to Class::MOP::Class::instance_metaclass, avg 4µs/call
302}
303
304
# spent 18.4ms (693µs+17.7) within Class::MOP::Class::_fix_metaclass_incompatibility which was called 44 times, avg 418µs/call: # 44 times (693µs+17.7ms) by Class::MOP::Class::_check_metaclass_compatibility at line 212, avg 418µs/call
sub _fix_metaclass_incompatibility {
305220326µs1µs my $self = shift;
30652214µs4µs my @supers = map { Class::MOP::Class->initialize($_) } @_;
# spent 896µs making 52 calls to Class::MOP::Class::initialize, avg 3µs/call, max recursion depth 1
307
308 my $necessary = 0;
309 for my $super (@supers) {
31052264µs5µs $necessary = 1
# spent 16.8ms making 52 calls to Class::MOP::Class::_can_fix_metaclass_incompatibility, avg 323µs/call
311 if $self->_can_fix_metaclass_incompatibility($super);
312 }
313 return unless $necessary;
314
315 for my $super (@supers) {
316 if (!$self->_class_metaclass_is_compatible($super->name)) {
317 $self->_fix_class_metaclass_incompatibility($super);
318 }
319 }
320
321 my %base_metaclass = $self->_base_metaclasses;
322 for my $metaclass_type (keys %base_metaclass) {
323 for my $super (@supers) {
324 if (!$self->_single_metaclass_is_compatible($metaclass_type, $super->name)) {
325 $self->_fix_single_metaclass_incompatibility(
326 $metaclass_type, $super
327 );
328 }
329 }
330 }
331}
332
333
# spent 16.8ms (1.62+15.2) within Class::MOP::Class::_can_fix_metaclass_incompatibility which was called 52 times, avg 323µs/call: # 52 times (1.62ms+15.2ms) by Class::MOP::Class::_fix_metaclass_incompatibility at line 310, avg 323µs/call
sub _can_fix_metaclass_incompatibility {
3343121.13ms4µs my $self = shift;
335 my ($super_meta) = @_;
336
337 return 1 if $self->_class_metaclass_can_be_made_compatible($super_meta);
# spent 1.96ms making 52 calls to Class::MOP::Class::_class_metaclass_can_be_made_compatible, avg 38µs/call
338
339 my %base_metaclass = $self->_base_metaclasses;
# spent 515µs making 11 calls to Moose::Meta::Class::_base_metaclasses, avg 47µs/call # spent 296µs making 41 calls to Class::MOP::Class::_base_metaclasses, avg 7µs/call
340 for my $metaclass_type (keys %base_metaclass) {
3413231.26ms4µs return 1 if $self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type);
# spent 12.4ms making 323 calls to Class::MOP::Class::_single_metaclass_can_be_made_compatible, avg 38µs/call
342 }
343
344 return;
345}
346
347
# spent 1.96ms (376µs+1.58) within Class::MOP::Class::_class_metaclass_can_be_made_compatible which was called 52 times, avg 38µs/call: # 52 times (376µs+1.58ms) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 337, avg 38µs/call
sub _class_metaclass_can_be_made_compatible {
348156510µs3µs my $self = shift;
349 my ($super_meta) = @_;
350
351 return $self->_can_be_made_compatible_with($super_meta->_real_ref_name);
# spent 800µs making 52 calls to Class::MOP::Object::_can_be_made_compatible_with, avg 15µs/call # spent 785µs making 52 calls to Class::MOP::Class::_real_ref_name, avg 15µs/call
352}
353
354
# spent 12.4ms (4.03+8.40) within Class::MOP::Class::_single_metaclass_can_be_made_compatible which was called 323 times, avg 38µs/call: # 323 times (4.03ms+8.40ms) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 341, avg 38µs/call
sub _single_metaclass_can_be_made_compatible {
35525026.67ms3µs my $self = shift;
356 my ($super_meta, $metaclass_type) = @_;
357
358 my $specific_meta = $self->$metaclass_type;
# spent 276µs making 52 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 5µs/call # spent 269µs making 52 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 5µs/call # spent 256µs making 52 calls to Class::MOP::Class::instance_metaclass, avg 5µs/call # spent 236µs making 52 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 5µs/call # spent 167µs making 41 calls to Class::MOP::Class::constructor_class, avg 4µs/call # spent 149µs making 41 calls to Class::MOP::Class::destructor_class, avg 4µs/call # spent 76µs making 11 calls to Moose::Meta::Class::destructor_class, avg 7µs/call # spent 68µs making 11 calls to Moose::Meta::Class::constructor_class, avg 6µs/call # spent 67µs making 11 calls to Moose::Meta::Class::error_class, avg 6µs/call
359
360 return unless $super_meta->can($metaclass_type);
# spent 907µs making 323 calls to UNIVERSAL::can, avg 3µs/call
361 my $super_specific_meta = $super_meta->$metaclass_type;
# spent 303µs making 52 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 6µs/call # spent 292µs making 52 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 6µs/call # spent 278µs making 52 calls to Class::MOP::Class::instance_metaclass, avg 5µs/call # spent 269µs making 52 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 5µs/call # spent 223µs making 41 calls to Class::MOP::Class::constructor_class, avg 5µs/call # spent 178µs making 41 calls to Class::MOP::Class::destructor_class, avg 4µs/call # spent 96µs making 11 calls to Moose::Meta::Class::constructor_class, avg 9µs/call # spent 87µs making 11 calls to Moose::Meta::Class::destructor_class, avg 8µs/call # spent 50µs making 11 calls to Moose::Meta::Class::error_class, avg 5µs/call
362
363 # for instance, Moose::Meta::Class has a destructor_class, but
364 # Class::MOP::Class doesn't - this shouldn't be an error
365 return unless defined $super_specific_meta;
366
367 # if metaclass is defined in superclass but not here, it's fixable
368 # this is a really odd case
369 return 1 unless defined $specific_meta;
370
371 return 1 if $specific_meta->_can_be_made_compatible_with($super_specific_meta);
# spent 4.15ms making 282 calls to Class::MOP::Object::_can_be_made_compatible_with, avg 15µs/call
372}
373
374sub _fix_class_metaclass_incompatibility {
375 my $self = shift;
376 my ( $super_meta ) = @_;
377
378 if ($self->_class_metaclass_can_be_made_compatible($super_meta)) {
379 ($self->is_pristine)
380 || confess "Can't fix metaclass incompatibility for "
381 . $self->name
382 . " because it is not pristine.";
383
384 my $super_meta_name = $super_meta->_real_ref_name;
385
386 $self->_make_compatible_with($super_meta_name);
387 }
388}
389
390sub _fix_single_metaclass_incompatibility {
391 my $self = shift;
392 my ( $metaclass_type, $super_meta ) = @_;
393
394 if ($self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type)) {
395 ($self->is_pristine)
396 || confess "Can't fix metaclass incompatibility for "
397 . $self->name
398 . " because it is not pristine.";
399
400 my $new_metaclass = $self->$metaclass_type
401 ? $self->$metaclass_type->_get_compatible_metaclass($super_meta->$metaclass_type)
402 : $super_meta->$metaclass_type;
403 $self->{$metaclass_type} = $new_metaclass;
404 }
405}
406
407sub _restore_metaobjects_from {
408 my $self = shift;
409 my ($old_meta) = @_;
410
411 $self->_restore_metamethods_from($old_meta);
412 $self->_restore_metaattributes_from($old_meta);
413}
414
415sub _remove_generated_metaobjects {
416 my $self = shift;
417
418 for my $attr (map { $self->get_attribute($_) } $self->get_attribute_list) {
419 $attr->remove_accessors;
420 }
421}
422
423## ANON classes
424
425{
426 # NOTE:
427 # this should be sufficient, if you have a
428 # use case where it is not, write a test and
429 # I will change it.
43032µs600ns my $ANON_CLASS_SERIAL = 0;
431
432 # NOTE:
433 # we need a sufficiently annoying prefix
434 # this should suffice for now, this is
435 # used in a couple of places below, so
436 # need to put it up here for now.
437 my $ANON_CLASS_PREFIX = 'Class::MOP::Class::__ANON__::SERIAL::';
438
439
# spent 1.04ms (749µs+291µs) within Class::MOP::Class::is_anon_class which was called 114 times, avg 9µs/call: # 71 times (486µs+183µs) by Class::MOP::Class::_construct_class_instance at line 112, avg 9µs/call # 43 times (262µs+108µs) by Class::MOP::Class::_construct_instance at line 602, avg 9µs/call
sub is_anon_class {
440228801µs4µs my $self = shift;
4413133µs44µs no warnings 'uninitialized';
# spent 29µs making 1 call to warnings::unimport
442 $self->name =~ /^$ANON_CLASS_PREFIX/o;
# spent 291µs making 114 calls to Class::MOP::Package::name, avg 3µs/call
443 }
444
445 sub create_anon_class {
446 my ($class, %options) = @_;
447 my $package_name = $ANON_CLASS_PREFIX . ++$ANON_CLASS_SERIAL;
448 return $class->create($package_name, %options);
449 }
450
451 # NOTE:
452 # this will only get called for
453 # anon-classes, all other calls
454 # are assumed to occur during
455 # global destruction and so don't
456 # really need to be handled explicitly
457 sub DESTROY {
458 my $self = shift;
459
460 return if in_global_destruction(); # it'll happen soon anyway and this just makes things more complicated
461
462388µs29µs no warnings 'uninitialized';
# spent 20µs making 1 call to warnings::unimport
463 my $name = $self->name;
464 return unless $name =~ /^$ANON_CLASS_PREFIX/o;
465
466 # Moose does a weird thing where it replaces the metaclass for
467 # class when fixing metaclass incompatibility. In that case,
468 # we don't want to clean out the namespace now. We can detect
469 # that because Moose will explicitly update the singleton
470 # cache in Class::MOP.
471 my $current_meta = Class::MOP::get_metaclass_by_name($name);
472 return if $current_meta ne $self;
473
474 my ($serial_id) = ($name =~ /^$ANON_CLASS_PREFIX(\d+)/o);
47534.67ms1.56ms no strict 'refs';
# spent 21µs making 1 call to strict::unimport
476 @{$name . '::ISA'} = ();
477 %{$name . '::'} = ();
478 delete ${$ANON_CLASS_PREFIX}{$serial_id . '::'};
479
480 Class::MOP::remove_metaclass_by_name($name);
481 }
482
483}
484
485# creating classes with MOP ...
486
487
# spent 3.13ms (90µs+3.04) within Class::MOP::Class::create which was called 2 times, avg 1.56ms/call: # 2 times (90µs+3.04ms) by Class::MOP::Class::_immutable_metaclass at line 1214, avg 1.56ms/call
sub create {
48834111µs3µs my ( $class, @args ) = @_;
489
490 unshift @args, 'package' if @args % 2 == 1;
491
492 my (%options) = @args;
493 my $package_name = $options{package};
494
495 (ref $options{superclasses} eq 'ARRAY')
496 || confess "You must pass an ARRAY ref of superclasses"
497 if exists $options{superclasses};
498
499 (ref $options{attributes} eq 'ARRAY')
500 || confess "You must pass an ARRAY ref of attributes"
501 if exists $options{attributes};
502
503 (ref $options{methods} eq 'HASH')
504 || confess "You must pass a HASH ref of methods"
505 if exists $options{methods};
506
507 $options{meta_name} = 'meta'
508 unless exists $options{meta_name};
509
510 my (%initialize_options) = @args;
511 delete @initialize_options{qw(
512 package
513 superclasses
514 attributes
515 methods
516 meta_name
517 version
518 authority
519 )};
520 my $meta = $class->initialize( $package_name => %initialize_options );
# spent 383µs making 2 calls to Class::MOP::Class::initialize, avg 192µs/call
521
522 $meta->_instantiate_module( $options{version}, $options{authority} );
# spent 74µs making 2 calls to Class::MOP::Module::_instantiate_module, avg 37µs/call
523
524 $meta->_add_meta_method($options{meta_name})
# spent 1.36ms making 2 calls to Class::MOP::Mixin::HasMethods::_add_meta_method, avg 678µs/call
525 if defined $options{meta_name};
526
527 $meta->superclasses(@{$options{superclasses}})
# spent 1.22ms making 2 calls to Class::MOP::Class::superclasses, avg 612µs/call
528 if exists $options{superclasses};
529 # NOTE:
530 # process attributes first, so that they can
531 # install accessors, but locally defined methods
532 # can then overwrite them. It is maybe a little odd, but
533 # I think this should be the order of things.
534 if (exists $options{attributes}) {
535 foreach my $attr (@{$options{attributes}}) {
536 $meta->add_attribute($attr);
537 }
538 }
539 if (exists $options{methods}) {
540 foreach my $method_name (keys %{$options{methods}}) {
541 $meta->add_method($method_name, $options{methods}->{$method_name});
542 }
543 }
544 return $meta;
545}
546
547## Attribute readers
548
549# NOTE:
550# all these attribute readers will be bootstrapped
551# away in the Class::MOP bootstrap section
552
553344820µs2µssub instance_metaclass { $_[0]->{'instance_metaclass'} }
554102353µs3µssub immutable_trait { $_[0]->{'immutable_trait'} }
555166388µs2µssub constructor_class { $_[0]->{'constructor_class'} }
55658151µs3µssub constructor_name { $_[0]->{'constructor_name'} }
557166320µs2µssub destructor_class { $_[0]->{'destructor_class'} }
558
559# Instance Construction & Cloning
560
561
# spent 13.6ms (339µs+13.3) within Class::MOP::Class::new_object which was called 35 times, avg 389µs/call: # 26 times (243µs+8.78ms) by Class::MOP::Method::_new at line 54 of /usr/local/lib/perl/5.10.0/Class/MOP/Method.pm, avg 347µs/call # 7 times (65µs+2.87ms) by Class::MOP::Method::Generated::__ANON__[(eval 0)[/usr/local/lib/perl/5.10.0/Class/MOP/Method/Generated.pm:53]:24] at line 4 of (eval 0)[/usr/local/lib/perl/5.10.0/Class/MOP/Method/Generated.pm:53] at line 53 of /usr/local/lib/perl/5.10.0/Class/MOP/Method/Generated.pm, avg 419µs/call # once (18µs+1.22ms) by Class::MOP::Attribute::_new at line 62 of /usr/local/lib/perl/5.10.0/Class/MOP/Attribute.pm # once (14µs+400µs) by Class::MOP::Object::_new at line 22 of /usr/local/lib/perl/5.10.0/Class/MOP/Object.pm
sub new_object {
562105664µs6µs my $class = shift;
563
564 # NOTE:
565 # we need to protect the integrity of the
566 # Class::MOP::Class singletons here, so we
567 # delegate this to &construct_class_instance
568 # which will deal with the singletons
569 return $class->_construct_class_instance(@_)
# spent 225µs making 35 calls to UNIVERSAL::isa, avg 6µs/call # spent 105µs making 35 calls to Class::MOP::Package::name, avg 3µs/call
570 if $class->name->isa('Class::MOP::Class');
571 return $class->_construct_instance(@_);
# spent 12.9ms making 35 calls to Class::MOP::Class::_construct_instance, avg 370µs/call
572}
573
574
# spent 21.7ms (1.89+19.8) within Class::MOP::Class::_construct_instance which was called 43 times, avg 505µs/call: # 35 times (1.20ms+11.7ms) by Class::MOP::Class::new_object at line 571, avg 370µs/call # 8 times (694µs+8.10ms) by Class::MOP::Class::_construct_class_instance at line 101, avg 1.10ms/call
sub _construct_instance {
5753441.30ms4µs my $class = shift;
576 my $params = @_ == 1 ? $_[0] : {@_};
577 my $meta_instance = $class->get_meta_instance();
# spent 2.09ms making 16 calls to Class::MOP::Class::get_meta_instance, avg 130µs/call # spent 482µs making 27 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_meta_instance, avg 18µs/call
578 # FIXME:
579 # the code below is almost certainly incorrect
580 # but this is foreign inheritance, so we might
581 # have to kludge it in the end.
582 my $instance;
58343195µs5µs if (my $instance_class = blessed($params->{__INSTANCE__})) {
# spent 187µs making 43 calls to Scalar::Util::blessed, avg 4µs/call
584 ($instance_class eq $class->name)
585 || confess "Objects passed as the __INSTANCE__ parameter must "
586 . "already be blessed into the correct class, but "
587 . "$params->{__INSTANCE__} is not a " . $class->name;
588 $instance = $params->{__INSTANCE__};
589 }
590 elsif (exists $params->{__INSTANCE__}) {
591 confess "The __INSTANCE__ parameter must be a blessed reference, not "
592 . $params->{__INSTANCE__};
593 }
594 else {
595 $instance = $meta_instance->create_instance();
# spent 2.29ms making 43 calls to Class::MOP::Instance::create_instance, avg 53µs/call
596 }
597 foreach my $attr ($class->get_all_attributes()) {
# spent 1.85ms making 16 calls to Class::MOP::Class::get_all_attributes, avg 116µs/call # spent 843µs making 27 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_all_attributes, avg 31µs/call
5983471.65ms5µs $attr->initialize_instance_slot($meta_instance, $instance, $params);
# spent 11.7ms making 347 calls to Class::MOP::Attribute::initialize_instance_slot, avg 34µs/call
599 }
600 # NOTE:
601 # this will only work for a HASH instance type
602 if ($class->is_anon_class) {
# spent 371µs making 43 calls to Class::MOP::Class::is_anon_class, avg 9µs/call
603 (reftype($instance) eq 'HASH')
604 || confess "Currently only HASH based instances are supported with instance of anon-classes";
605 # NOTE:
606 # At some point we should make this official
607 # as a reserved slot name, but right now I am
608 # going to keep it here.
609 # my $RESERVED_MOP_SLOT = '__MOP__';
610 $instance->{'__MOP__'} = $class;
611 }
612 return $instance;
613}
614
615
616
# spent 15.8ms (1.58+14.2) within Class::MOP::Class::get_meta_instance which was called 321 times, avg 49µs/call: # 126 times (510µs+2.06ms) by Class::MOP::Attribute::inline_set at line 419 of /usr/local/lib/perl/5.10.0/Class/MOP/Attribute.pm, avg 20µs/call # 78 times (441µs+3.37ms) by Class::MOP::Attribute::inline_get at line 411 of /usr/local/lib/perl/5.10.0/Class/MOP/Attribute.pm, avg 49µs/call # 38 times (211µs+2.11ms) by Class::MOP::Class::inline_create_instance at line 638, avg 61µs/call # 23 times (125µs+1.34ms) by Moose::Meta::Attribute::inline_set at line 587 of /usr/local/lib/perl/5.10.0/Moose/Meta/Attribute.pm, avg 64µs/call # 22 times (108µs+3.10ms) by Class::MOP::Class::Immutable::Trait::get_meta_instance at line 74 of /usr/local/lib/perl/5.10.0/Class/MOP/Class/Immutable/Trait.pm, avg 146µs/call # 16 times (92µs+1.99ms) by Class::MOP::Class::_construct_instance at line 577, avg 130µs/call # 13 times (53µs+0s) by Class::MOP::Attribute::inline_has at line 428 of /usr/local/lib/perl/5.10.0/Class/MOP/Attribute.pm, avg 4µs/call # 3 times (22µs+0s) by Class::MOP::Attribute::get_raw_value at line 274 of /usr/local/lib/perl/5.10.0/Class/MOP/Attribute.pm, avg 7µs/call # once (12µs+228µs) at line 683 of /usr/local/lib/perl/5.10.0/Class/MOP.pm # once (7µs+0s) by Class::MOP::Attribute::has_value at line 282 of /usr/local/lib/perl/5.10.0/Class/MOP/Attribute.pm
sub get_meta_instance {
6176421.02ms2µs my $self = shift;
618 $self->{'_meta_instance'} ||= $self->_create_meta_instance();
# spent 14.2ms making 58 calls to Class::MOP::Class::_create_meta_instance, avg 245µs/call
619}
620
621
# spent 14.2ms (661µs+13.5) within Class::MOP::Class::_create_meta_instance which was called 58 times, avg 245µs/call: # 58 times (661µs+13.5ms) by Class::MOP::Class::get_meta_instance at line 618, avg 245µs/call
sub _create_meta_instance {
6222321.14ms5µs my $self = shift;
623
624 my $instance = $self->instance_metaclass->new(
# spent 7.21ms making 58 calls to Class::MOP::Instance::new, avg 124µs/call # spent 4.42ms making 46 calls to Class::MOP::Class::get_all_attributes, avg 96µs/call # spent 1.43ms making 12 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_all_attributes, avg 119µs/call # spent 278µs making 58 calls to Class::MOP::Class::instance_metaclass, avg 5µs/call
625 associated_metaclass => $self,
626 attributes => [ $self->get_all_attributes() ],
627 );
628
629 $self->add_meta_instance_dependencies()
# spent 204µs making 58 calls to Class::MOP::Instance::is_dependent_on_superclasses, avg 4µs/call
630 if $instance->is_dependent_on_superclasses();
631
632 return $instance;
633}
634
635
# spent 2.85ms (272µs+2.58) within Class::MOP::Class::inline_create_instance which was called 38 times, avg 75µs/call: # 31 times (217µs+2.19ms) by Class::MOP::Method::Constructor::_generate_constructor_method_inline at line 112 of /usr/local/lib/perl/5.10.0/Class/MOP/Method/Constructor.pm, avg 78µs/call # 7 times (55µs+382µs) by Moose::Meta::Method::Constructor::_generate_instance at line 131 of /usr/local/lib/perl/5.10.0/Moose/Meta/Method/Constructor.pm, avg 62µs/call
sub inline_create_instance {
63676356µs5µs my $self = shift;
637
638 return $self->get_meta_instance->inline_create_instance(@_);
# spent 2.32ms making 38 calls to Class::MOP::Class::get_meta_instance, avg 61µs/call # spent 253µs making 38 calls to Class::MOP::Instance::inline_create_instance, avg 7µs/call
639}
640
641sub inline_rebless_instance {
642 my $self = shift;
643
644 return $self->get_meta_instance->inline_rebless_instance_structure(@_);
645}
646
647sub clone_object {
648 my $class = shift;
649 my $instance = shift;
650 (blessed($instance) && $instance->isa($class->name))
651 || confess "You must pass an instance of the metaclass (" . (ref $class ? $class->name : $class) . "), not ($instance)";
652
653 # NOTE:
654 # we need to protect the integrity of the
655 # Class::MOP::Class singletons here, they
656 # should not be cloned.
657 return $instance if $instance->isa('Class::MOP::Class');
658 $class->_clone_instance($instance, @_);
659}
660
661sub _clone_instance {
662 my ($class, $instance, %params) = @_;
663 (blessed($instance))
664 || confess "You can only clone instances, ($instance) is not a blessed instance";
665 my $meta_instance = $class->get_meta_instance();
666 my $clone = $meta_instance->clone_instance($instance);
667 foreach my $attr ($class->get_all_attributes()) {
668 if ( defined( my $init_arg = $attr->init_arg ) ) {
669 if (exists $params{$init_arg}) {
670 $attr->set_value($clone, $params{$init_arg});
671 }
672 }
673 }
674 return $clone;
675}
676
677sub _force_rebless_instance {
678 my ($self, $instance, %params) = @_;
679 my $old_metaclass = Class::MOP::class_of($instance);
680
681 $old_metaclass->rebless_instance_away($instance, $self, %params)
682 if $old_metaclass;
683
684 my $meta_instance = $self->get_meta_instance;
685
686 # rebless!
687 # we use $_[1] here because of t/306_rebless_overload.t regressions on 5.8.8
688 $meta_instance->rebless_instance_structure($_[1], $self);
689
690 $self->_fixup_attributes_after_rebless($instance, $old_metaclass, %params);
691}
692
693sub rebless_instance {
694 my ($self, $instance, %params) = @_;
695 my $old_metaclass = Class::MOP::class_of($instance);
696
697 my $old_class = $old_metaclass ? $old_metaclass->name : blessed($instance);
698 $self->name->isa($old_class)
699 || confess "You may rebless only into a subclass of ($old_class), of which (". $self->name .") isn't.";
700
701 $self->_force_rebless_instance($_[1], %params);
702
703 return $instance;
704}
705
706sub rebless_instance_back {
707 my ( $self, $instance ) = @_;
708 my $old_metaclass = Class::MOP::class_of($instance);
709
710 my $old_class
711 = $old_metaclass ? $old_metaclass->name : blessed($instance);
712 $old_class->isa( $self->name )
713 || confess
714 "You may rebless only into a superclass of ($old_class), of which ("
715 . $self->name
716 . ") isn't.";
717
718 $self->_force_rebless_instance($_[1]);
719
720 return $instance;
721}
722
723sub rebless_instance_away {
724 # this intentionally does nothing, it is just a hook
725}
726
727sub _fixup_attributes_after_rebless {
728 my $self = shift;
729 my ($instance, $rebless_from, %params) = @_;
730 my $meta_instance = $self->get_meta_instance;
731
732 for my $attr ( $rebless_from->get_all_attributes ) {
733 next if $self->find_attribute_by_name( $attr->name );
734 $meta_instance->deinitialize_slot( $instance, $_ ) for $attr->slots;
735 }
736
737 foreach my $attr ( $self->get_all_attributes ) {
738 if ( $attr->has_value($instance) ) {
739 if ( defined( my $init_arg = $attr->init_arg ) ) {
740 $params{$init_arg} = $attr->get_value($instance)
741 unless exists $params{$init_arg};
742 }
743 else {
744 $attr->set_value($instance, $attr->get_value($instance));
745 }
746 }
747 }
748
749 foreach my $attr ($self->get_all_attributes) {
750 $attr->initialize_instance_slot($meta_instance, $instance, \%params);
751 }
752}
753
754
# spent 2.51ms (664µs+1.84) within Class::MOP::Class::_attach_attribute which was called 123 times, avg 20µs/call: # 123 times (664µs+1.84ms) by Class::MOP::Mixin::HasAttributes::add_attribute at line 28 of /usr/local/lib/perl/5.10.0/Class/MOP/Mixin/HasAttributes.pm, avg 20µs/call
sub _attach_attribute {
755246670µs3µs my ($self, $attribute) = @_;
756 $attribute->attach_to_class($self);
# spent 1.84ms making 123 calls to Class::MOP::Attribute::attach_to_class, avg 15µs/call
757}
758
759
# spent 65.8ms (1.61+64.2) within Class::MOP::Class::_post_add_attribute which was called 123 times, avg 535µs/call: # 123 times (1.61ms+64.2ms) by Class::MOP::Mixin::HasAttributes::add_attribute at line 45 of /usr/local/lib/perl/5.10.0/Class/MOP/Mixin/HasAttributes.pm, avg 535µs/call
sub _post_add_attribute {
7603692.19ms6µs my ( $self, $attribute ) = @_;
761
762 $self->invalidate_meta_instances;
# spent 1.50ms making 123 calls to Class::MOP::Class::invalidate_meta_instances, avg 12µs/call
763
764 # invalidate package flag here
765
# spent 59.5ms (1.30+58.2) within Class::MOP::Class::__ANON__[/usr/local/lib/perl/5.10.0/Class/MOP/Class.pm:768] which was called 123 times, avg 484µs/call: # 123 times (1.30ms+58.2ms) by Try::Tiny::try at line 76 of /usr/local/share/perl/5.10.0/Try/Tiny.pm, avg 484µs/call
try {
7662461.26ms5µs local $SIG{__DIE__};
767 $attribute->install_accessors;
# spent 40.5ms making 114 calls to Class::MOP::Attribute::install_accessors, avg 355µs/call # spent 17.7ms making 9 calls to Moose::Meta::Attribute::install_accessors, avg 1.97ms/call
768 }
769 catch {
770 $self->remove_attribute( $attribute->name );
771 die $_;
772 };
# spent 61.8ms making 123 calls to Try::Tiny::try, avg 490µs/call, max recursion depth 1 # spent 865µs making 123 calls to Try::Tiny::catch, avg 7µs/call
773}
774
775sub remove_attribute {
776 my $self = shift;
777
778 my $removed_attribute = $self->SUPER::remove_attribute(@_)
779 or return;
780
781 $self->invalidate_meta_instances;
782
783 $removed_attribute->remove_accessors;
784 $removed_attribute->detach_from_class;
785
786 return$removed_attribute;
787}
788
789
# spent 3.79ms (779µs+3.01) within Class::MOP::Class::find_attribute_by_name which was called 58 times, avg 65µs/call: # 58 times (779µs+3.01ms) by Class::MOP::Class::_immutable_metaclass at line 1191, avg 65µs/call
sub find_attribute_by_name {
790116407µs4µs my ( $self, $attr_name ) = @_;
791
792 foreach my $class ( $self->linearized_isa ) {
# spent 996µs making 54 calls to Class::MOP::Class::Immutable::Class::MOP::Class::linearized_isa, avg 18µs/call # spent 42µs making 4 calls to Class::MOP::Class::linearized_isa, avg 11µs/call
793 # fetch the meta-class ...
794116873µs8µs my $meta = Class::MOP::Class->initialize($class);
# spent 638µs making 58 calls to Class::MOP::Class::initialize, avg 11µs/call
795 return $meta->get_attribute($attr_name)
# spent 736µs making 58 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 13µs/call # spent 598µs making 58 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 10µs/call
796 if $meta->has_attribute($attr_name);
797 }
798
799 return;
800}
801
802
# spent 12.0ms (3.96+8.00) within Class::MOP::Class::get_all_attributes which was called 116 times, avg 103µs/call: # 46 times (1.51ms+2.90ms) by Class::MOP::Class::_create_meta_instance at line 624, avg 96µs/call # 38 times (1.26ms+2.44ms) by Class::MOP::Method::Constructor::_attributes at line 77 of /usr/local/lib/perl/5.10.0/Class/MOP/Method/Constructor.pm, avg 97µs/call # 16 times (580µs+1.27ms) by Class::MOP::Class::_construct_instance at line 597, avg 116µs/call # 15 times (521µs+1.29ms) by Class::MOP::Class::Immutable::Trait::get_all_attributes at line 68 of /usr/local/lib/perl/5.10.0/Class/MOP/Class/Immutable/Trait.pm, avg 120µs/call # once (82µs+100µs) by Moose::Meta::Attribute::new at line 63 of /usr/local/lib/perl/5.10.0/Moose/Meta/Attribute.pm
sub get_all_attributes {
8033482.02ms6µs my $self = shift;
8048443.58ms4µs my %attrs = map { %{ Class::MOP::Class->initialize($_)->_attribute_map } }
# spent 4.46ms making 422 calls to Class::MOP::Class::initialize, avg 10µs/call, max recursion depth 1 # spent 1.66ms making 422 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 4µs/call # spent 1.43ms making 101 calls to Class::MOP::Class::linearized_isa, avg 14µs/call # spent 454µs making 15 calls to Class::MOP::Class::Immutable::Class::MOP::Class::linearized_isa, avg 30µs/call
805 reverse $self->linearized_isa;
806 return values %attrs;
807}
808
809# Inheritance
810
811sub superclasses {
8124161.26ms3µs my $self = shift;
813
814 my $isa = $self->get_or_add_package_symbol(
# spent 6.17ms making 104 calls to Class::MOP::Package::get_or_add_package_symbol, avg 59µs/call
815 { sigil => '@', type => 'ARRAY', name => 'ISA' } );
816
81778551µs7µs if (@_) {
818 my @supers = @_;
819 @{$isa} = @supers;
820
821 # NOTE:
822 # on 5.8 and below, we need to call
823 # a method to get Perl to detect
824 # a cycle in the class hierarchy
825 my $class = $self->name;
# spent 50µs making 13 calls to Class::MOP::Package::name, avg 4µs/call
826 $class->isa($class);
# spent 57µs making 13 calls to UNIVERSAL::isa, avg 4µs/call
827
828 # NOTE:
829 # we need to check the metaclass
830 # compatibility here so that we can
831 # be sure that the superclass is
832 # not potentially creating an issues
833 # we don't know about
834
835 $self->_check_metaclass_compatibility();
# spent 13.8ms making 13 calls to Class::MOP::Class::_check_metaclass_compatibility, avg 1.06ms/call
836 $self->_superclasses_updated();
# spent 150µs making 13 calls to Class::MOP::Class::_superclasses_updated, avg 12µs/call
837 }
838
839 return @{$isa};
840}
841
842
# spent 150µs (85+65) within Class::MOP::Class::_superclasses_updated which was called 13 times, avg 12µs/call: # 13 times (85µs+65µs) at line 836, avg 12µs/call
sub _superclasses_updated {
8432675µs3µs my $self = shift;
844 $self->update_meta_instance_dependencies();
# spent 65µs making 13 calls to Class::MOP::Class::update_meta_instance_dependencies, avg 5µs/call
845}
846
847sub subclasses {
848 my $self = shift;
849 my $super_class = $self->name;
850
851 return @{ $super_class->mro::get_isarev() };
852}
853
854sub direct_subclasses {
855 my $self = shift;
856 my $super_class = $self->name;
857
858 return grep {
859 grep {
860 $_ eq $super_class
861 } Class::MOP::Class->initialize($_)->superclasses
862 } $self->subclasses;
863}
864
865
# spent 4.64ms (2.19+2.45) within Class::MOP::Class::linearized_isa which was called 347 times, avg 13µs/call: # 108 times (659µs+703µs) by Class::MOP::Class::find_method_by_name at line 985, avg 13µs/call # 101 times (637µs+791µs) by Class::MOP::Class::get_all_attributes at line 804, avg 14µs/call # 95 times (622µs+648µs) by Class::MOP::Class::find_next_method_by_name at line 1032, avg 13µs/call # 17 times (103µs+132µs) by Class::MOP::Class::Immutable::Trait::linearized_isa at line 50 of /usr/local/lib/perl/5.10.0/Class/MOP/Class/Immutable/Trait.pm, avg 14µs/call # 14 times (102µs+78µs) by Class::MOP::Class::find_all_methods_by_name at line 1016, avg 13µs/call # 8 times (48µs+74µs) by Class::MOP::Class::get_all_methods at line 996, avg 15µs/call # 4 times (22µs+20µs) by Class::MOP::Class::find_attribute_by_name at line 792, avg 11µs/call
sub linearized_isa {
8663473.91ms11µs return @{ mro::get_linear_isa( (shift)->name ) };
# spent 1.61ms making 347 calls to mro::get_linear_isa, avg 5µs/call # spent 839µs making 347 calls to Class::MOP::Package::name, avg 2µs/call
867}
868
869sub class_precedence_list {
870 my $self = shift;
871 my $name = $self->name;
872
873 unless (Class::MOP::IS_RUNNING_ON_5_10()) {
874 # NOTE:
875 # We need to check for circular inheritance here
876 # if we are are not on 5.10, cause 5.8 detects it
877 # late. This will do nothing if all is well, and
878 # blow up otherwise. Yes, it's an ugly hack, better
879 # suggestions are welcome.
880 # - SL
881 ($name || return)->isa('This is a test for circular inheritance')
882 }
883
884 # if our mro is c3, we can
885 # just grab the linear_isa
886 if (mro::get_mro($name) eq 'c3') {
887 return @{ mro::get_linear_isa($name) }
888 }
889 else {
890 # NOTE:
891 # we can't grab the linear_isa for dfs
892 # since it has all the duplicates
893 # already removed.
894 return (
895 $name,
896 map {
897 Class::MOP::Class->initialize($_)->class_precedence_list()
898 } $self->superclasses()
899 );
900 }
901}
902
903## Methods
904
905{
9061600ns600ns
# spent 21.0ms (806µs+20.2) within Class::MOP::Class::__ANON__[/usr/local/lib/perl/5.10.0/Class/MOP/Class.pm:935] which was called 46 times, avg 457µs/call: # 46 times (806µs+20.2ms) by Class::MOP::Class::add_around_method_modifier at line 961, avg 457µs/call
my $fetch_and_prepare_method = sub {
907276759µs3µs my ($self, $method_name) = @_;
908 my $wrapped_metaclass = $self->wrapped_method_metaclass;
# spent 194µs making 46 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 4µs/call
909 # fetch it locally
910 my $method = $self->get_method($method_name);
# spent 2.03ms making 46 calls to Class::MOP::Mixin::HasMethods::get_method, avg 44µs/call
911 # if we dont have local ...
912138551µs4µs unless ($method) {
913 # try to find the next method
914 $method = $self->find_next_method_by_name($method_name);
# spent 8.71ms making 46 calls to Class::MOP::Class::find_next_method_by_name, avg 189µs/call
915 # die if it does not exist
916 (defined $method)
917 || confess "The method '$method_name' was not found in the inheritance hierarchy for " . $self->name;
918 # and now make sure to wrap it
919 # even if it is already wrapped
920 # because we need a new sub ref
921 $method = $wrapped_metaclass->wrap($method,
# spent 4.10ms making 46 calls to Class::MOP::Method::Wrapped::wrap, avg 89µs/call # spent 113µs making 46 calls to Class::MOP::Package::name, avg 2µs/call
922 package_name => $self->name,
923 name => $method_name,
924 );
925 }
926 else {
927 # now make sure we wrap it properly
928 $method = $wrapped_metaclass->wrap($method,
929 package_name => $self->name,
930 name => $method_name,
931 ) unless $method->isa($wrapped_metaclass);
932 }
933 $self->add_method($method_name => $method);
# spent 5.09ms making 46 calls to Class::MOP::Mixin::HasMethods::add_method, avg 111µs/call
934 return $method;
93515µs5µs };
936
937 sub add_before_method_modifier {
938 my ($self, $method_name, $method_modifier) = @_;
939 (defined $method_name && length $method_name)
940 || confess "You must pass in a method name";
941 my $method = $fetch_and_prepare_method->($self, $method_name);
942 $method->add_before_modifier(
943 subname(':before' => $method_modifier)
944 );
945 }
946
947 sub add_after_method_modifier {
948 my ($self, $method_name, $method_modifier) = @_;
949 (defined $method_name && length $method_name)
950 || confess "You must pass in a method name";
951 my $method = $fetch_and_prepare_method->($self, $method_name);
952 $method->add_after_modifier(
953 subname(':after' => $method_modifier)
954 );
955 }
956
957
# spent 23.4ms (394µs+23.0) within Class::MOP::Class::add_around_method_modifier which was called 46 times, avg 510µs/call: # 46 times (394µs+23.0ms) by Class::MOP::MiniTrait::apply at line 21 of /usr/local/lib/perl/5.10.0/Class/MOP/MiniTrait.pm, avg 510µs/call
sub add_around_method_modifier {
958184889µs5µs my ($self, $method_name, $method_modifier) = @_;
959 (defined $method_name && length $method_name)
960 || confess "You must pass in a method name";
961 my $method = $fetch_and_prepare_method->($self, $method_name);
# spent 21.0ms making 46 calls to Class::MOP::Class::__ANON__[/usr/local/lib/perl/5.10.0/Class/MOP/Class.pm:935], avg 457µs/call
962 $method->add_around_modifier(
# spent 1.63ms making 46 calls to Class::MOP::Method::Wrapped::add_around_modifier, avg 36µs/call # spent 368µs making 46 calls to Sub::Name::subname, avg 8µs/call
963 subname(':around' => $method_modifier)
964 );
965 }
966
967 # NOTE:
968 # the methods above used to be named like this:
969 # ${pkg}::${method}:(before|after|around)
970 # but this proved problematic when using one modifier
971 # to wrap multiple methods (something which is likely
972 # to happen pretty regularly IMO). So instead of naming
973 # it like this, I have chosen to just name them purely
974 # with their modifier names, like so:
975 # :(before|after|around)
976 # The fact is that in a stack trace, it will be fairly
977 # evident from the context what method they are attached
978 # to, and so don't need the fully qualified name.
979}
980
981
# spent 30.3ms (2.09+28.2) within Class::MOP::Class::find_method_by_name which was called 108 times, avg 281µs/call: # 56 times (1.26ms+19.9ms) by Class::MOP::MiniTrait::apply at line 21 of /usr/local/lib/perl/5.10.0/Class/MOP/MiniTrait.pm, avg 378µs/call # 31 times (461µs+3.39ms) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 25 of /usr/local/lib/perl/5.10.0/Class/MOP/Mixin/HasMethods.pm, avg 124µs/call # 7 times (160µs+2.74ms) by Moose::Meta::Method::Constructor::_generate_BUILDARGS at line 145 of /usr/local/lib/perl/5.10.0/Moose/Meta/Method/Constructor.pm, avg 414µs/call # 7 times (132µs+1.53ms) by Moose::Meta::Method::Destructor::is_needed at line 62 of /usr/local/lib/perl/5.10.0/Moose/Meta/Method/Destructor.pm, avg 238µs/call # 7 times (83µs+639µs) at line 14 of /usr/local/lib/perl/5.10.0/Moose/Meta/Attribute/Native.pm, avg 103µs/call
sub find_method_by_name {
982370754µs2µs my ($self, $method_name) = @_;
983 (defined $method_name && length $method_name)
984 || confess "You must define a method name to find";
985 foreach my $class ($self->linearized_isa) {
# spent 1.36ms making 108 calls to Class::MOP::Class::linearized_isa, avg 13µs/call
9866022.44ms4µs my $method = Class::MOP::Class->initialize($class)->get_method($method_name);
# spent 23.8ms making 301 calls to Class::MOP::Mixin::HasMethods::get_method, avg 79µs/call # spent 3.11ms making 301 calls to Class::MOP::Class::initialize, avg 10µs/call
987 return $method if defined $method;
988 }
989 return;
990}
991
992
# spent 7.14ms (296µs+6.84) within Class::MOP::Class::get_all_methods which was called 8 times, avg 892µs/call: # 8 times (296µs+6.84ms) by Class::MOP::MiniTrait::apply at line 18 of /usr/local/lib/perl/5.10.0/Class/MOP/MiniTrait.pm, avg 892µs/call
sub get_all_methods {
9933289µs3µs my $self = shift;
994
995 my %methods;
996 for my $class ( reverse $self->linearized_isa ) {
# spent 122µs making 8 calls to Class::MOP::Class::linearized_isa, avg 15µs/call
99727211µs8µs my $meta = Class::MOP::Class->initialize($class);
# spent 119µs making 9 calls to Class::MOP::Class::initialize, avg 13µs/call
998
999 $methods{ $_->name } = $_ for $meta->_get_local_methods;
# spent 6.46ms making 9 calls to Class::MOP::Mixin::HasMethods::_get_local_methods, avg 718µs/call # spent 137µs making 56 calls to Class::MOP::Method::name, avg 2µs/call
1000 }
1001
10021185µs185µs return values %methods;
1003}
1004
1005sub get_all_method_names {
1006 my $self = shift;
1007 my %uniq;
1008 return grep { !$uniq{$_}++ } map { Class::MOP::Class->initialize($_)->get_method_list } $self->linearized_isa;
1009}
1010
1011
# spent 3.22ms (347µs+2.88) within Class::MOP::Class::find_all_methods_by_name which was called 14 times, avg 230µs/call: # 7 times (208µs+1.48ms) by Moose::Meta::Method::Constructor::_generate_BUILDALL at line 163 of /usr/local/lib/perl/5.10.0/Moose/Meta/Method/Constructor.pm, avg 241µs/call # 7 times (139µs+1.40ms) by Moose::Meta::Method::Destructor::_initialize_body at line 81 of /usr/local/lib/perl/5.10.0/Moose/Meta/Method/Destructor.pm, avg 219µs/call
sub find_all_methods_by_name {
101270146µs2µs my ($self, $method_name) = @_;
1013 (defined $method_name && length $method_name)
1014 || confess "You must define a method name to find";
1015 my @methods;
1016 foreach my $class ($self->linearized_isa) {
# spent 179µs making 14 calls to Class::MOP::Class::linearized_isa, avg 13µs/call
1017 # fetch the meta-class ...
101872336µs5µs my $meta = Class::MOP::Class->initialize($class);
# spent 386µs making 36 calls to Class::MOP::Class::initialize, avg 11µs/call
1019 push @methods => {
# spent 2.31ms making 36 calls to Class::MOP::Mixin::HasMethods::has_method, avg 64µs/call
1020 name => $method_name,
1021 class => $class,
1022 code => $meta->get_method($method_name)
1023 } if $meta->has_method($method_name);
1024 }
1025 return @methods;
1026}
1027
1028
# spent 17.3ms (2.09+15.2) within Class::MOP::Class::find_next_method_by_name which was called 103 times, avg 168µs/call: # 46 times (1.03ms+7.67ms) by Class::MOP::Class::__ANON__[/usr/local/lib/perl/5.10.0/Class/MOP/Class.pm:935] at line 914, avg 189µs/call # 45 times (856µs+5.96ms) by Class::MOP::Method::Inlined::can_be_inlined at line 40 of /usr/local/lib/perl/5.10.0/Class/MOP/Method/Inlined.pm, avg 151µs/call # 8 times (104µs+721µs) by Class::MOP::Method::Inlined::_uninlined_body at line 20 of /usr/local/lib/perl/5.10.0/Class/MOP/Method/Inlined.pm, avg 103µs/call # 4 times (91µs+862µs) by Moose::Meta::Method::Overridden::new at line 23 of /usr/local/lib/perl/5.10.0/Moose/Meta/Method/Overridden.pm, avg 238µs/call
sub find_next_method_by_name {
10295181.21ms2µs my ($self, $method_name) = @_;
1030 (defined $method_name && length $method_name)
1031 || confess "You must define a method name to find";
1032 my @cpl = $self->linearized_isa;
# spent 1.27ms making 95 calls to Class::MOP::Class::linearized_isa, avg 13µs/call # spent 164µs making 8 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::linearized_isa, avg 21µs/call
1033 shift @cpl; # discard ourselves
1034 foreach my $class (@cpl) {
10353501.63ms5µs my $method = Class::MOP::Class->initialize($class)->get_method($method_name);
# spent 12.0ms making 175 calls to Class::MOP::Mixin::HasMethods::get_method, avg 68µs/call # spent 1.82ms making 175 calls to Class::MOP::Class::initialize, avg 10µs/call
1036 return $method if defined $method;
1037 }
1038 return;
1039}
1040
1041
# spent 65µs within Class::MOP::Class::update_meta_instance_dependencies which was called 13 times, avg 5µs/call: # 13 times (65µs+0s) by Class::MOP::Class::_superclasses_updated at line 844, avg 5µs/call
sub update_meta_instance_dependencies {
10422628µs1µs my $self = shift;
1043
1044 if ( $self->{meta_instance_dependencies} ) {
1045 return $self->add_meta_instance_dependencies;
1046 }
1047}
1048
1049sub add_meta_instance_dependencies {
1050 my $self = shift;
1051
1052 $self->remove_meta_instance_dependencies;
1053
1054 my @attrs = $self->get_all_attributes();
1055
1056 my %seen;
1057 my @classes = grep { not $seen{ $_->name }++ }
1058 map { $_->associated_class } @attrs;
1059
1060 foreach my $class (@classes) {
1061 $class->add_dependent_meta_instance($self);
1062 }
1063
1064 $self->{meta_instance_dependencies} = \@classes;
1065}
1066
1067sub remove_meta_instance_dependencies {
1068 my $self = shift;
1069
1070 if ( my $classes = delete $self->{meta_instance_dependencies} ) {
1071 foreach my $class (@$classes) {
1072 $class->remove_dependent_meta_instance($self);
1073 }
1074
1075 return $classes;
1076 }
1077
1078 return;
1079
1080}
1081
1082sub add_dependent_meta_instance {
1083 my ( $self, $metaclass ) = @_;
1084 push @{ $self->{dependent_meta_instances} }, $metaclass;
1085}
1086
1087sub remove_dependent_meta_instance {
1088 my ( $self, $metaclass ) = @_;
1089 my $name = $metaclass->name;
1090 @$_ = grep { $_->name ne $name } @$_
1091 for $self->{dependent_meta_instances};
1092}
1093
1094
# spent 1.50ms (927µs+576µs) within Class::MOP::Class::invalidate_meta_instances which was called 123 times, avg 12µs/call: # 123 times (927µs+576µs) by Class::MOP::Class::_post_add_attribute at line 762, avg 12µs/call
sub invalidate_meta_instances {
1095369982µs3µs my $self = shift;
1096 $_->invalidate_meta_instance()
1097 for $self, @{ $self->{dependent_meta_instances} };
# spent 576µs making 123 calls to Class::MOP::Class::invalidate_meta_instance, avg 5µs/call
1098}
1099
1100
# spent 576µs within Class::MOP::Class::invalidate_meta_instance which was called 123 times, avg 5µs/call: # 123 times (576µs+0s) by Class::MOP::Class::invalidate_meta_instances at line 1097, avg 5µs/call
sub invalidate_meta_instance {
1101246274µs1µs my $self = shift;
1102 undef $self->{_meta_instance};
1103}
1104
1105# check if we can reinitialize
1106sub is_pristine {
1107 my $self = shift;
1108
1109 # if any local attr is defined
1110 return if $self->get_attribute_list;
1111
1112 # or any non-declared methods
1113 for my $method ( map { $self->get_method($_) } $self->get_method_list ) {
1114 return if $method->isa("Class::MOP::Method::Generated");
1115 # FIXME do we need to enforce this too? return unless $method->isa( $self->method_metaclass );
1116 }
1117
1118 return 1;
1119}
1120
1121## Class closing
1122
112389109µs1µs
# spent 303µs within Class::MOP::Class::is_mutable which was called 89 times, avg 3µs/call: # 58 times (227µs+0s) by Class::MOP::Class::make_immutable at line 1147, avg 4µs/call # 22 times (52µs+0s) at line 231 of /usr/local/lib/perl/5.10.0/Moose.pm, avg 2µs/call # 9 times (24µs+0s) at line 688 of /usr/local/lib/perl/5.10.0/Moose/Util/TypeConstraints.pm, avg 3µs/call
sub is_mutable { 1 }
11244549µs1µs
# spent 141µs within Class::MOP::Class::is_immutable which was called 45 times, avg 3µs/call: # 45 times (141µs+0s) by Class::MOP::Class::_real_ref_name at line 122, avg 3µs/call
sub is_immutable { 0 }
1125
1126sub immutable_options { %{ $_[0]{__immutable}{options} || {} } }
1127
1128
# spent 2.02ms (827µs+1.19) within Class::MOP::Class::_immutable_options which was called 58 times, avg 35µs/call: # 51 times (703µs+1.03ms) by Class::MOP::Class::make_immutable at line 1148, avg 34µs/call # 7 times (124µs+161µs) by Moose::Meta::Class::_immutable_options at line 454 of /usr/local/lib/perl/5.10.0/Moose/Meta/Class.pm, avg 41µs/call
sub _immutable_options {
11291161.18ms10µs my ( $self, @args ) = @_;
1130
1131 return (
1132 inline_accessors => 1,
# spent 358µs making 51 calls to Class::MOP::Class::immutable_trait, avg 7µs/call # spent 279µs making 58 calls to Class::MOP::Class::constructor_name, avg 5µs/call # spent 231µs making 51 calls to Class::MOP::Class::constructor_class, avg 5µs/call # spent 203µs making 51 calls to Class::MOP::Class::destructor_class, avg 4µs/call # spent 49µs making 7 calls to Moose::Meta::Class::immutable_trait, avg 7µs/call # spent 37µs making 7 calls to Moose::Meta::Class::constructor_class, avg 5µs/call # spent 34µs making 7 calls to Moose::Meta::Class::destructor_class, avg 5µs/call
1133 inline_constructor => 1,
1134 inline_destructor => 0,
1135 debug => 0,
1136 immutable_trait => $self->immutable_trait,
1137 constructor_name => $self->constructor_name,
1138 constructor_class => $self->constructor_class,
1139 destructor_class => $self->destructor_class,
1140 @args,
1141 );
1142}
1143
1144
# spent 205ms (1.00+204) within Class::MOP::Class::make_immutable which was called 58 times, avg 3.53ms/call: # 22 times (408µs+79.0ms) at line 236 of /usr/local/lib/perl/5.10.0/Moose.pm, avg 3.61ms/call # 13 times (170µs+25.3ms) at line 698 of /usr/local/lib/perl/5.10.0/Class/MOP.pm, avg 1.96ms/call # 9 times (169µs+34.3ms) at line 693 of /usr/local/lib/perl/5.10.0/Moose/Util/TypeConstraints.pm, avg 3.83ms/call # 4 times (52µs+661µs) at line 723 of /usr/local/lib/perl/5.10.0/Class/MOP.pm, avg 178µs/call # 2 times (34µs+-34µs) by Class::MOP::Class::_immutable_metaclass at line 1221, avg 0s/call # once (34µs+30.9ms) at line 104 of /home/tamil/util/marc-moose/lib/MARC/Moose/Record.pm # once (16µs+9.28ms) at line 268 of /usr/local/lib/perl/5.10.0/Moose.pm # once (21µs+6.65ms) at line 39 of /home/tamil/util/marc-moose/lib/MARC/Moose/Field/Std.pm # once (17µs+4.05ms) at line 17 of /home/tamil/util/marc-moose/lib/MARC/Moose/Field/Control.pm # once (20µs+3.93ms) at line 43 of /home/tamil/util/marc-moose/lib/MARC/Moose/Parser/MarcxmlSax.pm # once (19µs+3.52ms) at line 64 of /home/tamil/util/marc-moose/lib/MARC/Moose/Parser/Marcxml.pm # once (22µs+3.17ms) at line 16 of /home/tamil/util/marc-moose/lib/MARC/Moose/Field.pm # once (19µs+2.99ms) at line 30 of /home/tamil/util/marc-moose/lib/MARC/Moose/Parser.pm
sub make_immutable {
1145116440µs4µs my ( $self, @args ) = @_;
1146
11471741.02ms6µs if ( $self->is_mutable ) {
# spent 227µs making 58 calls to Class::MOP::Class::is_mutable, avg 4µs/call
1148 $self->_initialize_immutable( $self->_immutable_options(@args) );
# spent 146ms making 58 calls to Class::MOP::Class::_initialize_immutable, avg 2.51ms/call # spent 1.73ms making 51 calls to Class::MOP::Class::_immutable_options, avg 34µs/call # spent 361µs making 7 calls to Moose::Meta::Class::_immutable_options, avg 52µs/call
1149 $self->_rebless_as_immutable(@args);
# spent 56.3ms making 58 calls to Class::MOP::Class::_rebless_as_immutable, avg 965µs/call, max recursion depth 1
1150 return $self;
1151 }
1152 else {
1153 return;
1154 }
1155}
1156
1157sub make_mutable {
1158 my $self = shift;
1159
1160 if ( $self->is_immutable ) {
1161 my @args = $self->immutable_options;
1162 $self->_rebless_as_mutable();
1163 $self->_remove_inlined_code(@args);
1164 delete $self->{__immutable};
1165 return $self;
1166 }
1167 else {
1168 return;
1169 }
1170}
1171
1172
# spent 56.0ms (777µs+55.2) within Class::MOP::Class::_rebless_as_immutable which was called 58 times, avg 965µs/call: # 58 times (777µs+55.2ms) by Class::MOP::Class::make_immutable at line 1149, avg 965µs/call
sub _rebless_as_immutable {
1173174772µs4µs my ( $self, @args ) = @_;
1174
1175 $self->{__immutable}{original_class} = ref $self;
1176
1177 bless $self => $self->_immutable_metaclass(@args);
# spent 55.5ms making 58 calls to Class::MOP::Class::_immutable_metaclass, avg 952µs/call, max recursion depth 1
1178}
1179
1180
# spent 55.2ms (1.26+54.0) within Class::MOP::Class::_immutable_metaclass which was called 58 times, avg 952µs/call: # 58 times (1.26ms+54.0ms) by Class::MOP::Class::_rebless_as_immutable at line 1177, avg 952µs/call
sub _immutable_metaclass {
11814742.11ms4µs my ( $self, %args ) = @_;
1182
1183 if ( my $class = $args{immutable_metaclass} ) {
1184 return $class;
1185 }
1186
1187 my $trait = $args{immutable_trait} = $self->immutable_trait
# spent 209µs making 51 calls to Class::MOP::Class::immutable_trait, avg 4µs/call # spent 38µs making 7 calls to Moose::Meta::Class::immutable_trait, avg 5µs/call
1188 || confess "no immutable trait specified for $self";
1189
1190 my $meta = $self->meta;
# spent 1.21ms making 58 calls to Class::MOP::Object::meta, avg 21µs/call
1191 my $meta_attr = $meta->find_attribute_by_name("immutable_trait");
# spent 3.79ms making 58 calls to Class::MOP::Class::find_attribute_by_name, avg 65µs/call
1192
1193 my $class_name;
1194
1195 if ( $meta_attr and $trait eq $meta_attr->default ) {
# spent 340µs making 58 calls to Class::MOP::Mixin::AttributeCore::default, avg 6µs/call
1196 # if the trait is the same as the default we try and pick a
1197 # predictable name for the immutable metaclass
1198 $class_name = 'Class::MOP::Class::Immutable::' . ref($self);
1199 }
1200 else {
1201 $class_name = join '::', 'Class::MOP::Class::Immutable::CustomTrait',
1202 $trait, 'ForMetaClass', ref($self);
1203 }
1204
1205 return $class_name
# spent 406µs making 58 calls to Class::MOP::is_class_loaded, avg 7µs/call
1206 if Class::MOP::is_class_loaded($class_name);
1207
1208 # If the metaclass is a subclass of CMOP::Class which has had
1209 # metaclass roles applied (via Moose), then we want to make sure
1210 # that we preserve that anonymous class (see Fey::ORM for an
1211 # example of where this matters).
1212 my $meta_name = $meta->_real_ref_name;
# spent 40µs making 2 calls to Class::MOP::Class::_real_ref_name, avg 20µs/call
1213
1214 my $immutable_meta = $meta_name->create(
# spent 3.13ms making 2 calls to Class::MOP::Class::create, avg 1.56ms/call
1215 $class_name,
1216 superclasses => [ ref $self ],
1217 );
1218
1219 Class::MOP::MiniTrait::apply( $immutable_meta, $trait );
# spent 44.6ms making 2 calls to Class::MOP::MiniTrait::apply, avg 22.3ms/call
1220
1221 $immutable_meta->make_immutable(
# spent 452µs making 2 calls to Class::MOP::Class::make_immutable, avg 0s/call, max recursion depth 1
1222 inline_constructor => 0,
1223 inline_accessors => 0,
1224 );
1225
1226 return $class_name;
1227}
1228
1229sub _remove_inlined_code {
1230 my $self = shift;
1231
1232 $self->remove_method( $_->name ) for $self->_inlined_methods;
1233
1234 delete $self->{__immutable}{inlined_methods};
1235}
1236
1237sub _inlined_methods { @{ $_[0]{__immutable}{inlined_methods} || [] } }
1238
1239
# spent 411µs within Class::MOP::Class::_add_inlined_method which was called 45 times, avg 9µs/call: # 38 times (366µs+0s) by Class::MOP::Class::_inline_constructor at line 1308, avg 10µs/call # 7 times (45µs+0s) by Class::MOP::Class::_inline_destructor at line 1341, avg 6µs/call
sub _add_inlined_method {
124090246µs3µs my ( $self, $method ) = @_;
1241
1242 push @{ $self->{__immutable}{inlined_methods} ||= [] }, $method;
1243}
1244
1245
# spent 146ms (1.29+144) within Class::MOP::Class::_initialize_immutable which was called 58 times, avg 2.51ms/call: # 58 times (1.29ms+144ms) by Class::MOP::Class::make_immutable at line 1148, avg 2.51ms/call
sub _initialize_immutable {
12461741.27ms7µs my ( $self, %args ) = @_;
1247
1248 $self->{__immutable}{options} = \%args;
1249 $self->_install_inlined_code(%args);
# spent 144ms making 58 calls to Class::MOP::Class::_install_inlined_code, avg 2.49ms/call
1250}
1251
1252
# spent 144ms (1.04+143) within Class::MOP::Class::_install_inlined_code which was called 58 times, avg 2.49ms/call: # 58 times (1.04ms+143ms) by Class::MOP::Class::_initialize_immutable at line 1249, avg 2.49ms/call
sub _install_inlined_code {
12532321.10ms5µs my ( $self, %args ) = @_;
1254
1255 # FIXME
1256 $self->_inline_accessors(%args) if $args{inline_accessors};
# spent 51.3ms making 32 calls to Class::MOP::Class::_inline_accessors, avg 1.60ms/call
1257 $self->_inline_constructor(%args) if $args{inline_constructor};
# spent 83.1ms making 38 calls to Class::MOP::Class::_inline_constructor, avg 2.19ms/call
1258 $self->_inline_destructor(%args) if $args{inline_destructor};
# spent 8.92ms making 7 calls to Class::MOP::Class::_inline_destructor, avg 1.27ms/call
1259}
1260
1261sub _rebless_as_mutable {
1262 my $self = shift;
1263
1264 bless $self, $self->_get_mutable_metaclass_name;
1265
1266 return $self;
1267}
1268
1269
# spent 51.3ms (477µs+50.8) within Class::MOP::Class::_inline_accessors which was called 32 times, avg 1.60ms/call: # 32 times (477µs+50.8ms) by Class::MOP::Class::_install_inlined_code at line 1256, avg 1.60ms/call
sub _inline_accessors {
127064230µs4µs my $self = shift;
1271
1272 foreach my $attr_name ( $self->get_attribute_list ) {
# spent 391µs making 32 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 12µs/call
127368571µs8µs $self->get_attribute($attr_name)->install_accessors(1);
# spent 47.5ms making 67 calls to Class::MOP::Attribute::install_accessors, avg 710µs/call # spent 1.96ms making 1 call to Moose::Meta::Attribute::install_accessors # spent 920µs making 68 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 14µs/call
1274 }
1275}
1276
1277
# spent 83.1ms (1.10+82.0) within Class::MOP::Class::_inline_constructor which was called 38 times, avg 2.19ms/call: # 38 times (1.10ms+82.0ms) by Class::MOP::Class::_install_inlined_code at line 1257, avg 2.19ms/call
sub _inline_constructor {
12783041.47ms5µs my ( $self, %args ) = @_;
1279
1280 my $name = $args{constructor_name};
1281 # A class may not even have a constructor, and that's okay.
1282 return unless defined $name;
1283
1284 if ( $self->has_method($name) && !$args{replace_constructor} ) {
# spent 3.26ms making 38 calls to Class::MOP::Mixin::HasMethods::has_method, avg 86µs/call
1285 my $class = $self->name;
1286 warn "Not inlining a constructor for $class since it defines"
1287 . " its own constructor.\n"
1288 . "If you are certain you don't need to inline your"
1289 . " constructor, specify inline_constructor => 0 in your"
1290 . " call to $class->meta->make_immutable\n";
1291 return;
1292 }
1293
1294 my $constructor_class = $args{constructor_class};
1295
1296 Class::MOP::load_class($constructor_class);
# spent 2.52ms making 38 calls to Class::MOP::load_class, avg 63µs/call, max recursion depth 1
1297
1298 my $constructor = $constructor_class->new(
# spent 47.7ms making 31 calls to Class::MOP::Method::Constructor::new, avg 1.54ms/call # spent 14.1ms making 7 calls to Moose::Meta::Method::Constructor::new, avg 2.02ms/call # spent 131µs making 38 calls to Class::MOP::Package::name, avg 3µs/call
1299 options => \%args,
1300 metaclass => $self,
1301 is_inline => 1,
1302 package_name => $self->name,
1303 name => $name,
1304 );
1305
130676404µs5µs if ( $args{replace_constructor} or $constructor->can_be_inlined ) {
# spent 8.99ms making 38 calls to Class::MOP::Method::Inlined::can_be_inlined, avg 237µs/call
1307 $self->add_method( $name => $constructor );
# spent 4.98ms making 38 calls to Class::MOP::Mixin::HasMethods::add_method, avg 131µs/call
1308 $self->_add_inlined_method($constructor);
# spent 366µs making 38 calls to Class::MOP::Class::_add_inlined_method, avg 10µs/call
1309 }
1310}
1311
1312
# spent 8.92ms (248µs+8.67) within Class::MOP::Class::_inline_destructor which was called 7 times, avg 1.27ms/call: # 7 times (248µs+8.67ms) by Class::MOP::Class::_install_inlined_code at line 1258, avg 1.27ms/call
sub _inline_destructor {
131356327µs6µs my ( $self, %args ) = @_;
1314
1315 ( exists $args{destructor_class} && defined $args{destructor_class} )
1316 || confess "The 'inline_destructor' option is present, but "
1317 . "no destructor class was specified";
1318
1319 if ( $self->has_method('DESTROY') && ! $args{replace_destructor} ) {
# spent 558µs making 7 calls to Class::MOP::Mixin::HasMethods::has_method, avg 80µs/call
1320 my $class = $self->name;
1321 warn "Not inlining a destructor for $class since it defines"
1322 . " its own destructor.\n";
1323 return;
1324 }
1325
1326 my $destructor_class = $args{destructor_class};
1327
1328 Class::MOP::load_class($destructor_class);
# spent 469µs making 7 calls to Class::MOP::load_class, avg 48µs/call, max recursion depth 1
1329
1330 return unless $destructor_class->is_needed($self);
# spent 1.79ms making 7 calls to Moose::Meta::Method::Destructor::is_needed, avg 255µs/call
1331
1332 my $destructor = $destructor_class->new(
# spent 3.67ms making 7 calls to Moose::Meta::Method::Destructor::new, avg 524µs/call # spent 23µs making 7 calls to Class::MOP::Package::name, avg 3µs/call
1333 options => \%args,
1334 metaclass => $self,
1335 package_name => $self->name,
1336 name => 'DESTROY'
1337 );
1338
13391470µs5µs if ( $args{replace_destructor} or $destructor->can_be_inlined ) {
# spent 1.19ms making 7 calls to Class::MOP::Method::Inlined::can_be_inlined, avg 170µs/call
1340 $self->add_method( 'DESTROY' => $destructor );
# spent 929µs making 7 calls to Class::MOP::Mixin::HasMethods::add_method, avg 133µs/call
1341 $self->_add_inlined_method($destructor);
# spent 45µs making 7 calls to Class::MOP::Class::_add_inlined_method, avg 6µs/call
1342 }
1343}
1344
1345116µs16µs1;
1346
1347__END__
1348
1349=pod
1350
1351=head1 NAME
1352
1353Class::MOP::Class - Class Meta Object
1354
1355=head1 SYNOPSIS
1356
1357 # assuming that class Foo
1358 # has been defined, you can
1359
1360 # use this for introspection ...
1361
1362 # add a method to Foo ...
1363 Foo->meta->add_method( 'bar' => sub {...} )
1364
1365 # get a list of all the classes searched
1366 # the method dispatcher in the correct order
1367 Foo->meta->class_precedence_list()
1368
1369 # remove a method from Foo
1370 Foo->meta->remove_method('bar');
1371
1372 # or use this to actually create classes ...
1373
1374 Class::MOP::Class->create(
1375 'Bar' => (
1376 version => '0.01',
1377 superclasses => ['Foo'],
1378 attributes => [
1379 Class::MOP::Attribute->new('$bar'),
1380 Class::MOP::Attribute->new('$baz'),
1381 ],
1382 methods => {
1383 calculate_bar => sub {...},
1384 construct_baz => sub {...}
1385 }
1386 )
1387 );
1388
1389=head1 DESCRIPTION
1390
1391The Class Protocol is the largest and most complex part of the
1392Class::MOP meta-object protocol. It controls the introspection and
1393manipulation of Perl 5 classes, and it can create them as well. The
1394best way to understand what this module can do is to read the
1395documentation for each of its methods.
1396
1397=head1 INHERITANCE
1398
1399C<Class::MOP::Class> is a subclass of L<Class::MOP::Module>.
1400
1401=head1 METHODS
1402
1403=head2 Class construction
1404
1405These methods all create new C<Class::MOP::Class> objects. These
1406objects can represent existing classes or they can be used to create
1407new classes from scratch.
1408
1409The metaclass object for a given class is a singleton. If you attempt
1410to create a metaclass for the same class twice, you will just get the
1411existing object.
1412
1413=over 4
1414
1415=item B<< Class::MOP::Class->create($package_name, %options) >>
1416
1417This method creates a new C<Class::MOP::Class> object with the given
1418package name. It accepts a number of options:
1419
1420=over 8
1421
1422=item * version
1423
1424An optional version number for the newly created package.
1425
1426=item * authority
1427
1428An optional authority for the newly created package.
1429
1430=item * superclasses
1431
1432An optional array reference of superclass names.
1433
1434=item * methods
1435
1436An optional hash reference of methods for the class. The keys of the
1437hash reference are method names and values are subroutine references.
1438
1439=item * attributes
1440
1441An optional array reference of L<Class::MOP::Attribute> objects.
1442
1443=item * meta_name
1444
1445Specifies the name to install the C<meta> method for this class under.
1446If it is not passed, C<meta> is assumed, and if C<undef> is explicitly
1447given, no meta method will be installed.
1448
1449=back
1450
1451=item B<< Class::MOP::Class->create_anon_class(%options) >>
1452
1453This method works just like C<< Class::MOP::Class->create >> but it
1454creates an "anonymous" class. In fact, the class does have a name, but
1455that name is a unique name generated internally by this module.
1456
1457It accepts the same C<superclasses>, C<methods>, and C<attributes>
1458parameters that C<create> accepts.
1459
1460Anonymous classes are destroyed once the metaclass they are attached
1461to goes out of scope, and will be removed from Perl's internal symbol
1462table.
1463
1464All instances of an anonymous class keep a special reference to the
1465metaclass object, which prevents the metaclass from going out of scope
1466while any instances exist.
1467
1468This only works if the instance is based on a hash reference, however.
1469
1470=item B<< Class::MOP::Class->initialize($package_name, %options) >>
1471
1472This method will initialize a C<Class::MOP::Class> object for the
1473named package. Unlike C<create>, this method I<will not> create a new
1474class.
1475
1476The purpose of this method is to retrieve a C<Class::MOP::Class>
1477object for introspecting an existing class.
1478
1479If an existing C<Class::MOP::Class> object exists for the named
1480package, it will be returned, and any options provided will be
1481ignored!
1482
1483If the object does not yet exist, it will be created.
1484
1485The valid options that can be passed to this method are
1486C<attribute_metaclass>, C<method_metaclass>,
1487C<wrapped_method_metaclass>, and C<instance_metaclass>. These are all
1488optional, and default to the appropriate class in the C<Class::MOP>
1489distribution.
1490
1491=back
1492
1493=head2 Object instance construction and cloning
1494
1495These methods are all related to creating and/or cloning object
1496instances.
1497
1498=over 4
1499
1500=item B<< $metaclass->clone_object($instance, %params) >>
1501
1502This method clones an existing object instance. Any parameters you
1503provide are will override existing attribute values in the object.
1504
1505This is a convenience method for cloning an object instance, then
1506blessing it into the appropriate package.
1507
1508You could implement a clone method in your class, using this method:
1509
1510 sub clone {
1511 my ($self, %params) = @_;
1512 $self->meta->clone_object($self, %params);
1513 }
1514
1515=item B<< $metaclass->rebless_instance($instance, %params) >>
1516
1517This method changes the class of C<$instance> to the metaclass's class.
1518
1519You can only rebless an instance into a subclass of its current
1520class. If you pass any additional parameters, these will be treated
1521like constructor parameters and used to initialize the object's
1522attributes. Any existing attributes that are already set will be
1523overwritten.
1524
1525Before reblessing the instance, this method will call
1526C<rebless_instance_away> on the instance's current metaclass. This method
1527will be passed the instance, the new metaclass, and any parameters
1528specified to C<rebless_instance>. By default, C<rebless_instance_away>
1529does nothing; it is merely a hook.
1530
1531=item B<< $metaclass->rebless_instance_back($instance) >>
1532
1533Does the same thing as C<rebless_instance>, except that you can only
1534rebless an instance into one of its superclasses. Any attributes that
1535do not exist in the superclass will be deinitialized.
1536
1537This is a much more dangerous operation than C<rebless_instance>,
1538especially when multiple inheritance is involved, so use this carefully!
1539
1540=item B<< $metaclass->new_object(%params) >>
1541
1542This method is used to create a new object of the metaclass's
1543class. Any parameters you provide are used to initialize the
1544instance's attributes. A special C<__INSTANCE__> key can be passed to
1545provide an already generated instance, rather than having Class::MOP
1546generate it for you. This is mostly useful for using Class::MOP with
1547foreign classes which generate instances using their own constructors.
1548
1549=item B<< $metaclass->instance_metaclass >>
1550
1551Returns the class name of the instance metaclass. See
1552L<Class::MOP::Instance> for more information on the instance
1553metaclass.
1554
1555=item B<< $metaclass->get_meta_instance >>
1556
1557Returns an instance of the C<instance_metaclass> to be used in the
1558construction of a new instance of the class.
1559
1560=item B<< $metaclass->inline_create_instance($class_var) >>
1561
1562=item B<< $metaclass->inline_rebless_instance($instance_var, $class_var) >>
1563
1564These methods takes variable names, and use them to create an inline snippet
1565of code that will create a new instance of the class.
1566
1567=back
1568
1569=head2 Informational predicates
1570
1571These are a few predicate methods for asking information about the
1572class itself.
1573
1574=over 4
1575
1576=item B<< $metaclass->is_anon_class >>
1577
1578This returns true if the class was created by calling C<<
1579Class::MOP::Class->create_anon_class >>.
1580
1581=item B<< $metaclass->is_mutable >>
1582
1583This returns true if the class is still mutable.
1584
1585=item B<< $metaclass->is_immutable >>
1586
1587This returns true if the class has been made immutable.
1588
1589=item B<< $metaclass->is_pristine >>
1590
1591A class is I<not> pristine if it has non-inherited attributes or if it
1592has any generated methods.
1593
1594=back
1595
1596=head2 Inheritance Relationships
1597
1598=over 4
1599
1600=item B<< $metaclass->superclasses(@superclasses) >>
1601
1602This is a read-write accessor which represents the superclass
1603relationships of the metaclass's class.
1604
1605This is basically sugar around getting and setting C<@ISA>.
1606
1607=item B<< $metaclass->class_precedence_list >>
1608
1609This returns a list of all of the class's ancestor classes. The
1610classes are returned in method dispatch order.
1611
1612=item B<< $metaclass->linearized_isa >>
1613
1614This returns a list based on C<class_precedence_list> but with all
1615duplicates removed.
1616
1617=item B<< $metaclass->subclasses >>
1618
1619This returns a list of all subclasses for this class, even indirect
1620subclasses.
1621
1622=item B<< $metaclass->direct_subclasses >>
1623
1624This returns a list of immediate subclasses for this class, which does not
1625include indirect subclasses.
1626
1627=back
1628
1629=head2 Method introspection and creation
1630
1631These methods allow you to introspect a class's methods, as well as
1632add, remove, or change methods.
1633
1634Determining what is truly a method in a Perl 5 class requires some
1635heuristics (aka guessing).
1636
1637Methods defined outside the package with a fully qualified name (C<sub
1638Package::name { ... }>) will be included. Similarly, methods named
1639with a fully qualified name using L<Sub::Name> are also included.
1640
1641However, we attempt to ignore imported functions.
1642
1643Ultimately, we are using heuristics to determine what truly is a
1644method in a class, and these heuristics may get the wrong answer in
1645some edge cases. However, for most "normal" cases the heuristics work
1646correctly.
1647
1648=over 4
1649
1650=item B<< $metaclass->get_method($method_name) >>
1651
1652This will return a L<Class::MOP::Method> for the specified
1653C<$method_name>. If the class does not have the specified method, it
1654returns C<undef>
1655
1656=item B<< $metaclass->has_method($method_name) >>
1657
1658Returns a boolean indicating whether or not the class defines the
1659named method. It does not include methods inherited from parent
1660classes.
1661
1662=item B<< $metaclass->get_method_list >>
1663
1664This will return a list of method I<names> for all methods defined in
1665this class.
1666
1667=item B<< $metaclass->add_method($method_name, $method) >>
1668
1669This method takes a method name and a subroutine reference, and adds
1670the method to the class.
1671
1672The subroutine reference can be a L<Class::MOP::Method>, and you are
1673strongly encouraged to pass a meta method object instead of a code
1674reference. If you do so, that object gets stored as part of the
1675class's method map directly. If not, the meta information will have to
1676be recreated later, and may be incorrect.
1677
1678If you provide a method object, this method will clone that object if
1679the object's package name does not match the class name. This lets us
1680track the original source of any methods added from other classes
1681(notably Moose roles).
1682
1683=item B<< $metaclass->remove_method($method_name) >>
1684
1685Remove the named method from the class. This method returns the
1686L<Class::MOP::Method> object for the method.
1687
1688=item B<< $metaclass->method_metaclass >>
1689
1690Returns the class name of the method metaclass, see
1691L<Class::MOP::Method> for more information on the method metaclass.
1692
1693=item B<< $metaclass->wrapped_method_metaclass >>
1694
1695Returns the class name of the wrapped method metaclass, see
1696L<Class::MOP::Method::Wrapped> for more information on the wrapped
1697method metaclass.
1698
1699=item B<< $metaclass->get_all_methods >>
1700
1701This will traverse the inheritance hierarchy and return a list of all
1702the L<Class::MOP::Method> objects for this class and its parents.
1703
1704=item B<< $metaclass->find_method_by_name($method_name) >>
1705
1706This will return a L<Class::MOP::Method> for the specified
1707C<$method_name>. If the class does not have the specified method, it
1708returns C<undef>
1709
1710Unlike C<get_method>, this method I<will> look for the named method in
1711superclasses.
1712
1713=item B<< $metaclass->get_all_method_names >>
1714
1715This will return a list of method I<names> for all of this class's
1716methods, including inherited methods.
1717
1718=item B<< $metaclass->find_all_methods_by_name($method_name) >>
1719
1720This method looks for the named method in the class and all of its
1721parents. It returns every matching method it finds in the inheritance
1722tree, so it returns a list of methods.
1723
1724Each method is returned as a hash reference with three keys. The keys
1725are C<name>, C<class>, and C<code>. The C<code> key has a
1726L<Class::MOP::Method> object as its value.
1727
1728The list of methods is distinct.
1729
1730=item B<< $metaclass->find_next_method_by_name($method_name) >>
1731
1732This method returns the first method in any superclass matching the
1733given name. It is effectively the method that C<SUPER::$method_name>
1734would dispatch to.
1735
1736=back
1737
1738=head2 Attribute introspection and creation
1739
1740Because Perl 5 does not have a core concept of attributes in classes,
1741we can only return information about attributes which have been added
1742via this class's methods. We cannot discover information about
1743attributes which are defined in terms of "regular" Perl 5 methods.
1744
1745=over 4
1746
1747=item B<< $metaclass->get_attribute($attribute_name) >>
1748
1749This will return a L<Class::MOP::Attribute> for the specified
1750C<$attribute_name>. If the class does not have the specified
1751attribute, it returns C<undef>.
1752
1753NOTE that get_attribute does not search superclasses, for that you
1754need to use C<find_attribute_by_name>.
1755
1756=item B<< $metaclass->has_attribute($attribute_name) >>
1757
1758Returns a boolean indicating whether or not the class defines the
1759named attribute. It does not include attributes inherited from parent
1760classes.
1761
1762=item B<< $metaclass->get_attribute_list >>
1763
1764This will return a list of attributes I<names> for all attributes
1765defined in this class. Note that this operates on the current class
1766only, it does not traverse the inheritance hierarchy.
1767
1768=item B<< $metaclass->get_all_attributes >>
1769
1770This will traverse the inheritance hierarchy and return a list of all
1771the L<Class::MOP::Attribute> objects for this class and its parents.
1772
1773=item B<< $metaclass->find_attribute_by_name($attribute_name) >>
1774
1775This will return a L<Class::MOP::Attribute> for the specified
1776C<$attribute_name>. If the class does not have the specified
1777attribute, it returns C<undef>.
1778
1779Unlike C<get_attribute>, this attribute I<will> look for the named
1780attribute in superclasses.
1781
1782=item B<< $metaclass->add_attribute(...) >>
1783
1784This method accepts either an existing L<Class::MOP::Attribute>
1785object or parameters suitable for passing to that class's C<new>
1786method.
1787
1788The attribute provided will be added to the class.
1789
1790Any accessor methods defined by the attribute will be added to the
1791class when the attribute is added.
1792
1793If an attribute of the same name already exists, the old attribute
1794will be removed first.
1795
1796=item B<< $metaclass->remove_attribute($attribute_name) >>
1797
1798This will remove the named attribute from the class, and
1799L<Class::MOP::Attribute> object.
1800
1801Removing an attribute also removes any accessor methods defined by the
1802attribute.
1803
1804However, note that removing an attribute will only affect I<future>
1805object instances created for this class, not existing instances.
1806
1807=item B<< $metaclass->attribute_metaclass >>
1808
1809Returns the class name of the attribute metaclass for this class. By
1810default, this is L<Class::MOP::Attribute>.
1811
1812=back
1813
1814=head2 Class Immutability
1815
1816Making a class immutable "freezes" the class definition. You can no
1817longer call methods which alter the class, such as adding or removing
1818methods or attributes.
1819
1820Making a class immutable lets us optimize the class by inlining some
1821methods, and also allows us to optimize some methods on the metaclass
1822object itself.
1823
1824After immutabilization, the metaclass object will cache most informational
1825methods that returns information about methods or attributes. Methods which
1826would alter the class, such as C<add_attribute> and C<add_method>, will
1827throw an error on an immutable metaclass object.
1828
1829The immutabilization system in L<Moose> takes much greater advantage
1830of the inlining features than Class::MOP itself does.
1831
1832=over 4
1833
1834=item B<< $metaclass->make_immutable(%options) >>
1835
1836This method will create an immutable transformer and use it to make
1837the class and its metaclass object immutable.
1838
1839This method accepts the following options:
1840
1841=over 8
1842
1843=item * inline_accessors
1844
1845=item * inline_constructor
1846
1847=item * inline_destructor
1848
1849These are all booleans indicating whether the specified method(s)
1850should be inlined.
1851
1852By default, accessors and the constructor are inlined, but not the
1853destructor.
1854
1855=item * immutable_trait
1856
1857The name of a class which will be used as a parent class for the
1858metaclass object being made immutable. This "trait" implements the
1859post-immutability functionality of the metaclass (but not the
1860transformation itself).
1861
1862This defaults to L<Class::MOP::Class::Immutable::Trait>.
1863
1864=item * constructor_name
1865
1866This is the constructor method name. This defaults to "new".
1867
1868=item * constructor_class
1869
1870The name of the method metaclass for constructors. It will be used to
1871generate the inlined constructor. This defaults to
1872"Class::MOP::Method::Constructor".
1873
1874=item * replace_constructor
1875
1876This is a boolean indicating whether an existing constructor should be
1877replaced when inlining a constructor. This defaults to false.
1878
1879=item * destructor_class
1880
1881The name of the method metaclass for destructors. It will be used to
1882generate the inlined destructor. This defaults to
1883"Class::MOP::Method::Denstructor".
1884
1885=item * replace_destructor
1886
1887This is a boolean indicating whether an existing destructor should be
1888replaced when inlining a destructor. This defaults to false.
1889
1890=back
1891
1892=item B<< $metaclass->immutable_options >>
1893
1894Returns a hash of the options used when making the class immutable, including
1895both defaults and anything supplied by the user in the call to C<<
1896$metaclass->make_immutable >>. This is useful if you need to temporarily make
1897a class mutable and then restore immutability as it was before.
1898
1899=item B<< $metaclass->make_mutable >>
1900
1901Calling this method reverse the immutabilization transformation.
1902
1903=back
1904
1905=head2 Method Modifiers
1906
1907Method modifiers are hooks which allow a method to be wrapped with
1908I<before>, I<after> and I<around> method modifiers. Every time a
1909method is called, its modifiers are also called.
1910
1911A class can modify its own methods, as well as methods defined in
1912parent classes.
1913
1914=head3 How method modifiers work?
1915
1916Method modifiers work by wrapping the original method and then
1917replacing it in the class's symbol table. The wrappers will handle
1918calling all the modifiers in the appropriate order and preserving the
1919calling context for the original method.
1920
1921The return values of C<before> and C<after> modifiers are
1922ignored. This is because their purpose is B<not> to filter the input
1923and output of the primary method (this is done with an I<around>
1924modifier).
1925
1926This may seem like an odd restriction to some, but doing this allows
1927for simple code to be added at the beginning or end of a method call
1928without altering the function of the wrapped method or placing any
1929extra responsibility on the code of the modifier.
1930
1931Of course if you have more complex needs, you can use the C<around>
1932modifier which allows you to change both the parameters passed to the
1933wrapped method, as well as its return value.
1934
1935Before and around modifiers are called in last-defined-first-called
1936order, while after modifiers are called in first-defined-first-called
1937order. So the call tree might looks something like this:
1938
1939 before 2
1940 before 1
1941 around 2
1942 around 1
1943 primary
1944 around 1
1945 around 2
1946 after 1
1947 after 2
1948
1949=head3 What is the performance impact?
1950
1951Of course there is a performance cost associated with method
1952modifiers, but we have made every effort to make that cost directly
1953proportional to the number of modifier features you use.
1954
1955The wrapping method does its best to B<only> do as much work as it
1956absolutely needs to. In order to do this we have moved some of the
1957performance costs to set-up time, where they are easier to amortize.
1958
1959All this said, our benchmarks have indicated the following:
1960
1961 simple wrapper with no modifiers 100% slower
1962 simple wrapper with simple before modifier 400% slower
1963 simple wrapper with simple after modifier 450% slower
1964 simple wrapper with simple around modifier 500-550% slower
1965 simple wrapper with all 3 modifiers 1100% slower
1966
1967These numbers may seem daunting, but you must remember, every feature
1968comes with some cost. To put things in perspective, just doing a
1969simple C<AUTOLOAD> which does nothing but extract the name of the
1970method called and return it costs about 400% over a normal method
1971call.
1972
1973=over 4
1974
1975=item B<< $metaclass->add_before_method_modifier($method_name, $code) >>
1976
1977This wraps the specified method with the supplied subroutine
1978reference. The modifier will be called as a method itself, and will
1979receive the same arguments as are passed to the method.
1980
1981When the modifier exits, the wrapped method will be called.
1982
1983The return value of the modifier will be ignored.
1984
1985=item B<< $metaclass->add_after_method_modifier($method_name, $code) >>
1986
1987This wraps the specified method with the supplied subroutine
1988reference. The modifier will be called as a method itself, and will
1989receive the same arguments as are passed to the method.
1990
1991When the wrapped methods exits, the modifier will be called.
1992
1993The return value of the modifier will be ignored.
1994
1995=item B<< $metaclass->add_around_method_modifier($method_name, $code) >>
1996
1997This wraps the specified method with the supplied subroutine
1998reference.
1999
2000The first argument passed to the modifier will be a subroutine
2001reference to the wrapped method. The second argument is the object,
2002and after that come any arguments passed when the method is called.
2003
2004The around modifier can choose to call the original method, as well as
2005what arguments to pass if it does so.
2006
2007The return value of the modifier is what will be seen by the caller.
2008
2009=back
2010
2011=head2 Introspection
2012
2013=over 4
2014
2015=item B<< Class::MOP::Class->meta >>
2016
2017This will return a L<Class::MOP::Class> instance for this class.
2018
2019It should also be noted that L<Class::MOP> will actually bootstrap
2020this module by installing a number of attribute meta-objects into its
2021metaclass.
2022
2023=back
2024
2025=head1 AUTHORS
2026
2027Stevan Little E<lt>stevan@iinteractive.comE<gt>
2028
2029=head1 COPYRIGHT AND LICENSE
2030
2031Copyright 2006-2010 by Infinity Interactive, Inc.
2032
2033L<http://www.iinteractive.com>
2034
2035This library is free software; you can redistribute it and/or modify
2036it under the same terms as Perl itself.
2037
2038=cut