| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/intermediate_language.h" | 5 #include "vm/intermediate_language.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/dart_entry.h" | 8 #include "vm/dart_entry.h" |
| 9 #include "vm/flow_graph_allocator.h" | 9 #include "vm/flow_graph_allocator.h" |
| 10 #include "vm/flow_graph_builder.h" | 10 #include "vm/flow_graph_builder.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 GraphEntryInstr::GraphEntryInstr(TargetEntryInstr* normal_entry) | 113 GraphEntryInstr::GraphEntryInstr(TargetEntryInstr* normal_entry) |
| 114 : BlockEntryInstr(CatchClauseNode::kInvalidTryIndex), | 114 : BlockEntryInstr(CatchClauseNode::kInvalidTryIndex), |
| 115 normal_entry_(normal_entry), | 115 normal_entry_(normal_entry), |
| 116 catch_entries_(), | 116 catch_entries_(), |
| 117 start_env_(NULL), | 117 start_env_(NULL), |
| 118 constant_null_(NULL), | 118 constant_null_(NULL), |
| 119 spill_slot_count_(0) { | 119 spill_slot_count_(0) { |
| 120 } | 120 } |
| 121 | 121 |
| 122 | 122 |
| 123 static bool CompareNames(const Library& lib, |
| 124 const char* test_name, |
| 125 const String& name) { |
| 126 // If both names are private mangle test_name before comparison. |
| 127 if ((name.CharAt(0) == '_') && (test_name[0] == '_')) { |
| 128 const String& test_name_symbol = String::Handle(Symbols::New(test_name)); |
| 129 return String::Handle(lib.PrivateName(test_name_symbol)).Equals(name); |
| 130 } |
| 131 return name.Equals(test_name); |
| 132 } |
| 133 |
| 134 |
| 123 MethodRecognizer::Kind MethodRecognizer::RecognizeKind( | 135 MethodRecognizer::Kind MethodRecognizer::RecognizeKind( |
| 124 const Function& function) { | 136 const Function& function) { |
| 125 // Only core and math library methods can be recognized. | 137 // Only core and math library methods can be recognized. |
| 126 const Library& core_lib = Library::Handle(Library::CoreLibrary()); | 138 const Library& core_lib = Library::Handle(Library::CoreLibrary()); |
| 127 const Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary()); | 139 const Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary()); |
| 128 const Library& math_lib = Library::Handle(Library::MathLibrary()); | 140 const Library& math_lib = Library::Handle(Library::MathLibrary()); |
| 129 const Class& function_class = Class::Handle(function.Owner()); | 141 const Class& function_class = Class::Handle(function.Owner()); |
| 130 if ((function_class.library() != core_lib.raw()) && | 142 if ((function_class.library() != core_lib.raw()) && |
| 131 (function_class.library() != core_impl_lib.raw()) && | 143 (function_class.library() != core_impl_lib.raw()) && |
| 132 (function_class.library() != math_lib.raw())) { | 144 (function_class.library() != math_lib.raw())) { |
| 133 return kUnknown; | 145 return kUnknown; |
| 134 } | 146 } |
| 135 const String& recognize_name = String::Handle(function.name()); | 147 const Library& lib = Library::Handle(function_class.library()); |
| 136 const String& recognize_class = String::Handle(function_class.Name()); | 148 const String& function_name = String::Handle(function.name()); |
| 137 String& test_function_name = String::Handle(); | 149 const String& class_name = String::Handle(function_class.Name()); |
| 138 String& test_class_name = String::Handle(); | 150 |
| 139 #define RECOGNIZE_FUNCTION(class_name, function_name, enum_name) \ | 151 #define RECOGNIZE_FUNCTION(test_class_name, test_function_name, enum_name) \ |
| 140 test_function_name = Symbols::New(#function_name); \ | 152 if (CompareNames(lib, #test_function_name, function_name) && \ |
| 141 test_class_name = Symbols::New(#class_name); \ | 153 CompareNames(lib, #test_class_name, class_name)) { \ |
| 142 if (recognize_name.Equals(test_function_name) && \ | |
| 143 recognize_class.Equals(test_class_name)) { \ | |
| 144 return k##enum_name; \ | 154 return k##enum_name; \ |
| 145 } | 155 } |
| 146 RECOGNIZED_LIST(RECOGNIZE_FUNCTION) | 156 RECOGNIZED_LIST(RECOGNIZE_FUNCTION) |
| 147 #undef RECOGNIZE_FUNCTION | 157 #undef RECOGNIZE_FUNCTION |
| 148 return kUnknown; | 158 return kUnknown; |
| 149 } | 159 } |
| 150 | 160 |
| 151 | 161 |
| 152 const char* MethodRecognizer::KindToCString(Kind kind) { | 162 const char* MethodRecognizer::KindToCString(Kind kind) { |
| 153 #define KIND_TO_STRING(class_name, function_name, enum_name) \ | 163 #define KIND_TO_STRING(class_name, function_name, enum_name) \ |
| (...skipping 1504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1658 value->set_use_index(use_index++); | 1668 value->set_use_index(use_index++); |
| 1659 value->AddToEnvUseList(); | 1669 value->AddToEnvUseList(); |
| 1660 } | 1670 } |
| 1661 instr->set_env(copy); | 1671 instr->set_env(copy); |
| 1662 } | 1672 } |
| 1663 | 1673 |
| 1664 | 1674 |
| 1665 #undef __ | 1675 #undef __ |
| 1666 | 1676 |
| 1667 } // namespace dart | 1677 } // namespace dart |
| OLD | NEW |