changeset 505:b900129cef2e

rebase to current hsx/hotspot-comp
author jrose
date Fri, 05 Oct 2012 16:42:57 -0700
parents c7d00d950bdb
children aa8f59e8372f
files final-obj.patch series value-obj.txt
diffstat 3 files changed, 50 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/final-obj.patch	Fri Oct 05 16:42:57 2012 -0700
@@ -0,0 +1,14 @@
+Infrastructure for immutable objects supporting "value types".
+  See https://blogs.oracle.com/jrose/entry/value_types_in_the_vm
+Rules:
+- objects marked immutable cannot be changed, even via privileged reflection
+- a non-array can be marked immutable, but only if all of its fields are 'final'
+- an array can be marked immutable, but then (of course) its elements cannot be stored to
+- an object marked immutable must be unreferenced by any other thread
+- the reference returned from the (unsafe) marking primitive must be used for all future accesses
+- any previous references (including the one passed to the marking primitive) must be unused
+- in practice, this means you must mark an object immutable immediately after constructing it
+- at the time it is marked immutable, an object must not be locked (in fact, should never have been?)
+- an immutable object should not be locked (you may get a hang or an IllegalMonitorStateException)
+- an immutable object should not be tested for pointer equality (there may be a test for this)
+- an immutable object should not be asked for its identity hash code (there may be a test for this)
--- a/series	Sun Sep 30 21:35:21 2012 -0700
+++ b/series	Fri Oct 05 16:42:57 2012 -0700
@@ -1,16 +1,16 @@
-# base = 7eca5de9e0b6 in http://hg.openjdk.java.net/hsx/hotspot-comp/hotspot [2012-09-20]
+# base = bf2edd3c9b0f in http://hg.openjdk.java.net/hsx/hotspot-comp/hotspot [2012-10-04]
 
 # review pending before push to hotspot-comp:
 
 # non-pushed files are under review or development, or merely experimental:
-anno-stable.patch               #-/meth #+7eca5de9e0b6 #-buildable
-meth.patch                      #-/meth #+7eca5de9e0b6
+anno-stable.patch               #-/meth #+bf2edd3c9b0f #-testable
+meth.patch                      #-/meth #+bf2edd3c9b0f
 
 meth.proj.patch                 #-/meth #+projects
 anonk.proj.patch                #-/anonk #+projects
 
 # Keep these separate, for debugging and review:
-tagu.patch      #+tagu          #-/tagu #+7eca5de9e0b6 #-buildable
+tagu.patch      #+tagu          #-/tagu #+89d0a5d40008 #-buildable
 inti.patch      #+inti          #-/inti #+d1605aabd0a1 #+jdk7-b30 #-buildable
 callcc_old.patch #+callcc_old   #-/callcc_old #+d6d1af32c5f9 #-testable
 continuation.patch  #+continuation #-/continuation #+4afae810a801
@@ -20,7 +20,7 @@
 hotswaplight.patch   #+hotswaplight       #-/hotswaplight
 
 # Coroutine patches: full version and simple version (no thread migration, no serialization, no stack sharing) 
-coro.patch                      #+coro          #(7eca5de9e0b6)
-coro-simple.patch               #+coro-simple   #(7eca5de9e0b6)
+coro.patch                      #+coro          #(bf2edd3c9b0f)
+coro-simple.patch               #+coro-simple   #(bf2edd3c9b0f)
 
 tuple-tsig.patch        #+tuple #-/tuple #-testable
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/value-obj.txt	Fri Oct 05 16:42:57 2012 -0700
@@ -0,0 +1,30 @@
+Infrastructure for immutable objects, in support of value types.
+See <http://blogs.oracle.com/jrose/entry/value_types_in_the_vm>
+
+The term _immutable_ is a general term for certain classes of data structures.
+Inside the JVM, we need a specific, positive term for an object which has been made immutable.
+We could say it has been _locked_ or _frozen_, but instead will repurpose the term _final_.
+This is not a perfect choice, since it is not related to finalizers.
+But it does allow intuitive API names like `Arrays.finalCopyOf` or `Objects.cloneAsFinal`.
+It will now apply in a consistent way, to individual objects, in addition to their fields.
+
+Rules:
+
+- restrictions on classes of final objects
+    - all fields must be final (what about static fields?)
+    - there must be no finalizer method (no override to Object.finalize)
+    - an array can be marked final, but then (of course) its elements cannot be stored to
+- restricted operations on final objects (could be enforced, or else documented as producing undefined results)
+    - do not use any astore or putfield instructions, nor their reflective equivalents, to change any field
+    - do not lock (you may get a hang or an IllegalMonitorStateException)
+    - do not test for pointer equality; use Object.equals instead (there may be a test for this)
+    - do not ask for an identity hash code; use Object.hashCode instead (there may be a test for this)
+    - do not call wait, notify, or notifyAll methods in Object
+    - at the time it is marked final, an object must not be locked (in fact, should never have been?)
+- lifecycle restrictions
+    - all objects are initially created in a non-final state
+    - an object marked final cannot be reverted to a non-final state
+    - an object marked final must be unreferenced by any other thread
+    - the reference returned from the (unsafe) marking primitive must be used for all future accesses
+    - any previous references (including the one passed to the marking primitive) must be unused
+    - in practice, this means you must mark an object final immediately after constructing it