Max javascript file size for Context.compileString()

92 views
Skip to first unread message

William Chantry

unread,
Sep 8, 2016, 1:25:44 PM9/8/16
to mozilla-rhino
I'm trying to embed a babel transpiler in my java code.  I.E. ES6 javascript is fed in, and ES5 javascript comes out.  Unfortunately the file size of the compiler script is a wopping 1.4 MB minified and I run into a 

"org.mozilla.javascript.EvaluatorException: Encountered code generation error while compiling script: generated bytecode for method exceeds 64K limit. (babel-standalone-6.15.js#1)" 


error.  What is the max file size?  and/or is there a way around this using java?  I could potentially write my own standalone module that is a little slimmer, or even go a step further and break the compiler up into the parser, transpiler, and generator steps.  Unfortunately seperating the code from the standalone project will be... difficult for me.


Thanks,


goofiw

gabriel munteanu

unread,
Sep 8, 2016, 1:43:13 PM9/8/16
to mozill...@googlegroups.com
see here: http://stackoverflow.com/questions/9779809/how-to-split-iife-to-fit-into-java-jvm-rhino-64k-bytecode-limit
, it seems rhino 1.8 can help you.
gabi
> --
> You received this message because you are subscribed to the Google Groups
> "mozilla-rhino" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mozilla-rhin...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

William Chantry

unread,
Sep 8, 2016, 2:10:55 PM9/8/16
to mozilla-rhino
The object in question would appear to be one large object literal, I'm not sure it can be broken up programatically.

Is there a simple was to point to a github repo in my pom.xml to test?

Greg Brail

unread,
Sep 8, 2016, 4:20:00 PM9/8/16
to mozill...@googlegroups.com
Yep -- rhino puts the whole file into a single ".class" file of bytecode and the hard-coded limit in the JVM is 64K. 

Rarely have I seen actual CODE that ends up being larger than 64K after compiling. However there are often cases like this where there are huge literals or lots of them, mainly from code that uses source code as a sort of data store.

In that case one way to work around them is to catch the exception raised while compiling, and then run that one script in interpreted mode. Trireme does this and it is able to handle these kind of conditions fairly well.

I wasn't aware of that particular (very old) branch from Hannes. If it solves your problem then perhaps we can look in to merging it.

--
You received this message because you are subscribed to the Google Groups "mozilla-rhino" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mozilla-rhino+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Greg Brail | apigee twitter @gbrail @apigee


Reply all
Reply to author
Forward
0 new messages