RVM

Compiler confusion over equal but non-identical objects

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 2.9.2
  • Fix Version/s: 2.9.3
  • Component/s: Compiler: Optimizing
  • Labels:
    None
  • Testcase included:
    yes
  • Patch Submitted:
    Yes
  • Number of attachments :
    3

Description

When the optimising compiler folds a chain of final references it may substitute the target of the references chain with an equal but non-identical object.

The attached patch against 2.9.2 fixes this by changing VM_Statics.objectLiterals to use identity instead of equality. While this corrects the problem it may or may not be the best way of solving it.

STATEMENT OF ORIGIN FOR A SINGLE CONTRIBUTOR
I, Yuval Yarom:

(a) represent that either:

I am the only author and owner of the contributed software
(described as/entitled fixing runtime package isolation),
which was neither derived nor copied from any other software,
or

(ii) that any exception to is software which was obtained under the
CPL (Common Public License),

and

(b) hereby agree to license this contributed software under the CPL.

  1. Confusion.java
    06/Feb/08 3:13 AM
    0.7 kB
    Yuval Yarom
  2. patch.diff
    06/Feb/08 3:13 AM
    3 kB
    Yuval Yarom
  3. patch2.diff
    06/Feb/08 6:28 AM
    3 kB
    Yuval Yarom

Issue Links

Activity

Hide
Ian Rogers added a comment -

I agree with the problem and that the fix should solve it, however, it seems ugly to me to put an identity hash map implementation in to the already crowded VM_Statics. We could refactor VM_HashMap so that it has an overridable means of determining whether two values are equal and then create an identity hash map that overrides this method (to use == instead of .equals). We can then change the map for objects in VM_Statics to use an identity hashmap rather than a regular hashmap, and the rest of the code in VM_Statics can remain unchanged.

Show
Ian Rogers added a comment - I agree with the problem and that the fix should solve it, however, it seems ugly to me to put an identity hash map implementation in to the already crowded VM_Statics. We could refactor VM_HashMap so that it has an overridable means of determining whether two values are equal and then create an identity hash map that overrides this method (to use == instead of .equals). We can then change the map for objects in VM_Statics to use an identity hashmap rather than a regular hashmap, and the rest of the code in VM_Statics can remain unchanged.
Hide
Yuval Yarom added a comment -

A second fix - following Ian's comment.

Show
Yuval Yarom added a comment - A second fix - following Ian's comment.
Hide
Ian Rogers added a comment -

Thanks Yuval, this change appears to be exposing a latent bug in the boot image in DaCapo's jython. I'm looking into it, here's the trace:

WARNING: bad level 'INFO'
java.lang.IllegalArgumentException: Not the name of a standard logging level: "INFO"
at java.util.logging.Level.parse(Level.java:363)
at java.util.logging.LogManager.readConfiguration(LogManager.java:593)
at java.util.logging.LogManager.readConfiguration(LogManager.java:527)
at java.util.logging.LogManager.initLogManager(LogManager.java:203)
at java.util.logging.LogManager.getLogManager(LogManager.java:168)
at java.util.logging.Logger.getLogger(Logger.java:276)
at java.util.logging.Logger.getLogger(Logger.java:224)
at java.util.logging.Logger$1.run(Logger.java:91)
at java.security.AccessController.doPrivileged(AccessController.java:96)
at java.util.logging.Logger.<clinit>(Logger.java:86)
at org.jikesrvm.VM.runClassInitializer(VM.java:475)
at org.jikesrvm.VM.finishBooting(VM.java:349)
at org.jikesrvm.VM.boot(VM.java:151)
sys-package-mgr: processing new jar, '/home/antigua/IanR/workspace/ligen/jikesrvm/components/dacapo/2006-10-MR2/dacapo.jar'
sys-package-mgr: processing new jar, '/home/antigua/IanR/workspace/ligen/jikesrvm/dist/development_ia32-linux/jksvm.jar'
sys-package-mgr: processing new jar, '/home/antigua/IanR/workspace/ligen/jikesrvm/dist/development_ia32-linux/rvmrt.jar'
error importing site
Traceback (innermost last):
File "/home/antigua/IanR/workspace/ligen/jikesrvm/./scratch/jython/Lib/site.py", line 66, in ?
AttributeError: 'stringmap' object has no attribute 'values'

Show
Ian Rogers added a comment - Thanks Yuval, this change appears to be exposing a latent bug in the boot image in DaCapo's jython. I'm looking into it, here's the trace: WARNING: bad level 'INFO' java.lang.IllegalArgumentException: Not the name of a standard logging level: "INFO" at java.util.logging.Level.parse(Level.java:363) at java.util.logging.LogManager.readConfiguration(LogManager.java:593) at java.util.logging.LogManager.readConfiguration(LogManager.java:527) at java.util.logging.LogManager.initLogManager(LogManager.java:203) at java.util.logging.LogManager.getLogManager(LogManager.java:168) at java.util.logging.Logger.getLogger(Logger.java:276) at java.util.logging.Logger.getLogger(Logger.java:224) at java.util.logging.Logger$1.run(Logger.java:91) at java.security.AccessController.doPrivileged(AccessController.java:96) at java.util.logging.Logger.<clinit>(Logger.java:86) at org.jikesrvm.VM.runClassInitializer(VM.java:475) at org.jikesrvm.VM.finishBooting(VM.java:349) at org.jikesrvm.VM.boot(VM.java:151) sys-package-mgr: processing new jar, '/home/antigua/IanR/workspace/ligen/jikesrvm/components/dacapo/2006-10-MR2/dacapo.jar' sys-package-mgr: processing new jar, '/home/antigua/IanR/workspace/ligen/jikesrvm/dist/development_ia32-linux/jksvm.jar' sys-package-mgr: processing new jar, '/home/antigua/IanR/workspace/ligen/jikesrvm/dist/development_ia32-linux/rvmrt.jar' error importing site Traceback (innermost last): File "/home/antigua/IanR/workspace/ligen/jikesrvm/./scratch/jython/Lib/site.py", line 66, in ? AttributeError: 'stringmap' object has no attribute 'values'
Hide
Ian Rogers added a comment -

So the problem is that VM_Statics.findStringLiteral is broken after this change, it's at least broken for Strings from the bootstrap compared to those created in the running VM.. we call findStringLiteral from java.lang.VMString.intern. I'm trying to think of the best fix.

Show
Ian Rogers added a comment - So the problem is that VM_Statics.findStringLiteral is broken after this change, it's at least broken for Strings from the bootstrap compared to those created in the running VM.. we call findStringLiteral from java.lang.VMString.intern. I'm trying to think of the best fix.
Hide
Ian Rogers added a comment -

Patch and fix to interning committed in r13956.

Show
Ian Rogers added a comment - Patch and fix to interning committed in r13956.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: