From: Brad C. <pr...@ya...> - 2004-09-29 18:40:02
|
I tried the change and it seems to at least speed up htmlunit's unit tests by a couple of seconds. Compiling all the javascript when most of the time it's only used once seems a little wasteful anyway, so I'm going to check it in. Chris: if this change doesn't fix the 64k barrier problem you're having please post a bug in the tracker. Brad C --- Andrey Subbotin <asu...@oi...> wrote: > The Rhino javascript interpreter HtmlUnit uses can run in two modes: > compilation (where javascript code is converted into java classes; this is > your case) and interpretation. If you have HtmlUnit source, you can go to > JavascriptEngine.getPageInfo() and add line > > newPageInfo.context_.setOptimizationLevel(-1); > > That will switch Rhino to interpretation mode and presumably solve your > problem. > > In fact I'd request HtmlUnit authors to either make it default mode, or at > least make it configurable from public API. The compilation mode caused VM > crashes for me (JDK 1.3.1.09 both Windows and Linux; our pages have large js > files of about 500KB per page; after a sequence of 3-5 pages VM throws > OutOfMemory exceptions in random places without actually taking significant > memory from OS); switching to interpretation code fixed that without > noticeable slowdown. The interpretation mode is more stable without any > obvious downside. > > Best regards > Andrey > > From: "Erskine, Chris" <chr...@ed...> > > I am getting the following Exception for a test that I am trying to > develop. > > It looks like the root cause is > > java.lang.RuntimeException: java.lang.ClassFormatError: > > org/mozilla/javascript/gen/c396 (Code of a method longer than 65535 bytes) > > This appears to be due to compiling the JavaScript arrays that are defined > > in on the page. Is there some way to get around this problem? Would it > be > > possible to fix HtmlUnit to break the source up into some smaller modules > to > > prevent this from happening. If it is thought that this would work, I can > > try to see if I can get it to work. > > .. > > > Enclosed exception: > > java.lang.RuntimeException: java.lang.ClassFormatError: > > org/mozilla/javascript/gen/c396 (Code of a method longer than 65535 bytes) > > at > > org.mozilla.javascript.optimizer.Codegen.compile(Codegen.java:113) > > at org.mozilla.javascript.Context.compile(Context.java:2076) > > at org.mozilla.javascript.Context.compile(Context.java:2006) > > at org.mozilla.javascript.Context.compileReader(Context.java:899) > > at org.mozilla.javascript.Context.evaluateReader(Context.java:817) > > at org.mozilla.javascript.Context.evaluateString(Context.java:784) > > ... > > |