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

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 11187003: Fix receiver's type for constructors. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_optimizer.cc
===================================================================
--- runtime/vm/flow_graph_optimizer.cc (revision 13684)
+++ runtime/vm/flow_graph_optimizer.cc (working copy)
@@ -2181,19 +2181,26 @@
// i.e. the receiver argument or the constructor phase argument.
AbstractType& param_type = AbstractType::Handle(Type::DynamicType());
param->SetPropagatedCid(kDynamicCid);
- if (param->index() < 2) {
+ bool param_type_is_known = false;
+ if (param->index() == 0) {
const Function& function = parsed_function().function();
- if (((param->index() == 0) && function.IsDynamicFunction()) ||
- ((param->index() == 1) && function.IsConstructor())) {
- // Parameter is the receiver or the constructor phase.
- LocalScope* scope = parsed_function().node_sequence()->scope();
- param_type = scope->VariableAt(param->index())->type().raw();
- if (FLAG_use_cha) {
- const intptr_t cid = Class::Handle(param_type.type_class()).id();
- if (!CHA::HasSubclasses(cid)) {
- // Receiver's class has no subclasses.
- param->SetPropagatedCid(cid);
- }
+ if ((function.IsDynamicFunction() || function.IsConstructor())) {
+ // Parameter is the receiver .
+ param_type_is_known = true;
+ }
+ } else if ((param->index() == 1) &&
+ parsed_function().function().IsConstructor()) {
+ // Parameter is the constructor phase.
+ param_type_is_known = true;
+ }
+ if (param_type_is_known) {
+ LocalScope* scope = parsed_function().node_sequence()->scope();
+ param_type = scope->VariableAt(param->index())->type().raw();
+ if (FLAG_use_cha) {
+ const intptr_t cid = Class::Handle(param_type.type_class()).id();
+ if (!CHA::HasSubclasses(cid)) {
+ // Receiver's class has no subclasses.
+ param->SetPropagatedCid(cid);
}
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698