kohlhaas / google-gin

Automatically exported from code.google.com/p/google-gin
Apache License 2.0
0 stars 0 forks source link

Code bloat with native methods #35

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
We currently use native methods to allow access control in Gin but that
seems to break the code optimization in the GWT compiler (it treats native
method bodies as blobs). 

To ultimately solve this problem, we'll have to introduce a better
reflection "light" mechanism in GWT, either through improving native method
analysis or by adding a dedicated syntax. In the meantime, we should at
least inject publicly accessible members in java to allow older versions of
GWT some optimization.

Original issue reported on code.google.com by aragos on 21 Apr 2009 at 2:53

GoogleCodeExporter commented 9 years ago
Created patch for java-only injection of public methods and submitted for 
review:
http://codereview.appspot.com/49046

Original comment by aragos on 22 Apr 2009 at 6:36

GoogleCodeExporter commented 9 years ago
This is still a major issue but is mitigated somewhat by the fix mentioned in 
the
previous comment. Next step requires changes in the GWT compiler.

Original comment by aragos on 25 May 2009 at 2:29

GoogleCodeExporter commented 9 years ago
Well, and if a client is concerned about the bloat, he can always just make 
methods
public for now.

Original comment by bsto...@google.com on 25 May 2009 at 6:52

GoogleCodeExporter commented 9 years ago
Brian, is there a GWT issue filed describing the compiler changes needed? Can 
it get
linked here?

Original comment by rj...@google.com on 26 May 2009 at 3:21

GoogleCodeExporter commented 9 years ago
I don't think there is an issue filed with GWT. I was discussing possible 
solutions
with Lex a few weeks back and we agreed that an additional conversion in the AST
seems best, i.e. replacing a JSNI AST branch with a java AST branch where 
possible. I
haven't had much time to work on it, but here is an example by Lex how this 
might work:

=============

Attached is a patch for the pattern I was describing.  It includes
conversion of "return 0" as a sample.  I tried it on a hacked Hello
sample, and got trace output like this (abbreviated):

---------------------------
JAVA INITIAL:
---------------------------
public static native int returnZero() /*-{
 return 0;
}-*/;
---------------------------
JAVA INITIAL:
---------------------------
public void onModuleLoad(){
 Window.alert("Zero is " + Hello.returnZero());
}
---------------------------
ConvertJsniToJava:
---------------------------
public static int returnZero(){
 return 0;
}
---------------------------
InliningVisitor:
---------------------------
public static final void $onModuleLoad(Hello this$static){
 Window.alert("Zero is " + ((0)));
}
---------------------------
DeadCodeVisitor:
---------------------------
public static final void $onModuleLoad(Hello this$static){
 Window.alert("Zero is 0");
}

Original comment by aragos on 26 May 2009 at 3:31

GoogleCodeExporter commented 9 years ago
http://code.google.com/p/google-web-toolkit/issues/detail?id=3696

Original comment by rj...@google.com on 26 May 2009 at 3:39

GoogleCodeExporter commented 9 years ago
As of r95, injections of public members don't use JSNI. So you can always avoid 
this
code bloat by making things public. Lowering priority thusly. (Also, future
improvement will likely come from changes in GWT.)

Original comment by bstoler+code@google.com on 31 May 2009 at 10:22