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

Unified Diff: runtime/vm/flow_graph_type_propagator.cc

Issue 15141004: Fix crash with --no-use-cha: the optimizer expects a concrete type for array creation, not dynamic … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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_optimizer.cc ('k') | runtime/vm/object.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
===================================================================
--- runtime/vm/flow_graph_type_propagator.cc (revision 22650)
+++ runtime/vm/flow_graph_type_propagator.cc (working copy)
@@ -473,6 +473,20 @@
}
+// Return true if the class is private to our internal libraries (not extendable
+// or implementable by users).
+// (TODO): Allow more libraries.
+static bool IsKnownPrivateClass(const Class& type_class) {
+ if (!Library::IsPrivate(String::Handle(type_class.Name()))) return false;
+ const Library& library = Library::Handle(type_class.library());
+ if (library.raw() == Library::CoreLibrary()) return true;
+ if (library.raw() == Library::CollectionLibrary()) return true;
+ if (library.raw() == Library::TypedDataLibrary()) return true;
+ if (library.raw() == Library::MathLibrary()) return true;
+ return false;
+}
+
+
intptr_t CompileType::ToNullableCid() {
if (cid_ == kIllegalCid) {
ASSERT(type_ != NULL);
@@ -481,11 +495,16 @@
cid_ = kDynamicCid;
} else if (type_->IsVoidType()) {
cid_ = kNullCid;
- } else if (FLAG_use_cha && type_->HasResolvedTypeClass()) {
+ } else if (type_->HasResolvedTypeClass()) {
const Class& type_class = Class::Handle(type_->type_class());
- if (!type_class.is_implemented() &&
- !CHA::HasSubclasses(type_class.id())) {
- cid_ = type_class.id();
+ if (FLAG_use_cha || IsKnownPrivateClass(type_class)) {
+ // A known private class cannot be subclassed or implemented.
+ if (!type_class.is_implemented() &&
+ !CHA::HasSubclasses(type_class.id())) {
+ cid_ = type_class.id();
+ } else {
+ cid_ = kDynamicCid;
+ }
} else {
cid_ = kDynamicCid;
}
« no previous file with comments | « runtime/vm/flow_graph_optimizer.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698