Hi,

So I am trying to figure out a way to control inlining in GWT compiler and
potentially if it will be compatible with J2CL. My motivation is that I
want to build type-safe builders that are compiled away at runtime. The
idea is to compile something like

new InputBuilder().type( InputType.checkbox ).className( "foo"
).child( "Hello" ).build()

to

React.createElement('input', { className: 'foo' }, 'Hello')

And browsing the code I thought I could make use of @ForceInline and
@HasNoSideEffects in appropriate places to control the inlining. The goal
would essentially be to move most of the building code into caller which
allow the data flow analyzer to zap it into a nice compact form. But I can
not seem to get it to work.

It is unclear whether I am using it wrong or it just won't work and reading
through the compiler source code is proving to be slow way to understand
the problem.

@ForceInline does not seem to force inlining but instead raises an error if
code is not inlined? Am I understanding this correctly? Certainly adding
the annotation to all the places that I wanted that occur causes a error
like "Function X is marked as @ForceInline but it could not be inlined".
Reading through the JsInliner source code has not enlightened me why.

So more code less talk. Here is the example I have been working with

https://gist.github.com/realityforge/5c9c04cd86dc6ada80f05558d609a3ae

Next question is around optimisation of the new jsinterop code. It seems
that GWT compiler does not work particularly well and something like

final JsPropertyMapOfAny prop = JsPropertyMap.of();
prop.set( "a", 1 );
prop.set( "b", 2 );
prop.set( "c", 3 );

will not produce an object literal.

So do you think this is an achievable goal with GWT2, what about in
J2CL? Any suggestions on how I could achieve this?

BTW I know using things like @ForceInline and @HasNoSideEffects is
"dangerous" and unsupported but I am comfortable with the impact I would
have on compile size/time. (Once worked on JikesRVM which is a JVM written
in Java which has similar annotations and similar tradeoffs - see
http://www.jikesrvm.org/JavaDoc/org/vmmagic/pragma/package-summary.html)

-- 
Cheers,

Peter Donald

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

Reply via email to