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

Unified Diff: runtime/vm/flow_graph_builder.cc

Issue 11342014: Fold away x === null comparisons when propagated cid of x is not kDynamicCid. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix error in type recognition for List. call Created 8 years, 2 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 | « no previous file | runtime/vm/flow_graph_optimizer.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
diff --git a/runtime/vm/flow_graph_builder.cc b/runtime/vm/flow_graph_builder.cc
index 072feb846e2bd88181659bb3f4efb2869415dbde..3dcc995e5e94a58d0bebf6699df1aa14f05a55a0 100644
--- a/runtime/vm/flow_graph_builder.cc
+++ b/runtime/vm/flow_graph_builder.cc
@@ -1668,22 +1668,52 @@ void EffectGraphVisitor::BuildConstructorCall(
}
+static bool IsRecognizedConstructor(const Function& function,
+ const String& expected) {
+ const Class& clazz = Class::Handle(function.Owner());
+ const Library& lib = Library::Handle(clazz.library());
+
+ const String& expected_class_name =
+ String::Handle(lib.PrivateName(expected));
+ if (!String::Handle(clazz.Name()).Equals(expected_class_name)) {
+ return false;
+ }
+
+ const String& function_name = String::Handle(function.name());
+ const String& expected_function_name = String::Handle(
+ String::Concat(expected_class_name, String::Handle(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());
+ const Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary());
+
+ if (function_class.library() != core_impl_lib.raw()) {
+ return kDynamicCid;
+ }
+
if (node->constructor().IsFactory()) {
- const Function& function = node->constructor();
- const Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary());
- const Class& function_class = Class::Handle(function.Owner());
-
- if (function_class.library() == core_impl_lib.raw()) {
- if (function_class.Name() == Symbols::ListImplementation()) {
- if (function.name() == Symbols::ListFactory()) {
- if (node->arguments()->length() == 0) {
- return kGrowableObjectArrayCid;
- } else {
- ASSERT(node->arguments()->length() == 1);
- return kArrayCid;
- }
- }
+ if ((function_class.Name() == Symbols::ListImplementation()) &&
+ (function.name() == Symbols::ListFactory())) {
+ // If there are no arguments then the result is guaranteed to be a
+ // GrowableObjectArray. However if there is an argument the result
+ // is not guaranteed to be a fixed size array because the argument
+ // can be null.
+ if (node->arguments()->length() == 0) {
+ return kGrowableObjectArrayCid;
+ }
+ } else {
+ if (IsRecognizedConstructor(function,
+ String::Handle(Symbols::ObjectArray())) &&
+ (node->arguments()->length() == 1)) {
+ return kArrayCid;
+ } else if (IsRecognizedConstructor(function,
+ String::Handle(Symbols::GrowableObjectArray())) &&
+ (node->arguments()->length() == 0)) {
+ return kGrowableObjectArrayCid;
}
}
}
« no previous file with comments | « no previous file | runtime/vm/flow_graph_optimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698