Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(916)

Unified Diff: runtime/vm/flow_graph_builder.cc

Issue 12374024: Fix factory name to result cid mapping, run type propagation once more after constant propagation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/compiler.cc ('k') | runtime/vm/flow_graph_type_propagator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_builder.cc
===================================================================
--- runtime/vm/flow_graph_builder.cc (revision 19253)
+++ runtime/vm/flow_graph_builder.cc (working copy)
@@ -1976,24 +1976,42 @@
}
-static bool IsRecognizedConstructor(const Function& function,
- const String& expected) {
- const Class& clazz = Class::Handle(function.Owner());
- const Library& lib = Library::Handle(clazz.library());
+// List of recognized factories in core lib (factories with known result-cid):
+// (factory-name-symbol, result-cid, fingerprint).
+#define RECOGNIZED_FACTORY_LIST(V) \
+ V(ObjectArrayDot, kArrayCid, 97987288) \
+ V(GrowableObjectArrayWithData, kGrowableObjectArrayCid, 816132033) \
+ V(GrowableObjectArrayDot, kGrowableObjectArrayCid, 1896741574) \
- const String& expected_class_name =
- String::Handle(lib.PrivateName(expected));
- if (!String::Handle(clazz.Name()).Equals(expected_class_name)) {
- return false;
+
+// Class that recognizes factories and returns corresponding result cid.
+class FactoryRecognizer : public AllStatic {
+ public:
+ // Return kDynamicCid if factory is not recognized.
+ static intptr_t ResultCid(const Function& factory) {
+ ASSERT(factory.IsFactory());
+ const Class& function_class = Class::Handle(factory.Owner());
+ const Library& lib = Library::Handle(function_class.library());
+ if (lib.raw() != Library::CoreLibrary()) {
+ // Only core library factories recognized.
+ return kDynamicCid;
+ }
+ const String& factory_name = String::Handle(factory.name());
+#define RECOGNIZE_FACTORY(test_factory_symbol, cid, fp) \
+ if (String::EqualsIgnoringPrivateKey( \
+ factory_name, Symbols::test_factory_symbol())) { \
+ ASSERT(factory.CheckSourceFingerprint(fp)); \
+ return cid; \
+ } \
+
+RECOGNIZED_FACTORY_LIST(RECOGNIZE_FACTORY);
+#undef RECOGNIZE_FACTORY
+
+ return kDynamicCid;
}
+};
- const String& function_name = String::Handle(function.name());
- const String& expected_function_name = String::Handle(
- String::Concat(expected_class_name, Symbols::Dot()));
- return function_name.Equals(expected_function_name);
-}
-
static intptr_t GetResultCidOfConstructor(ConstructorCallNode* node) {
const Function& function = node->constructor();
const Class& function_class = Class::Handle(function.Owner());
@@ -2006,20 +2024,13 @@
if (node->constructor().IsFactory()) {
if ((function_class.Name() == Symbols::List().raw()) &&
(function.name() == Symbols::ListFactory().raw())) {
+ // Special recognition of 'new List()' vs 'new List(n)'.
if (node->arguments()->length() == 0) {
return kGrowableObjectArrayCid;
}
return kArrayCid;
- } else {
- if (IsRecognizedConstructor(function, Symbols::ObjectArray()) &&
- (node->arguments()->length() == 1)) {
- return kArrayCid;
- } else if (IsRecognizedConstructor(function,
- Symbols::GrowableObjectArray()) &&
- (node->arguments()->length() == 0)) {
- return kGrowableObjectArrayCid;
- }
}
+ return FactoryRecognizer::ResultCid(function);
}
return kDynamicCid; // Result cid not known.
}
« no previous file with comments | « runtime/vm/compiler.cc ('k') | runtime/vm/flow_graph_type_propagator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698