-
Notifications
You must be signed in to change notification settings - Fork 381
Enhance AstDumper for debugging and testing #10177
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
base: main
Are you sure you want to change the base?
Conversation
in multiple other places
|
Example of generating an AST dump with JS output included, while working on a fix for #9731 - running a build of the Hello sample before and after the change, and running function Button(handler){
$clinit_FocusWidget();
ButtonBase.call(this, $createPushButtonElement($doc));
($clinit_DOM() , this.element).className = 'gwt-Button' || '';
- ($clinit_DOM() , this.element).innerHTML = 'Click me' || '';
- $addDomHandler(this, handler, ($clinit_ClickEvent() , $clinit_ClickEvent() , TYPE));
+ this.element.innerHTML = 'Click me' || '';
+ $addDomHandler(this, handler, ($clinit_ClickEvent() , TYPE));
} |
|
CompilerTest doesn't fail locally, investigating... |
|
Failures appear to be an example of #9947, rerunning. |
|
Here's an example of the output when writing emulation unit testing - if you add gwt/user/test/com/google/gwt/emultest/java/lang/StringTest.java Lines 130 to 164 in a0bbaf0
If you are doing draft tests (e.g. test.draft.htmlunit), you won't see as much, while prod tests (e.g. test.web.htmlunit) will show more steps to get to the final JS. This isn't a particularly interesting method to look at, so I'm not pasting the whole results (see my gist for the whole thing), but one more interesting thing to call out is that by just jumping to the bottom, you can see the unobfuscated (but still optimized) JS method: _.testConcat = function testConcat(){
var abc, c, def, empty, s;
abc = valueOf(stampJavaTypeInfo(getClassLiteralForArray(C_classLit, 1), {8:1, 3:1}, 7, 15, [97, 98, 99]));
def = valueOf(stampJavaTypeInfo(getClassLiteralForArray(C_classLit, 1), {8:1, 3:1}, 7, 15, [100, 101, 102]));
empty = valueOf(stampJavaTypeInfo(getClassLiteralForArray(C_classLit, 1), {8:1, 3:1}, 7, 15, []));
assertEquals('abcdef', abc + def);
assertEquals('abcdef', (checkCriticalNotNull(abc) , abc + (checkCriticalNotNull(def) , def)));
assertEquals('', (checkCriticalNotNull(empty) , empty + (checkCriticalNotNull(empty) , empty)));
c = (checkCriticalStringElementIndex(0, def.length) , def.charCodeAt(0));
s = abc;
assertEquals('abcd', abc + 'd');
assertEquals('abcd', abc + String.fromCharCode(c));
assertEquals('abcd', s + 'd');
assertEquals('abcd', s + String.fromCharCode(c));
s += String.fromCharCode(c);
assertEquals('abcd', s);
try {
($wnd.Math.random() < -1 && fail() , null).$_nullMethod();
fail();
}
catch ($e0) {
$e0 = toJava($e0);
if (!instanceOf($e0, 13))
if (!instanceOf($e0, 15))
throw toJs($e0);
}
try {
$concat(($wnd.Math.random() < -1 && fail() , ''), ($wnd.Math.random() < -1 && fail() , null));
fail();
}
catch ($e1) {
$e1 = toJava($e1);
if (!instanceOf($e1, 13))
if (!instanceOf($e1, 15))
throw toJs($e1);
}
} |
Enhances the AstDumper utility class with the aim of bringing back some of the functionality previously removed in 64f9b00, where individual methods could be traced from source Java all the way to JS output. This is a small step in that direction that nevertheless provides more insight into what the compiler is doing, through a series of changes:
More improvement remains - multiple permutations may end up mixed in the same file, different compiler passes are not individually listed or labeled, arguments are re-parsed every time they are used, but impact to the API is minimal for now.