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

Unified Diff: runtime/vm/precompiler.cc

Issue 1644543004: Precompilation: canonicalize lists of stackmaps. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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/precompiler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/precompiler.cc
diff --git a/runtime/vm/precompiler.cc b/runtime/vm/precompiler.cc
index 2131fafdc551bda867454b23bafbf1b77f07f215..0425cfc812e67c9c91912d9e94032f0187702552 100644
--- a/runtime/vm/precompiler.cc
+++ b/runtime/vm/precompiler.cc
@@ -119,6 +119,7 @@ void Precompiler::DoCompileAll(
BindStaticCalls();
DedupStackmaps();
+ DedupStackmapLists();
if (FLAG_trace_precompiler) {
THR_Print("Precompiled %" Pd " functions, %" Pd " dynamic types,"
@@ -1108,6 +1109,55 @@ void Precompiler::DedupStackmaps() {
}
+void Precompiler::DedupStackmapLists() {
+ class DedupStackmapListsVisitor : public FunctionVisitor {
+ public:
+ explicit DedupStackmapListsVisitor(Zone* zone) :
+ zone_(zone),
+ canonical_stackmap_lists_(),
+ code_(Code::Handle(zone)),
+ stackmaps_(Array::Handle(zone)),
+ stackmap_(Stackmap::Handle(zone)) {
+ }
+
+ void VisitFunction(const Function& function) {
+ if (!function.HasCode()) {
+ ASSERT(function.HasImplicitClosureFunction());
+ return;
+ }
+ code_ = function.CurrentCode();
+ stackmaps_ = code_.stackmaps();
+ if (stackmaps_.IsNull()) return;
+
+ stackmaps_ = DedupStackmapList(stackmaps_);
+ code_.set_stackmaps(stackmaps_);
+ }
+
+ RawArray* DedupStackmapList(const Array& stackmaps) {
+ const Array* canonical_stackmap_list =
+ canonical_stackmap_lists_.Lookup(&stackmaps);
+ if (canonical_stackmap_list == NULL) {
+ canonical_stackmap_lists_.Insert(
+ &Array::ZoneHandle(zone_, stackmaps.raw()));
+ return stackmaps.raw();
+ } else {
+ return canonical_stackmap_list->raw();
+ }
+ }
+
+ private:
+ Zone* zone_;
+ ArraySet canonical_stackmap_lists_;
+ Code& code_;
+ Array& stackmaps_;
+ Stackmap& stackmap_;
+ };
+
+ DedupStackmapListsVisitor visitor(Z);
+ VisitFunctions(&visitor);
+}
+
+
void Precompiler::VisitFunctions(FunctionVisitor* visitor) {
Library& lib = Library::Handle(Z);
Class& cls = Class::Handle(Z);
« no previous file with comments | « runtime/vm/precompiler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698