Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP/Class.pm |
Statements | Executed 32394 statements in 69.3ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1404 | 25 | 15 | 6.16ms | 30.6ms | initialize (recurses: max depth 1, inclusive time 560µs) | Class::MOP::Class::
148 | 7 | 4 | 4.51ms | 8.92ms | get_all_attributes | Class::MOP::Class::
60 | 2 | 1 | 4.33ms | 5.56ms | CORE:sort (opcode) | Class::MOP::Class::
328 | 1 | 1 | 3.77ms | 6.96ms | _single_metaclass_can_be_made_compatible | Class::MOP::Class::
286 | 1 | 1 | 2.94ms | 21.0ms | _inline_slot_initializer | Class::MOP::Class::
58 | 2 | 1 | 2.59ms | 23.1ms | _construct_instance (recurses: max depth 1, inclusive time 154µs) | Class::MOP::Class::
275 | 1 | 1 | 2.24ms | 11.6ms | _inline_init_attr_from_constructor | Class::MOP::Class::
84 | 2 | 1 | 1.59ms | 21.1ms | _check_metaclass_compatibility (recurses: max depth 1, inclusive time 88µs) | Class::MOP::Class::
53 | 1 | 1 | 1.54ms | 10.5ms | _can_fix_metaclass_incompatibility | Class::MOP::Class::
286 | 1 | 1 | 1.54ms | 2.30ms | _inline_default_value | Class::MOP::Class::
73 | 1 | 1 | 1.50ms | 23.1ms | _construct_class_instance (recurses: max depth 1, inclusive time 147µs) | Class::MOP::Class::
286 | 2 | 1 | 1.50ms | 6.23ms | _inline_init_attr_from_default | Class::MOP::Class::
75 | 4 | 4 | 1.49ms | 9.85ms | find_method_by_name | Class::MOP::Class::
288 | 4 | 2 | 1.45ms | 2.32ms | linearized_isa | Class::MOP::Class::
131 | 1 | 1 | 1.31ms | 49.8ms | _post_add_attribute | Class::MOP::Class::
1 | 1 | 1 | 1.30ms | 1.45ms | BEGIN@13 | Class::MOP::Class::
70 | 1 | 1 | 1.22ms | 2.00ms | _single_metaclass_is_compatible | Class::MOP::Class::
1 | 1 | 1 | 1.16ms | 5.91ms | BEGIN@15 | Class::MOP::Class::
30 | 1 | 1 | 1.06ms | 62.5ms | _inline_constructor | Class::MOP::Class::
52 | 1 | 1 | 1.02ms | 16.6ms | _immutable_metaclass (recurses: max depth 1, inclusive time 85µs) | Class::MOP::Class::
52 | 6 | 4 | 1.00ms | 130ms | make_immutable (recurses: max depth 1, inclusive time 166µs) | Class::MOP::Class::
64 | 1 | 1 | 943µs | 943µs | _new | Class::MOP::Class::
53 | 2 | 2 | 921µs | 4.51ms | find_next_method_by_name | Class::MOP::Class::
1 | 1 | 1 | 916µs | 1.09ms | BEGIN@14 | Class::MOP::Class::
30 | 1 | 1 | 907µs | 26.7ms | _inline_slot_initializers | Class::MOP::Class::
30 | 1 | 1 | 894µs | 5.44ms | _eval_environment | Class::MOP::Class::
56 | 1 | 1 | 789µs | 8.69ms | _create_meta_instance | Class::MOP::Class::
131 | 1 | 1 | 746µs | 45.6ms | __ANON__[:892] | Class::MOP::Class::
53 | 2 | 2 | 718µs | 2.18ms | find_attribute_by_name | Class::MOP::Class::
52 | 1 | 1 | 709µs | 875µs | _immutable_options | Class::MOP::Class::
1 | 1 | 1 | 688µs | 1.63ms | BEGIN@16 | Class::MOP::Class::
131 | 1 | 1 | 666µs | 856µs | invalidate_meta_instances | Class::MOP::Class::
52 | 1 | 1 | 658µs | 110ms | _install_inlined_code | Class::MOP::Class::
338 | 11 | 5 | 656µs | 9.35ms | get_meta_instance | Class::MOP::Class::
52 | 1 | 1 | 616µs | 111ms | _initialize_immutable | Class::MOP::Class::
49 | 6 | 6 | 581µs | 16.8ms | new_object (recurses: max depth 1, inclusive time 165µs) | Class::MOP::Class::
33 | 1 | 1 | 574µs | 46.8ms | _inline_accessors | Class::MOP::Class::
30 | 1 | 1 | 533µs | 29.9ms | _inline_new_object | Class::MOP::Class::
43 | 1 | 1 | 525µs | 11.5ms | _fix_metaclass_incompatibility | Class::MOP::Class::
52 | 1 | 1 | 486µs | 17.1ms | _rebless_as_immutable (recurses: max depth 1, inclusive time 106µs) | Class::MOP::Class::
131 | 1 | 1 | 460µs | 1.65ms | _attach_attribute | Class::MOP::Class::
135 | 3 | 1 | 446µs | 1.51ms | _method_lookup_order | Class::MOP::Class::
17 | 3 | 2 | 446µs | 1.82ms | class_precedence_list (recurses: max depth 2, inclusive time 794µs) | Class::MOP::Class::
23 | 1 | 1 | 417µs | 5.55ms | __ANON__[:1072] | Class::MOP::Class::
75 | 4 | 1 | 366µs | 725µs | _real_ref_name | Class::MOP::Class::
53 | 1 | 1 | 355µs | 1.38ms | _class_metaclass_can_be_made_compatible | Class::MOP::Class::
30 | 1 | 1 | 303µs | 410µs | _inline_fallback_constructor | Class::MOP::Class::
7 | 1 | 1 | 303µs | 2.77ms | get_all_methods | Class::MOP::Class::
70 | 1 | 1 | 301µs | 2.30ms | _check_single_metaclass_compatibility | Class::MOP::Class::
96 | 3 | 2 | 280µs | 280µs | _base_metaclasses | Class::MOP::Class::
1 | 1 | 1 | 244µs | 309µs | BEGIN@17 | Class::MOP::Class::
30 | 1 | 1 | 203µs | 1.65ms | _inline_create_instance | Class::MOP::Class::
131 | 1 | 1 | 191µs | 191µs | invalidate_meta_instance | Class::MOP::Class::
30 | 1 | 1 | 186µs | 1.83ms | _inline_generate_instance | Class::MOP::Class::
23 | 1 | 1 | 183µs | 6.19ms | add_around_method_modifier | Class::MOP::Class::
30 | 1 | 1 | 178µs | 372µs | _inline_preserve_weak_metaclasses | Class::MOP::Class::
11 | 1 | 1 | 173µs | 641µs | _superclasses_updated | Class::MOP::Class::
2 | 2 | 2 | 160µs | 7.51ms | create | Class::MOP::Class::
30 | 1 | 1 | 138µs | 138µs | _add_inlined_method | Class::MOP::Class::
10 | 1 | 1 | 112µs | 217µs | _class_metaclass_is_compatible | Class::MOP::Class::
30 | 1 | 1 | 102µs | 102µs | _inline_params | Class::MOP::Class::
30 | 1 | 1 | 90µs | 90µs | _generate_fallback_constructor | Class::MOP::Class::
85 | 4 | 3 | 80µs | 80µs | is_mutable | Class::MOP::Class::
10 | 1 | 1 | 70µs | 287µs | _check_class_metaclass_compatibility | Class::MOP::Class::
51 | 1 | 1 | 56µs | 56µs | is_immutable | Class::MOP::Class::
11 | 1 | 1 | 34µs | 34µs | _superclass_metas | Class::MOP::Class::
30 | 1 | 1 | 29µs | 29µs | _inline_extra_init | Class::MOP::Class::
11 | 1 | 1 | 26µs | 26µs | update_meta_instance_dependencies | Class::MOP::Class::
1 | 1 | 1 | 9µs | 28µs | BEGIN@24 | Class::MOP::Class::
1 | 1 | 1 | 8µs | 8µs | BEGIN@3 | Class::MOP::Class::
1 | 1 | 1 | 8µs | 23µs | BEGIN@11 | Class::MOP::Class::
1 | 1 | 1 | 8µs | 12µs | BEGIN@10 | Class::MOP::Class::
1 | 1 | 1 | 7µs | 26µs | BEGIN@22 | Class::MOP::Class::
1 | 1 | 1 | 7µs | 6.53ms | BEGIN@26 | Class::MOP::Class::
1 | 1 | 1 | 6µs | 33µs | BEGIN@23 | Class::MOP::Class::
1 | 1 | 1 | 6µs | 29µs | BEGIN@20 | Class::MOP::Class::
1 | 1 | 1 | 6µs | 33µs | BEGIN@21 | Class::MOP::Class::
1 | 1 | 1 | 6µs | 26µs | BEGIN@19 | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | __ANON__[:216] | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | __ANON__[:896] | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | _anon_cache_key | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | _anon_package_prefix | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | _clone_instance | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | _fix_class_metaclass_incompatibility | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | _fix_single_metaclass_incompatibility | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | _fixup_attributes_after_rebless | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | _force_rebless_instance | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | _inline_clear_mop_slot | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | _inline_destructor | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | _inline_get_mop_slot | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | _inline_rebless_instance | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | _inline_set_mop_slot | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | _inlined_methods | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | _rebless_as_mutable | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | _remove_generated_metaobjects | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | _remove_inlined_code | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | _restore_metaobjects_from | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | add_after_method_modifier | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | add_before_method_modifier | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | add_dependent_meta_instance | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | add_meta_instance_dependencies | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | clone_object | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | create_anon_class | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | direct_subclasses | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | find_all_methods_by_name | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | get_all_method_names | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | immutable_options | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | is_anon_class | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | is_pristine | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | make_mutable | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | rebless_instance | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | rebless_instance_away | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | rebless_instance_back | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | reinitialize | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | remove_attribute | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | remove_dependent_meta_instance | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | remove_meta_instance_dependencies | Class::MOP::Class::
0 | 0 | 0 | 0s | 0s | subclasses | Class::MOP::Class::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | |||||
2 | package Class::MOP::Class; | ||||
3 | # spent 8µs within Class::MOP::Class::BEGIN@3 which was called:
# once (8µs+0s) by Class::MOP::BEGIN@26 at line 5 | ||||
4 | 1 | 4µs | $Class::MOP::Class::AUTHORITY = 'cpan:STEVAN'; | ||
5 | 1 | 21µs | 1 | 8µs | } # spent 8µs making 1 call to Class::MOP::Class::BEGIN@3 |
6 | { | ||||
7 | 2 | 3µs | $Class::MOP::Class::VERSION = '2.0602'; | ||
8 | } | ||||
9 | |||||
10 | 3 | 18µs | 2 | 17µs | # spent 12µs (8+4) within Class::MOP::Class::BEGIN@10 which was called:
# once (8µs+4µs) by Class::MOP::BEGIN@26 at line 10 # spent 12µs making 1 call to Class::MOP::Class::BEGIN@10
# spent 4µs making 1 call to strict::import |
11 | 3 | 18µs | 2 | 38µs | # spent 23µs (8+15) within Class::MOP::Class::BEGIN@11 which was called:
# once (8µs+15µs) by Class::MOP::BEGIN@26 at line 11 # spent 23µs making 1 call to Class::MOP::Class::BEGIN@11
# spent 15µs making 1 call to warnings::import |
12 | |||||
13 | 3 | 82µs | 1 | 1.45ms | # spent 1.45ms (1.30+150µs) within Class::MOP::Class::BEGIN@13 which was called:
# once (1.30ms+150µs) by Class::MOP::BEGIN@26 at line 13 # spent 1.45ms making 1 call to Class::MOP::Class::BEGIN@13 |
14 | 3 | 88µs | 1 | 1.09ms | # spent 1.09ms (916µs+174µs) within Class::MOP::Class::BEGIN@14 which was called:
# once (916µs+174µs) by Class::MOP::BEGIN@26 at line 14 # spent 1.09ms making 1 call to Class::MOP::Class::BEGIN@14 |
15 | 3 | 104µs | 1 | 5.91ms | # spent 5.91ms (1.16+4.76) within Class::MOP::Class::BEGIN@15 which was called:
# once (1.16ms+4.76ms) by Class::MOP::BEGIN@26 at line 15 # spent 5.91ms making 1 call to Class::MOP::Class::BEGIN@15 |
16 | 3 | 132µs | 1 | 1.63ms | # spent 1.63ms (688µs+944µs) within Class::MOP::Class::BEGIN@16 which was called:
# once (688µs+944µs) by Class::MOP::BEGIN@26 at line 16 # spent 1.63ms making 1 call to Class::MOP::Class::BEGIN@16 |
17 | 3 | 82µs | 1 | 309µs | # spent 309µs (244+65) within Class::MOP::Class::BEGIN@17 which was called:
# once (244µs+65µs) by Class::MOP::BEGIN@26 at line 17 # spent 309µs making 1 call to Class::MOP::Class::BEGIN@17 |
18 | |||||
19 | 3 | 18µs | 2 | 47µs | # spent 26µs (6+21) within Class::MOP::Class::BEGIN@19 which was called:
# once (6µs+21µs) by Class::MOP::BEGIN@26 at line 19 # spent 26µs making 1 call to Class::MOP::Class::BEGIN@19
# spent 21µs making 1 call to Exporter::import |
20 | 3 | 19µs | 2 | 52µs | # spent 29µs (6+23) within Class::MOP::Class::BEGIN@20 which was called:
# once (6µs+23µs) by Class::MOP::BEGIN@26 at line 20 # spent 29µs making 1 call to Class::MOP::Class::BEGIN@20
# spent 23µs making 1 call to Exporter::import |
21 | 3 | 18µs | 2 | 60µs | # spent 33µs (6+27) within Class::MOP::Class::BEGIN@21 which was called:
# once (6µs+27µs) by Class::MOP::BEGIN@26 at line 21 # spent 33µs making 1 call to Class::MOP::Class::BEGIN@21
# spent 27µs making 1 call to Exporter::import |
22 | 3 | 17µs | 2 | 44µs | # spent 26µs (7+19) within Class::MOP::Class::BEGIN@22 which was called:
# once (7µs+19µs) by Class::MOP::BEGIN@26 at line 22 # spent 26µs making 1 call to Class::MOP::Class::BEGIN@22
# spent 19µs making 1 call to Exporter::import |
23 | 3 | 19µs | 2 | 60µs | # spent 33µs (6+27) within Class::MOP::Class::BEGIN@23 which was called:
# once (6µs+27µs) by Class::MOP::BEGIN@26 at line 23 # spent 33µs making 1 call to Class::MOP::Class::BEGIN@23
# spent 27µs making 1 call to Exporter::import |
24 | 3 | 22µs | 2 | 48µs | # spent 28µs (9+20) within Class::MOP::Class::BEGIN@24 which was called:
# once (9µs+20µs) by Class::MOP::BEGIN@26 at line 24 # spent 28µs making 1 call to Class::MOP::Class::BEGIN@24
# spent 20µs making 1 call to Exporter::import |
25 | |||||
26 | 1 | 9µs | 1 | 6.53ms | # spent 6.53ms (7µs+6.53) within Class::MOP::Class::BEGIN@26 which was called:
# once (7µs+6.53ms) by Class::MOP::BEGIN@26 at line 28 # spent 6.53ms making 1 call to base::import |
27 | 'Class::MOP::Mixin::HasAttributes', | ||||
28 | 2 | 5.19ms | 1 | 6.53ms | 'Class::MOP::Mixin::HasMethods'; # spent 6.53ms making 1 call to Class::MOP::Class::BEGIN@26 |
29 | |||||
30 | # Creation | ||||
31 | |||||
32 | # spent 30.6ms (6.16+24.4) within Class::MOP::Class::initialize which was called 1404 times, avg 22µs/call:
# 548 times (2.06ms+476µs) by Class::MOP::Class::get_all_attributes at line 928, avg 5µs/call
# 232 times (880µs+298µs) by Class::MOP::Class::find_method_by_name at line 1123, avg 5µs/call
# 224 times (1.14ms+4.17ms) by Class::MOP::Mixin::meta or Class::MOP::Object::meta or Moose::Meta::Role::Application::RoleSummation::meta or Moose::Meta::Role::Application::ToClass::meta or Moose::Meta::Role::Application::ToInstance::meta or Moose::Meta::Role::Application::ToRole::meta or Moose::Meta::Role::Application::meta or Moose::Meta::Role::Composite::meta or Moose::Meta::Role::Method::Required::meta or Moose::Meta::Role::meta or Moose::Meta::TypeCoercion::Union::meta or Moose::Meta::TypeCoercion::meta or Moose::Meta::TypeConstraint::Class::meta or Moose::Meta::TypeConstraint::DuckType::meta or Moose::Meta::TypeConstraint::Enum::meta or Moose::Meta::TypeConstraint::Parameterizable::meta or Moose::Meta::TypeConstraint::Parameterized::meta or Moose::Meta::TypeConstraint::Registry::meta or Moose::Meta::TypeConstraint::Role::meta or Moose::Meta::TypeConstraint::Union::meta or Moose::Meta::TypeConstraint::meta or MooseX::Traits::__ANON__::SERIAL::1::meta or Tapper::MCP::Scheduler::Algorithm::meta at line 48 of Class/MOP/Method/Meta.pm, avg 24µs/call
# 90 times (361µs+102µs) by Class::MOP::Class::find_next_method_by_name at line 1171, avg 5µs/call
# 53 times (207µs+48µs) by Class::MOP::Class::find_attribute_by_name at line 918, avg 5µs/call
# 53 times (234µs+-160µs) by Class::MOP::Class::_fix_metaclass_incompatibility at line 300, avg 1µs/call
# 33 times (157µs+3.47ms) by Class::MOP::Object::meta at line 20 of Class/MOP/Object.pm, avg 110µs/call
# 23 times (89µs+804µs) by Class::MOP::Method::_new at line 56 of Class/MOP/Method.pm, avg 39µs/call
# 19 times (187µs+1.96ms) by metaclass::import at line 48 of metaclass.pm, avg 113µs/call
# 18 times (88µs+1.22ms) by Class::MOP::Mixin::meta at line 16 of Class/MOP/Mixin.pm, avg 73µs/call
# 14 times (53µs+15µs) by Class::MOP::Class::get_all_methods at line 1134, avg 5µs/call
# 13 times (120µs+2.19ms) by Class::MOP::MiniTrait::apply at line 19 of Class/MOP/MiniTrait.pm, avg 178µs/call
# 12 times (55µs+20µs) by Moose::Meta::Method::_new at line 7 of (eval 170)[Eval/Closure.pm:125], avg 6µs/call
# 12 times (45µs+14µs) by Class::MOP::Attribute::get_raw_value at line 297 of Class/MOP/Attribute.pm, avg 5µs/call
# 12 times (44µs+13µs) by Class::MOP::Attribute::has_value at line 318 of Class/MOP/Attribute.pm, avg 5µs/call
# 10 times (93µs+26µs) by Class::MOP::Class::class_precedence_list at line 1028, avg 12µs/call
# 9 times (133µs+8.58ms) by Moose::Meta::Class::initialize at line 79 of Moose/Meta/Class.pm, avg 969µs/call
# 9 times (48µs+507µs) by Class::MOP::Method::Accessor::_new at line 50 of Class/MOP/Method/Accessor.pm, avg 62µs/call
# 7 times (49µs+481µs) by Moose::BEGIN@47 at line 15 of Moose/Meta/Attribute/Native.pm, avg 76µs/call
# 4 times (23µs+6µs) by Class::MOP::Attribute::set_initial_value at line 261 of Class/MOP/Attribute.pm, avg 7µs/call
# 3 times (49µs+16µs) by Moose::Object::does at line 122 of Moose/Object.pm, avg 22µs/call
# 3 times (11µs+4µs) by Moose::Object::new at line 28 of Moose/Object.pm, avg 5µs/call
# once (8µs+122µs) by Class::MOP::Package::create at line 72 of Class/MOP/Package.pm
# once (27µs+8µs) by namespace::autoclean::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/namespace/autoclean.pm:57] at line 44 of namespace/autoclean.pm
# once (4µs+1µs) by Class::MOP::Attribute::_new at line 64 of Class/MOP/Attribute.pm | ||||
33 | 1404 | 573µs | my $class = shift; | ||
34 | |||||
35 | 1404 | 241µs | my $package_name; | ||
36 | |||||
37 | 1404 | 904µs | if ( @_ % 2 ) { | ||
38 | $package_name = shift; | ||||
39 | } else { | ||||
40 | my %options = @_; | ||||
41 | $package_name = $options{package}; | ||||
42 | } | ||||
43 | |||||
44 | 1404 | 341µs | ($package_name && !ref($package_name)) | ||
45 | || confess "You must pass a package name and it cannot be blessed"; | ||||
46 | |||||
47 | 1404 | 3.95ms | 1477 | 24.8ms | return Class::MOP::get_metaclass_by_name($package_name) # spent 23.3ms making 73 calls to Class::MOP::Class::_construct_class_instance, avg 319µs/call, recursion: max depth 1, sum of overlapping time 147µs
# spent 1.70ms making 1404 calls to Class::MOP::get_metaclass_by_name, avg 1µs/call |
48 | || $class->_construct_class_instance(package => $package_name, @_); | ||||
49 | } | ||||
50 | |||||
51 | sub reinitialize { | ||||
52 | my ( $class, @args ) = @_; | ||||
53 | unshift @args, "package" if @args % 2; | ||||
54 | my %options = @args; | ||||
55 | my $old_metaclass = blessed($options{package}) | ||||
56 | ? $options{package} | ||||
57 | : Class::MOP::get_metaclass_by_name($options{package}); | ||||
58 | $options{weaken} = Class::MOP::metaclass_is_weak($old_metaclass->name) | ||||
59 | if !exists $options{weaken} | ||||
60 | && blessed($old_metaclass) | ||||
61 | && $old_metaclass->isa('Class::MOP::Class'); | ||||
62 | $old_metaclass->_remove_generated_metaobjects | ||||
63 | if $old_metaclass && $old_metaclass->isa('Class::MOP::Class'); | ||||
64 | my $new_metaclass = $class->SUPER::reinitialize(%options); | ||||
65 | $new_metaclass->_restore_metaobjects_from($old_metaclass) | ||||
66 | if $old_metaclass && $old_metaclass->isa('Class::MOP::Class'); | ||||
67 | return $new_metaclass; | ||||
68 | } | ||||
69 | |||||
70 | # NOTE: (meta-circularity) | ||||
71 | # this is a special form of _construct_instance | ||||
72 | # (see below), which is used to construct class | ||||
73 | # meta-object instances for any Class::MOP::* | ||||
74 | # class. All other classes will use the more | ||||
75 | # normal &construct_instance. | ||||
76 | # spent 23.1ms (1.50+21.6) within Class::MOP::Class::_construct_class_instance which was called 73 times, avg 317µs/call:
# 73 times (1.50ms+21.6ms) by Class::MOP::Class::initialize at line 47, avg 317µs/call | ||||
77 | 73 | 37µs | my $class = shift; | ||
78 | 73 | 157µs | my $options = @_ == 1 ? $_[0] : {@_}; | ||
79 | 73 | 57µs | my $package_name = $options->{package}; | ||
80 | 73 | 30µs | (defined $package_name && $package_name) | ||
81 | || confess "You must pass a package name"; | ||||
82 | # NOTE: | ||||
83 | # return the metaclass if we have it cached, | ||||
84 | # and it is still defined (it has not been | ||||
85 | # reaped by DESTROY yet, which can happen | ||||
86 | # annoyingly enough during global destruction) | ||||
87 | |||||
88 | 73 | 93µs | 73 | 67µs | if (defined(my $meta = Class::MOP::get_metaclass_by_name($package_name))) { # spent 67µs making 73 calls to Class::MOP::get_metaclass_by_name, avg 919ns/call |
89 | return $meta; | ||||
90 | } | ||||
91 | |||||
92 | $class | ||||
93 | 73 | 60µs | 11 | 208µs | = ref $class # spent 208µs making 11 calls to Class::MOP::Class::_real_ref_name, avg 19µs/call |
94 | ? $class->_real_ref_name | ||||
95 | : $class; | ||||
96 | |||||
97 | # now create the metaclass | ||||
98 | 73 | 16µs | my $meta; | ||
99 | 73 | 161µs | 64 | 943µs | if ($class eq 'Class::MOP::Class') { # spent 943µs making 64 calls to Class::MOP::Class::_new, avg 15µs/call |
100 | $meta = $class->_new($options); | ||||
101 | } | ||||
102 | else { | ||||
103 | # NOTE: | ||||
104 | # it is safe to use meta here because | ||||
105 | # class will always be a subclass of | ||||
106 | # Class::MOP::Class, which defines meta | ||||
107 | 9 | 75µs | 18 | 7.17ms | $meta = $class->meta->_construct_instance($options) # spent 6.99ms making 9 calls to Class::MOP::Class::_construct_instance, avg 776µs/call
# spent 186µs making 9 calls to Class::MOP::Object::meta, avg 21µs/call |
108 | } | ||||
109 | |||||
110 | # and check the metaclass compatibility | ||||
111 | 73 | 202µs | 73 | 13.1ms | $meta->_check_metaclass_compatibility(); # spent 13.2ms making 73 calls to Class::MOP::Class::_check_metaclass_compatibility, avg 181µs/call, recursion: max depth 1, sum of overlapping time 88µs |
112 | |||||
113 | 73 | 133µs | 73 | 175µs | Class::MOP::store_metaclass_by_name($package_name, $meta); # spent 175µs making 73 calls to Class::MOP::store_metaclass_by_name, avg 2µs/call |
114 | |||||
115 | # NOTE: | ||||
116 | # we need to weaken any anon classes | ||||
117 | # so that they can call DESTROY properly | ||||
118 | 73 | 33µs | Class::MOP::weaken_metaclass($package_name) if $options->{weaken}; | ||
119 | |||||
120 | 73 | 216µs | $meta; | ||
121 | } | ||||
122 | |||||
123 | # spent 725µs (366+359) within Class::MOP::Class::_real_ref_name which was called 75 times, avg 10µs/call:
# 53 times (242µs+223µs) by Class::MOP::Class::_class_metaclass_can_be_made_compatible at line 345, avg 9µs/call
# 11 times (82µs+126µs) by Class::MOP::Class::_construct_class_instance at line 93, avg 19µs/call
# 10 times (36µs+10µs) by Class::MOP::Class::_class_metaclass_is_compatible at line 255, avg 5µs/call
# once (5µs+1µs) by Class::MOP::Class::_immutable_metaclass at line 1352 | ||||
124 | 75 | 26µs | my $self = shift; | ||
125 | |||||
126 | # NOTE: we need to deal with the possibility of class immutability here, | ||||
127 | # and then get the name of the class appropriately | ||||
128 | 75 | 338µs | 99 | 359µs | return $self->is_immutable # spent 235µs making 24 calls to Class::MOP::Class::Immutable::Class::MOP::Class::is_immutable, avg 10µs/call
# spent 68µs making 24 calls to Class::MOP::Class::Immutable::Trait::_get_mutable_metaclass_name, avg 3µs/call
# spent 56µs making 51 calls to Class::MOP::Class::is_immutable, avg 1µs/call |
129 | ? $self->_get_mutable_metaclass_name() | ||||
130 | : ref $self; | ||||
131 | } | ||||
132 | |||||
133 | # spent 943µs within Class::MOP::Class::_new which was called 64 times, avg 15µs/call:
# 64 times (943µs+0s) by Class::MOP::Class::_construct_class_instance at line 99, avg 15µs/call | ||||
134 | 64 | 32µs | my $class = shift; | ||
135 | |||||
136 | 64 | 30µs | return Class::MOP::Class->initialize($class)->new_object(@_) | ||
137 | if $class ne __PACKAGE__; | ||||
138 | |||||
139 | 64 | 42µs | my $options = @_ == 1 ? $_[0] : {@_}; | ||
140 | |||||
141 | 64 | 913µs | return bless { | ||
142 | # inherited from Class::MOP::Package | ||||
143 | 'package' => $options->{package}, | ||||
144 | |||||
145 | # NOTE: | ||||
146 | # since the following attributes will | ||||
147 | # actually be loaded from the symbol | ||||
148 | # table, and actually bypass the instance | ||||
149 | # entirely, we can just leave these things | ||||
150 | # listed here for reference, because they | ||||
151 | # should not actually have a value associated | ||||
152 | # with the slot. | ||||
153 | 'namespace' => \undef, | ||||
154 | 'methods' => {}, | ||||
155 | |||||
156 | # inherited from Class::MOP::Module | ||||
157 | 'version' => \undef, | ||||
158 | 'authority' => \undef, | ||||
159 | |||||
160 | # defined in Class::MOP::Class | ||||
161 | 'superclasses' => \undef, | ||||
162 | |||||
163 | 'attributes' => {}, | ||||
164 | 'attribute_metaclass' => | ||||
165 | ( $options->{'attribute_metaclass'} || 'Class::MOP::Attribute' ), | ||||
166 | 'method_metaclass' => | ||||
167 | ( $options->{'method_metaclass'} || 'Class::MOP::Method' ), | ||||
168 | 'wrapped_method_metaclass' => ( | ||||
169 | $options->{'wrapped_method_metaclass'} | ||||
170 | || 'Class::MOP::Method::Wrapped' | ||||
171 | ), | ||||
172 | 'instance_metaclass' => | ||||
173 | ( $options->{'instance_metaclass'} || 'Class::MOP::Instance' ), | ||||
174 | 'immutable_trait' => ( | ||||
175 | $options->{'immutable_trait'} | ||||
176 | || 'Class::MOP::Class::Immutable::Trait' | ||||
177 | ), | ||||
178 | 'constructor_name' => ( $options->{constructor_name} || 'new' ), | ||||
179 | 'constructor_class' => ( | ||||
180 | $options->{constructor_class} || 'Class::MOP::Method::Constructor' | ||||
181 | ), | ||||
182 | 'destructor_class' => $options->{destructor_class}, | ||||
183 | }, $class; | ||||
184 | } | ||||
185 | |||||
186 | ## Metaclass compatibility | ||||
187 | { | ||||
188 | 2 | 6µs | my %base_metaclass = ( | ||
189 | attribute_metaclass => 'Class::MOP::Attribute', | ||||
190 | method_metaclass => 'Class::MOP::Method', | ||||
191 | wrapped_method_metaclass => 'Class::MOP::Method::Wrapped', | ||||
192 | instance_metaclass => 'Class::MOP::Instance', | ||||
193 | constructor_class => 'Class::MOP::Method::Constructor', | ||||
194 | destructor_class => 'Class::MOP::Method::Destructor', | ||||
195 | ); | ||||
196 | |||||
197 | 96 | 383µs | # spent 280µs within Class::MOP::Class::_base_metaclasses which was called 96 times, avg 3µs/call:
# 43 times (139µs+0s) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 333, avg 3µs/call
# 33 times (68µs+0s) by Class::MOP::Class::_check_metaclass_compatibility at line 208, avg 2µs/call
# 20 times (73µs+0s) by Moose::Meta::Class::_base_metaclasses at line 620 of Moose/Meta/Class.pm, avg 4µs/call | ||
198 | } | ||||
199 | |||||
200 | # spent 21.1ms (1.59+19.5) within Class::MOP::Class::_check_metaclass_compatibility which was called 84 times, avg 251µs/call:
# 73 times (836µs+12.3ms) by Class::MOP::Class::_construct_class_instance at line 111, avg 180µs/call
# 11 times (756µs+7.19ms) by Class::MOP::Class::superclasses at line 958, avg 722µs/call | ||||
201 | 84 | 37µs | my $self = shift; | ||
202 | |||||
203 | 84 | 334µs | 84 | 3.81ms | my @superclasses = $self->superclasses # spent 2.96ms making 65 calls to Class::MOP::Class::superclasses, avg 46µs/call, recursion: max depth 1, sum of overlapping time 14µs
# spent 1.31ms making 19 calls to Moose::Meta::Class::superclasses, avg 69µs/call, recursion: max depth 2, sum of overlapping time 438µs |
204 | or return; | ||||
205 | |||||
206 | 43 | 94µs | 43 | 11.5ms | $self->_fix_metaclass_incompatibility(@superclasses); # spent 11.5ms making 43 calls to Class::MOP::Class::_fix_metaclass_incompatibility, avg 267µs/call |
207 | |||||
208 | 43 | 224µs | 43 | 429µs | my %base_metaclass = $self->_base_metaclasses; # spent 361µs making 10 calls to Moose::Meta::Class::_base_metaclasses, avg 36µs/call
# spent 68µs making 33 calls to Class::MOP::Class::_base_metaclasses, avg 2µs/call |
209 | |||||
210 | # this is always okay ... | ||||
211 | return | ||||
212 | if ref($self) eq 'Class::MOP::Class' | ||||
213 | && all { | ||||
214 | 198 | 498µs | 198 | 124µs | my $meta = $self->$_; # spent 44µs making 33 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 1µs/call
# spent 17µs making 33 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 503ns/call
# spent 16µs making 33 calls to Class::MOP::Class::instance_metaclass, avg 494ns/call
# spent 16µs making 33 calls to Class::MOP::Class::constructor_class, avg 491ns/call
# spent 16µs making 33 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 491ns/call
# spent 15µs making 33 calls to Class::MOP::Class::destructor_class, avg 464ns/call |
215 | 198 | 253µs | !defined($meta) || $meta eq $base_metaclass{$_}; | ||
216 | } | ||||
217 | 43 | 215µs | 33 | 710µs | keys %base_metaclass; # spent 710µs making 33 calls to List::MoreUtils::all, avg 22µs/call |
218 | |||||
219 | 10 | 11µs | for my $superclass (@superclasses) { | ||
220 | 10 | 36µs | 10 | 287µs | $self->_check_class_metaclass_compatibility($superclass); # spent 287µs making 10 calls to Class::MOP::Class::_check_class_metaclass_compatibility, avg 29µs/call |
221 | } | ||||
222 | |||||
223 | 10 | 56µs | for my $metaclass_type ( keys %base_metaclass ) { | ||
224 | 70 | 181µs | 70 | 80µs | next unless defined $self->$metaclass_type; # spent 19µs making 10 calls to Moose::Meta::Class::error_class, avg 2µs/call
# spent 16µs making 10 calls to Moose::Meta::Class::destructor_class, avg 2µs/call
# spent 16µs making 10 calls to Moose::Meta::Class::constructor_class, avg 2µs/call
# spent 8µs making 10 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 770ns/call
# spent 7µs making 10 calls to Class::MOP::Class::instance_metaclass, avg 730ns/call
# spent 7µs making 10 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 730ns/call
# spent 7µs making 10 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 690ns/call |
225 | 70 | 65µs | for my $superclass (@superclasses) { | ||
226 | 70 | 146µs | 70 | 2.30ms | $self->_check_single_metaclass_compatibility( $metaclass_type, # spent 2.30ms making 70 calls to Class::MOP::Class::_check_single_metaclass_compatibility, avg 33µs/call |
227 | $superclass ); | ||||
228 | } | ||||
229 | } | ||||
230 | } | ||||
231 | |||||
232 | # spent 287µs (70+217) within Class::MOP::Class::_check_class_metaclass_compatibility which was called 10 times, avg 29µs/call:
# 10 times (70µs+217µs) by Class::MOP::Class::_check_metaclass_compatibility at line 220, avg 29µs/call | ||||
233 | 10 | 5µs | my $self = shift; | ||
234 | 10 | 9µs | my ( $superclass_name ) = @_; | ||
235 | |||||
236 | 10 | 51µs | 10 | 217µs | if (!$self->_class_metaclass_is_compatible($superclass_name)) { # spent 217µs making 10 calls to Class::MOP::Class::_class_metaclass_is_compatible, avg 22µs/call |
237 | my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name); | ||||
238 | |||||
239 | my $super_meta_type = $super_meta->_real_ref_name; | ||||
240 | |||||
241 | confess "The metaclass of " . $self->name . " (" | ||||
242 | . (ref($self)) . ")" . " is not compatible with " | ||||
243 | . "the metaclass of its superclass, " | ||||
244 | . $superclass_name . " (" . ($super_meta_type) . ")"; | ||||
245 | } | ||||
246 | } | ||||
247 | |||||
248 | # spent 217µs (112+105) within Class::MOP::Class::_class_metaclass_is_compatible which was called 10 times, avg 22µs/call:
# 10 times (112µs+105µs) by Class::MOP::Class::_check_class_metaclass_compatibility at line 236, avg 22µs/call | ||||
249 | 10 | 4µs | my $self = shift; | ||
250 | 10 | 9µs | my ( $superclass_name ) = @_; | ||
251 | |||||
252 | 10 | 15µs | 10 | 14µs | my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name) # spent 14µs making 10 calls to Class::MOP::get_metaclass_by_name, avg 1µs/call |
253 | || return 1; | ||||
254 | |||||
255 | 10 | 20µs | 10 | 46µs | my $super_meta_name = $super_meta->_real_ref_name; # spent 46µs making 10 calls to Class::MOP::Class::_real_ref_name, avg 5µs/call |
256 | |||||
257 | 10 | 40µs | 10 | 46µs | return $self->_is_compatible_with($super_meta_name); # spent 46µs making 10 calls to Class::MOP::Object::_is_compatible_with, avg 5µs/call |
258 | } | ||||
259 | |||||
260 | # spent 2.30ms (301µs+2.00) within Class::MOP::Class::_check_single_metaclass_compatibility which was called 70 times, avg 33µs/call:
# 70 times (301µs+2.00ms) by Class::MOP::Class::_check_metaclass_compatibility at line 226, avg 33µs/call | ||||
261 | 70 | 21µs | my $self = shift; | ||
262 | 70 | 42µs | my ( $metaclass_type, $superclass_name ) = @_; | ||
263 | |||||
264 | 70 | 228µs | 70 | 2.00ms | if (!$self->_single_metaclass_is_compatible($metaclass_type, $superclass_name)) { # spent 2.00ms making 70 calls to Class::MOP::Class::_single_metaclass_is_compatible, avg 29µs/call |
265 | my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name); | ||||
266 | my $metaclass_type_name = $metaclass_type; | ||||
267 | $metaclass_type_name =~ s/_(?:meta)?class$//; | ||||
268 | $metaclass_type_name =~ s/_/ /g; | ||||
269 | confess "The $metaclass_type_name metaclass for " | ||||
270 | . $self->name . " (" . ($self->$metaclass_type) | ||||
271 | . ")" . " is not compatible with the " | ||||
272 | . "$metaclass_type_name metaclass of its " | ||||
273 | . "superclass, $superclass_name (" | ||||
274 | . ($super_meta->$metaclass_type) . ")"; | ||||
275 | } | ||||
276 | } | ||||
277 | |||||
278 | # spent 2.00ms (1.22+781µs) within Class::MOP::Class::_single_metaclass_is_compatible which was called 70 times, avg 29µs/call:
# 70 times (1.22ms+781µs) by Class::MOP::Class::_check_single_metaclass_compatibility at line 264, avg 29µs/call | ||||
279 | 70 | 18µs | my $self = shift; | ||
280 | 70 | 36µs | my ( $metaclass_type, $superclass_name ) = @_; | ||
281 | |||||
282 | 70 | 83µs | 70 | 83µs | my $super_meta = Class::MOP::get_metaclass_by_name($superclass_name) # spent 83µs making 70 calls to Class::MOP::get_metaclass_by_name, avg 1µs/call |
283 | || return 1; | ||||
284 | |||||
285 | # for instance, Moose::Meta::Class has a error_class attribute, but | ||||
286 | # Class::MOP::Class doesn't - this shouldn't be an error | ||||
287 | 70 | 204µs | 70 | 67µs | return 1 unless $super_meta->can($metaclass_type); # spent 67µs making 70 calls to UNIVERSAL::can, avg 953ns/call |
288 | # for instance, Moose::Meta::Class has a destructor_class, but | ||||
289 | # Class::MOP::Class doesn't - this shouldn't be an error | ||||
290 | 70 | 161µs | 70 | 72µs | return 1 unless defined $super_meta->$metaclass_type; # spent 15µs making 10 calls to Moose::Meta::Class::error_class, avg 2µs/call
# spent 14µs making 10 calls to Moose::Meta::Class::constructor_class, avg 1µs/call
# spent 14µs making 10 calls to Moose::Meta::Class::destructor_class, avg 1µs/call
# spent 7µs making 10 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 710ns/call
# spent 7µs making 10 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 690ns/call
# spent 7µs making 10 calls to Class::MOP::Class::instance_metaclass, avg 680ns/call
# spent 7µs making 10 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 670ns/call |
291 | # if metaclass is defined in superclass but not here, it's not compatible | ||||
292 | # this is a really odd case | ||||
293 | 70 | 155µs | 70 | 63µs | return 0 unless defined $self->$metaclass_type; # spent 14µs making 10 calls to Moose::Meta::Class::constructor_class, avg 1µs/call
# spent 13µs making 10 calls to Moose::Meta::Class::error_class, avg 1µs/call
# spent 13µs making 10 calls to Moose::Meta::Class::destructor_class, avg 1µs/call
# spent 6µs making 10 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 600ns/call
# spent 6µs making 10 calls to Class::MOP::Class::instance_metaclass, avg 580ns/call
# spent 6µs making 10 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 570ns/call
# spent 6µs making 10 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 570ns/call |
294 | |||||
295 | 70 | 527µs | 210 | 497µs | return $self->$metaclass_type->_is_compatible_with($super_meta->$metaclass_type); # spent 376µs making 70 calls to Class::MOP::Object::_is_compatible_with, avg 5µs/call
# spent 27µs making 20 calls to Moose::Meta::Class::error_class, avg 1µs/call
# spent 26µs making 20 calls to Moose::Meta::Class::constructor_class, avg 1µs/call
# spent 25µs making 20 calls to Moose::Meta::Class::destructor_class, avg 1µs/call
# spent 11µs making 20 calls to Class::MOP::Class::instance_metaclass, avg 555ns/call
# spent 11µs making 20 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 550ns/call
# spent 11µs making 20 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 550ns/call
# spent 10µs making 20 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 515ns/call |
296 | } | ||||
297 | |||||
298 | # spent 11.5ms (525µs+11.0) within Class::MOP::Class::_fix_metaclass_incompatibility which was called 43 times, avg 267µs/call:
# 43 times (525µs+11.0ms) by Class::MOP::Class::_check_metaclass_compatibility at line 206, avg 267µs/call | ||||
299 | 43 | 19µs | my $self = shift; | ||
300 | 96 | 159µs | 53 | 74µs | my @supers = map { Class::MOP::Class->initialize($_) } @_; # spent 449µs making 53 calls to Class::MOP::Class::initialize, avg 8µs/call, recursion: max depth 1, sum of overlapping time 376µs |
301 | |||||
302 | 43 | 16µs | my $necessary = 0; | ||
303 | 43 | 39µs | for my $super (@supers) { | ||
304 | 53 | 139µs | 53 | 10.5ms | $necessary = 1 # spent 10.5ms making 53 calls to Class::MOP::Class::_can_fix_metaclass_incompatibility, avg 198µs/call |
305 | if $self->_can_fix_metaclass_incompatibility($super); | ||||
306 | } | ||||
307 | 43 | 96µs | return unless $necessary; | ||
308 | |||||
309 | for my $super (@supers) { | ||||
310 | if (!$self->_class_metaclass_is_compatible($super->name)) { | ||||
311 | $self->_fix_class_metaclass_incompatibility($super); | ||||
312 | } | ||||
313 | } | ||||
314 | |||||
315 | my %base_metaclass = $self->_base_metaclasses; | ||||
316 | for my $metaclass_type (keys %base_metaclass) { | ||||
317 | for my $super (@supers) { | ||||
318 | if (!$self->_single_metaclass_is_compatible($metaclass_type, $super->name)) { | ||||
319 | $self->_fix_single_metaclass_incompatibility( | ||||
320 | $metaclass_type, $super | ||||
321 | ); | ||||
322 | } | ||||
323 | } | ||||
324 | } | ||||
325 | } | ||||
326 | |||||
327 | # spent 10.5ms (1.54+8.97) within Class::MOP::Class::_can_fix_metaclass_incompatibility which was called 53 times, avg 198µs/call:
# 53 times (1.54ms+8.97ms) by Class::MOP::Class::_fix_metaclass_incompatibility at line 304, avg 198µs/call | ||||
328 | 53 | 19µs | my $self = shift; | ||
329 | 53 | 21µs | my ($super_meta) = @_; | ||
330 | |||||
331 | 53 | 92µs | 53 | 1.38ms | return 1 if $self->_class_metaclass_can_be_made_compatible($super_meta); # spent 1.38ms making 53 calls to Class::MOP::Class::_class_metaclass_can_be_made_compatible, avg 26µs/call |
332 | |||||
333 | 53 | 322µs | 53 | 621µs | my %base_metaclass = $self->_base_metaclasses; # spent 482µs making 10 calls to Moose::Meta::Class::_base_metaclasses, avg 48µs/call
# spent 139µs making 43 calls to Class::MOP::Class::_base_metaclasses, avg 3µs/call |
334 | 53 | 87µs | for my $metaclass_type (keys %base_metaclass) { | ||
335 | 328 | 521µs | 328 | 6.96ms | return 1 if $self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type); # spent 6.96ms making 328 calls to Class::MOP::Class::_single_metaclass_can_be_made_compatible, avg 21µs/call |
336 | } | ||||
337 | |||||
338 | 53 | 149µs | return; | ||
339 | } | ||||
340 | |||||
341 | # spent 1.38ms (355µs+1.03) within Class::MOP::Class::_class_metaclass_can_be_made_compatible which was called 53 times, avg 26µs/call:
# 53 times (355µs+1.03ms) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 331, avg 26µs/call | ||||
342 | 53 | 16µs | my $self = shift; | ||
343 | 53 | 20µs | my ($super_meta) = @_; | ||
344 | |||||
345 | 53 | 285µs | 106 | 1.03ms | return $self->_can_be_made_compatible_with($super_meta->_real_ref_name); # spent 561µs making 53 calls to Class::MOP::Object::_can_be_made_compatible_with, avg 11µs/call
# spent 465µs making 53 calls to Class::MOP::Class::_real_ref_name, avg 9µs/call |
346 | } | ||||
347 | |||||
348 | # spent 6.96ms (3.77+3.19) within Class::MOP::Class::_single_metaclass_can_be_made_compatible which was called 328 times, avg 21µs/call:
# 328 times (3.77ms+3.19ms) by Class::MOP::Class::_can_fix_metaclass_incompatibility at line 335, avg 21µs/call | ||||
349 | 328 | 83µs | my $self = shift; | ||
350 | 328 | 155µs | my ($super_meta, $metaclass_type) = @_; | ||
351 | |||||
352 | 328 | 1.15ms | 328 | 325µs | my $specific_meta = $self->$metaclass_type; # spent 46µs making 53 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 872ns/call
# spent 45µs making 53 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 853ns/call
# spent 43µs making 53 calls to Class::MOP::Class::instance_metaclass, avg 808ns/call
# spent 39µs making 53 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 732ns/call
# spent 38µs making 10 calls to Moose::Meta::Class::error_class, avg 4µs/call
# spent 29µs making 43 calls to Class::MOP::Class::constructor_class, avg 681ns/call
# spent 29µs making 10 calls to Moose::Meta::Class::constructor_class, avg 3µs/call
# spent 28µs making 43 calls to Class::MOP::Class::destructor_class, avg 660ns/call
# spent 28µs making 10 calls to Moose::Meta::Class::destructor_class, avg 3µs/call |
353 | |||||
354 | 328 | 869µs | 328 | 280µs | return unless $super_meta->can($metaclass_type); # spent 280µs making 328 calls to UNIVERSAL::can, avg 854ns/call |
355 | 328 | 845µs | 328 | 232µs | my $super_specific_meta = $super_meta->$metaclass_type; # spent 37µs making 53 calls to Class::MOP::Class::instance_metaclass, avg 698ns/call
# spent 36µs making 53 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 675ns/call
# spent 33µs making 53 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 621ns/call
# spent 30µs making 53 calls to Class::MOP::Mixin::HasAttributes::attribute_metaclass, avg 570ns/call
# spent 25µs making 43 calls to Class::MOP::Class::destructor_class, avg 570ns/call
# spent 22µs making 43 calls to Class::MOP::Class::constructor_class, avg 523ns/call
# spent 17µs making 10 calls to Moose::Meta::Class::error_class, avg 2µs/call
# spent 16µs making 10 calls to Moose::Meta::Class::constructor_class, avg 2µs/call
# spent 16µs making 10 calls to Moose::Meta::Class::destructor_class, avg 2µs/call |
356 | |||||
357 | # for instance, Moose::Meta::Class has a destructor_class, but | ||||
358 | # Class::MOP::Class doesn't - this shouldn't be an error | ||||
359 | 328 | 131µs | return unless defined $super_specific_meta; | ||
360 | |||||
361 | # if metaclass is defined in superclass but not here, it's fixable | ||||
362 | # this is a really odd case | ||||
363 | 285 | 42µs | return 1 unless defined $specific_meta; | ||
364 | |||||
365 | 285 | 1.13ms | 285 | 2.36ms | return 1 if $specific_meta->_can_be_made_compatible_with($super_specific_meta); # spent 2.36ms making 285 calls to Class::MOP::Object::_can_be_made_compatible_with, avg 8µs/call |
366 | } | ||||
367 | |||||
368 | sub _fix_class_metaclass_incompatibility { | ||||
369 | my $self = shift; | ||||
370 | my ( $super_meta ) = @_; | ||||
371 | |||||
372 | if ($self->_class_metaclass_can_be_made_compatible($super_meta)) { | ||||
373 | ($self->is_pristine) | ||||
374 | || confess "Can't fix metaclass incompatibility for " | ||||
375 | . $self->name | ||||
376 | . " because it is not pristine."; | ||||
377 | |||||
378 | my $super_meta_name = $super_meta->_real_ref_name; | ||||
379 | |||||
380 | $self->_make_compatible_with($super_meta_name); | ||||
381 | } | ||||
382 | } | ||||
383 | |||||
384 | sub _fix_single_metaclass_incompatibility { | ||||
385 | my $self = shift; | ||||
386 | my ( $metaclass_type, $super_meta ) = @_; | ||||
387 | |||||
388 | if ($self->_single_metaclass_can_be_made_compatible($super_meta, $metaclass_type)) { | ||||
389 | ($self->is_pristine) | ||||
390 | || confess "Can't fix metaclass incompatibility for " | ||||
391 | . $self->name | ||||
392 | . " because it is not pristine."; | ||||
393 | |||||
394 | my $new_metaclass = $self->$metaclass_type | ||||
395 | ? $self->$metaclass_type->_get_compatible_metaclass($super_meta->$metaclass_type) | ||||
396 | : $super_meta->$metaclass_type; | ||||
397 | $self->{$metaclass_type} = $new_metaclass; | ||||
398 | } | ||||
399 | } | ||||
400 | |||||
401 | sub _restore_metaobjects_from { | ||||
402 | my $self = shift; | ||||
403 | my ($old_meta) = @_; | ||||
404 | |||||
405 | $self->_restore_metamethods_from($old_meta); | ||||
406 | $self->_restore_metaattributes_from($old_meta); | ||||
407 | } | ||||
408 | |||||
409 | sub _remove_generated_metaobjects { | ||||
410 | my $self = shift; | ||||
411 | |||||
412 | for my $attr (map { $self->get_attribute($_) } $self->get_attribute_list) { | ||||
413 | $attr->remove_accessors; | ||||
414 | } | ||||
415 | } | ||||
416 | |||||
417 | # creating classes with MOP ... | ||||
418 | |||||
419 | # spent 7.51ms (160µs+7.35) within Class::MOP::Class::create which was called 2 times, avg 3.76ms/call:
# once (101µs+6.26ms) by Moose::Meta::Class::create at line 102 of Moose/Meta/Class.pm
# once (59µs+1.09ms) by Class::MOP::Class::_immutable_metaclass at line 1354 | ||||
420 | 2 | 2µs | my $class = shift; | ||
421 | 2 | 8µs | my @args = @_; | ||
422 | |||||
423 | 2 | 5µs | unshift @args, 'package' if @args % 2 == 1; | ||
424 | 2 | 6µs | my %options = @args; | ||
425 | |||||
426 | 2 | 4µs | (ref $options{superclasses} eq 'ARRAY') | ||
427 | || confess "You must pass an ARRAY ref of superclasses" | ||||
428 | if exists $options{superclasses}; | ||||
429 | |||||
430 | 2 | 2µs | (ref $options{attributes} eq 'ARRAY') | ||
431 | || confess "You must pass an ARRAY ref of attributes" | ||||
432 | if exists $options{attributes}; | ||||
433 | |||||
434 | 2 | 2µs | (ref $options{methods} eq 'HASH') | ||
435 | || confess "You must pass a HASH ref of methods" | ||||
436 | if exists $options{methods}; | ||||
437 | |||||
438 | 2 | 4µs | my $package = delete $options{package}; | ||
439 | 2 | 2µs | my $superclasses = delete $options{superclasses}; | ||
440 | 2 | 2µs | my $attributes = delete $options{attributes}; | ||
441 | 2 | 1µs | my $methods = delete $options{methods}; | ||
442 | 2 | 3µs | my $meta_name = exists $options{meta_name} | ||
443 | ? delete $options{meta_name} | ||||
444 | : 'meta'; | ||||
445 | |||||
446 | 2 | 70µs | 2 | 2.22ms | my $meta = $class->SUPER::create($package => %options); # spent 2.22ms making 2 calls to Class::MOP::Module::create, avg 1.11ms/call |
447 | |||||
448 | 2 | 13µs | 2 | 2.36ms | $meta->_add_meta_method($meta_name) # spent 2.36ms making 2 calls to Class::MOP::Mixin::HasMethods::_add_meta_method, avg 1.18ms/call |
449 | if defined $meta_name; | ||||
450 | |||||
451 | 2 | 7µs | 2 | 2.78ms | $meta->superclasses(@{$superclasses}) # spent 2.39ms making 1 call to Moose::Meta::Class::superclasses
# spent 393µs making 1 call to Class::MOP::Class::superclasses |
452 | if defined $superclasses; | ||||
453 | # NOTE: | ||||
454 | # process attributes first, so that they can | ||||
455 | # install accessors, but locally defined methods | ||||
456 | # can then overwrite them. It is maybe a little odd, but | ||||
457 | # I think this should be the order of things. | ||||
458 | 2 | 1µs | if (defined $attributes) { | ||
459 | foreach my $attr (@{$attributes}) { | ||||
460 | $meta->add_attribute($attr); | ||||
461 | } | ||||
462 | } | ||||
463 | 2 | 1µs | if (defined $methods) { | ||
464 | foreach my $method_name (keys %{$methods}) { | ||||
465 | $meta->add_method($method_name, $methods->{$method_name}); | ||||
466 | } | ||||
467 | } | ||||
468 | 2 | 20µs | return $meta; | ||
469 | } | ||||
470 | |||||
471 | # XXX: something more intelligent here? | ||||
472 | sub _anon_package_prefix { 'Class::MOP::Class::__ANON__::SERIAL::' } | ||||
473 | |||||
474 | sub create_anon_class { shift->create_anon(@_) } | ||||
475 | sub is_anon_class { shift->is_anon(@_) } | ||||
476 | |||||
477 | sub _anon_cache_key { | ||||
478 | my $class = shift; | ||||
479 | my %options = @_; | ||||
480 | # Makes something like Super::Class|Super::Class::2 | ||||
481 | return join '=' => ( | ||||
482 | join( '|', sort @{ $options{superclasses} || [] } ), | ||||
483 | ); | ||||
484 | } | ||||
485 | |||||
486 | # Instance Construction & Cloning | ||||
487 | |||||
488 | # spent 16.8ms (581µs+16.2) within Class::MOP::Class::new_object which was called 49 times, avg 343µs/call:
# 23 times (238µs+4.39ms) by Class::MOP::Method::_new at line 56 of Class/MOP/Method.pm, avg 201µs/call
# 12 times (155µs+4.08ms) by Moose::Meta::Method::_new at line 7 of (eval 170)[Eval/Closure.pm:125], avg 353µs/call
# 9 times (121µs+3.08ms) by Class::MOP::Method::Accessor::_new at line 50 of Class/MOP/Method/Accessor.pm, avg 355µs/call
# 3 times (35µs+3.79ms) by Moose::Meta::Class::new_object at line 274 of Moose/Meta/Class.pm, avg 1.28ms/call
# once (18µs+625µs) by Class::MOP::Attribute::_new at line 64 of Class/MOP/Attribute.pm
# once (14µs+275µs) by Class::MOP::Object::_new at line 24 of Class/MOP/Object.pm | ||||
489 | 49 | 21µs | my $class = shift; | ||
490 | |||||
491 | # NOTE: | ||||
492 | # we need to protect the integrity of the | ||||
493 | # Class::MOP::Class singletons here, so we | ||||
494 | # delegate this to &construct_class_instance | ||||
495 | # which will deal with the singletons | ||||
496 | 49 | 500µs | 98 | 176µs | return $class->_construct_class_instance(@_) # spent 140µs making 49 calls to UNIVERSAL::isa, avg 3µs/call
# spent 36µs making 49 calls to Class::MOP::Package::name, avg 739ns/call |
497 | if $class->name->isa('Class::MOP::Class'); | ||||
498 | 49 | 227µs | 49 | 16.1ms | return $class->_construct_instance(@_); # spent 16.2ms making 49 calls to Class::MOP::Class::_construct_instance, avg 331µs/call, recursion: max depth 1, sum of overlapping time 154µs |
499 | } | ||||
500 | |||||
501 | # spent 23.1ms (2.59+20.5) within Class::MOP::Class::_construct_instance which was called 58 times, avg 398µs/call:
# 49 times (1.79ms+14.3ms) by Class::MOP::Class::new_object at line 498, avg 328µs/call
# 9 times (794µs+6.19ms) by Class::MOP::Class::_construct_class_instance at line 107, avg 776µs/call | ||||
502 | 58 | 29µs | my $class = shift; | ||
503 | 58 | 37µs | my $params = @_ == 1 ? $_[0] : {@_}; | ||
504 | 58 | 147µs | 58 | 2.03ms | my $meta_instance = $class->get_meta_instance(); # spent 1.47ms making 24 calls to Class::MOP::Class::get_meta_instance, avg 61µs/call
# spent 562µs making 34 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_meta_instance, avg 17µs/call |
505 | # FIXME: | ||||
506 | # the code below is almost certainly incorrect | ||||
507 | # but this is foreign inheritance, so we might | ||||
508 | # have to kludge it in the end. | ||||
509 | 58 | 19µs | my $instance; | ||
510 | 58 | 372µs | 58 | 87µs | if (my $instance_class = blessed($params->{__INSTANCE__})) { # spent 87µs making 58 calls to Scalar::Util::blessed, avg 1µs/call |
511 | ($instance_class eq $class->name) | ||||
512 | || confess "Objects passed as the __INSTANCE__ parameter must " | ||||
513 | . "already be blessed into the correct class, but " | ||||
514 | . "$params->{__INSTANCE__} is not a " . $class->name; | ||||
515 | $instance = $params->{__INSTANCE__}; | ||||
516 | } | ||||
517 | elsif (exists $params->{__INSTANCE__}) { | ||||
518 | confess "The __INSTANCE__ parameter must be a blessed reference, not " | ||||
519 | . $params->{__INSTANCE__}; | ||||
520 | } | ||||
521 | else { | ||||
522 | 58 | 181µs | 58 | 3.45ms | $instance = $meta_instance->create_instance(); # spent 3.45ms making 58 calls to Class::MOP::Instance::create_instance, avg 60µs/call |
523 | } | ||||
524 | 58 | 188µs | 58 | 2.43ms | foreach my $attr ($class->get_all_attributes()) { # spent 1.69ms making 24 calls to Class::MOP::Class::get_all_attributes, avg 70µs/call
# spent 738µs making 34 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_all_attributes, avg 22µs/call |
525 | 456 | 864µs | 456 | 12.3ms | $attr->initialize_instance_slot($meta_instance, $instance, $params); # spent 8.84ms making 448 calls to Class::MOP::Attribute::initialize_instance_slot, avg 20µs/call
# spent 3.44ms making 8 calls to Moose::Meta::Attribute::initialize_instance_slot, avg 430µs/call |
526 | } | ||||
527 | 58 | 317µs | 116 | 349µs | if (Class::MOP::metaclass_is_weak($class->name)) { # spent 307µs making 58 calls to Class::MOP::metaclass_is_weak, avg 5µs/call
# spent 42µs making 58 calls to Class::MOP::Package::name, avg 724ns/call |
528 | $meta_instance->_set_mop_slot($instance, $class); | ||||
529 | } | ||||
530 | 58 | 150µs | return $instance; | ||
531 | } | ||||
532 | |||||
533 | # spent 29.9ms (533µs+29.4) within Class::MOP::Class::_inline_new_object which was called 30 times, avg 998µs/call:
# 30 times (533µs+29.4ms) by Class::MOP::Method::Constructor::_generate_constructor_method_inline at line 101 of Class/MOP/Method/Constructor.pm, avg 998µs/call | ||||
534 | 30 | 11µs | my $self = shift; | ||
535 | |||||
536 | return ( | ||||
537 | 30 | 420µs | 180 | 29.4ms | 'my $class = shift;', # spent 26.7ms making 30 calls to Class::MOP::Class::_inline_slot_initializers, avg 889µs/call
# spent 1.83ms making 30 calls to Class::MOP::Class::_inline_generate_instance, avg 61µs/call
# spent 410µs making 30 calls to Class::MOP::Class::_inline_fallback_constructor, avg 14µs/call
# spent 372µs making 30 calls to Class::MOP::Class::_inline_preserve_weak_metaclasses, avg 12µs/call
# spent 102µs making 30 calls to Class::MOP::Class::_inline_params, avg 3µs/call
# spent 29µs making 30 calls to Class::MOP::Class::_inline_extra_init, avg 960ns/call |
538 | '$class = Scalar::Util::blessed($class) || $class;', | ||||
539 | $self->_inline_fallback_constructor('$class'), | ||||
540 | $self->_inline_params('$params', '$class'), | ||||
541 | $self->_inline_generate_instance('$instance', '$class'), | ||||
542 | $self->_inline_slot_initializers, | ||||
543 | $self->_inline_preserve_weak_metaclasses, | ||||
544 | $self->_inline_extra_init, | ||||
545 | 'return $instance', | ||||
546 | ); | ||||
547 | } | ||||
548 | |||||
549 | # spent 410µs (303+107) within Class::MOP::Class::_inline_fallback_constructor which was called 30 times, avg 14µs/call:
# 30 times (303µs+107µs) by Class::MOP::Class::_inline_new_object at line 537, avg 14µs/call | ||||
550 | 30 | 10µs | my $self = shift; | ||
551 | 30 | 19µs | my ($class) = @_; | ||
552 | return ( | ||||
553 | 30 | 268µs | 60 | 107µs | 'return ' . $self->_generate_fallback_constructor($class), # spent 90µs making 30 calls to Class::MOP::Class::_generate_fallback_constructor, avg 3µs/call
# spent 17µs making 30 calls to Class::MOP::Package::name, avg 560ns/call |
554 | 'if ' . $class . ' ne \'' . $self->name . '\';', | ||||
555 | ); | ||||
556 | } | ||||
557 | |||||
558 | # spent 90µs within Class::MOP::Class::_generate_fallback_constructor which was called 30 times, avg 3µs/call:
# 30 times (90µs+0s) by Class::MOP::Class::_inline_fallback_constructor at line 553, avg 3µs/call | ||||
559 | 30 | 14µs | my $self = shift; | ||
560 | 30 | 21µs | my ($class) = @_; | ||
561 | 30 | 98µs | return 'Class::MOP::Class->initialize(' . $class . ')->new_object(@_)', | ||
562 | } | ||||
563 | |||||
564 | # spent 102µs within Class::MOP::Class::_inline_params which was called 30 times, avg 3µs/call:
# 30 times (102µs+0s) by Class::MOP::Class::_inline_new_object at line 537, avg 3µs/call | ||||
565 | 30 | 13µs | my $self = shift; | ||
566 | 30 | 25µs | my ($params, $class) = @_; | ||
567 | return ( | ||||
568 | 30 | 89µs | 'my ' . $params . ' = @_ == 1 ? $_[0] : {@_};', | ||
569 | ); | ||||
570 | } | ||||
571 | |||||
572 | # spent 1.83ms (186µs+1.65) within Class::MOP::Class::_inline_generate_instance which was called 30 times, avg 61µs/call:
# 30 times (186µs+1.65ms) by Class::MOP::Class::_inline_new_object at line 537, avg 61µs/call | ||||
573 | 30 | 13µs | my $self = shift; | ||
574 | 30 | 25µs | my ($inst, $class) = @_; | ||
575 | return ( | ||||
576 | 30 | 129µs | 30 | 1.65ms | 'my ' . $inst . ' = ' . $self->_inline_create_instance($class) . ';', # spent 1.65ms making 30 calls to Class::MOP::Class::_inline_create_instance, avg 55µs/call |
577 | ); | ||||
578 | } | ||||
579 | |||||
580 | # spent 1.65ms (203µs+1.44) within Class::MOP::Class::_inline_create_instance which was called 30 times, avg 55µs/call:
# 30 times (203µs+1.44ms) by Class::MOP::Class::_inline_generate_instance at line 576, avg 55µs/call | ||||
581 | 30 | 9µs | my $self = shift; | ||
582 | |||||
583 | 30 | 162µs | 60 | 1.44ms | return $self->get_meta_instance->inline_create_instance(@_); # spent 1.37ms making 30 calls to Class::MOP::Class::get_meta_instance, avg 46µs/call
# spent 71µs making 30 calls to Class::MOP::Instance::inline_create_instance, avg 2µs/call |
584 | } | ||||
585 | |||||
586 | # spent 26.7ms (907µs+25.8) within Class::MOP::Class::_inline_slot_initializers which was called 30 times, avg 889µs/call:
# 30 times (907µs+25.8ms) by Class::MOP::Class::_inline_new_object at line 537, avg 889µs/call | ||||
587 | 30 | 10µs | my $self = shift; | ||
588 | |||||
589 | 30 | 11µs | my $idx = 0; | ||
590 | |||||
591 | 1029 | 3.23ms | 1772 | 21.6ms | return map { $self->_inline_slot_initializer($_, $idx++) } # spent 21.0ms making 286 calls to Class::MOP::Class::_inline_slot_initializer, avg 73µs/call
# spent 634µs making 1486 calls to Class::MOP::Mixin::AttributeCore::name, avg 426ns/call |
592 | 30 | 319µs | 60 | 4.75ms | sort { $a->name cmp $b->name } $self->get_all_attributes; # spent 2.87ms making 30 calls to Class::MOP::Class::CORE:sort, avg 96µs/call
# spent 1.88ms making 30 calls to Class::MOP::Class::get_all_attributes, avg 63µs/call |
593 | } | ||||
594 | |||||
595 | # spent 21.0ms (2.94+18.1) within Class::MOP::Class::_inline_slot_initializer which was called 286 times, avg 73µs/call:
# 286 times (2.94ms+18.1ms) by Class::MOP::Class::_inline_slot_initializers at line 591, avg 73µs/call | ||||
596 | 286 | 74µs | my $self = shift; | ||
597 | 286 | 100µs | my ($attr, $idx) = @_; | ||
598 | |||||
599 | 286 | 898µs | 297 | 913µs | if (defined(my $init_arg = $attr->init_arg)) { # spent 660µs making 11 calls to Class::MOP::Class::_inline_init_attr_from_default, avg 60µs/call
# spent 253µs making 286 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 884ns/call |
600 | 275 | 679µs | 275 | 11.6ms | my @source = ( # spent 11.6ms making 275 calls to Class::MOP::Class::_inline_init_attr_from_constructor, avg 42µs/call |
601 | 'if (exists $params->{\'' . $init_arg . '\'}) {', | ||||
602 | $self->_inline_init_attr_from_constructor($attr, $idx), | ||||
603 | '}', | ||||
604 | ); | ||||
605 | 275 | 445µs | 275 | 5.57ms | if (my @default = $self->_inline_init_attr_from_default($attr, $idx)) { # spent 5.57ms making 275 calls to Class::MOP::Class::_inline_init_attr_from_default, avg 20µs/call |
606 | push @source, ( | ||||
607 | 'else {', | ||||
608 | @default, | ||||
609 | '}', | ||||
610 | ); | ||||
611 | } | ||||
612 | 275 | 716µs | return @source; | ||
613 | } | ||||
614 | elsif (my @default = $self->_inline_init_attr_from_default($attr, $idx)) { | ||||
615 | return ( | ||||
616 | '{', | ||||
617 | @default, | ||||
618 | '}', | ||||
619 | ); | ||||
620 | } | ||||
621 | else { | ||||
622 | 1 | 2µs | return (); | ||
623 | } | ||||
624 | } | ||||
625 | |||||
626 | # spent 11.6ms (2.24+9.35) within Class::MOP::Class::_inline_init_attr_from_constructor which was called 275 times, avg 42µs/call:
# 275 times (2.24ms+9.35ms) by Class::MOP::Class::_inline_slot_initializer at line 600, avg 42µs/call | ||||
627 | 275 | 62µs | my $self = shift; | ||
628 | 275 | 86µs | my ($attr, $idx) = @_; | ||
629 | |||||
630 | 275 | 1.08ms | 550 | 8.98ms | my @initial_value = $attr->_inline_set_value( # spent 8.16ms making 273 calls to Class::MOP::Attribute::_inline_set_value, avg 30µs/call
# spent 692µs making 2 calls to Moose::Meta::Attribute::_inline_set_value, avg 346µs/call
# spent 130µs making 275 calls to Class::MOP::Mixin::AttributeCore::init_arg, avg 472ns/call |
631 | '$instance', '$params->{\'' . $attr->init_arg . '\'}', | ||||
632 | ); | ||||
633 | |||||
634 | 275 | 337µs | 275 | 366µs | push @initial_value, ( # spent 366µs making 275 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 1µs/call |
635 | '$attrs->[' . $idx . ']->set_initial_value(', | ||||
636 | '$instance,', | ||||
637 | $attr->_inline_instance_get('$instance'), | ||||
638 | ');', | ||||
639 | ) if $attr->has_initializer; | ||||
640 | |||||
641 | 275 | 577µs | return @initial_value; | ||
642 | } | ||||
643 | |||||
644 | # spent 6.23ms (1.50+4.73) within Class::MOP::Class::_inline_init_attr_from_default which was called 286 times, avg 22µs/call:
# 275 times (1.42ms+4.15ms) by Class::MOP::Class::_inline_slot_initializer at line 605, avg 20µs/call
# 11 times (87µs+573µs) by Class::MOP::Class::_inline_slot_initializer at line 599, avg 60µs/call | ||||
645 | 286 | 71µs | my $self = shift; | ||
646 | 286 | 91µs | my ($attr, $idx) = @_; | ||
647 | |||||
648 | 286 | 334µs | 286 | 2.30ms | my $default = $self->_inline_default_value($attr, $idx); # spent 2.30ms making 286 calls to Class::MOP::Class::_inline_default_value, avg 8µs/call |
649 | 286 | 374µs | return unless $default; | ||
650 | |||||
651 | 96 | 178µs | 96 | 2.32ms | my @initial_value = $attr->_inline_set_value('$instance', $default); # spent 2.32ms making 96 calls to Class::MOP::Attribute::_inline_set_value, avg 24µs/call |
652 | |||||
653 | 96 | 108µs | 96 | 105µs | push @initial_value, ( # spent 105µs making 96 calls to Class::MOP::Mixin::AttributeCore::has_initializer, avg 1µs/call |
654 | '$attrs->[' . $idx . ']->set_initial_value(', | ||||
655 | '$instance,', | ||||
656 | $attr->_inline_instance_get('$instance'), | ||||
657 | ');', | ||||
658 | ) if $attr->has_initializer; | ||||
659 | |||||
660 | 96 | 194µs | return @initial_value; | ||
661 | } | ||||
662 | |||||
663 | # spent 2.30ms (1.54+766µs) within Class::MOP::Class::_inline_default_value which was called 286 times, avg 8µs/call:
# 286 times (1.54ms+766µs) by Class::MOP::Class::_inline_init_attr_from_default at line 648, avg 8µs/call | ||||
664 | 286 | 64µs | my $self = shift; | ||
665 | 286 | 87µs | my ($attr, $index) = @_; | ||
666 | |||||
667 | 286 | 753µs | 572 | 766µs | if ($attr->has_default) { # spent 313µs making 286 calls to Class::MOP::Mixin::AttributeCore::has_default, avg 1µs/call
# spent 231µs making 96 calls to Class::MOP::Mixin::AttributeCore::is_default_a_coderef, avg 2µs/call
# spent 222µs making 190 calls to Class::MOP::Mixin::AttributeCore::has_builder, avg 1µs/call |
668 | # NOTE: | ||||
669 | # default values can either be CODE refs | ||||
670 | # in which case we need to call them. Or | ||||
671 | # they can be scalars (strings/numbers) | ||||
672 | # in which case we can just deal with them | ||||
673 | # in the code we eval. | ||||
674 | if ($attr->is_default_a_coderef) { | ||||
675 | return '$defaults->[' . $index . ']->($instance)'; | ||||
676 | } | ||||
677 | else { | ||||
678 | 30 | 66µs | return '$defaults->[' . $index . ']'; | ||
679 | } | ||||
680 | } | ||||
681 | elsif ($attr->has_builder) { | ||||
682 | return '$instance->' . $attr->builder; | ||||
683 | } | ||||
684 | else { | ||||
685 | 190 | 348µs | return; | ||
686 | } | ||||
687 | } | ||||
688 | |||||
689 | # spent 372µs (178+194) within Class::MOP::Class::_inline_preserve_weak_metaclasses which was called 30 times, avg 12µs/call:
# 30 times (178µs+194µs) by Class::MOP::Class::_inline_new_object at line 537, avg 12µs/call | ||||
690 | 30 | 11µs | my $self = shift; | ||
691 | 30 | 138µs | 60 | 194µs | if (Class::MOP::metaclass_is_weak($self->name)) { # spent 176µs making 30 calls to Class::MOP::metaclass_is_weak, avg 6µs/call
# spent 17µs making 30 calls to Class::MOP::Package::name, avg 567ns/call |
692 | return ( | ||||
693 | $self->_inline_set_mop_slot( | ||||
694 | '$instance', 'Class::MOP::class_of($class)' | ||||
695 | ) . ';' | ||||
696 | ); | ||||
697 | } | ||||
698 | else { | ||||
699 | 30 | 73µs | return (); | ||
700 | } | ||||
701 | } | ||||
702 | |||||
703 | 30 | 55µs | # spent 29µs within Class::MOP::Class::_inline_extra_init which was called 30 times, avg 960ns/call:
# 30 times (29µs+0s) by Class::MOP::Class::_inline_new_object at line 537, avg 960ns/call | ||
704 | |||||
705 | # spent 5.44ms (894µs+4.55) within Class::MOP::Class::_eval_environment which was called 30 times, avg 181µs/call:
# 30 times (894µs+4.55ms) by Class::MOP::Method::Constructor::_eval_environment at line 89 of Class/MOP/Method/Constructor.pm, avg 181µs/call | ||||
706 | 30 | 16µs | my $self = shift; | ||
707 | |||||
708 | 773 | 2.82ms | 1546 | 4.75ms | my @attrs = sort { $a->name cmp $b->name } $self->get_all_attributes; # spent 2.69ms making 30 calls to Class::MOP::Class::CORE:sort, avg 90µs/call
# spent 1.47ms making 30 calls to Class::MOP::Class::get_all_attributes, avg 49µs/call
# spent 595µs making 1486 calls to Class::MOP::Mixin::AttributeCore::name, avg 400ns/call |
709 | |||||
710 | 316 | 408µs | 286 | 391µs | my $defaults = [map { $_->default } @attrs]; # spent 391µs making 286 calls to Class::MOP::Mixin::AttributeCore::default, avg 1µs/call |
711 | |||||
712 | return { | ||||
713 | 30 | 130µs | '$defaults' => \$defaults, | ||
714 | }; | ||||
715 | } | ||||
716 | |||||
717 | |||||
718 | # spent 9.35ms (656µs+8.69) within Class::MOP::Class::get_meta_instance which was called 338 times, avg 28µs/call:
# 151 times (252µs+2.28ms) by Class::MOP::Attribute::_inline_instance_set at line 287 of Class/MOP/Attribute.pm, avg 17µs/call
# 84 times (155µs+2.02ms) by Class::MOP::Attribute::_inline_instance_get at line 310 of Class/MOP/Attribute.pm, avg 26µs/call
# 30 times (72µs+1.30ms) by Class::MOP::Class::_inline_create_instance at line 583, avg 46µs/call
# 24 times (81µs+1.39ms) by Class::MOP::Class::_construct_instance at line 504, avg 61µs/call
# 21 times (54µs+1.58ms) by Class::MOP::Class:::around at line 84 of Class/MOP/Class/Immutable/Trait.pm, avg 78µs/call
# 17 times (23µs+0s) by Class::MOP::Attribute::_inline_instance_has at line 331 of Class/MOP/Attribute.pm, avg 1µs/call
# 4 times (7µs+0s) by Class::MOP::Attribute::set_initial_value at line 261 of Class/MOP/Attribute.pm, avg 2µs/call
# 3 times (4µs+0s) by Class::MOP::Attribute::has_value at line 318 of Class/MOP/Attribute.pm, avg 1µs/call
# 2 times (2µs+0s) by Class::MOP::Attribute::get_raw_value at line 297 of Class/MOP/Attribute.pm, avg 1µs/call
# once (4µs+126µs) by Moose::Exporter::BEGIN@13 at line 672 of Class/MOP.pm
# once (1µs+0s) by Moose::Meta::Attribute::_inline_weaken_value at line 756 of Moose/Meta/Attribute.pm | ||||
719 | 338 | 93µs | my $self = shift; | ||
720 | 338 | 831µs | 56 | 8.69ms | $self->{'_meta_instance'} ||= $self->_create_meta_instance(); # spent 8.69ms making 56 calls to Class::MOP::Class::_create_meta_instance, avg 155µs/call |
721 | } | ||||
722 | |||||
723 | # spent 8.69ms (789µs+7.90) within Class::MOP::Class::_create_meta_instance which was called 56 times, avg 155µs/call:
# 56 times (789µs+7.90ms) by Class::MOP::Class::get_meta_instance at line 720, avg 155µs/call | ||||
724 | 56 | 20µs | my $self = shift; | ||
725 | |||||
726 | 56 | 492µs | 168 | 7.83ms | my $instance = $self->instance_metaclass->new( # spent 4.44ms making 56 calls to Class::MOP::Instance::new, avg 79µs/call
# spent 2.59ms making 45 calls to Class::MOP::Class::get_all_attributes, avg 57µs/call
# spent 761µs making 11 calls to Class::MOP::Class::Immutable::Class::MOP::Class::get_all_attributes, avg 69µs/call
# spent 41µs making 56 calls to Class::MOP::Class::instance_metaclass, avg 727ns/call |
727 | associated_metaclass => $self, | ||||
728 | attributes => [ $self->get_all_attributes() ], | ||||
729 | ); | ||||
730 | |||||
731 | 56 | 131µs | 56 | 72µs | $self->add_meta_instance_dependencies() # spent 72µs making 56 calls to Class::MOP::Instance::is_dependent_on_superclasses, avg 1µs/call |
732 | if $instance->is_dependent_on_superclasses(); | ||||
733 | |||||
734 | 56 | 122µs | return $instance; | ||
735 | } | ||||
736 | |||||
737 | # TODO: this is actually not being used! | ||||
738 | sub _inline_rebless_instance { | ||||
739 | my $self = shift; | ||||
740 | |||||
741 | return $self->get_meta_instance->inline_rebless_instance_structure(@_); | ||||
742 | } | ||||
743 | |||||
744 | sub _inline_get_mop_slot { | ||||
745 | my $self = shift; | ||||
746 | |||||
747 | return $self->get_meta_instance->_inline_get_mop_slot(@_); | ||||
748 | } | ||||
749 | |||||
750 | sub _inline_set_mop_slot { | ||||
751 | my $self = shift; | ||||
752 | |||||
753 | return $self->get_meta_instance->_inline_set_mop_slot(@_); | ||||
754 | } | ||||
755 | |||||
756 | sub _inline_clear_mop_slot { | ||||
757 | my $self = shift; | ||||
758 | |||||
759 | return $self->get_meta_instance->_inline_clear_mop_slot(@_); | ||||
760 | } | ||||
761 | |||||
762 | sub clone_object { | ||||
763 | my $class = shift; | ||||
764 | my $instance = shift; | ||||
765 | (blessed($instance) && $instance->isa($class->name)) | ||||
766 | || confess "You must pass an instance of the metaclass (" . (ref $class ? $class->name : $class) . "), not ($instance)"; | ||||
767 | |||||
768 | # NOTE: | ||||
769 | # we need to protect the integrity of the | ||||
770 | # Class::MOP::Class singletons here, they | ||||
771 | # should not be cloned. | ||||
772 | return $instance if $instance->isa('Class::MOP::Class'); | ||||
773 | $class->_clone_instance($instance, @_); | ||||
774 | } | ||||
775 | |||||
776 | sub _clone_instance { | ||||
777 | my ($class, $instance, %params) = @_; | ||||
778 | (blessed($instance)) | ||||
779 | || confess "You can only clone instances, ($instance) is not a blessed instance"; | ||||
780 | my $meta_instance = $class->get_meta_instance(); | ||||
781 | my $clone = $meta_instance->clone_instance($instance); | ||||
782 | foreach my $attr ($class->get_all_attributes()) { | ||||
783 | if ( defined( my $init_arg = $attr->init_arg ) ) { | ||||
784 | if (exists $params{$init_arg}) { | ||||
785 | $attr->set_value($clone, $params{$init_arg}); | ||||
786 | } | ||||
787 | } | ||||
788 | } | ||||
789 | return $clone; | ||||
790 | } | ||||
791 | |||||
792 | sub _force_rebless_instance { | ||||
793 | my ($self, $instance, %params) = @_; | ||||
794 | my $old_metaclass = Class::MOP::class_of($instance); | ||||
795 | |||||
796 | $old_metaclass->rebless_instance_away($instance, $self, %params) | ||||
797 | if $old_metaclass; | ||||
798 | |||||
799 | my $meta_instance = $self->get_meta_instance; | ||||
800 | |||||
801 | if (Class::MOP::metaclass_is_weak($old_metaclass->name)) { | ||||
802 | $meta_instance->_clear_mop_slot($instance); | ||||
803 | } | ||||
804 | |||||
805 | # rebless! | ||||
806 | # we use $_[1] here because of t/cmop/rebless_overload.t regressions | ||||
807 | # on 5.8.8 | ||||
808 | $meta_instance->rebless_instance_structure($_[1], $self); | ||||
809 | |||||
810 | $self->_fixup_attributes_after_rebless($instance, $old_metaclass, %params); | ||||
811 | |||||
812 | if (Class::MOP::metaclass_is_weak($self->name)) { | ||||
813 | $meta_instance->_set_mop_slot($instance, $self); | ||||
814 | } | ||||
815 | } | ||||
816 | |||||
817 | sub rebless_instance { | ||||
818 | my ($self, $instance, %params) = @_; | ||||
819 | my $old_metaclass = Class::MOP::class_of($instance); | ||||
820 | |||||
821 | my $old_class = $old_metaclass ? $old_metaclass->name : blessed($instance); | ||||
822 | $self->name->isa($old_class) | ||||
823 | || confess "You may rebless only into a subclass of ($old_class), of which (". $self->name .") isn't."; | ||||
824 | |||||
825 | $self->_force_rebless_instance($_[1], %params); | ||||
826 | |||||
827 | return $instance; | ||||
828 | } | ||||
829 | |||||
830 | sub rebless_instance_back { | ||||
831 | my ( $self, $instance ) = @_; | ||||
832 | my $old_metaclass = Class::MOP::class_of($instance); | ||||
833 | |||||
834 | my $old_class | ||||
835 | = $old_metaclass ? $old_metaclass->name : blessed($instance); | ||||
836 | $old_class->isa( $self->name ) | ||||
837 | || confess | ||||
838 | "You may rebless only into a superclass of ($old_class), of which (" | ||||
839 | . $self->name | ||||
840 | . ") isn't."; | ||||
841 | |||||
842 | $self->_force_rebless_instance($_[1]); | ||||
843 | |||||
844 | return $instance; | ||||
845 | } | ||||
846 | |||||
847 | sub rebless_instance_away { | ||||
848 | # this intentionally does nothing, it is just a hook | ||||
849 | } | ||||
850 | |||||
851 | sub _fixup_attributes_after_rebless { | ||||
852 | my $self = shift; | ||||
853 | my ($instance, $rebless_from, %params) = @_; | ||||
854 | my $meta_instance = $self->get_meta_instance; | ||||
855 | |||||
856 | for my $attr ( $rebless_from->get_all_attributes ) { | ||||
857 | next if $self->find_attribute_by_name( $attr->name ); | ||||
858 | $meta_instance->deinitialize_slot( $instance, $_ ) for $attr->slots; | ||||
859 | } | ||||
860 | |||||
861 | foreach my $attr ( $self->get_all_attributes ) { | ||||
862 | if ( $attr->has_value($instance) ) { | ||||
863 | if ( defined( my $init_arg = $attr->init_arg ) ) { | ||||
864 | $params{$init_arg} = $attr->get_value($instance) | ||||
865 | unless exists $params{$init_arg}; | ||||
866 | } | ||||
867 | else { | ||||
868 | $attr->set_value($instance, $attr->get_value($instance)); | ||||
869 | } | ||||
870 | } | ||||
871 | } | ||||
872 | |||||
873 | foreach my $attr ($self->get_all_attributes) { | ||||
874 | $attr->initialize_instance_slot($meta_instance, $instance, \%params); | ||||
875 | } | ||||
876 | } | ||||
877 | |||||
878 | # spent 1.65ms (460µs+1.19) within Class::MOP::Class::_attach_attribute which was called 131 times, avg 13µs/call:
# 131 times (460µs+1.19ms) by Class::MOP::Mixin::HasAttributes::add_attribute at line 27 of Class/MOP/Mixin/HasAttributes.pm, avg 13µs/call | ||||
879 | 131 | 69µs | my ($self, $attribute) = @_; | ||
880 | 131 | 443µs | 131 | 1.19ms | $attribute->attach_to_class($self); # spent 1.19ms making 131 calls to Class::MOP::Attribute::attach_to_class, avg 9µs/call |
881 | } | ||||
882 | |||||
883 | # spent 49.8ms (1.31+48.5) within Class::MOP::Class::_post_add_attribute which was called 131 times, avg 380µs/call:
# 131 times (1.31ms+48.5ms) by Class::MOP::Mixin::HasAttributes::add_attribute at line 44 of Class/MOP/Mixin/HasAttributes.pm, avg 380µs/call | ||||
884 | 131 | 64µs | my ( $self, $attribute ) = @_; | ||
885 | |||||
886 | 131 | 176µs | 131 | 856µs | $self->invalidate_meta_instances; # spent 856µs making 131 calls to Class::MOP::Class::invalidate_meta_instances, avg 7µs/call |
887 | |||||
888 | # invalidate package flag here | ||||
889 | # spent 45.6ms (746µs+44.8) within Class::MOP::Class::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP/Class.pm:892] which was called 131 times, avg 348µs/call:
# 131 times (746µs+44.8ms) by Try::Tiny::try at line 76 of Try/Tiny.pm, avg 348µs/call | ||||
890 | 131 | 214µs | local $SIG{__DIE__}; | ||
891 | 131 | 498µs | 131 | 44.8ms | $attribute->install_accessors; # spent 28.5ms making 122 calls to Class::MOP::Attribute::install_accessors, avg 234µs/call
# spent 16.3ms making 9 calls to Moose::Meta::Attribute::install_accessors, avg 1.81ms/call |
892 | } | ||||
893 | catch { | ||||
894 | $self->remove_attribute( $attribute->name ); | ||||
895 | die $_; | ||||
896 | 131 | 934µs | 262 | 47.6ms | }; # spent 47.2ms making 131 calls to Try::Tiny::try, avg 360µs/call
# spent 444µs making 131 calls to Try::Tiny::catch, avg 3µs/call |
897 | } | ||||
898 | |||||
899 | sub remove_attribute { | ||||
900 | my $self = shift; | ||||
901 | |||||
902 | my $removed_attribute = $self->SUPER::remove_attribute(@_) | ||||
903 | or return; | ||||
904 | |||||
905 | $self->invalidate_meta_instances; | ||||
906 | |||||
907 | $removed_attribute->remove_accessors; | ||||
908 | $removed_attribute->detach_from_class; | ||||
909 | |||||
910 | return$removed_attribute; | ||||
911 | } | ||||
912 | |||||
913 | # spent 2.18ms (718µs+1.46) within Class::MOP::Class::find_attribute_by_name which was called 53 times, avg 41µs/call:
# 52 times (659µs+1.38ms) by Class::MOP::Class::_immutable_metaclass at line 1331, avg 39µs/call
# once (59µs+75µs) by MooseX::Traits::Util::transform_trait at line 27 of MooseX/Traits/Util.pm | ||||
914 | 53 | 37µs | my ( $self, $attr_name ) = @_; | ||
915 | |||||
916 | 53 | 115µs | 53 | 587µs | foreach my $class ( $self->linearized_isa ) { # spent 540µs making 48 calls to Class::MOP::Class::Immutable::Class::MOP::Class::linearized_isa, avg 11µs/call
# spent 47µs making 5 calls to Class::MOP::Class::linearized_isa, avg 9µs/call |
917 | # fetch the meta-class ... | ||||
918 | 53 | 83µs | 53 | 255µs | my $meta = Class::MOP::Class->initialize($class); # spent 255µs making 53 calls to Class::MOP::Class::initialize, avg 5µs/call |
919 | 53 | 338µs | 106 | 617µs | return $meta->get_attribute($attr_name) # spent 361µs making 53 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 7µs/call
# spent 256µs making 53 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 5µs/call |
920 | if $meta->has_attribute($attr_name); | ||||
921 | } | ||||
922 | |||||
923 | return; | ||||
924 | } | ||||
925 | |||||
926 | # spent 8.92ms (4.51+4.41) within Class::MOP::Class::get_all_attributes which was called 148 times, avg 60µs/call:
# 45 times (1.39ms+1.20ms) by Class::MOP::Class::_create_meta_instance at line 726, avg 57µs/call
# 30 times (950µs+929µs) by Class::MOP::Class::_inline_slot_initializers at line 592, avg 63µs/call
# 30 times (733µs+732µs) by Class::MOP::Class::_eval_environment at line 708, avg 49µs/call
# 24 times (867µs+821µs) by Class::MOP::Class::_construct_instance at line 524, avg 70µs/call
# 15 times (450µs+615µs) by Class::MOP::Class:::around at line 78 of Class/MOP/Class/Immutable/Trait.pm, avg 71µs/call
# 3 times (58µs+68µs) by Moose::Meta::Class::_call_all_triggers at line 286 of Moose/Meta/Class.pm, avg 42µs/call
# once (66µs+43µs) by Moose::Meta::Attribute::new at line 95 of Moose/Meta/Attribute.pm | ||||
927 | 148 | 41µs | my $self = shift; | ||
928 | 1244 | 3.94ms | 1244 | 4.30ms | my %attrs = map { %{ Class::MOP::Class->initialize($_)->_attribute_map } } # spent 2.64ms making 548 calls to Class::MOP::Class::initialize, avg 5µs/call, recursion: max depth 1, sum of overlapping time 110µs
# spent 1.07ms making 133 calls to Class::MOP::Class::linearized_isa, avg 8µs/call
# spent 392µs making 548 calls to Class::MOP::Mixin::HasAttributes::_attribute_map, avg 716ns/call
# spent 303µs making 15 calls to Class::MOP::Class::Immutable::Class::MOP::Class::linearized_isa, avg 20µs/call |
929 | reverse $self->linearized_isa; | ||||
930 | 148 | 554µs | return values %attrs; | ||
931 | } | ||||
932 | |||||
933 | # Inheritance | ||||
934 | |||||
935 | sub superclasses { | ||||
936 | 130 | 61µs | my $self = shift; | ||
937 | |||||
938 | 130 | 317µs | 130 | 3.98ms | my $isa = $self->get_or_add_package_symbol('@ISA'); # spent 3.98ms making 130 calls to Class::MOP::Package::get_or_add_package_symbol, avg 31µs/call |
939 | |||||
940 | 130 | 52µs | if (@_) { | ||
941 | 11 | 14µs | my @supers = @_; | ||
942 | 11 | 171µs | @{$isa} = @supers; | ||
943 | |||||
944 | # NOTE: | ||||
945 | # on 5.8 and below, we need to call | ||||
946 | # a method to get Perl to detect | ||||
947 | # a cycle in the class hierarchy | ||||
948 | 11 | 60µs | 11 | 11µs | my $class = $self->name; # spent 11µs making 11 calls to Class::MOP::Package::name, avg 982ns/call |
949 | 11 | 123µs | 11 | 17µs | $class->isa($class); # spent 17µs making 11 calls to UNIVERSAL::isa, avg 2µs/call |
950 | |||||
951 | # NOTE: | ||||
952 | # we need to check the metaclass | ||||
953 | # compatibility here so that we can | ||||
954 | # be sure that the superclass is | ||||
955 | # not potentially creating an issues | ||||
956 | # we don't know about | ||||
957 | |||||
958 | 11 | 25µs | 11 | 7.95ms | $self->_check_metaclass_compatibility(); # spent 7.95ms making 11 calls to Class::MOP::Class::_check_metaclass_compatibility, avg 722µs/call |
959 | 11 | 28µs | 11 | 641µs | $self->_superclasses_updated(); # spent 641µs making 11 calls to Class::MOP::Class::_superclasses_updated, avg 58µs/call |
960 | } | ||||
961 | |||||
962 | 130 | 384µs | return @{$isa}; | ||
963 | } | ||||
964 | |||||
965 | # spent 641µs (173+469) within Class::MOP::Class::_superclasses_updated which was called 11 times, avg 58µs/call:
# 11 times (173µs+469µs) by Class::MOP::Class::superclasses at line 959, avg 58µs/call | ||||
966 | 11 | 5µs | my $self = shift; | ||
967 | 11 | 27µs | 11 | 26µs | $self->update_meta_instance_dependencies(); # spent 26µs making 11 calls to Class::MOP::Class::update_meta_instance_dependencies, avg 2µs/call |
968 | # keep strong references to all our parents, so they don't disappear if | ||||
969 | # they are anon classes and don't have any direct instances | ||||
970 | 11 | 18µs | 11 | 54µs | $self->_superclass_metas( # spent 54µs making 11 calls to Class::MOP::class_of, avg 5µs/call |
971 | 11 | 73µs | 22 | 34µs | map { Class::MOP::class_of($_) } $self->superclasses # spent 34µs making 11 calls to Class::MOP::Class::_superclass_metas, avg 3µs/call
# spent 13µs making 1 call to Class::MOP::Class::superclasses, recursion: max depth 1, sum of overlapping time 13µs
# spent 342µs making 10 calls to Moose::Meta::Class::superclasses, avg 34µs/call, recursion: max depth 2, sum of overlapping time 342µs |
972 | ); | ||||
973 | } | ||||
974 | |||||
975 | # spent 34µs within Class::MOP::Class::_superclass_metas which was called 11 times, avg 3µs/call:
# 11 times (34µs+0s) by Class::MOP::Class::_superclasses_updated at line 971, avg 3µs/call | ||||
976 | 11 | 4µs | my $self = shift; | ||
977 | 11 | 41µs | $self->{_superclass_metas} = [@_]; | ||
978 | } | ||||
979 | |||||
980 | sub subclasses { | ||||
981 | my $self = shift; | ||||
982 | my $super_class = $self->name; | ||||
983 | |||||
984 | return @{ $super_class->mro::get_isarev() }; | ||||
985 | } | ||||
986 | |||||
987 | sub direct_subclasses { | ||||
988 | my $self = shift; | ||||
989 | my $super_class = $self->name; | ||||
990 | |||||
991 | return grep { | ||||
992 | grep { | ||||
993 | $_ eq $super_class | ||||
994 | } Class::MOP::Class->initialize($_)->superclasses | ||||
995 | } $self->subclasses; | ||||
996 | } | ||||
997 | |||||
998 | # spent 2.32ms (1.45+868µs) within Class::MOP::Class::linearized_isa which was called 288 times, avg 8µs/call:
# 135 times (637µs+427µs) by Class::MOP::Class::_method_lookup_order at line 1037, avg 8µs/call
# 133 times (686µs+383µs) by Class::MOP::Class::get_all_attributes at line 928, avg 8µs/call
# 15 times (95µs+44µs) by Class::MOP::Class:::around at line 60 of Class/MOP/Class/Immutable/Trait.pm, avg 9µs/call
# 5 times (33µs+15µs) by Class::MOP::Class::find_attribute_by_name at line 916, avg 9µs/call | ||||
999 | 288 | 2.59ms | 576 | 868µs | return @{ mro::get_linear_isa( (shift)->name ) }; # spent 711µs making 288 calls to mro::get_linear_isa, avg 2µs/call
# spent 157µs making 288 calls to Class::MOP::Package::name, avg 546ns/call |
1000 | } | ||||
1001 | |||||
1002 | # spent 1.82ms (446µs+1.37) within Class::MOP::Class::class_precedence_list which was called 17 times, avg 107µs/call:
# 10 times (162µs+-162µs) by Class::MOP::Class::class_precedence_list at line 1028, avg 0s/call
# 4 times (149µs+787µs) by Moose::Meta::Class::excludes_role at line 257 of Moose/Meta/Class.pm, avg 234µs/call
# 3 times (135µs+749µs) by Moose::Meta::Class::does_role at line 237 of Moose/Meta/Class.pm, avg 295µs/call | ||||
1003 | 17 | 9µs | my $self = shift; | ||
1004 | 17 | 105µs | 17 | 26µs | my $name = $self->name; # spent 26µs making 17 calls to Class::MOP::Package::name, avg 2µs/call |
1005 | |||||
1006 | 17 | 86µs | 17 | 22µs | unless (Class::MOP::IS_RUNNING_ON_5_10()) { # spent 22µs making 17 calls to Class::MOP::__ANON__, avg 1µs/call |
1007 | # NOTE: | ||||
1008 | # We need to check for circular inheritance here | ||||
1009 | # if we are are not on 5.10, cause 5.8 detects it | ||||
1010 | # late. This will do nothing if all is well, and | ||||
1011 | # blow up otherwise. Yes, it's an ugly hack, better | ||||
1012 | # suggestions are welcome. | ||||
1013 | # - SL | ||||
1014 | ($name || return)->isa('This is a test for circular inheritance') | ||||
1015 | } | ||||
1016 | |||||
1017 | # if our mro is c3, we can | ||||
1018 | # just grab the linear_isa | ||||
1019 | 17 | 135µs | 17 | 74µs | if (mro::get_mro($name) eq 'c3') { # spent 74µs making 17 calls to mro::get_mro, avg 4µs/call |
1020 | return @{ mro::get_linear_isa($name) } | ||||
1021 | } | ||||
1022 | else { | ||||
1023 | # NOTE: | ||||
1024 | # we can't grab the linear_isa for dfs | ||||
1025 | # since it has all the duplicates | ||||
1026 | # already removed. | ||||
1027 | return ( | ||||
1028 | 10 | 61µs | 20 | 119µs | $name, # spent 119µs making 10 calls to Class::MOP::Class::initialize, avg 12µs/call
# spent 794µs making 10 calls to Class::MOP::Class::class_precedence_list, avg 79µs/call, recursion: max depth 2, sum of overlapping time 794µs |
1029 | map { | ||||
1030 | 17 | 136µs | 17 | 1.13ms | Class::MOP::Class->initialize($_)->class_precedence_list() # spent 1.13ms making 17 calls to Moose::Meta::Class::superclasses, avg 67µs/call |
1031 | } $self->superclasses() | ||||
1032 | ); | ||||
1033 | } | ||||
1034 | } | ||||
1035 | |||||
1036 | # spent 1.51ms (446µs+1.06) within Class::MOP::Class::_method_lookup_order which was called 135 times, avg 11µs/call:
# 75 times (250µs+602µs) by Class::MOP::Class::find_method_by_name at line 1122, avg 11µs/call
# 53 times (166µs+383µs) by Class::MOP::Class::find_next_method_by_name at line 1168, avg 10µs/call
# 7 times (30µs+79µs) by Class::MOP::Class::get_all_methods at line 1133, avg 16µs/call | ||||
1037 | 135 | 449µs | 135 | 1.06ms | return (shift->linearized_isa, 'UNIVERSAL'); # spent 1.06ms making 135 calls to Class::MOP::Class::linearized_isa, avg 8µs/call |
1038 | } | ||||
1039 | |||||
1040 | ## Methods | ||||
1041 | |||||
1042 | { | ||||
1043 | 1 | 300ns | # spent 5.55ms (417µs+5.13) within Class::MOP::Class::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP/Class.pm:1072] which was called 23 times, avg 241µs/call:
# 23 times (417µs+5.13ms) by Class::MOP::Class::add_around_method_modifier at line 1098, avg 241µs/call | ||
1044 | 23 | 12µs | my ($self, $method_name) = @_; | ||
1045 | 23 | 71µs | 23 | 15µs | my $wrapped_metaclass = $self->wrapped_method_metaclass; # spent 15µs making 23 calls to Class::MOP::Mixin::HasMethods::wrapped_method_metaclass, avg 639ns/call |
1046 | # fetch it locally | ||||
1047 | 23 | 25µs | 23 | 418µs | my $method = $self->get_method($method_name); # spent 418µs making 23 calls to Class::MOP::Mixin::HasMethods::get_method, avg 18µs/call |
1048 | # if we dont have local ... | ||||
1049 | 23 | 16µs | unless ($method) { | ||
1050 | # try to find the next method | ||||
1051 | 23 | 39µs | 23 | 1.80ms | $method = $self->find_next_method_by_name($method_name); # spent 1.80ms making 23 calls to Class::MOP::Class::find_next_method_by_name, avg 78µs/call |
1052 | # die if it does not exist | ||||
1053 | 23 | 6µs | (defined $method) | ||
1054 | || confess "The method '$method_name' was not found in the inheritance hierarchy for " . $self->name; | ||||
1055 | # and now make sure to wrap it | ||||
1056 | # even if it is already wrapped | ||||
1057 | # because we need a new sub ref | ||||
1058 | 23 | 107µs | 46 | 1.50ms | $method = $wrapped_metaclass->wrap($method, # spent 1.48ms making 23 calls to Class::MOP::Method::Wrapped::wrap, avg 64µs/call
# spent 14µs making 23 calls to Class::MOP::Package::name, avg 613ns/call |
1059 | package_name => $self->name, | ||||
1060 | name => $method_name, | ||||
1061 | ); | ||||
1062 | } | ||||
1063 | else { | ||||
1064 | # now make sure we wrap it properly | ||||
1065 | $method = $wrapped_metaclass->wrap($method, | ||||
1066 | package_name => $self->name, | ||||
1067 | name => $method_name, | ||||
1068 | ) unless $method->isa($wrapped_metaclass); | ||||
1069 | } | ||||
1070 | 23 | 38µs | 23 | 1.40ms | $self->add_method($method_name => $method); # spent 1.40ms making 23 calls to Class::MOP::Mixin::HasMethods::add_method, avg 61µs/call |
1071 | 23 | 53µs | return $method; | ||
1072 | 1 | 4µs | }; | ||
1073 | |||||
1074 | sub add_before_method_modifier { | ||||
1075 | my ($self, $method_name, $method_modifier) = @_; | ||||
1076 | (defined $method_name && length $method_name) | ||||
1077 | || confess "You must pass in a method name"; | ||||
1078 | my $method = $fetch_and_prepare_method->($self, $method_name); | ||||
1079 | $method->add_before_modifier( | ||||
1080 | subname(':before' => $method_modifier) | ||||
1081 | ); | ||||
1082 | } | ||||
1083 | |||||
1084 | sub add_after_method_modifier { | ||||
1085 | my ($self, $method_name, $method_modifier) = @_; | ||||
1086 | (defined $method_name && length $method_name) | ||||
1087 | || confess "You must pass in a method name"; | ||||
1088 | my $method = $fetch_and_prepare_method->($self, $method_name); | ||||
1089 | $method->add_after_modifier( | ||||
1090 | subname(':after' => $method_modifier) | ||||
1091 | ); | ||||
1092 | } | ||||
1093 | |||||
1094 | # spent 6.19ms (183µs+6.00) within Class::MOP::Class::add_around_method_modifier which was called 23 times, avg 269µs/call:
# 23 times (183µs+6.00ms) by Class::MOP::MiniTrait::apply at line 25 of Class/MOP/MiniTrait.pm, avg 269µs/call | ||||
1095 | 23 | 16µs | my ($self, $method_name, $method_modifier) = @_; | ||
1096 | 23 | 8µs | (defined $method_name && length $method_name) | ||
1097 | || confess "You must pass in a method name"; | ||||
1098 | 23 | 36µs | 23 | 5.55ms | my $method = $fetch_and_prepare_method->($self, $method_name); # spent 5.55ms making 23 calls to Class::MOP::Class::__ANON__[Class/MOP/Class.pm:1072], avg 241µs/call |
1099 | 23 | 163µs | 46 | 456µs | $method->add_around_modifier( # spent 397µs making 23 calls to Class::MOP::Method::Wrapped::add_around_modifier, avg 17µs/call
# spent 59µs making 23 calls to Sub::Name::subname, avg 3µs/call |
1100 | subname(':around' => $method_modifier) | ||||
1101 | ); | ||||
1102 | } | ||||
1103 | |||||
1104 | # NOTE: | ||||
1105 | # the methods above used to be named like this: | ||||
1106 | # ${pkg}::${method}:(before|after|around) | ||||
1107 | # but this proved problematic when using one modifier | ||||
1108 | # to wrap multiple methods (something which is likely | ||||
1109 | # to happen pretty regularly IMO). So instead of naming | ||||
1110 | # it like this, I have chosen to just name them purely | ||||
1111 | # with their modifier names, like so: | ||||
1112 | # :(before|after|around) | ||||
1113 | # The fact is that in a stack trace, it will be fairly | ||||
1114 | # evident from the context what method they are attached | ||||
1115 | # to, and so don't need the fully qualified name. | ||||
1116 | } | ||||
1117 | |||||
1118 | # spent 9.85ms (1.49+8.35) within Class::MOP::Class::find_method_by_name which was called 75 times, avg 131µs/call:
# 33 times (775µs+4.98ms) by Class::MOP::MiniTrait::apply at line 25 of Class/MOP/MiniTrait.pm, avg 175µs/call
# 31 times (562µs+2.63ms) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 28 of Class/MOP/Mixin/HasMethods.pm, avg 103µs/call
# 7 times (88µs+416µs) by Moose::BEGIN@47 at line 18 of Moose/Meta/Attribute/Native.pm, avg 72µs/call
# 4 times (70µs+328µs) by Moose::Meta::Role::Application::ToClass::check_required_methods at line 69 of Moose/Meta/Role/Application/ToClass.pm, avg 99µs/call | ||||
1119 | 75 | 52µs | my ($self, $method_name) = @_; | ||
1120 | 75 | 37µs | (defined $method_name && length $method_name) | ||
1121 | || confess "You must define a method name to find"; | ||||
1122 | 75 | 153µs | 75 | 852µs | foreach my $class ($self->_method_lookup_order) { # spent 852µs making 75 calls to Class::MOP::Class::_method_lookup_order, avg 11µs/call |
1123 | 232 | 597µs | 464 | 7.50ms | my $method = Class::MOP::Class->initialize($class)->get_method($method_name); # spent 6.32ms making 232 calls to Class::MOP::Mixin::HasMethods::get_method, avg 27µs/call
# spent 1.18ms making 232 calls to Class::MOP::Class::initialize, avg 5µs/call |
1124 | 232 | 193µs | return $method if defined $method; | ||
1125 | } | ||||
1126 | 46 | 98µs | return; | ||
1127 | } | ||||
1128 | |||||
1129 | # spent 2.77ms (303µs+2.47) within Class::MOP::Class::get_all_methods which was called 7 times, avg 396µs/call:
# 7 times (303µs+2.47ms) by Class::MOP::MiniTrait::apply at line 22 of Class/MOP/MiniTrait.pm, avg 396µs/call | ||||
1130 | 7 | 4µs | my $self = shift; | ||
1131 | |||||
1132 | 7 | 2µs | my %methods; | ||
1133 | 7 | 22µs | 7 | 109µs | for my $class ( reverse $self->_method_lookup_order ) { # spent 109µs making 7 calls to Class::MOP::Class::_method_lookup_order, avg 16µs/call |
1134 | 14 | 21µs | 14 | 68µs | my $meta = Class::MOP::Class->initialize($class); # spent 68µs making 14 calls to Class::MOP::Class::initialize, avg 5µs/call |
1135 | |||||
1136 | 28 | 236µs | 75 | 2.29ms | $methods{ $_->name } = $_ for $meta->_get_local_methods; # spent 2.25ms making 14 calls to Class::MOP::Mixin::HasMethods::_get_local_methods, avg 161µs/call
# spent 36µs making 61 calls to Class::MOP::Method::name, avg 587ns/call |
1137 | } | ||||
1138 | |||||
1139 | 7 | 35µs | return values %methods; | ||
1140 | } | ||||
1141 | |||||
1142 | sub get_all_method_names { | ||||
1143 | my $self = shift; | ||||
1144 | map { $_->name } $self->get_all_methods; | ||||
1145 | } | ||||
1146 | |||||
1147 | sub find_all_methods_by_name { | ||||
1148 | my ($self, $method_name) = @_; | ||||
1149 | (defined $method_name && length $method_name) | ||||
1150 | || confess "You must define a method name to find"; | ||||
1151 | my @methods; | ||||
1152 | foreach my $class ($self->_method_lookup_order) { | ||||
1153 | # fetch the meta-class ... | ||||
1154 | my $meta = Class::MOP::Class->initialize($class); | ||||
1155 | push @methods => { | ||||
1156 | name => $method_name, | ||||
1157 | class => $class, | ||||
1158 | code => $meta->get_method($method_name) | ||||
1159 | } if $meta->has_method($method_name); | ||||
1160 | } | ||||
1161 | return @methods; | ||||
1162 | } | ||||
1163 | |||||
1164 | # spent 4.51ms (921µs+3.59) within Class::MOP::Class::find_next_method_by_name which was called 53 times, avg 85µs/call:
# 30 times (509µs+2.20ms) by Class::MOP::Method::Inlined::can_be_inlined at line 40 of Class/MOP/Method/Inlined.pm, avg 90µs/call
# 23 times (413µs+1.39ms) by Class::MOP::Class::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP/Class.pm:1072] at line 1051, avg 78µs/call | ||||
1165 | 53 | 40µs | my ($self, $method_name) = @_; | ||
1166 | 53 | 30µs | (defined $method_name && length $method_name) | ||
1167 | || confess "You must define a method name to find"; | ||||
1168 | 53 | 205µs | 53 | 549µs | my @cpl = ($self->_method_lookup_order); # spent 549µs making 53 calls to Class::MOP::Class::_method_lookup_order, avg 10µs/call |
1169 | 53 | 17µs | shift @cpl; # discard ourselves | ||
1170 | 53 | 42µs | foreach my $class (@cpl) { | ||
1171 | 90 | 265µs | 180 | 3.04ms | my $method = Class::MOP::Class->initialize($class)->get_method($method_name); # spent 2.58ms making 90 calls to Class::MOP::Mixin::HasMethods::get_method, avg 29µs/call
# spent 463µs making 90 calls to Class::MOP::Class::initialize, avg 5µs/call |
1172 | 90 | 183µs | return $method if defined $method; | ||
1173 | } | ||||
1174 | 2 | 4µs | return; | ||
1175 | } | ||||
1176 | |||||
1177 | # spent 26µs within Class::MOP::Class::update_meta_instance_dependencies which was called 11 times, avg 2µs/call:
# 11 times (26µs+0s) by Class::MOP::Class::_superclasses_updated at line 967, avg 2µs/call | ||||
1178 | 11 | 4µs | my $self = shift; | ||
1179 | |||||
1180 | 11 | 40µs | if ( $self->{meta_instance_dependencies} ) { | ||
1181 | return $self->add_meta_instance_dependencies; | ||||
1182 | } | ||||
1183 | } | ||||
1184 | |||||
1185 | sub add_meta_instance_dependencies { | ||||
1186 | my $self = shift; | ||||
1187 | |||||
1188 | $self->remove_meta_instance_dependencies; | ||||
1189 | |||||
1190 | my @attrs = $self->get_all_attributes(); | ||||
1191 | |||||
1192 | my %seen; | ||||
1193 | my @classes = grep { not $seen{ $_->name }++ } | ||||
1194 | map { $_->associated_class } @attrs; | ||||
1195 | |||||
1196 | foreach my $class (@classes) { | ||||
1197 | $class->add_dependent_meta_instance($self); | ||||
1198 | } | ||||
1199 | |||||
1200 | $self->{meta_instance_dependencies} = \@classes; | ||||
1201 | } | ||||
1202 | |||||
1203 | sub remove_meta_instance_dependencies { | ||||
1204 | my $self = shift; | ||||
1205 | |||||
1206 | if ( my $classes = delete $self->{meta_instance_dependencies} ) { | ||||
1207 | foreach my $class (@$classes) { | ||||
1208 | $class->remove_dependent_meta_instance($self); | ||||
1209 | } | ||||
1210 | |||||
1211 | return $classes; | ||||
1212 | } | ||||
1213 | |||||
1214 | return; | ||||
1215 | |||||
1216 | } | ||||
1217 | |||||
1218 | sub add_dependent_meta_instance { | ||||
1219 | my ( $self, $metaclass ) = @_; | ||||
1220 | push @{ $self->{dependent_meta_instances} }, $metaclass; | ||||
1221 | } | ||||
1222 | |||||
1223 | sub remove_dependent_meta_instance { | ||||
1224 | my ( $self, $metaclass ) = @_; | ||||
1225 | my $name = $metaclass->name; | ||||
1226 | @$_ = grep { $_->name ne $name } @$_ | ||||
1227 | for $self->{dependent_meta_instances}; | ||||
1228 | } | ||||
1229 | |||||
1230 | # spent 856µs (666+191) within Class::MOP::Class::invalidate_meta_instances which was called 131 times, avg 7µs/call:
# 131 times (666µs+191µs) by Class::MOP::Class::_post_add_attribute at line 886, avg 7µs/call | ||||
1231 | 131 | 40µs | my $self = shift; | ||
1232 | $_->invalidate_meta_instance() | ||||
1233 | 262 | 601µs | 131 | 191µs | for $self, @{ $self->{dependent_meta_instances} }; # spent 191µs making 131 calls to Class::MOP::Class::invalidate_meta_instance, avg 1µs/call |
1234 | } | ||||
1235 | |||||
1236 | # spent 191µs within Class::MOP::Class::invalidate_meta_instance which was called 131 times, avg 1µs/call:
# 131 times (191µs+0s) by Class::MOP::Class::invalidate_meta_instances at line 1233, avg 1µs/call | ||||
1237 | 131 | 37µs | my $self = shift; | ||
1238 | 131 | 274µs | undef $self->{_meta_instance}; | ||
1239 | } | ||||
1240 | |||||
1241 | # check if we can reinitialize | ||||
1242 | sub is_pristine { | ||||
1243 | my $self = shift; | ||||
1244 | |||||
1245 | # if any local attr is defined | ||||
1246 | return if $self->get_attribute_list; | ||||
1247 | |||||
1248 | # or any non-declared methods | ||||
1249 | for my $method ( map { $self->get_method($_) } $self->get_method_list ) { | ||||
1250 | return if $method->isa("Class::MOP::Method::Generated"); | ||||
1251 | # FIXME do we need to enforce this too? return unless $method->isa( $self->method_metaclass ); | ||||
1252 | } | ||||
1253 | |||||
1254 | return 1; | ||||
1255 | } | ||||
1256 | |||||
1257 | ## Class closing | ||||
1258 | |||||
1259 | 85 | 157µs | # spent 80µs within Class::MOP::Class::is_mutable which was called 85 times, avg 935ns/call:
# 52 times (56µs+0s) by Class::MOP::Class::make_immutable at line 1283, avg 1µs/call
# 21 times (13µs+0s) by Tapper::MCP::Scheduler::Controller::BEGIN@6 at line 228 of Moose.pm, avg 638ns/call
# 9 times (7µs+0s) by Moose::Meta::Attribute::BEGIN@24 at line 707 of Moose/Util/TypeConstraints.pm, avg 778ns/call
# 3 times (3µs+0s) by Tapper::MCP::Scheduler::Controller::BEGIN@6 at line 264 of Moose.pm, avg 967ns/call | ||
1260 | 51 | 103µs | # spent 56µs within Class::MOP::Class::is_immutable which was called 51 times, avg 1µs/call:
# 51 times (56µs+0s) by Class::MOP::Class::_real_ref_name at line 128, avg 1µs/call | ||
1261 | |||||
1262 | sub immutable_options { %{ $_[0]{__immutable}{options} || {} } } | ||||
1263 | |||||
1264 | # spent 875µs (709+166) within Class::MOP::Class::_immutable_options which was called 52 times, avg 17µs/call:
# 52 times (709µs+166µs) by Class::MOP::Class::make_immutable at line 1287, avg 17µs/call | ||||
1265 | 52 | 55µs | my ( $self, @args ) = @_; | ||
1266 | |||||
1267 | return ( | ||||
1268 | 52 | 848µs | 208 | 166µs | inline_accessors => 1, # spent 45µs making 52 calls to Class::MOP::Class::immutable_trait, avg 867ns/call
# spent 43µs making 52 calls to Class::MOP::Class::constructor_name, avg 821ns/call
# spent 40µs making 52 calls to Class::MOP::Class::destructor_class, avg 762ns/call
# spent 39µs making 52 calls to Class::MOP::Class::constructor_class, avg 742ns/call |
1269 | inline_constructor => 1, | ||||
1270 | inline_destructor => 0, | ||||
1271 | debug => 0, | ||||
1272 | immutable_trait => $self->immutable_trait, | ||||
1273 | constructor_name => $self->constructor_name, | ||||
1274 | constructor_class => $self->constructor_class, | ||||
1275 | destructor_class => $self->destructor_class, | ||||
1276 | @args, | ||||
1277 | ); | ||||
1278 | } | ||||
1279 | |||||
1280 | # spent 130ms (1.00+129) within Class::MOP::Class::make_immutable which was called 52 times, avg 2.49ms/call:
# 21 times (498µs+69.4ms) by Tapper::MCP::Scheduler::Controller::BEGIN@6 at line 233 of Moose.pm, avg 3.33ms/call
# 14 times (173µs+13.9ms) by Moose::Exporter::BEGIN@13 at line 687 of Class/MOP.pm, avg 1.01ms/call
# 9 times (216µs+37.4ms) by Moose::Meta::Attribute::BEGIN@24 at line 712 of Moose/Util/TypeConstraints.pm, avg 4.18ms/call
# 4 times (45µs+336µs) by Moose::Exporter::BEGIN@13 at line 713 of Class/MOP.pm, avg 95µs/call
# 3 times (49µs+7.51ms) by Tapper::MCP::Scheduler::Controller::BEGIN@6 at line 269 of Moose.pm, avg 2.52ms/call
# once (22µs+-22µs) by Class::MOP::Class::_immutable_metaclass at line 1361 | ||||
1281 | 52 | 81µs | my ( $self, @args ) = @_; | ||
1282 | |||||
1283 | 52 | 89µs | 52 | 56µs | return $self unless $self->is_mutable; # spent 56µs making 52 calls to Class::MOP::Class::is_mutable, avg 1µs/call |
1284 | |||||
1285 | 52 | 105µs | my ($file, $line) = (caller)[1..2]; | ||
1286 | |||||
1287 | 52 | 343µs | 104 | 111ms | $self->_initialize_immutable( # spent 111ms making 52 calls to Class::MOP::Class::_initialize_immutable, avg 2.13ms/call
# spent 875µs making 52 calls to Class::MOP::Class::_immutable_options, avg 17µs/call |
1288 | file => $file, | ||||
1289 | line => $line, | ||||
1290 | $self->_immutable_options(@args), | ||||
1291 | ); | ||||
1292 | 52 | 130µs | 52 | 17.1ms | $self->_rebless_as_immutable(@args); # spent 17.2ms making 52 calls to Class::MOP::Class::_rebless_as_immutable, avg 330µs/call, recursion: max depth 1, sum of overlapping time 106µs |
1293 | |||||
1294 | 52 | 166µs | return $self; | ||
1295 | } | ||||
1296 | |||||
1297 | sub make_mutable { | ||||
1298 | my $self = shift; | ||||
1299 | |||||
1300 | if ( $self->is_immutable ) { | ||||
1301 | my @args = $self->immutable_options; | ||||
1302 | $self->_rebless_as_mutable(); | ||||
1303 | $self->_remove_inlined_code(@args); | ||||
1304 | delete $self->{__immutable}; | ||||
1305 | return $self; | ||||
1306 | } | ||||
1307 | else { | ||||
1308 | return; | ||||
1309 | } | ||||
1310 | } | ||||
1311 | |||||
1312 | # spent 17.1ms (486µs+16.6) within Class::MOP::Class::_rebless_as_immutable which was called 52 times, avg 328µs/call:
# 52 times (486µs+16.6ms) by Class::MOP::Class::make_immutable at line 1292, avg 328µs/call | ||||
1313 | 52 | 86µs | my ( $self, @args ) = @_; | ||
1314 | |||||
1315 | 52 | 63µs | $self->{__immutable}{original_class} = ref $self; | ||
1316 | |||||
1317 | 52 | 301µs | 52 | 16.6ms | bless $self => $self->_immutable_metaclass(@args); # spent 16.7ms making 52 calls to Class::MOP::Class::_immutable_metaclass, avg 321µs/call, recursion: max depth 1, sum of overlapping time 85µs |
1318 | } | ||||
1319 | |||||
1320 | # spent 16.6ms (1.02+15.6) within Class::MOP::Class::_immutable_metaclass which was called 52 times, avg 319µs/call:
# 52 times (1.02ms+15.6ms) by Class::MOP::Class::_rebless_as_immutable at line 1317, avg 319µs/call | ||||
1321 | 52 | 85µs | my ( $self, %args ) = @_; | ||
1322 | |||||
1323 | 52 | 26µs | if ( my $class = $args{immutable_metaclass} ) { | ||
1324 | return $class; | ||||
1325 | } | ||||
1326 | |||||
1327 | 52 | 229µs | 52 | 44µs | my $trait = $args{immutable_trait} = $self->immutable_trait # spent 44µs making 52 calls to Class::MOP::Class::immutable_trait, avg 850ns/call |
1328 | || confess "no immutable trait specified for $self"; | ||||
1329 | |||||
1330 | 52 | 115µs | 52 | 626µs | my $meta = $self->meta; # spent 626µs making 52 calls to Class::MOP::Object::meta, avg 12µs/call |
1331 | 52 | 127µs | 52 | 2.04ms | my $meta_attr = $meta->find_attribute_by_name("immutable_trait"); # spent 2.04ms making 52 calls to Class::MOP::Class::find_attribute_by_name, avg 39µs/call |
1332 | |||||
1333 | 52 | 12µs | my $class_name; | ||
1334 | |||||
1335 | 52 | 148µs | 52 | 133µs | if ( $meta_attr and $trait eq $meta_attr->default ) { # spent 133µs making 52 calls to Class::MOP::Mixin::AttributeCore::default, avg 3µs/call |
1336 | # if the trait is the same as the default we try and pick a | ||||
1337 | # predictable name for the immutable metaclass | ||||
1338 | $class_name = 'Class::MOP::Class::Immutable::' . ref($self); | ||||
1339 | } | ||||
1340 | else { | ||||
1341 | $class_name = join '::', 'Class::MOP::Class::Immutable::CustomTrait', | ||||
1342 | $trait, 'ForMetaClass', ref($self); | ||||
1343 | } | ||||
1344 | |||||
1345 | 52 | 512µs | 52 | 244µs | return $class_name # spent 244µs making 52 calls to Class::Load::XS::is_class_loaded, avg 5µs/call |
1346 | if is_class_loaded($class_name); | ||||
1347 | |||||
1348 | # If the metaclass is a subclass of CMOP::Class which has had | ||||
1349 | # metaclass roles applied (via Moose), then we want to make sure | ||||
1350 | # that we preserve that anonymous class (see Fey::ORM for an | ||||
1351 | # example of where this matters). | ||||
1352 | 1 | 3µs | 1 | 7µs | my $meta_name = $meta->_real_ref_name; # spent 7µs making 1 call to Class::MOP::Class::_real_ref_name |
1353 | |||||
1354 | 1 | 4µs | 1 | 1.15ms | my $immutable_meta = $meta_name->create( # spent 1.15ms making 1 call to Class::MOP::Class::create |
1355 | $class_name, | ||||
1356 | superclasses => [ ref $self ], | ||||
1357 | ); | ||||
1358 | |||||
1359 | 1 | 6µs | 1 | 11.3ms | Class::MOP::MiniTrait::apply( $immutable_meta, $trait ); # spent 11.3ms making 1 call to Class::MOP::MiniTrait::apply |
1360 | |||||
1361 | 1 | 5µs | 1 | 0s | $immutable_meta->make_immutable( # spent 166µs making 1 call to Class::MOP::Class::make_immutable, recursion: max depth 1, sum of overlapping time 166µs |
1362 | inline_constructor => 0, | ||||
1363 | inline_accessors => 0, | ||||
1364 | ); | ||||
1365 | |||||
1366 | 1 | 4µs | return $class_name; | ||
1367 | } | ||||
1368 | |||||
1369 | sub _remove_inlined_code { | ||||
1370 | my $self = shift; | ||||
1371 | |||||
1372 | $self->remove_method( $_->name ) for $self->_inlined_methods; | ||||
1373 | |||||
1374 | delete $self->{__immutable}{inlined_methods}; | ||||
1375 | } | ||||
1376 | |||||
1377 | sub _inlined_methods { @{ $_[0]{__immutable}{inlined_methods} || [] } } | ||||
1378 | |||||
1379 | # spent 138µs within Class::MOP::Class::_add_inlined_method which was called 30 times, avg 5µs/call:
# 30 times (138µs+0s) by Class::MOP::Class::_inline_constructor at line 1453, avg 5µs/call | ||||
1380 | 30 | 17µs | my ( $self, $method ) = @_; | ||
1381 | |||||
1382 | 30 | 144µs | push @{ $self->{__immutable}{inlined_methods} ||= [] }, $method; | ||
1383 | } | ||||
1384 | |||||
1385 | # spent 111ms (616µs+110) within Class::MOP::Class::_initialize_immutable which was called 52 times, avg 2.13ms/call:
# 52 times (616µs+110ms) by Class::MOP::Class::make_immutable at line 1287, avg 2.13ms/call | ||||
1386 | 52 | 246µs | my ( $self, %args ) = @_; | ||
1387 | |||||
1388 | 52 | 84µs | $self->{__immutable}{options} = \%args; | ||
1389 | 52 | 271µs | 52 | 110ms | $self->_install_inlined_code(%args); # spent 110ms making 52 calls to Class::MOP::Class::_install_inlined_code, avg 2.12ms/call |
1390 | } | ||||
1391 | |||||
1392 | # spent 110ms (658µs+109) within Class::MOP::Class::_install_inlined_code which was called 52 times, avg 2.12ms/call:
# 52 times (658µs+109ms) by Class::MOP::Class::_initialize_immutable at line 1389, avg 2.12ms/call | ||||
1393 | 52 | 125µs | my ( $self, %args ) = @_; | ||
1394 | |||||
1395 | # FIXME | ||||
1396 | 52 | 147µs | 33 | 46.8ms | $self->_inline_accessors(%args) if $args{inline_accessors}; # spent 46.8ms making 33 calls to Class::MOP::Class::_inline_accessors, avg 1.42ms/call |
1397 | 52 | 154µs | 30 | 62.5ms | $self->_inline_constructor(%args) if $args{inline_constructor}; # spent 62.5ms making 30 calls to Class::MOP::Class::_inline_constructor, avg 2.08ms/call |
1398 | 52 | 222µs | $self->_inline_destructor(%args) if $args{inline_destructor}; | ||
1399 | } | ||||
1400 | |||||
1401 | sub _rebless_as_mutable { | ||||
1402 | my $self = shift; | ||||
1403 | |||||
1404 | bless $self, $self->_get_mutable_metaclass_name; | ||||
1405 | |||||
1406 | return $self; | ||||
1407 | } | ||||
1408 | |||||
1409 | # spent 46.8ms (574µs+46.2) within Class::MOP::Class::_inline_accessors which was called 33 times, avg 1.42ms/call:
# 33 times (574µs+46.2ms) by Class::MOP::Class::_install_inlined_code at line 1396, avg 1.42ms/call | ||||
1410 | 33 | 14µs | my $self = shift; | ||
1411 | |||||
1412 | 33 | 198µs | 33 | 203µs | foreach my $attr_name ( $self->get_attribute_list ) { # spent 203µs making 33 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 6µs/call |
1413 | 76 | 280µs | 152 | 46.0ms | $self->get_attribute($attr_name)->install_accessors(1); # spent 44.0ms making 75 calls to Class::MOP::Attribute::install_accessors, avg 587µs/call
# spent 1.63ms making 1 call to Moose::Meta::Attribute::install_accessors
# spent 376µs making 76 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 5µs/call |
1414 | } | ||||
1415 | } | ||||
1416 | |||||
1417 | # spent 62.5ms (1.06+61.5) within Class::MOP::Class::_inline_constructor which was called 30 times, avg 2.08ms/call:
# 30 times (1.06ms+61.5ms) by Class::MOP::Class::_install_inlined_code at line 1397, avg 2.08ms/call | ||||
1418 | 30 | 115µs | my ( $self, %args ) = @_; | ||
1419 | |||||
1420 | 30 | 19µs | my $name = $args{constructor_name}; | ||
1421 | # A class may not even have a constructor, and that's okay. | ||||
1422 | 30 | 10µs | return unless defined $name; | ||
1423 | |||||
1424 | 30 | 87µs | 30 | 988µs | if ( $self->has_method($name) && !$args{replace_constructor} ) { # spent 988µs making 30 calls to Class::MOP::Mixin::HasMethods::has_method, avg 33µs/call |
1425 | my $class = $self->name; | ||||
1426 | warn "Not inlining a constructor for $class since it defines" | ||||
1427 | . " its own constructor.\n" | ||||
1428 | . "If you are certain you don't need to inline your" | ||||
1429 | . " constructor, specify inline_constructor => 0 in your" | ||||
1430 | . " call to $class->meta->make_immutable\n"; | ||||
1431 | return; | ||||
1432 | } | ||||
1433 | |||||
1434 | 30 | 20µs | my $constructor_class = $args{constructor_class}; | ||
1435 | |||||
1436 | 30 | 98µs | 30 | 1.31ms | load_class($constructor_class); # spent 1.31ms making 30 calls to Class::Load::load_class, avg 44µs/call |
1437 | |||||
1438 | 30 | 343µs | 90 | 52.9ms | my $constructor = $constructor_class->new( # spent 52.9ms making 30 calls to Class::MOP::Method::Constructor::new, avg 1.76ms/call
# spent 33µs making 60 calls to Class::MOP::Package::name, avg 558ns/call |
1439 | options => \%args, | ||||
1440 | metaclass => $self, | ||||
1441 | is_inline => 1, | ||||
1442 | package_name => $self->name, | ||||
1443 | name => $name, | ||||
1444 | definition_context => { | ||||
1445 | description => "constructor " . $self->name . "::" . $name, | ||||
1446 | file => $args{file}, | ||||
1447 | line => $args{line}, | ||||
1448 | }, | ||||
1449 | ); | ||||
1450 | |||||
1451 | 30 | 197µs | 30 | 3.56ms | if ( $args{replace_constructor} or $constructor->can_be_inlined ) { # spent 3.56ms making 30 calls to Class::MOP::Method::Inlined::can_be_inlined, avg 119µs/call |
1452 | 30 | 72µs | 30 | 2.58ms | $self->add_method( $name => $constructor ); # spent 2.58ms making 30 calls to Class::MOP::Mixin::HasMethods::add_method, avg 86µs/call |
1453 | 30 | 69µs | 30 | 138µs | $self->_add_inlined_method($constructor); # spent 138µs making 30 calls to Class::MOP::Class::_add_inlined_method, avg 5µs/call |
1454 | } | ||||
1455 | } | ||||
1456 | |||||
1457 | sub _inline_destructor { | ||||
1458 | my ( $self, %args ) = @_; | ||||
1459 | |||||
1460 | ( exists $args{destructor_class} && defined $args{destructor_class} ) | ||||
1461 | || confess "The 'inline_destructor' option is present, but " | ||||
1462 | . "no destructor class was specified"; | ||||
1463 | |||||
1464 | if ( $self->has_method('DESTROY') && ! $args{replace_destructor} ) { | ||||
1465 | my $class = $self->name; | ||||
1466 | warn "Not inlining a destructor for $class since it defines" | ||||
1467 | . " its own destructor.\n"; | ||||
1468 | return; | ||||
1469 | } | ||||
1470 | |||||
1471 | my $destructor_class = $args{destructor_class}; | ||||
1472 | |||||
1473 | load_class($destructor_class); | ||||
1474 | |||||
1475 | return unless $destructor_class->is_needed($self); | ||||
1476 | |||||
1477 | my $destructor = $destructor_class->new( | ||||
1478 | options => \%args, | ||||
1479 | metaclass => $self, | ||||
1480 | package_name => $self->name, | ||||
1481 | name => 'DESTROY', | ||||
1482 | definition_context => { | ||||
1483 | description => "destructor " . $self->name . "::DESTROY", | ||||
1484 | file => $args{file}, | ||||
1485 | line => $args{line}, | ||||
1486 | }, | ||||
1487 | ); | ||||
1488 | |||||
1489 | if ( $args{replace_destructor} or $destructor->can_be_inlined ) { | ||||
1490 | $self->add_method( 'DESTROY' => $destructor ); | ||||
1491 | $self->_add_inlined_method($destructor); | ||||
1492 | } | ||||
1493 | } | ||||
1494 | |||||
1495 | 1 | 8µs | 1; | ||
1496 | |||||
1497 | # ABSTRACT: Class Meta Object | ||||
1498 | |||||
- - | |||||
1501 | =pod | ||||
1502 | |||||
1503 | =head1 NAME | ||||
1504 | |||||
1505 | Class::MOP::Class - Class Meta Object | ||||
1506 | |||||
1507 | =head1 VERSION | ||||
1508 | |||||
1509 | version 2.0602 | ||||
1510 | |||||
1511 | =head1 SYNOPSIS | ||||
1512 | |||||
1513 | # assuming that class Foo | ||||
1514 | # has been defined, you can | ||||
1515 | |||||
1516 | # use this for introspection ... | ||||
1517 | |||||
1518 | # add a method to Foo ... | ||||
1519 | Foo->meta->add_method( 'bar' => sub {...} ) | ||||
1520 | |||||
1521 | # get a list of all the classes searched | ||||
1522 | # the method dispatcher in the correct order | ||||
1523 | Foo->meta->class_precedence_list() | ||||
1524 | |||||
1525 | # remove a method from Foo | ||||
1526 | Foo->meta->remove_method('bar'); | ||||
1527 | |||||
1528 | # or use this to actually create classes ... | ||||
1529 | |||||
1530 | Class::MOP::Class->create( | ||||
1531 | 'Bar' => ( | ||||
1532 | version => '0.01', | ||||
1533 | superclasses => ['Foo'], | ||||
1534 | attributes => [ | ||||
1535 | Class::MOP::Attribute->new('$bar'), | ||||
1536 | Class::MOP::Attribute->new('$baz'), | ||||
1537 | ], | ||||
1538 | methods => { | ||||
1539 | calculate_bar => sub {...}, | ||||
1540 | construct_baz => sub {...} | ||||
1541 | } | ||||
1542 | ) | ||||
1543 | ); | ||||
1544 | |||||
1545 | =head1 DESCRIPTION | ||||
1546 | |||||
1547 | The Class Protocol is the largest and most complex part of the | ||||
1548 | Class::MOP meta-object protocol. It controls the introspection and | ||||
1549 | manipulation of Perl 5 classes, and it can create them as well. The | ||||
1550 | best way to understand what this module can do is to read the | ||||
1551 | documentation for each of its methods. | ||||
1552 | |||||
1553 | =head1 INHERITANCE | ||||
1554 | |||||
1555 | C<Class::MOP::Class> is a subclass of L<Class::MOP::Module>. | ||||
1556 | |||||
1557 | =head1 METHODS | ||||
1558 | |||||
1559 | =head2 Class construction | ||||
1560 | |||||
1561 | These methods all create new C<Class::MOP::Class> objects. These | ||||
1562 | objects can represent existing classes or they can be used to create | ||||
1563 | new classes from scratch. | ||||
1564 | |||||
1565 | The metaclass object for a given class is a singleton. If you attempt | ||||
1566 | to create a metaclass for the same class twice, you will just get the | ||||
1567 | existing object. | ||||
1568 | |||||
1569 | =over 4 | ||||
1570 | |||||
1571 | =item B<< Class::MOP::Class->create($package_name, %options) >> | ||||
1572 | |||||
1573 | This method creates a new C<Class::MOP::Class> object with the given | ||||
1574 | package name. It accepts a number of options: | ||||
1575 | |||||
1576 | =over 8 | ||||
1577 | |||||
1578 | =item * version | ||||
1579 | |||||
1580 | An optional version number for the newly created package. | ||||
1581 | |||||
1582 | =item * authority | ||||
1583 | |||||
1584 | An optional authority for the newly created package. | ||||
1585 | |||||
1586 | =item * superclasses | ||||
1587 | |||||
1588 | An optional array reference of superclass names. | ||||
1589 | |||||
1590 | =item * methods | ||||
1591 | |||||
1592 | An optional hash reference of methods for the class. The keys of the | ||||
1593 | hash reference are method names and values are subroutine references. | ||||
1594 | |||||
1595 | =item * attributes | ||||
1596 | |||||
1597 | An optional array reference of L<Class::MOP::Attribute> objects. | ||||
1598 | |||||
1599 | =item * meta_name | ||||
1600 | |||||
1601 | Specifies the name to install the C<meta> method for this class under. | ||||
1602 | If it is not passed, C<meta> is assumed, and if C<undef> is explicitly | ||||
1603 | given, no meta method will be installed. | ||||
1604 | |||||
1605 | =item * weaken | ||||
1606 | |||||
1607 | If true, the metaclass that is stored in the global cache will be a | ||||
1608 | weak reference. | ||||
1609 | |||||
1610 | Classes created in this way are destroyed once the metaclass they are | ||||
1611 | attached to goes out of scope, and will be removed from Perl's internal | ||||
1612 | symbol table. | ||||
1613 | |||||
1614 | All instances of a class with a weakened metaclass keep a special | ||||
1615 | reference to the metaclass object, which prevents the metaclass from | ||||
1616 | going out of scope while any instances exist. | ||||
1617 | |||||
1618 | This only works if the instance is based on a hash reference, however. | ||||
1619 | |||||
1620 | =back | ||||
1621 | |||||
1622 | =item B<< Class::MOP::Class->create_anon_class(%options) >> | ||||
1623 | |||||
1624 | This method works just like C<< Class::MOP::Class->create >> but it | ||||
1625 | creates an "anonymous" class. In fact, the class does have a name, but | ||||
1626 | that name is a unique name generated internally by this module. | ||||
1627 | |||||
1628 | It accepts the same C<superclasses>, C<methods>, and C<attributes> | ||||
1629 | parameters that C<create> accepts. | ||||
1630 | |||||
1631 | Anonymous classes default to C<< weaken => 1 >>, although this can be | ||||
1632 | overridden. | ||||
1633 | |||||
1634 | =item B<< Class::MOP::Class->initialize($package_name, %options) >> | ||||
1635 | |||||
1636 | This method will initialize a C<Class::MOP::Class> object for the | ||||
1637 | named package. Unlike C<create>, this method I<will not> create a new | ||||
1638 | class. | ||||
1639 | |||||
1640 | The purpose of this method is to retrieve a C<Class::MOP::Class> | ||||
1641 | object for introspecting an existing class. | ||||
1642 | |||||
1643 | If an existing C<Class::MOP::Class> object exists for the named | ||||
1644 | package, it will be returned, and any options provided will be | ||||
1645 | ignored! | ||||
1646 | |||||
1647 | If the object does not yet exist, it will be created. | ||||
1648 | |||||
1649 | The valid options that can be passed to this method are | ||||
1650 | C<attribute_metaclass>, C<method_metaclass>, | ||||
1651 | C<wrapped_method_metaclass>, and C<instance_metaclass>. These are all | ||||
1652 | optional, and default to the appropriate class in the C<Class::MOP> | ||||
1653 | distribution. | ||||
1654 | |||||
1655 | =back | ||||
1656 | |||||
1657 | =head2 Object instance construction and cloning | ||||
1658 | |||||
1659 | These methods are all related to creating and/or cloning object | ||||
1660 | instances. | ||||
1661 | |||||
1662 | =over 4 | ||||
1663 | |||||
1664 | =item B<< $metaclass->clone_object($instance, %params) >> | ||||
1665 | |||||
1666 | This method clones an existing object instance. Any parameters you | ||||
1667 | provide are will override existing attribute values in the object. | ||||
1668 | |||||
1669 | This is a convenience method for cloning an object instance, then | ||||
1670 | blessing it into the appropriate package. | ||||
1671 | |||||
1672 | You could implement a clone method in your class, using this method: | ||||
1673 | |||||
1674 | sub clone { | ||||
1675 | my ($self, %params) = @_; | ||||
1676 | $self->meta->clone_object($self, %params); | ||||
1677 | } | ||||
1678 | |||||
1679 | =item B<< $metaclass->rebless_instance($instance, %params) >> | ||||
1680 | |||||
1681 | This method changes the class of C<$instance> to the metaclass's class. | ||||
1682 | |||||
1683 | You can only rebless an instance into a subclass of its current | ||||
1684 | class. If you pass any additional parameters, these will be treated | ||||
1685 | like constructor parameters and used to initialize the object's | ||||
1686 | attributes. Any existing attributes that are already set will be | ||||
1687 | overwritten. | ||||
1688 | |||||
1689 | Before reblessing the instance, this method will call | ||||
1690 | C<rebless_instance_away> on the instance's current metaclass. This method | ||||
1691 | will be passed the instance, the new metaclass, and any parameters | ||||
1692 | specified to C<rebless_instance>. By default, C<rebless_instance_away> | ||||
1693 | does nothing; it is merely a hook. | ||||
1694 | |||||
1695 | =item B<< $metaclass->rebless_instance_back($instance) >> | ||||
1696 | |||||
1697 | Does the same thing as C<rebless_instance>, except that you can only | ||||
1698 | rebless an instance into one of its superclasses. Any attributes that | ||||
1699 | do not exist in the superclass will be deinitialized. | ||||
1700 | |||||
1701 | This is a much more dangerous operation than C<rebless_instance>, | ||||
1702 | especially when multiple inheritance is involved, so use this carefully! | ||||
1703 | |||||
1704 | =item B<< $metaclass->new_object(%params) >> | ||||
1705 | |||||
1706 | This method is used to create a new object of the metaclass's | ||||
1707 | class. Any parameters you provide are used to initialize the | ||||
1708 | instance's attributes. A special C<__INSTANCE__> key can be passed to | ||||
1709 | provide an already generated instance, rather than having Class::MOP | ||||
1710 | generate it for you. This is mostly useful for using Class::MOP with | ||||
1711 | foreign classes which generate instances using their own constructors. | ||||
1712 | |||||
1713 | =item B<< $metaclass->instance_metaclass >> | ||||
1714 | |||||
1715 | Returns the class name of the instance metaclass. See | ||||
1716 | L<Class::MOP::Instance> for more information on the instance | ||||
1717 | metaclass. | ||||
1718 | |||||
1719 | =item B<< $metaclass->get_meta_instance >> | ||||
1720 | |||||
1721 | Returns an instance of the C<instance_metaclass> to be used in the | ||||
1722 | construction of a new instance of the class. | ||||
1723 | |||||
1724 | =back | ||||
1725 | |||||
1726 | =head2 Informational predicates | ||||
1727 | |||||
1728 | These are a few predicate methods for asking information about the | ||||
1729 | class itself. | ||||
1730 | |||||
1731 | =over 4 | ||||
1732 | |||||
1733 | =item B<< $metaclass->is_anon_class >> | ||||
1734 | |||||
1735 | This returns true if the class was created by calling C<< | ||||
1736 | Class::MOP::Class->create_anon_class >>. | ||||
1737 | |||||
1738 | =item B<< $metaclass->is_mutable >> | ||||
1739 | |||||
1740 | This returns true if the class is still mutable. | ||||
1741 | |||||
1742 | =item B<< $metaclass->is_immutable >> | ||||
1743 | |||||
1744 | This returns true if the class has been made immutable. | ||||
1745 | |||||
1746 | =item B<< $metaclass->is_pristine >> | ||||
1747 | |||||
1748 | A class is I<not> pristine if it has non-inherited attributes or if it | ||||
1749 | has any generated methods. | ||||
1750 | |||||
1751 | =back | ||||
1752 | |||||
1753 | =head2 Inheritance Relationships | ||||
1754 | |||||
1755 | =over 4 | ||||
1756 | |||||
1757 | =item B<< $metaclass->superclasses(@superclasses) >> | ||||
1758 | |||||
1759 | This is a read-write accessor which represents the superclass | ||||
1760 | relationships of the metaclass's class. | ||||
1761 | |||||
1762 | This is basically sugar around getting and setting C<@ISA>. | ||||
1763 | |||||
1764 | =item B<< $metaclass->class_precedence_list >> | ||||
1765 | |||||
1766 | This returns a list of all of the class's ancestor classes. The | ||||
1767 | classes are returned in method dispatch order. | ||||
1768 | |||||
1769 | =item B<< $metaclass->linearized_isa >> | ||||
1770 | |||||
1771 | This returns a list based on C<class_precedence_list> but with all | ||||
1772 | duplicates removed. | ||||
1773 | |||||
1774 | =item B<< $metaclass->subclasses >> | ||||
1775 | |||||
1776 | This returns a list of all subclasses for this class, even indirect | ||||
1777 | subclasses. | ||||
1778 | |||||
1779 | =item B<< $metaclass->direct_subclasses >> | ||||
1780 | |||||
1781 | This returns a list of immediate subclasses for this class, which does not | ||||
1782 | include indirect subclasses. | ||||
1783 | |||||
1784 | =back | ||||
1785 | |||||
1786 | =head2 Method introspection and creation | ||||
1787 | |||||
1788 | These methods allow you to introspect a class's methods, as well as | ||||
1789 | add, remove, or change methods. | ||||
1790 | |||||
1791 | Determining what is truly a method in a Perl 5 class requires some | ||||
1792 | heuristics (aka guessing). | ||||
1793 | |||||
1794 | Methods defined outside the package with a fully qualified name (C<sub | ||||
1795 | Package::name { ... }>) will be included. Similarly, methods named | ||||
1796 | with a fully qualified name using L<Sub::Name> are also included. | ||||
1797 | |||||
1798 | However, we attempt to ignore imported functions. | ||||
1799 | |||||
1800 | Ultimately, we are using heuristics to determine what truly is a | ||||
1801 | method in a class, and these heuristics may get the wrong answer in | ||||
1802 | some edge cases. However, for most "normal" cases the heuristics work | ||||
1803 | correctly. | ||||
1804 | |||||
1805 | =over 4 | ||||
1806 | |||||
1807 | =item B<< $metaclass->get_method($method_name) >> | ||||
1808 | |||||
1809 | This will return a L<Class::MOP::Method> for the specified | ||||
1810 | C<$method_name>. If the class does not have the specified method, it | ||||
1811 | returns C<undef> | ||||
1812 | |||||
1813 | =item B<< $metaclass->has_method($method_name) >> | ||||
1814 | |||||
1815 | Returns a boolean indicating whether or not the class defines the | ||||
1816 | named method. It does not include methods inherited from parent | ||||
1817 | classes. | ||||
1818 | |||||
1819 | =item B<< $metaclass->get_method_list >> | ||||
1820 | |||||
1821 | This will return a list of method I<names> for all methods defined in | ||||
1822 | this class. | ||||
1823 | |||||
1824 | =item B<< $metaclass->add_method($method_name, $method) >> | ||||
1825 | |||||
1826 | This method takes a method name and a subroutine reference, and adds | ||||
1827 | the method to the class. | ||||
1828 | |||||
1829 | The subroutine reference can be a L<Class::MOP::Method>, and you are | ||||
1830 | strongly encouraged to pass a meta method object instead of a code | ||||
1831 | reference. If you do so, that object gets stored as part of the | ||||
1832 | class's method map directly. If not, the meta information will have to | ||||
1833 | be recreated later, and may be incorrect. | ||||
1834 | |||||
1835 | If you provide a method object, this method will clone that object if | ||||
1836 | the object's package name does not match the class name. This lets us | ||||
1837 | track the original source of any methods added from other classes | ||||
1838 | (notably Moose roles). | ||||
1839 | |||||
1840 | =item B<< $metaclass->remove_method($method_name) >> | ||||
1841 | |||||
1842 | Remove the named method from the class. This method returns the | ||||
1843 | L<Class::MOP::Method> object for the method. | ||||
1844 | |||||
1845 | =item B<< $metaclass->method_metaclass >> | ||||
1846 | |||||
1847 | Returns the class name of the method metaclass, see | ||||
1848 | L<Class::MOP::Method> for more information on the method metaclass. | ||||
1849 | |||||
1850 | =item B<< $metaclass->wrapped_method_metaclass >> | ||||
1851 | |||||
1852 | Returns the class name of the wrapped method metaclass, see | ||||
1853 | L<Class::MOP::Method::Wrapped> for more information on the wrapped | ||||
1854 | method metaclass. | ||||
1855 | |||||
1856 | =item B<< $metaclass->get_all_methods >> | ||||
1857 | |||||
1858 | This will traverse the inheritance hierarchy and return a list of all | ||||
1859 | the L<Class::MOP::Method> objects for this class and its parents. | ||||
1860 | |||||
1861 | =item B<< $metaclass->find_method_by_name($method_name) >> | ||||
1862 | |||||
1863 | This will return a L<Class::MOP::Method> for the specified | ||||
1864 | C<$method_name>. If the class does not have the specified method, it | ||||
1865 | returns C<undef> | ||||
1866 | |||||
1867 | Unlike C<get_method>, this method I<will> look for the named method in | ||||
1868 | superclasses. | ||||
1869 | |||||
1870 | =item B<< $metaclass->get_all_method_names >> | ||||
1871 | |||||
1872 | This will return a list of method I<names> for all of this class's | ||||
1873 | methods, including inherited methods. | ||||
1874 | |||||
1875 | =item B<< $metaclass->find_all_methods_by_name($method_name) >> | ||||
1876 | |||||
1877 | This method looks for the named method in the class and all of its | ||||
1878 | parents. It returns every matching method it finds in the inheritance | ||||
1879 | tree, so it returns a list of methods. | ||||
1880 | |||||
1881 | Each method is returned as a hash reference with three keys. The keys | ||||
1882 | are C<name>, C<class>, and C<code>. The C<code> key has a | ||||
1883 | L<Class::MOP::Method> object as its value. | ||||
1884 | |||||
1885 | The list of methods is distinct. | ||||
1886 | |||||
1887 | =item B<< $metaclass->find_next_method_by_name($method_name) >> | ||||
1888 | |||||
1889 | This method returns the first method in any superclass matching the | ||||
1890 | given name. It is effectively the method that C<SUPER::$method_name> | ||||
1891 | would dispatch to. | ||||
1892 | |||||
1893 | =back | ||||
1894 | |||||
1895 | =head2 Attribute introspection and creation | ||||
1896 | |||||
1897 | Because Perl 5 does not have a core concept of attributes in classes, | ||||
1898 | we can only return information about attributes which have been added | ||||
1899 | via this class's methods. We cannot discover information about | ||||
1900 | attributes which are defined in terms of "regular" Perl 5 methods. | ||||
1901 | |||||
1902 | =over 4 | ||||
1903 | |||||
1904 | =item B<< $metaclass->get_attribute($attribute_name) >> | ||||
1905 | |||||
1906 | This will return a L<Class::MOP::Attribute> for the specified | ||||
1907 | C<$attribute_name>. If the class does not have the specified | ||||
1908 | attribute, it returns C<undef>. | ||||
1909 | |||||
1910 | NOTE that get_attribute does not search superclasses, for that you | ||||
1911 | need to use C<find_attribute_by_name>. | ||||
1912 | |||||
1913 | =item B<< $metaclass->has_attribute($attribute_name) >> | ||||
1914 | |||||
1915 | Returns a boolean indicating whether or not the class defines the | ||||
1916 | named attribute. It does not include attributes inherited from parent | ||||
1917 | classes. | ||||
1918 | |||||
1919 | =item B<< $metaclass->get_attribute_list >> | ||||
1920 | |||||
1921 | This will return a list of attributes I<names> for all attributes | ||||
1922 | defined in this class. Note that this operates on the current class | ||||
1923 | only, it does not traverse the inheritance hierarchy. | ||||
1924 | |||||
1925 | =item B<< $metaclass->get_all_attributes >> | ||||
1926 | |||||
1927 | This will traverse the inheritance hierarchy and return a list of all | ||||
1928 | the L<Class::MOP::Attribute> objects for this class and its parents. | ||||
1929 | |||||
1930 | =item B<< $metaclass->find_attribute_by_name($attribute_name) >> | ||||
1931 | |||||
1932 | This will return a L<Class::MOP::Attribute> for the specified | ||||
1933 | C<$attribute_name>. If the class does not have the specified | ||||
1934 | attribute, it returns C<undef>. | ||||
1935 | |||||
1936 | Unlike C<get_attribute>, this attribute I<will> look for the named | ||||
1937 | attribute in superclasses. | ||||
1938 | |||||
1939 | =item B<< $metaclass->add_attribute(...) >> | ||||
1940 | |||||
1941 | This method accepts either an existing L<Class::MOP::Attribute> | ||||
1942 | object or parameters suitable for passing to that class's C<new> | ||||
1943 | method. | ||||
1944 | |||||
1945 | The attribute provided will be added to the class. | ||||
1946 | |||||
1947 | Any accessor methods defined by the attribute will be added to the | ||||
1948 | class when the attribute is added. | ||||
1949 | |||||
1950 | If an attribute of the same name already exists, the old attribute | ||||
1951 | will be removed first. | ||||
1952 | |||||
1953 | =item B<< $metaclass->remove_attribute($attribute_name) >> | ||||
1954 | |||||
1955 | This will remove the named attribute from the class, and | ||||
1956 | L<Class::MOP::Attribute> object. | ||||
1957 | |||||
1958 | Removing an attribute also removes any accessor methods defined by the | ||||
1959 | attribute. | ||||
1960 | |||||
1961 | However, note that removing an attribute will only affect I<future> | ||||
1962 | object instances created for this class, not existing instances. | ||||
1963 | |||||
1964 | =item B<< $metaclass->attribute_metaclass >> | ||||
1965 | |||||
1966 | Returns the class name of the attribute metaclass for this class. By | ||||
1967 | default, this is L<Class::MOP::Attribute>. | ||||
1968 | |||||
1969 | =back | ||||
1970 | |||||
1971 | =head2 Overload introspection and creation | ||||
1972 | |||||
1973 | These methods provide an API to the core L<overload> functionality. | ||||
1974 | |||||
1975 | =over 4 | ||||
1976 | |||||
1977 | =item B<< $metaclass->is_overloaded >> | ||||
1978 | |||||
1979 | Returns true if overloading is enabled for this class. Corresponds to | ||||
1980 | L<overload::Overloaded|overload/Public Functions>. | ||||
1981 | |||||
1982 | =item B<< $metaclass->get_overloaded_operator($op) >> | ||||
1983 | |||||
1984 | Returns the L<Class::MOP::Method::Overload> object corresponding to the | ||||
1985 | operator named C<$op>, if one exists for this class. | ||||
1986 | |||||
1987 | =item B<< $metaclass->has_overloaded_operator($op) >> | ||||
1988 | |||||
1989 | Returns whether or not the operator C<$op> is overloaded for this class. | ||||
1990 | |||||
1991 | =item B<< $metaclass->get_overload_list >> | ||||
1992 | |||||
1993 | Returns a list of operator names which have been overloaded (see | ||||
1994 | L<overload/Overloadable Operations> for the list of valid operator names). | ||||
1995 | |||||
1996 | =item B<< $metaclass->get_all_overloaded_operators >> | ||||
1997 | |||||
1998 | Returns a list of L<Class::MOP::Method::Overload> objects corresponding to the | ||||
1999 | operators that have been overloaded. | ||||
2000 | |||||
2001 | =item B<< $metaclass->add_overloaded_operator($op, $impl) >> | ||||
2002 | |||||
2003 | Overloads the operator C<$op> for this class, with the implementation C<$impl>. | ||||
2004 | C<$impl> can be either a coderef or a method name. Corresponds to | ||||
2005 | C<< use overload $op => $impl; >> | ||||
2006 | |||||
2007 | =item B<< $metaclass->remove_overloaded_operator($op) >> | ||||
2008 | |||||
2009 | Remove overloading for operator C<$op>. Corresponds to C<< no overload $op; >> | ||||
2010 | |||||
2011 | =back | ||||
2012 | |||||
2013 | =head2 Class Immutability | ||||
2014 | |||||
2015 | Making a class immutable "freezes" the class definition. You can no | ||||
2016 | longer call methods which alter the class, such as adding or removing | ||||
2017 | methods or attributes. | ||||
2018 | |||||
2019 | Making a class immutable lets us optimize the class by inlining some | ||||
2020 | methods, and also allows us to optimize some methods on the metaclass | ||||
2021 | object itself. | ||||
2022 | |||||
2023 | After immutabilization, the metaclass object will cache most informational | ||||
2024 | methods that returns information about methods or attributes. Methods which | ||||
2025 | would alter the class, such as C<add_attribute> and C<add_method>, will | ||||
2026 | throw an error on an immutable metaclass object. | ||||
2027 | |||||
2028 | The immutabilization system in L<Moose> takes much greater advantage | ||||
2029 | of the inlining features than Class::MOP itself does. | ||||
2030 | |||||
2031 | =over 4 | ||||
2032 | |||||
2033 | =item B<< $metaclass->make_immutable(%options) >> | ||||
2034 | |||||
2035 | This method will create an immutable transformer and use it to make | ||||
2036 | the class and its metaclass object immutable, and returns true | ||||
2037 | (you should not rely on the details of this value apart from its truth). | ||||
2038 | |||||
2039 | This method accepts the following options: | ||||
2040 | |||||
2041 | =over 8 | ||||
2042 | |||||
2043 | =item * inline_accessors | ||||
2044 | |||||
2045 | =item * inline_constructor | ||||
2046 | |||||
2047 | =item * inline_destructor | ||||
2048 | |||||
2049 | These are all booleans indicating whether the specified method(s) | ||||
2050 | should be inlined. | ||||
2051 | |||||
2052 | By default, accessors and the constructor are inlined, but not the | ||||
2053 | destructor. | ||||
2054 | |||||
2055 | =item * immutable_trait | ||||
2056 | |||||
2057 | The name of a class which will be used as a parent class for the | ||||
2058 | metaclass object being made immutable. This "trait" implements the | ||||
2059 | post-immutability functionality of the metaclass (but not the | ||||
2060 | transformation itself). | ||||
2061 | |||||
2062 | This defaults to L<Class::MOP::Class::Immutable::Trait>. | ||||
2063 | |||||
2064 | =item * constructor_name | ||||
2065 | |||||
2066 | This is the constructor method name. This defaults to "new". | ||||
2067 | |||||
2068 | =item * constructor_class | ||||
2069 | |||||
2070 | The name of the method metaclass for constructors. It will be used to | ||||
2071 | generate the inlined constructor. This defaults to | ||||
2072 | "Class::MOP::Method::Constructor". | ||||
2073 | |||||
2074 | =item * replace_constructor | ||||
2075 | |||||
2076 | This is a boolean indicating whether an existing constructor should be | ||||
2077 | replaced when inlining a constructor. This defaults to false. | ||||
2078 | |||||
2079 | =item * destructor_class | ||||
2080 | |||||
2081 | The name of the method metaclass for destructors. It will be used to | ||||
2082 | generate the inlined destructor. This defaults to | ||||
2083 | "Class::MOP::Method::Denstructor". | ||||
2084 | |||||
2085 | =item * replace_destructor | ||||
2086 | |||||
2087 | This is a boolean indicating whether an existing destructor should be | ||||
2088 | replaced when inlining a destructor. This defaults to false. | ||||
2089 | |||||
2090 | =back | ||||
2091 | |||||
2092 | =item B<< $metaclass->immutable_options >> | ||||
2093 | |||||
2094 | Returns a hash of the options used when making the class immutable, including | ||||
2095 | both defaults and anything supplied by the user in the call to C<< | ||||
2096 | $metaclass->make_immutable >>. This is useful if you need to temporarily make | ||||
2097 | a class mutable and then restore immutability as it was before. | ||||
2098 | |||||
2099 | =item B<< $metaclass->make_mutable >> | ||||
2100 | |||||
2101 | Calling this method reverse the immutabilization transformation. | ||||
2102 | |||||
2103 | =back | ||||
2104 | |||||
2105 | =head2 Method Modifiers | ||||
2106 | |||||
2107 | Method modifiers are hooks which allow a method to be wrapped with | ||||
2108 | I<before>, I<after> and I<around> method modifiers. Every time a | ||||
2109 | method is called, its modifiers are also called. | ||||
2110 | |||||
2111 | A class can modify its own methods, as well as methods defined in | ||||
2112 | parent classes. | ||||
2113 | |||||
2114 | =head3 How method modifiers work? | ||||
2115 | |||||
2116 | Method modifiers work by wrapping the original method and then | ||||
2117 | replacing it in the class's symbol table. The wrappers will handle | ||||
2118 | calling all the modifiers in the appropriate order and preserving the | ||||
2119 | calling context for the original method. | ||||
2120 | |||||
2121 | The return values of C<before> and C<after> modifiers are | ||||
2122 | ignored. This is because their purpose is B<not> to filter the input | ||||
2123 | and output of the primary method (this is done with an I<around> | ||||
2124 | modifier). | ||||
2125 | |||||
2126 | This may seem like an odd restriction to some, but doing this allows | ||||
2127 | for simple code to be added at the beginning or end of a method call | ||||
2128 | without altering the function of the wrapped method or placing any | ||||
2129 | extra responsibility on the code of the modifier. | ||||
2130 | |||||
2131 | Of course if you have more complex needs, you can use the C<around> | ||||
2132 | modifier which allows you to change both the parameters passed to the | ||||
2133 | wrapped method, as well as its return value. | ||||
2134 | |||||
2135 | Before and around modifiers are called in last-defined-first-called | ||||
2136 | order, while after modifiers are called in first-defined-first-called | ||||
2137 | order. So the call tree might looks something like this: | ||||
2138 | |||||
2139 | before 2 | ||||
2140 | before 1 | ||||
2141 | around 2 | ||||
2142 | around 1 | ||||
2143 | primary | ||||
2144 | around 1 | ||||
2145 | around 2 | ||||
2146 | after 1 | ||||
2147 | after 2 | ||||
2148 | |||||
2149 | =head3 What is the performance impact? | ||||
2150 | |||||
2151 | Of course there is a performance cost associated with method | ||||
2152 | modifiers, but we have made every effort to make that cost directly | ||||
2153 | proportional to the number of modifier features you use. | ||||
2154 | |||||
2155 | The wrapping method does its best to B<only> do as much work as it | ||||
2156 | absolutely needs to. In order to do this we have moved some of the | ||||
2157 | performance costs to set-up time, where they are easier to amortize. | ||||
2158 | |||||
2159 | All this said, our benchmarks have indicated the following: | ||||
2160 | |||||
2161 | simple wrapper with no modifiers 100% slower | ||||
2162 | simple wrapper with simple before modifier 400% slower | ||||
2163 | simple wrapper with simple after modifier 450% slower | ||||
2164 | simple wrapper with simple around modifier 500-550% slower | ||||
2165 | simple wrapper with all 3 modifiers 1100% slower | ||||
2166 | |||||
2167 | These numbers may seem daunting, but you must remember, every feature | ||||
2168 | comes with some cost. To put things in perspective, just doing a | ||||
2169 | simple C<AUTOLOAD> which does nothing but extract the name of the | ||||
2170 | method called and return it costs about 400% over a normal method | ||||
2171 | call. | ||||
2172 | |||||
2173 | =over 4 | ||||
2174 | |||||
2175 | =item B<< $metaclass->add_before_method_modifier($method_name, $code) >> | ||||
2176 | |||||
2177 | This wraps the specified method with the supplied subroutine | ||||
2178 | reference. The modifier will be called as a method itself, and will | ||||
2179 | receive the same arguments as are passed to the method. | ||||
2180 | |||||
2181 | When the modifier exits, the wrapped method will be called. | ||||
2182 | |||||
2183 | The return value of the modifier will be ignored. | ||||
2184 | |||||
2185 | =item B<< $metaclass->add_after_method_modifier($method_name, $code) >> | ||||
2186 | |||||
2187 | This wraps the specified method with the supplied subroutine | ||||
2188 | reference. The modifier will be called as a method itself, and will | ||||
2189 | receive the same arguments as are passed to the method. | ||||
2190 | |||||
2191 | When the wrapped methods exits, the modifier will be called. | ||||
2192 | |||||
2193 | The return value of the modifier will be ignored. | ||||
2194 | |||||
2195 | =item B<< $metaclass->add_around_method_modifier($method_name, $code) >> | ||||
2196 | |||||
2197 | This wraps the specified method with the supplied subroutine | ||||
2198 | reference. | ||||
2199 | |||||
2200 | The first argument passed to the modifier will be a subroutine | ||||
2201 | reference to the wrapped method. The second argument is the object, | ||||
2202 | and after that come any arguments passed when the method is called. | ||||
2203 | |||||
2204 | The around modifier can choose to call the original method, as well as | ||||
2205 | what arguments to pass if it does so. | ||||
2206 | |||||
2207 | The return value of the modifier is what will be seen by the caller. | ||||
2208 | |||||
2209 | =back | ||||
2210 | |||||
2211 | =head2 Introspection | ||||
2212 | |||||
2213 | =over 4 | ||||
2214 | |||||
2215 | =item B<< Class::MOP::Class->meta >> | ||||
2216 | |||||
2217 | This will return a L<Class::MOP::Class> instance for this class. | ||||
2218 | |||||
2219 | It should also be noted that L<Class::MOP> will actually bootstrap | ||||
2220 | this module by installing a number of attribute meta-objects into its | ||||
2221 | metaclass. | ||||
2222 | |||||
2223 | =back | ||||
2224 | |||||
2225 | =head1 AUTHOR | ||||
2226 | |||||
2227 | Moose is maintained by the Moose Cabal, along with the help of many contributors. See L<Moose/CABAL> and L<Moose/CONTRIBUTORS> for details. | ||||
2228 | |||||
2229 | =head1 COPYRIGHT AND LICENSE | ||||
2230 | |||||
2231 | This software is copyright (c) 2012 by Infinity Interactive, Inc.. | ||||
2232 | |||||
2233 | This is free software; you can redistribute it and/or modify it under | ||||
2234 | the same terms as the Perl 5 programming language system itself. | ||||
2235 | |||||
2236 | =cut | ||||
2237 | |||||
2238 | |||||
2239 | __END__ | ||||
sub Class::MOP::Class::CORE:sort; # opcode |