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

Unified Diff: runtime/vm/flow_graph_type_propagator.cc

Issue 12304009: Trust declared type of the receiver to compute its initial compile type. (Closed) Base URL: https://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/flow_graph_builder.cc ('k') | runtime/vm/intermediate_language.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_type_propagator.cc
diff --git a/runtime/vm/flow_graph_type_propagator.cc b/runtime/vm/flow_graph_type_propagator.cc
index 020172cd19e6581400c8b4c3048c8247e01303aa..941c2605ca7a8d76581051b15913a3828d03b67f 100644
--- a/runtime/vm/flow_graph_type_propagator.cc
+++ b/runtime/vm/flow_graph_type_propagator.cc
@@ -288,9 +288,7 @@ intptr_t CompileType::ToNullableCid() {
cid_ = kNullCid;
} else if (FLAG_use_cha && type_->HasResolvedTypeClass()) {
const intptr_t cid = Class::Handle(type_->type_class()).id();
- if (!CHA::HasSubclasses(cid)) {
- cid_ = cid;
- }
+ cid_ = !CHA::HasSubclasses(cid) ? cid : kDynamicCid;
} else {
cid_ = kDynamicCid;
}
@@ -445,13 +443,32 @@ bool PhiInstr::RecomputeType() {
}
+static bool CanTrustParameterType(const Function& function, intptr_t index) {
+ // Parameter is receiver.
+ if (index == 0) {
+ return function.IsDynamicFunction() || function.IsConstructor();
+ }
+
+ // Parameter is the constructor phase.
+ return (index == 1) && function.IsConstructor();
+}
+
CompileType* ParameterInstr::ComputeInitialType() const {
// Note that returning the declared type of the formal parameter would be
// incorrect, because ParameterInstr is used as input to the type check
// verifying the run time type of the passed-in parameter and this check would
// always be wrongly eliminated.
- return CompileType::Dynamic();
+ // However there are parameters that are known to match their declared type:
+ // for example reciever and construction phase.
Florian Schneider 2013/02/18 15:44:39 s/reciever/receiver/
srdjan 2013/02/19 16:41:59 How does this work: you can trust the receiver typ
+ if (!CanTrustParameterType(block_->parsed_function().function(),
+ index())) {
+ return CompileType::Dynamic();
+ }
+
+ LocalScope* scope = block_->parsed_function().node_sequence()->scope();
+ return CompileType::FromAbstractType(scope->VariableAt(index())->type(),
+ CompileType::kNonNullable);
}
« no previous file with comments | « runtime/vm/flow_graph_builder.cc ('k') | runtime/vm/intermediate_language.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698