Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8029667

Prototype linking is incorrect

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8u20
    • Fix Version/s: 9
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b02
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        When a property is found in a prototype of the object, the linkage we emit is incorrect, as we emit a method bound to the prototype instance, but guarding on the map and switchpointing on an event listener for the map. Here's a little reproducer that will print "Expecting 2: 1" in the second line instead of "Expecting 2: 2" as – well – expected. The reason for this is that the second invocation of function "inner" will keep its linkage for "dyn:getProp:x" bound to the prototype - in this case, the scope obect of f(x) invocation from the first invocation with f(1), and neither the map guard nor the prototype guard will be invalidated.

        function f(x) {
          return (function inner() {
              var y; (function dummy() { return y })() // force own scope for the inner function
              with({}) { // 'with' block turns off fast scopes
                  // Getter for 'x' will now use prototype-bound linking.
                  // Unfortunately, it'll get bound to the scope of the first invocation of f(x).
                  return x
              }
          })();
        }
        print("Expecting 1: " + f(1))
        print("Expecting 2: " + f(2))

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  hannesw Hannes Wallnoefer
                  Reporter:
                  attila Attila Szegedi
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: