Index: runtime/vm/precompiler.cc |
diff --git a/runtime/vm/precompiler.cc b/runtime/vm/precompiler.cc |
index 985617c748d2e4d2b92f757873b2d1a40586703a..66a43f15cd02bcab11fa122ab2aa9c5d0e57f404 100644 |
--- a/runtime/vm/precompiler.cc |
+++ b/runtime/vm/precompiler.cc |
@@ -396,8 +396,9 @@ void Precompiler::DoCompileAll( |
BindStaticCalls(); |
SwitchICCalls(); |
+ MegamorphicCache::ShareEmptyBuckets(); |
DedupStackmaps(); |
- DedupStackmapLists(); |
+ DedupLists(); |
if (FLAG_dedup_instructions) { |
// Reduces binary size but obfuscates profiler results. |
@@ -2202,50 +2203,73 @@ void Precompiler::DedupStackmaps() { |
} |
-void Precompiler::DedupStackmapLists() { |
- class DedupStackmapListsVisitor : public FunctionVisitor { |
+void Precompiler::DedupLists() { |
+ class DedupListsVisitor : public FunctionVisitor { |
public: |
- explicit DedupStackmapListsVisitor(Zone* zone) : |
+ explicit DedupListsVisitor(Zone* zone) : |
zone_(zone), |
- canonical_stackmap_lists_(), |
+ canonical_lists_(), |
code_(Code::Handle(zone)), |
- stackmaps_(Array::Handle(zone)), |
- stackmap_(Stackmap::Handle(zone)) { |
+ list_(Array::Handle(zone)) { |
} |
void Visit(const Function& function) { |
- if (!function.HasCode()) { |
- return; |
- } |
code_ = function.CurrentCode(); |
- stackmaps_ = code_.stackmaps(); |
- if (stackmaps_.IsNull()) return; |
+ if (!code_.IsNull()) { |
+ list_ = code_.stackmaps(); |
+ if (!list_.IsNull()) { |
+ list_ = DedupList(list_); |
+ code_.set_stackmaps(list_); |
+ } |
+ } |
- stackmaps_ = DedupStackmapList(stackmaps_); |
- code_.set_stackmaps(stackmaps_); |
+ list_ = function.parameter_types(); |
+ if (!list_.IsNull()) { |
+ if (!function.IsSignatureFunction() && |
+ !function.IsClosureFunction() && |
+ (function.name() != Symbols::Call().raw()) && |
+ !list_.InVMHeap()) { |
+ // Parameter types not needed for function type tests. |
+ for (intptr_t i = 0; i < list_.Length(); i++) { |
+ list_.SetAt(i, Object::dynamic_type()); |
+ } |
+ } |
+ list_ = DedupList(list_); |
+ function.set_parameter_types(list_); |
+ } |
+ |
+ list_ = function.parameter_names(); |
+ if (!list_.IsNull()) { |
+ if (!function.HasOptionalNamedParameters() && |
+ !list_.InVMHeap()) { |
+ // Parameter names not needed for resolution. |
+ for (intptr_t i = 0; i < list_.Length(); i++) { |
+ list_.SetAt(i, Symbols::OptimizedOut()); |
+ } |
+ } |
+ list_ = DedupList(list_); |
+ function.set_parameter_names(list_); |
+ } |
} |
- RawArray* DedupStackmapList(const Array& stackmaps) { |
- const Array* canonical_stackmap_list = |
- canonical_stackmap_lists_.LookupValue(&stackmaps); |
- if (canonical_stackmap_list == NULL) { |
- canonical_stackmap_lists_.Insert( |
- &Array::ZoneHandle(zone_, stackmaps.raw())); |
- return stackmaps.raw(); |
+ RawArray* DedupList(const Array& list) { |
+ const Array* canonical_list = canonical_lists_.LookupValue(&list); |
+ if (canonical_list == NULL) { |
+ canonical_lists_.Insert(&Array::ZoneHandle(zone_, list.raw())); |
+ return list.raw(); |
} else { |
- return canonical_stackmap_list->raw(); |
+ return canonical_list->raw(); |
} |
} |
private: |
Zone* zone_; |
- ArraySet canonical_stackmap_lists_; |
+ ArraySet canonical_lists_; |
Code& code_; |
- Array& stackmaps_; |
- Stackmap& stackmap_; |
+ Array& list_; |
}; |
- DedupStackmapListsVisitor visitor(Z); |
+ DedupListsVisitor visitor(Z); |
VisitFunctions(&visitor); |
} |