| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/flow_graph_optimizer.h" | 5 #include "vm/flow_graph_optimizer.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/cha.h" | 8 #include "vm/cha.h" |
| 9 #include "vm/dart_entry.h" |
| 9 #include "vm/flow_graph_builder.h" | 10 #include "vm/flow_graph_builder.h" |
| 10 #include "vm/flow_graph_compiler.h" | 11 #include "vm/flow_graph_compiler.h" |
| 11 #include "vm/hash_map.h" | 12 #include "vm/hash_map.h" |
| 12 #include "vm/il_printer.h" | 13 #include "vm/il_printer.h" |
| 13 #include "vm/intermediate_language.h" | 14 #include "vm/intermediate_language.h" |
| 14 #include "vm/object_store.h" | 15 #include "vm/object_store.h" |
| 15 #include "vm/parser.h" | 16 #include "vm/parser.h" |
| 16 #include "vm/resolver.h" | 17 #include "vm/resolver.h" |
| 17 #include "vm/scopes.h" | 18 #include "vm/scopes.h" |
| 18 #include "vm/stack_frame.h" | 19 #include "vm/stack_frame.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 ASSERT(call->ic_data()->num_args_tested() <= call->ArgumentCount()); | 96 ASSERT(call->ic_data()->num_args_tested() <= call->ArgumentCount()); |
| 96 for (intptr_t i = 0; i < call->ic_data()->num_args_tested(); i++) { | 97 for (intptr_t i = 0; i < call->ic_data()->num_args_tested(); i++) { |
| 97 intptr_t cid = call->PushArgumentAt(i)->value()->Type()->ToCid(); | 98 intptr_t cid = call->PushArgumentAt(i)->value()->Type()->ToCid(); |
| 98 class_ids.Add(cid); | 99 class_ids.Add(cid); |
| 99 } | 100 } |
| 100 // TODO(srdjan): Test for number of arguments checked greater than 1. | 101 // TODO(srdjan): Test for number of arguments checked greater than 1. |
| 101 if (class_ids.length() != 1) { | 102 if (class_ids.length() != 1) { |
| 102 return false; | 103 return false; |
| 103 } | 104 } |
| 104 if (class_ids[0] != kDynamicCid) { | 105 if (class_ids[0] != kDynamicCid) { |
| 105 const intptr_t num_named_arguments = call->argument_names().IsNull() ? | 106 ArgumentsDescriptor args_desc( |
| 106 0 : call->argument_names().Length(); | 107 Array::Handle(ArgumentsDescriptor::New(call->ArgumentCount(), |
| 108 call->argument_names()))); |
| 107 const Class& receiver_class = Class::Handle( | 109 const Class& receiver_class = Class::Handle( |
| 108 Isolate::Current()->class_table()->At(class_ids[0])); | 110 Isolate::Current()->class_table()->At(class_ids[0])); |
| 109 Function& function = Function::Handle(); | 111 const Function& function = Function::Handle( |
| 110 function = Resolver::ResolveDynamicForReceiverClass( | 112 Resolver::ResolveDynamicForReceiverClass( |
| 111 receiver_class, | 113 receiver_class, |
| 112 call->function_name(), | 114 call->function_name(), |
| 113 call->ArgumentCount(), | 115 args_desc)); |
| 114 num_named_arguments); | |
| 115 if (function.IsNull()) { | 116 if (function.IsNull()) { |
| 116 return false; | 117 return false; |
| 117 } | 118 } |
| 118 // Create new ICData, do not modify the one attached to the instruction | 119 // Create new ICData, do not modify the one attached to the instruction |
| 119 // since it is attached to the assembly instruction itself. | 120 // since it is attached to the assembly instruction itself. |
| 120 // TODO(srdjan): Prevent modification of ICData object that is | 121 // TODO(srdjan): Prevent modification of ICData object that is |
| 121 // referenced in assembly code. | 122 // referenced in assembly code. |
| 122 ICData& ic_data = ICData::ZoneHandle(ICData::New( | 123 ICData& ic_data = ICData::ZoneHandle(ICData::New( |
| 123 flow_graph_->parsed_function().function(), | 124 flow_graph_->parsed_function().function(), |
| 124 call->function_name(), | 125 call->function_name(), |
| (...skipping 2524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2649 compare->left()->Type()->ToNullableCid(); | 2650 compare->left()->Type()->ToNullableCid(); |
| 2650 | 2651 |
| 2651 if (receiver_cid == kDynamicCid) { | 2652 if (receiver_cid == kDynamicCid) { |
| 2652 return false; | 2653 return false; |
| 2653 } | 2654 } |
| 2654 | 2655 |
| 2655 const Class& receiver_class = Class::Handle( | 2656 const Class& receiver_class = Class::Handle( |
| 2656 Isolate::Current()->class_table()->At(receiver_cid)); | 2657 Isolate::Current()->class_table()->At(receiver_cid)); |
| 2657 | 2658 |
| 2658 // Resolve equality operator. | 2659 // Resolve equality operator. |
| 2660 const intptr_t kNumArgs = 2; |
| 2661 ArgumentsDescriptor args_desc( |
| 2662 Array::Handle(ArgumentsDescriptor::New(kNumArgs))); |
| 2659 const Function& function = Function::Handle( | 2663 const Function& function = Function::Handle( |
| 2660 Resolver::ResolveDynamicForReceiverClass( | 2664 Resolver::ResolveDynamicForReceiverClass( |
| 2661 receiver_class, | 2665 receiver_class, |
| 2662 Symbols::EqualOperator(), | 2666 Symbols::EqualOperator(), |
| 2663 2, | 2667 args_desc)); |
| 2664 0)); | |
| 2665 | 2668 |
| 2666 if (function.IsNull()) { | 2669 if (function.IsNull()) { |
| 2667 return false; | 2670 return false; |
| 2668 } | 2671 } |
| 2669 | 2672 |
| 2670 // Default equality operator declared on the Object class just calls | 2673 // Default equality operator declared on the Object class just calls |
| 2671 // identical. | 2674 // identical. |
| 2672 return (Class::Handle(function.Owner()).id() == kInstanceCid); | 2675 return (Class::Handle(function.Owner()).id() == kInstanceCid); |
| 2673 } | 2676 } |
| 2674 | 2677 |
| (...skipping 4506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7181 | 7184 |
| 7182 // Insert materializations at environment uses. | 7185 // Insert materializations at environment uses. |
| 7183 const Class& cls = Class::Handle(alloc->constructor().Owner()); | 7186 const Class& cls = Class::Handle(alloc->constructor().Owner()); |
| 7184 for (intptr_t i = 0; i < exits.length(); i++) { | 7187 for (intptr_t i = 0; i < exits.length(); i++) { |
| 7185 CreateMaterializationAt(exits[i], alloc, cls, *fields); | 7188 CreateMaterializationAt(exits[i], alloc, cls, *fields); |
| 7186 } | 7189 } |
| 7187 } | 7190 } |
| 7188 | 7191 |
| 7189 | 7192 |
| 7190 } // namespace dart | 7193 } // namespace dart |
| OLD | NEW |