JDK-8038416 : Access to undefined scoped variables deoptimized too much
  • Type: Bug
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Affected Version: 9
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2014-03-26
  • Updated: 2015-01-21
  • Resolved: 2014-03-27
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
8u40Fixed 9 b17Fixed
Related Reports
Relates :  
Description
JDK-8038396 deoptimizes access to scoped variables that start out as undefined too much.
E.g.

var x = foo()
var a = 3;
a++; // becomes double instead of optimistic int

function foo() { return null };

The reason is that the first deoptimizing recompilation happens when "foo()" is invoked and the return value doesn't fit in an int. At this time, "a" is not yet initialized, so naively observing Undefined value turns its subsequent accessor into Object one. The fix is to avoid inferring expression types for undefined scoped variables (those for which Property.getCurrentType() == null), instead of presuming Object.