JDK-8135190 : Method code too large in Babel browser.js script
  • Type: Bug
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2015-09-08
  • Updated: 2016-01-14
  • Resolved: 2015-09-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u72Fixed 9 b84Fixed
Description
The Babel compiler contains a script called browser.js (or browser.min.js for the minified version) that causes a "method code too large" exception in Nashorn.

http://dev.clojure.org/jira/browse/CLJS-1322

I tracked the problem down to a function with a huge nested object literal.

To reproduce: 

> jjs babel-min.js
Exception in thread "main" java.lang.RuntimeException: Method code too large!
	at jdk.internal.org.objectweb.asm.MethodWriter.getSize(MethodWriter.java:2065)
	at jdk.internal.org.objectweb.asm.ClassWriter.toByteArray(ClassWriter.java:856)
	at jdk.nashorn.internal.codegen.ClassEmitter.toByteArray(ClassEmitter.java:679)
	at jdk.nashorn.internal.codegen.CompilationPhase$13.transform(CompilationPhase.java:497)
	at jdk.nashorn.internal.codegen.CompilationPhase.apply(CompilationPhase.java:716)
	at jdk.nashorn.internal.codegen.Compiler.compile(Compiler.java:620)
	at jdk.nashorn.internal.runtime.RecompilableScriptFunctionData.compileTypeSpecialization(RecompilableScriptFunctionData.java:514)
	at jdk.nashorn.internal.runtime.RecompilableScriptFunctionData.getBest(RecompilableScriptFunctionData.java:688)
	at jdk.nashorn.internal.runtime.ScriptFunctionData.getBestInvoker(ScriptFunctionData.java:237)
	at jdk.nashorn.internal.runtime.ScriptFunction.findCallMethod(ScriptFunction.java:592)
	at jdk.nashorn.internal.runtime.ScriptObject.lookup(ScriptObject.java:1833)
	at jdk.nashorn.internal.runtime.linker.NashornLinker.getGuardedInvocation(NashornLinker.java:104)
	at jdk.nashorn.internal.runtime.linker.NashornLinker.getGuardedInvocation(NashornLinker.java:98)
	at jdk.internal.dynalink.support.CompositeTypeBasedGuardingDynamicLinker.getGuardedInvocation(CompositeTypeBasedGuardingDynamicLinker.java:176)
	at jdk.internal.dynalink.support.CompositeGuardingDynamicLinker.getGuardedInvocation(CompositeGuardingDynamicLinker.java:124)
	at jdk.internal.dynalink.support.LinkerServicesImpl.getGuardedInvocation(LinkerServicesImpl.java:154)
	at jdk.nashorn.internal.runtime.ScriptFunction.createApplyOrCallCall(ScriptFunction.java:772)
	at jdk.nashorn.internal.runtime.ScriptFunction.findCallMethod(ScriptFunction.java:583)
	at jdk.nashorn.internal.runtime.ScriptObject.lookup(ScriptObject.java:1833)
	at jdk.nashorn.internal.runtime.linker.NashornLinker.getGuardedInvocation(NashornLinker.java:104)
	at jdk.nashorn.internal.runtime.linker.NashornLinker.getGuardedInvocation(NashornLinker.java:98)
	at jdk.internal.dynalink.support.CompositeTypeBasedGuardingDynamicLinker.getGuardedInvocation(CompositeTypeBasedGuardingDynamicLinker.java:176)
	at jdk.internal.dynalink.support.CompositeGuardingDynamicLinker.getGuardedInvocation(CompositeGuardingDynamicLinker.java:124)
	at jdk.internal.dynalink.support.LinkerServicesImpl.getGuardedInvocation(LinkerServicesImpl.java:154)
	at jdk.internal.dynalink.DynamicLinker.relink(DynamicLinker.java:253)
	at jdk.nashorn.internal.scripts.Script$Recompilation$2$1AAA$babel_min.L:1(babel-min.js:2)
	at jdk.nashorn.internal.scripts.Script$Recompilation$1$babel_min.:program(babel-min.js:1)
	at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:640)
	at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:228)
	at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
	at jdk.nashorn.tools.Shell.apply(Shell.java:397)
	at jdk.nashorn.tools.Shell.runScripts(Shell.java:326)
	at jdk.nashorn.tools.Shell.run(Shell.java:172)
	at jdk.nashorn.tools.Shell.main(Shell.java:136)
	at jdk.nashorn.tools.Shell.main(Shell.java:112)

Comments
We currently only split array literals, but not object literals. Obviously we should split those, too.
08-09-2015