-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enhance collapse_vars
#4864
enhance collapse_vars
#4864
Conversation
@kzc this should round up #4858 (comment) $ cat test.js
!function() {
var e, t, r = {},
n = {};
t = n = function(e, t) {
return t.get ? t.get.call(e) : t.value
}, n.default = t, n.__esModule = true;
var u, a = n,
o = {};
u = o = function(e, t, r) {
if (!t.has(e)) throw new TypeError("attempted to " + r + " private field on non-instance");
return t.get(e)
}, o.default = u, o.__esModule = true;
var l = o;
e = r = function(e, t) {
var r = l(e, t, "get");
return a(e, r)
}, r.default = e, r.__esModule = true
}(); $ uglify-js test.js -bc
!function() {
var r;
o = function(e, t) {
return t.get ? t.get.call(e) : t.value;
};
(o.default = o).__esModule = !0;
var o, a = o;
o = function(e, t, r) {
if (!t.has(e)) throw new TypeError("attempted to " + r + " private field on non-instance");
return t.get(e);
};
(o.default = o).__esModule = !0;
var l = o;
r = function(e, r) {
r = l(e, r, "get");
return a(e, r);
};
(r.default = r).__esModule = !0;
}(); $ uglify-js test.js -bc passes=2
(also works with |
Wow, that was quick. Well done. So the gist of it is that you continue to scan past side effects for other possible aliases? |
So merge_vars doesn't interfere with this optimization? Or this optimization works even in spite of the repurposing of variables? |
We already have
This PR extends it to recognise
|
The reason why I mentioned merge_vars is illustrated in the following code produced by
Notice that If I take that output and run it through latest master it produces:
The repurposing of variables by merge_vars precludes the recent optimizations in collapse_vars. So I was a bit surprised that enhancing collapse_vars alone without changing merge_vars would effectively reduce the original code. Perhaps the order of the compress optimizations was significant in that case. I don't think the last output above can be optimized away very easily without using SSA in |
Oh I see what you mean − indeed |
No description provided.