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

Unified Diff: runtime/vm/flow_graph_compiler.cc

Issue 11348289: Attempt to do direct class comparison for type checks using CHA. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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_compiler_ia32.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_compiler.cc
===================================================================
--- runtime/vm/flow_graph_compiler.cc (revision 15478)
+++ runtime/vm/flow_graph_compiler.cc (working copy)
@@ -6,6 +6,7 @@
#include "vm/flow_graph_compiler.h"
+#include "vm/cha.h"
#include "vm/dart_entry.h"
#include "vm/debugger.h"
#include "vm/deopt_instructions.h"
@@ -28,6 +29,7 @@
DECLARE_FLAG(bool, propagate_ic_data);
DECLARE_FLAG(bool, report_usage_count);
DECLARE_FLAG(int, optimization_counter_threshold);
+DECLARE_FLAG(bool, use_cha);
void CompilerDeoptInfo::BuildReturnAddress(DeoptInfoBuilder* builder,
const Function& function,
@@ -1004,4 +1006,28 @@
}
}
+
+// Returns true if checking against this type is a direct class id comparison.
+bool FlowGraphCompiler::TypeCheckAsClassEquality(const AbstractType& type) {
+ ASSERT(type.IsFinalized() && !type.IsMalformed());
+ // Requires CHA, which can be applied in optimized code only,
+ if (!FLAG_use_cha || !is_optimizing()) return false;
+ if (!type.IsInstantiated()) return false;
+ const Class& type_class = Class::Handle(type.type_class());
+ // Could be an interface check?
+ if (type_class.is_implemented()) return false;
+ const intptr_t type_cid = type_class.id();
+ if (CHA::HasSubclasses(type_cid)) return false;
+ if (type_class.HasTypeArguments()) {
+ // Only raw types can be directly compared, thus disregarding type
+ // arguments.
+ const AbstractTypeArguments& type_arguments =
+ AbstractTypeArguments::Handle(type.arguments());
+ const bool is_raw_type = type_arguments.IsNull() ||
+ type_arguments.IsRaw(type_arguments.Length());
+ return is_raw_type;
+ }
+ return true;
+}
+
} // namespace dart
« no previous file with comments | « no previous file | runtime/vm/flow_graph_compiler_ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698