--- a/.hgtags Mon Jul 27 22:28:29 2009 -0700
+++ b/.hgtags Tue Aug 04 08:01:03 2009 -0700
@@ -39,3 +39,5 @@
6107cbff3130c747d243c25a7874cd59db5744a8 jdk7-b62
dfd8506f74c3731bb169ce93c72612d78ee0413b jdk7-b63
d22867c5f1b295a0a2b3b4bc8999a2676f6e20c3 jdk7-b64
+7d3bf00f3cc4f8125de1842521e7567f37dc84b8 jdk7-b65
+62109d1b9e7310f29ab51ca6f1d71b899c0ce6b0 jdk7-b66
--- a/.hgtags-top-repo Mon Jul 27 22:28:29 2009 -0700
+++ b/.hgtags-top-repo Tue Aug 04 08:01:03 2009 -0700
@@ -39,3 +39,5 @@
c7ed15ab92ce36a09d264a5e34025884b2d7607f jdk7-b62
57f7e028c7ad1806500ae89eb3f4cd9a51b10e18 jdk7-b63
269c1ec4435dfb7b452ae6e3bdde005d55c5c830 jdk7-b64
+e01380cd1de4ce048b87d059d238e5ab5e341947 jdk7-b65
+6bad5e3fe50337d95b1416d744780d65bc570da6 jdk7-b66
--- a/corba/.hgtags Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/.hgtags Tue Aug 04 08:01:03 2009 -0700
@@ -39,3 +39,5 @@
65b66117dbd70a493e9644aeb4033cf95a4e3c99 jdk7-b62
d20e45cd539f20405ff843652069cfd7550c5ab3 jdk7-b63
047dd27fddb607f8135296b3754131f6e13cb8c7 jdk7-b64
+97fd9b42f5c2d342b90d18f0a2b57e4117e39415 jdk7-b65
+a821e059a961bcb02830280d51f6dd030425c066 jdk7-b66
--- a/corba/make/Makefile Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/make/Makefile Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2007-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/corba/make/common/Library.gmk Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/make/common/Library.gmk Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 1995-2007 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 1995-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/corba/make/common/Rules.gmk Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/make/common/Rules.gmk Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 1995-2007 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 1995-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/corba/make/common/shared/Compiler-gcc.gmk Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/make/common/shared/Compiler-gcc.gmk Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/corba/make/common/shared/Defs-java.gmk Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/make/common/shared/Defs-java.gmk Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 1995-2007 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 1995-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/corba/make/common/shared/Defs-windows.gmk Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/make/common/shared/Defs-windows.gmk Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 2005-2007 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/corba/make/common/shared/Platform.gmk Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/make/common/shared/Platform.gmk Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/corba/make/jprt.properties Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/make/jprt.properties Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2006-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/corba/make/org/omg/idl/Makefile Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/make/org/omg/idl/Makefile Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 1999-2005 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/corba/make/tools/logutil/Makefile Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/make/tools/logutil/Makefile Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/corba/src/share/classes/com/sun/corba/se/impl/encoding/BufferManagerReadStream.java Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/src/share/classes/com/sun/corba/se/impl/encoding/BufferManagerReadStream.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/corba/src/share/classes/com/sun/corba/se/impl/io/ObjectStreamClass.java Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/src/share/classes/com/sun/corba/se/impl/io/ObjectStreamClass.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/corba/src/share/classes/com/sun/corba/se/impl/oa/poa/POAFactory.java Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/src/share/classes/com/sun/corba/se/impl/oa/poa/POAFactory.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2002-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/corba/src/share/classes/com/sun/corba/se/impl/orb/ORBImpl.java Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/src/share/classes/com/sun/corba/se/impl/orb/ORBImpl.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2002-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/corba/src/share/classes/com/sun/corba/se/impl/orb/ORBSingleton.java Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/src/share/classes/com/sun/corba/se/impl/orb/ORBSingleton.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/ORBUtility.java Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/ORBUtility.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/IDLNameTranslatorImpl.java Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/src/share/classes/com/sun/corba/se/impl/presentation/rmi/IDLNameTranslatorImpl.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/corba/src/share/classes/com/sun/corba/se/impl/resolver/INSURLOperationImpl.java Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/src/share/classes/com/sun/corba/se/impl/resolver/INSURLOperationImpl.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/corba/src/share/classes/com/sun/corba/se/impl/transport/SocketOrChannelConnectionImpl.java Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/src/share/classes/com/sun/corba/se/impl/transport/SocketOrChannelConnectionImpl.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/corba/src/share/classes/com/sun/corba/se/spi/logging/data/ORBUtil.mc Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/src/share/classes/com/sun/corba/se/spi/logging/data/ORBUtil.mc Tue Aug 04 08:01:03 2009 -0700
@@ -1,6 +1,6 @@
;
-; Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
+; Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
; DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
;
; This code is free software; you can redistribute it and/or modify it
--- a/corba/src/share/classes/com/sun/tools/corba/se/idl/Parser.java Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/src/share/classes/com/sun/tools/corba/se/idl/Parser.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/corba/src/share/classes/com/sun/tools/corba/se/idl/first.set Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/src/share/classes/com/sun/tools/corba/se/idl/first.set Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/corba/src/share/classes/com/sun/tools/corba/se/idl/follow.set Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/src/share/classes/com/sun/tools/corba/se/idl/follow.set Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/corba/src/share/classes/com/sun/tools/corba/se/idl/grammar.idl Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/src/share/classes/com/sun/tools/corba/se/idl/grammar.idl Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/corba/src/share/classes/com/sun/tools/corba/se/idl/grammar3.idl Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/src/share/classes/com/sun/tools/corba/se/idl/grammar3.idl Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/corba/src/share/classes/com/sun/tools/corba/se/idl/idl.prp Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/src/share/classes/com/sun/tools/corba/se/idl/idl.prp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 1999-2004 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/corba/src/share/classes/com/sun/tools/corba/se/idl/idl_ja.prp Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/src/share/classes/com/sun/tools/corba/se/idl/idl_ja.prp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 1999-2005 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/corba/src/share/classes/com/sun/tools/corba/se/idl/idl_zh_CN.prp Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/src/share/classes/com/sun/tools/corba/se/idl/idl_zh_CN.prp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/toJavaPortable.prp Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/toJavaPortable.prp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 1999-2004 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/toJavaPortable_ja.prp Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/toJavaPortable_ja.prp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 2001-2005 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/toJavaPortable_zh_CN.prp Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/src/share/classes/com/sun/tools/corba/se/idl/toJavaPortable/toJavaPortable_zh_CN.prp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/corba/src/share/classes/com/sun/tools/corba/se/logutil/Input.java Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/src/share/classes/com/sun/tools/corba/se/logutil/Input.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/corba/src/share/classes/com/sun/tools/corba/se/logutil/InputCode.java Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/src/share/classes/com/sun/tools/corba/se/logutil/InputCode.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/corba/src/share/classes/com/sun/tools/corba/se/logutil/InputException.java Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/src/share/classes/com/sun/tools/corba/se/logutil/InputException.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/corba/src/share/classes/com/sun/tools/corba/se/logutil/MC.java Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/src/share/classes/com/sun/tools/corba/se/logutil/MC.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/corba/src/share/classes/org/omg/CORBA/ORB.java Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/src/share/classes/org/omg/CORBA/ORB.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1995-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/corba/src/windows/resource/version.rc Mon Jul 27 22:28:29 2009 -0700
+++ b/corba/src/windows/resource/version.rc Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
//
-// Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
+// Copyright 2004-2009 Sun Microsystems, Inc. All Rights Reserved.
// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
//
// This code is free software; you can redistribute it and/or modify it
--- a/hotspot/.hgtags Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/.hgtags Tue Aug 04 08:01:03 2009 -0700
@@ -39,3 +39,5 @@
a88386380bdaaa5ab4ffbedf22c57bac5dbec034 jdk7-b62
32c83fb84370a35344676991a48440378e6b6c8a jdk7-b63
ba36394eb84b949b31212bdb32a518a8f92bab5b jdk7-b64
+ba313800759b678979434d6da8ed3bf49eb8bea4 jdk7-b65
+57c71ad0341b8b64ed20f81151eb7f06324f8894 jdk7-b66
--- a/hotspot/agent/src/os/linux/Makefile Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/agent/src/os/linux/Makefile Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 2002-2006 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2002-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/HotSpotTypeDataBase.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/HotSpotTypeDataBase.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/DebugInfoReadStream.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/DebugInfoReadStream.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/MonitorValue.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/MonitorValue.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/ScopeDesc.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/ScopeDesc.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/ScopeValue.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/ScopeValue.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2001 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/Debugger.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/Debugger.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/DebuggerBase.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/DebuggerBase.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/JVMDebugger.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/JVMDebugger.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/remote/RemoteDebugger.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/remote/RemoteDebugger.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2002-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/remote/RemoteDebuggerClient.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/remote/RemoteDebuggerClient.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2002-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/remote/RemoteDebuggerServer.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/remote/RemoteDebuggerServer.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2002-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/ObjectReferenceImpl.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/ObjectReferenceImpl.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2002-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/ThreadReferenceImpl.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/ThreadReferenceImpl.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2002-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/Universe.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/Universe.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/ClassConstants.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/ClassConstants.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2002-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/CompiledVFrame.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/CompiledVFrame.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/InterpretedVFrame.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/InterpretedVFrame.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2001 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/JavaThread.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/JavaThread.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/MonitorInfo.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/MonitorInfo.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/StackValue.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/StackValue.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2001 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/StubRoutines.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/StubRoutines.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Thread.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Thread.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Threads.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Threads.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ByteCodeRewriter.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ByteCodeRewriter.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2004 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2002-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ClassDump.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ClassDump.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2004 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2002-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ClassWriter.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ClassWriter.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2004 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2002-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ui/tree/OopTreeNodeAdapter.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ui/tree/OopTreeNodeAdapter.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaThread.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaThread.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2004-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/make/hotspot_version Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/make/hotspot_version Tue Aug 04 08:01:03 2009 -0700
@@ -35,7 +35,7 @@
HS_MAJOR_VER=16
HS_MINOR_VER=0
-HS_BUILD_NUMBER=06
+HS_BUILD_NUMBER=07
JDK_MAJOR_VER=1
JDK_MINOR_VER=7
--- a/hotspot/make/jprt.properties Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/make/jprt.properties Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 2006-2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2006-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/hotspot/make/linux/makefiles/jsig.make Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/make/linux/makefiles/jsig.make Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/hotspot/make/linux/makefiles/saproc.make Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/make/linux/makefiles/saproc.make Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/hotspot/make/solaris/makefiles/optimized.make Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/make/solaris/makefiles/optimized.make Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/hotspot/make/solaris/makefiles/sparcWorks.make Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/make/solaris/makefiles/sparcWorks.make Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/hotspot/make/windows/build_vm_def.sh Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/make/windows/build_vm_def.sh Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/hotspot/make/windows/create.bat Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/make/windows/create.bat Tue Aug 04 08:01:03 2009 -0700
@@ -1,6 +1,6 @@
@echo off
REM
-REM Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
+REM Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
REM DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
REM
REM This code is free software; you can redistribute it and/or modify it
--- a/hotspot/make/windows/get_msc_ver.sh Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/make/windows/get_msc_ver.sh Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/hotspot/make/windows/makefiles/adlc.make Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/make/windows/makefiles/adlc.make Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/hotspot/make/windows/makefiles/compile.make Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/make/windows/makefiles/compile.make Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/hotspot/make/windows/makefiles/makedeps.make Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/make/windows/makefiles/makedeps.make Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/hotspot/make/windows/makefiles/rules.make Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/make/windows/makefiles/rules.make Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/hotspot/make/windows/makefiles/sa.make Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/make/windows/makefiles/sa.make Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/hotspot/make/windows/makefiles/sanity.make Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/make/windows/makefiles/sanity.make Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 2006-2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2006-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/hotspot/make/windows/makefiles/vm.make Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/make/windows/makefiles/vm.make Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/cpu/sparc/vm/assembler_sparc.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/cpu/sparc/vm/assembler_sparc.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -4208,6 +4208,7 @@
PtrQueue::byte_offset_of_active()),
tmp);
}
+
// Check on whether to annul.
br_on_reg_cond(rc_z, /*annul*/false, Assembler::pt, tmp, filtered);
delayed() -> nop();
@@ -4215,13 +4216,13 @@
// satb_log_barrier_work1(tmp, offset);
if (index == noreg) {
if (Assembler::is_simm13(offset)) {
- ld_ptr(obj, offset, tmp);
+ load_heap_oop(obj, offset, tmp);
} else {
set(offset, tmp);
- ld_ptr(obj, tmp, tmp);
+ load_heap_oop(obj, tmp, tmp);
}
} else {
- ld_ptr(obj, index, tmp);
+ load_heap_oop(obj, index, tmp);
}
// satb_log_barrier_work2(obj, tmp, offset);
--- a/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/cpu/sparc/vm/frame_sparc.inline.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/cpu/sparc/vm/frame_sparc.inline.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/cpu/sparc/vm/globals_sparc.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/cpu/sparc/vm/globals_sparc.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/cpu/x86/vm/assembler_x86.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/cpu/x86/vm/assembler_x86.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -6805,14 +6805,18 @@
jcc(Assembler::equal, done);
// if (x.f == NULL) goto done;
- cmpptr(Address(obj, 0), NULL_WORD);
+#ifdef _LP64
+ load_heap_oop(tmp2, Address(obj, 0));
+#else
+ movptr(tmp2, Address(obj, 0));
+#endif
+ cmpptr(tmp2, (int32_t) NULL_WORD);
jcc(Assembler::equal, done);
// Can we store original value in the thread's buffer?
- LP64_ONLY(movslq(tmp, index);)
- movptr(tmp2, Address(obj, 0));
#ifdef _LP64
+ movslq(tmp, index);
cmpq(tmp, 0);
#else
cmpl(index, 0);
@@ -6834,8 +6838,7 @@
if(tosca_live) push(rax);
push(obj);
#ifdef _LP64
- movq(c_rarg0, Address(obj, 0));
- call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), c_rarg0, r15_thread);
+ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), tmp2, r15_thread);
#else
push(thread);
call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), tmp2, thread);
--- a/hotspot/src/cpu/x86/vm/c1_MacroAssembler_x86.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/cpu/x86/vm/c1_MacroAssembler_x86.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/cpu/x86/vm/frame_x86.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/cpu/x86/vm/frame_x86.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/cpu/x86/vm/globals_x86.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/cpu/x86/vm/globals_x86.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/cpu/x86/vm/interpreterRT_x86_64.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/cpu/x86/vm/interpreterRT_x86_64.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/cpu/x86/vm/methodHandles_x86.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/cpu/x86/vm/methodHandles_x86.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -269,11 +269,11 @@
#ifndef PRODUCT
void trace_method_handle_stub(const char* adaptername,
- oop mh,
+ oopDesc* mh,
intptr_t* entry_sp,
intptr_t* saved_sp) {
// called as a leaf from native code: do not block the JVM!
- printf("MH %s "PTR_FORMAT" "PTR_FORMAT" "INTX_FORMAT"\n", adaptername, mh, entry_sp, entry_sp - saved_sp);
+ printf("MH %s "PTR_FORMAT" "PTR_FORMAT" "INTX_FORMAT"\n", adaptername, (void*)mh, entry_sp, entry_sp - saved_sp);
}
#endif //PRODUCT
--- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1302,22 +1302,19 @@
const Register ic_reg = rax;
const Register receiver = j_rarg0;
- const Register tmp = rdx;
Label ok;
Label exception_pending;
+ assert_different_registers(ic_reg, receiver, rscratch1);
__ verify_oop(receiver);
- __ push(tmp); // spill (any other registers free here???)
- __ load_klass(tmp, receiver);
- __ cmpq(ic_reg, tmp);
+ __ load_klass(rscratch1, receiver);
+ __ cmpq(ic_reg, rscratch1);
__ jcc(Assembler::equal, ok);
- __ pop(tmp);
__ jump(RuntimeAddress(SharedRuntime::get_ic_miss_stub()));
__ bind(ok);
- __ pop(tmp);
// Verified entry point must be aligned
__ align(8);
--- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -709,7 +709,7 @@
//
// Input:
// start - starting address
- // end - element count
+ // count - element count
void gen_write_ref_array_pre_barrier(Register start, Register count) {
assert_different_registers(start, count);
BarrierSet* bs = Universe::heap()->barrier_set();
@@ -757,7 +757,6 @@
__ call(RuntimeAddress(CAST_FROM_FN_PTR(address, BarrierSet::static_write_ref_array_post)));
__ addptr(rsp, 2*wordSize);
__ popa();
-
}
break;
--- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1207,9 +1207,9 @@
__ pusha(); // push registers (overkill)
// must compute element count unless barrier set interface is changed (other platforms supply count)
assert_different_registers(start, end, scratch);
- __ lea(scratch, Address(end, wordSize));
- __ subptr(scratch, start);
- __ shrptr(scratch, LogBytesPerWord);
+ __ lea(scratch, Address(end, BytesPerHeapOop));
+ __ subptr(scratch, start); // subtract start to get #bytes
+ __ shrptr(scratch, LogBytesPerHeapOop); // convert to element count
__ mov(c_rarg0, start);
__ mov(c_rarg1, scratch);
__ call(RuntimeAddress(CAST_FROM_FN_PTR(address, BarrierSet::static_write_ref_array_post)));
@@ -1225,6 +1225,7 @@
Label L_loop;
__ shrptr(start, CardTableModRefBS::card_shift);
+ __ addptr(end, BytesPerHeapOop);
__ shrptr(end, CardTableModRefBS::card_shift);
__ subptr(end, start); // number of bytes to copy
@@ -2251,6 +2252,7 @@
// and report their number to the caller.
assert_different_registers(rax, r14_length, count, to, end_to, rcx);
__ lea(end_to, to_element_addr);
+ __ addptr(end_to, -heapOopSize); // make an inclusive end pointer
gen_write_ref_array_post_barrier(to, end_to, rscratch1);
__ movptr(rax, r14_length); // original oops
__ addptr(rax, count); // K = (original - remaining) oops
@@ -2259,7 +2261,7 @@
// Come here on success only.
__ BIND(L_do_card_marks);
- __ addptr(end_to, -wordSize); // make an inclusive end pointer
+ __ addptr(end_to, -heapOopSize); // make an inclusive end pointer
gen_write_ref_array_post_barrier(to, end_to, rscratch1);
__ xorptr(rax, rax); // return 0 on success
--- a/hotspot/src/cpu/x86/vm/templateTable_x86_32.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/cpu/x86/vm/templateTable_x86_32.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/cpu/x86/vm/templateTable_x86_64.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/cpu/x86/vm/templateTable_x86_64.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/cpu/x86/vm/vtableStubs_x86_32.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/cpu/x86/vm/vtableStubs_x86_32.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/cpu/x86/vm/vtableStubs_x86_64.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/cpu/x86/vm/vtableStubs_x86_64.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/os/linux/vm/os_linux.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/os/linux/vm/os_linux.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/os/solaris/dtrace/generateJvmOffsets.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/os/solaris/dtrace/generateJvmOffsets.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/os/solaris/dtrace/jhelper.d Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/os/solaris/dtrace/jhelper.d Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/os/solaris/dtrace/libjvm_db.c Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/os/solaris/dtrace/libjvm_db.c Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/os_cpu/linux_sparc/vm/globals_linux_sparc.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/os_cpu/linux_sparc/vm/globals_linux_sparc.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/os_cpu/linux_x86/vm/globals_linux_x86.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/os_cpu/linux_x86/vm/globals_linux_x86.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/os_cpu/linux_x86/vm/orderAccess_linux_x86.inline.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/os_cpu/linux_x86/vm/orderAccess_linux_x86.inline.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/os_cpu/solaris_sparc/vm/globals_solaris_sparc.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/os_cpu/solaris_sparc/vm/globals_solaris_sparc.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2004 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/os_cpu/solaris_sparc/vm/orderAccess_solaris_sparc.inline.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/os_cpu/solaris_sparc/vm/orderAccess_solaris_sparc.inline.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2004 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/os_cpu/solaris_x86/vm/globals_solaris_x86.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/os_cpu/solaris_x86/vm/globals_solaris_x86.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/os_cpu/solaris_x86/vm/orderAccess_solaris_x86.inline.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/os_cpu/solaris_x86/vm/orderAccess_solaris_x86.inline.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/os_cpu/windows_x86/vm/globals_windows_x86.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/os_cpu/windows_x86/vm/globals_windows_x86.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/os_cpu/windows_x86/vm/orderAccess_windows_x86.inline.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/os_cpu/windows_x86/vm/orderAccess_windows_x86.inline.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/os_cpu/windows_x86/vm/os_windows_x86.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/os_cpu/windows_x86/vm/os_windows_x86.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/os_cpu/windows_x86/vm/os_windows_x86.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/os_cpu/windows_x86/vm/os_windows_x86.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2004 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/os_cpu/windows_x86/vm/unwind_windows_x86.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/os_cpu/windows_x86/vm/unwind_windows_x86.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2004-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/tools/MakeDeps/BuildConfig.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/tools/MakeDeps/BuildConfig.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/tools/MakeDeps/WinGammaPlatformVC7.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/tools/MakeDeps/WinGammaPlatformVC7.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/tools/MakeDeps/WinGammaPlatformVC8.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/tools/MakeDeps/WinGammaPlatformVC8.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/tools/MakeDeps/WinGammaPlatformVC9.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/tools/MakeDeps/WinGammaPlatformVC9.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/tools/hsdis/Makefile Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/tools/hsdis/Makefile Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/tools/hsdis/hsdis-demo.c Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/tools/hsdis/hsdis-demo.c Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/tools/hsdis/hsdis.c Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/tools/hsdis/hsdis.c Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/adlc/adlc.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/adlc/adlc.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/adlc/formssel.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/adlc/formssel.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -420,6 +420,13 @@
return _matrule->is_ideal_load();
}
+// Return 'true' if this instruction matches an ideal 'LoadKlass' node
+bool InstructForm::skip_antidep_check() const {
+ if( _matrule == NULL ) return false;
+
+ return _matrule->skip_antidep_check();
+}
+
// Return 'true' if this instruction matches an ideal 'Load?' node
Form::DataType InstructForm::is_ideal_store() const {
if( _matrule == NULL ) return Form::none;
@@ -567,6 +574,8 @@
// loads from memory, so must check for anti-dependence
bool InstructForm::needs_anti_dependence_check(FormDict &globals) const {
+ if ( skip_antidep_check() ) return false;
+
// Machine independent loads must be checked for anti-dependences
if( is_ideal_load() != Form::none ) return true;
@@ -3957,6 +3966,28 @@
}
+bool MatchRule::skip_antidep_check() const {
+ // Some loads operate on what is effectively immutable memory so we
+ // should skip the anti dep computations. For some of these nodes
+ // the rewritable field keeps the anti dep logic from triggering but
+ // for certain kinds of LoadKlass it does not since they are
+ // actually reading memory which could be rewritten by the runtime,
+ // though never by generated code. This disables it uniformly for
+ // the nodes that behave like this: LoadKlass, LoadNKlass and
+ // LoadRange.
+ if ( _opType && (strcmp(_opType,"Set") == 0) && _rChild ) {
+ const char *opType = _rChild->_opType;
+ if (strcmp("LoadKlass", opType) == 0 ||
+ strcmp("LoadNKlass", opType) == 0 ||
+ strcmp("LoadRange", opType) == 0) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
Form::DataType MatchRule::is_ideal_store() const {
Form::DataType ideal_store = Form::none;
--- a/hotspot/src/share/vm/adlc/formssel.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/adlc/formssel.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -158,6 +158,9 @@
virtual Form::CallType is_ideal_call() const; // matches ideal 'Call'
virtual Form::DataType is_ideal_load() const; // node matches ideal 'LoadXNode'
+ // Should antidep checks be disabled for this Instruct
+ // See definition of MatchRule::skip_antidep_check
+ bool skip_antidep_check() const;
virtual Form::DataType is_ideal_store() const;// node matches ideal 'StoreXNode'
bool is_ideal_mem() const { return is_ideal_load() != Form::none || is_ideal_store() != Form::none; }
virtual uint two_address(FormDict &globals); // output reg must match input reg
@@ -1003,6 +1006,9 @@
bool is_ideal_loopEnd() const; // node matches ideal 'LoopEnd'
bool is_ideal_bool() const; // node matches ideal 'Bool'
Form::DataType is_ideal_load() const;// node matches ideal 'LoadXNode'
+ // Should antidep checks be disabled for this rule
+ // See definition of MatchRule::skip_antidep_check
+ bool skip_antidep_check() const;
Form::DataType is_ideal_store() const;// node matches ideal 'StoreXNode'
// Check if 'mRule2' is a cisc-spill variant of this MatchRule
--- a/hotspot/src/share/vm/asm/assembler.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/asm/assembler.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/c1/c1_Compilation.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/c1/c1_Compilation.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/c1/c1_LinearScan.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/c1/c1_LinearScan.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/ci/bcEscapeAnalyzer.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/ci/bcEscapeAnalyzer.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/ci/ciEnv.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/ci/ciEnv.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/ci/ciEnv.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/ci/ciEnv.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/ci/ciMethodBlocks.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/ci/ciMethodBlocks.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2006-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2006-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/ci/ciStreams.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/ci/ciStreams.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/ci/ciStreams.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/ci/ciStreams.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/ci/ciTypeFlow.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/ci/ciTypeFlow.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -3231,6 +3231,16 @@
this_klass->set_minor_version(minor_version);
this_klass->set_major_version(major_version);
+ // Set up methodOop::intrinsic_id as soon as we know the names of methods.
+ // (We used to do this lazily, but now we query it in Rewriter,
+ // which is eagerly done for every method, so we might as well do it now,
+ // when everything is fresh in memory.)
+ if (methodOopDesc::klass_id_for_intrinsics(this_klass->as_klassOop()) != vmSymbols::NO_SID) {
+ for (int j = 0; j < methods->length(); j++) {
+ ((methodOop)methods->obj_at(j))->init_intrinsic_id();
+ }
+ }
+
if (cached_class_file_bytes != NULL) {
// JVMTI: we have an instanceKlass now, tell it about the cached bytes
this_klass->set_cached_class_file(cached_class_file_bytes,
--- a/hotspot/src/share/vm/classfile/classLoader.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/classfile/classLoader.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/classfile/verifier.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/classfile/verifier.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/classfile/vmSymbols.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -513,9 +513,6 @@
//
// for Emacs: (let ((c-backslash-column 120) (c-backslash-max-column 120)) (c-backslash-region (point) (point-max) nil t))
#define VM_INTRINSICS_DO(do_intrinsic, do_class, do_name, do_signature, do_alias) \
- do_intrinsic(_Object_init, java_lang_Object, object_initializer_name, void_method_signature, F_R) \
- /* (symbol object_initializer_name defined above) */ \
- \
do_intrinsic(_hashCode, java_lang_Object, hashCode_name, void_int_signature, F_R) \
do_name( hashCode_name, "hashCode") \
do_intrinsic(_getClass, java_lang_Object, getClass_name, void_class_signature, F_R) \
@@ -635,9 +632,6 @@
do_intrinsic(_equalsC, java_util_Arrays, equals_name, equalsC_signature, F_S) \
do_signature(equalsC_signature, "([C[C)Z") \
\
- do_intrinsic(_invoke, java_lang_reflect_Method, invoke_name, object_array_object_object_signature, F_R) \
- /* (symbols invoke_name and invoke_signature defined above) */ \
- \
do_intrinsic(_compareTo, java_lang_String, compareTo_name, string_int_signature, F_R) \
do_name( compareTo_name, "compareTo") \
do_intrinsic(_indexOf, java_lang_String, indexOf_name, string_int_signature, F_R) \
@@ -656,8 +650,6 @@
do_name( attemptUpdate_name, "attemptUpdate") \
do_signature(attemptUpdate_signature, "(JJ)Z") \
\
- do_intrinsic(_fillInStackTrace, java_lang_Throwable, fillInStackTrace_name, void_throwable_signature, F_RNY) \
- \
/* support for sun.misc.Unsafe */ \
do_class(sun_misc_Unsafe, "sun/misc/Unsafe") \
\
@@ -819,10 +811,22 @@
do_name( prefetchReadStatic_name, "prefetchReadStatic") \
do_intrinsic(_prefetchWriteStatic, sun_misc_Unsafe, prefetchWriteStatic_name, prefetch_signature, F_SN) \
do_name( prefetchWriteStatic_name, "prefetchWriteStatic") \
+ /*== LAST_COMPILER_INLINE*/ \
+ /*the compiler does have special inlining code for these; bytecode inline is just fine */ \
+ \
+ do_intrinsic(_fillInStackTrace, java_lang_Throwable, fillInStackTrace_name, void_throwable_signature, F_RNY) \
+ \
+ do_intrinsic(_Object_init, java_lang_Object, object_initializer_name, void_method_signature, F_R) \
+ /* (symbol object_initializer_name defined above) */ \
+ \
+ do_intrinsic(_invoke, java_lang_reflect_Method, invoke_name, object_array_object_object_signature, F_R) \
+ /* (symbols invoke_name and invoke_signature defined above) */ \
+ \
/*end*/
+
// Class vmSymbols
class vmSymbols: AllStatic {
@@ -935,6 +939,7 @@
#undef VM_INTRINSIC_ENUM
ID_LIMIT,
+ LAST_COMPILER_INLINE = _prefetchWriteStatic,
FIRST_ID = _none + 1
};
@@ -972,4 +977,7 @@
static Flags flags_for(ID id);
static const char* short_name_as_C_string(ID id, char* buf, int size);
+
+ // Access to intrinsic methods:
+ static methodOop method_for(ID id);
};
--- a/hotspot/src/share/vm/code/vtableStubs.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/code/vtableStubs.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/compiler/compileBroker.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/compiler/compileBroker.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/compiler/oopMap.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/compiler/oopMap.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -379,7 +379,15 @@
if ( loc != NULL ) {
oop *base_loc = fr->oopmapreg_to_location(omv.content_reg(), reg_map);
oop *derived_loc = loc;
- derived_oop_fn(base_loc, derived_loc);
+ oop val = *base_loc;
+ if (val == (oop)NULL || Universe::is_narrow_oop_base(val)) {
+ // Ignore NULL oops and decoded NULL narrow oops which
+ // equal to Universe::narrow_oop_base when a narrow oop
+ // implicit null check is used in compiled code.
+ // The narrow_oop_base could be NULL or be the address
+ // of the page below heap depending on compressed oops mode.
+ } else
+ derived_oop_fn(base_loc, derived_loc);
}
oms.next();
} while (!oms.is_done());
@@ -394,6 +402,15 @@
oop* loc = fr->oopmapreg_to_location(omv.reg(),reg_map);
if ( loc != NULL ) {
if ( omv.type() == OopMapValue::oop_value ) {
+ oop val = *loc;
+ if (val == (oop)NULL || Universe::is_narrow_oop_base(val)) {
+ // Ignore NULL oops and decoded NULL narrow oops which
+ // equal to Universe::narrow_oop_base when a narrow oop
+ // implicit null check is used in compiled code.
+ // The narrow_oop_base could be NULL or be the address
+ // of the page below heap depending on compressed oops mode.
+ continue;
+ }
#ifdef ASSERT
if ((((uintptr_t)loc & (sizeof(*loc)-1)) != 0) ||
!Universe::heap()->is_in_or_null(*loc)) {
@@ -410,6 +427,8 @@
#endif // ASSERT
oop_fn->do_oop(loc);
} else if ( omv.type() == OopMapValue::value_value ) {
+ assert((*loc) == (oop)NULL || !Universe::is_narrow_oop_base(*loc),
+ "found invalid value pointer");
value_fn->do_oop(loc);
} else if ( omv.type() == OopMapValue::narrowoop_value ) {
narrowOop *nl = (narrowOop*)loc;
--- a/hotspot/src/share/vm/compiler/oopMap.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/compiler/oopMap.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -233,6 +233,10 @@
int heap_size() const;
void copy_to(address addr);
+ // Methods oops_do() and all_do() filter out NULL oops and
+ // oop == Universe::narrow_oop_base() before passing oops
+ // to closures.
+
// Iterates through frame for a compiled method
static void oops_do (const frame* fr,
const RegisterMap* reg_map, OopClosure* f);
--- a/hotspot/src/share/vm/gc_implementation/g1/bufferingOopClosure.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/bufferingOopClosure.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -42,35 +42,40 @@
BufferLength = 1024
};
- oop *_buffer[BufferLength];
- oop **_buffer_top;
- oop **_buffer_curr;
+ StarTask _buffer[BufferLength];
+ StarTask* _buffer_top;
+ StarTask* _buffer_curr;
- OopClosure *_oc;
- double _closure_app_seconds;
+ OopClosure* _oc;
+ double _closure_app_seconds;
void process_buffer () {
-
double start = os::elapsedTime();
- for (oop **curr = _buffer; curr < _buffer_curr; ++curr) {
- _oc->do_oop(*curr);
+ for (StarTask* curr = _buffer; curr < _buffer_curr; ++curr) {
+ if (curr->is_narrow()) {
+ assert(UseCompressedOops, "Error");
+ _oc->do_oop((narrowOop*)(*curr));
+ } else {
+ _oc->do_oop((oop*)(*curr));
+ }
}
_buffer_curr = _buffer;
_closure_app_seconds += (os::elapsedTime() - start);
}
-public:
- virtual void do_oop(narrowOop* p) {
- guarantee(false, "NYI");
- }
- virtual void do_oop(oop *p) {
+ template <class T> inline void do_oop_work(T* p) {
if (_buffer_curr == _buffer_top) {
process_buffer();
}
-
- *_buffer_curr = p;
+ StarTask new_ref(p);
+ *_buffer_curr = new_ref;
++_buffer_curr;
}
+
+public:
+ virtual void do_oop(narrowOop* p) { do_oop_work(p); }
+ virtual void do_oop(oop* p) { do_oop_work(p); }
+
void done () {
if (_buffer_curr > _buffer) {
process_buffer();
@@ -88,18 +93,17 @@
class BufferingOopsInGenClosure: public OopsInGenClosure {
BufferingOopClosure _boc;
OopsInGenClosure* _oc;
-public:
+ protected:
+ template <class T> inline void do_oop_work(T* p) {
+ assert(generation()->is_in_reserved((void*)p), "Must be in!");
+ _boc.do_oop(p);
+ }
+ public:
BufferingOopsInGenClosure(OopsInGenClosure *oc) :
_boc(oc), _oc(oc) {}
- virtual void do_oop(narrowOop* p) {
- guarantee(false, "NYI");
- }
-
- virtual void do_oop(oop* p) {
- assert(generation()->is_in_reserved(p), "Must be in!");
- _boc.do_oop(p);
- }
+ virtual void do_oop(narrowOop* p) { do_oop_work(p); }
+ virtual void do_oop(oop* p) { do_oop_work(p); }
void done() {
_boc.done();
@@ -130,14 +134,14 @@
BufferLength = 1024
};
- oop *_buffer[BufferLength];
- oop **_buffer_top;
- oop **_buffer_curr;
+ StarTask _buffer[BufferLength];
+ StarTask* _buffer_top;
+ StarTask* _buffer_curr;
- HeapRegion *_hr_buffer[BufferLength];
- HeapRegion **_hr_curr;
+ HeapRegion* _hr_buffer[BufferLength];
+ HeapRegion** _hr_curr;
- OopsInHeapRegionClosure *_oc;
+ OopsInHeapRegionClosure* _oc;
double _closure_app_seconds;
void process_buffer () {
@@ -146,15 +150,20 @@
"the two lengths should be the same");
double start = os::elapsedTime();
- HeapRegion **hr_curr = _hr_buffer;
- HeapRegion *hr_prev = NULL;
- for (oop **curr = _buffer; curr < _buffer_curr; ++curr) {
- HeapRegion *region = *hr_curr;
+ HeapRegion** hr_curr = _hr_buffer;
+ HeapRegion* hr_prev = NULL;
+ for (StarTask* curr = _buffer; curr < _buffer_curr; ++curr) {
+ HeapRegion* region = *hr_curr;
if (region != hr_prev) {
_oc->set_region(region);
hr_prev = region;
}
- _oc->do_oop(*curr);
+ if (curr->is_narrow()) {
+ assert(UseCompressedOops, "Error");
+ _oc->do_oop((narrowOop*)(*curr));
+ } else {
+ _oc->do_oop((oop*)(*curr));
+ }
++hr_curr;
}
_buffer_curr = _buffer;
@@ -163,17 +172,16 @@
}
public:
- virtual void do_oop(narrowOop *p) {
- guarantee(false, "NYI");
- }
+ virtual void do_oop(narrowOop* p) { do_oop_work(p); }
+ virtual void do_oop( oop* p) { do_oop_work(p); }
- virtual void do_oop(oop *p) {
+ template <class T> void do_oop_work(T* p) {
if (_buffer_curr == _buffer_top) {
assert(_hr_curr > _hr_buffer, "_hr_curr should be consistent with _buffer_curr");
process_buffer();
}
-
- *_buffer_curr = p;
+ StarTask new_ref(p);
+ *_buffer_curr = new_ref;
++_buffer_curr;
*_hr_curr = _from;
++_hr_curr;
--- a/hotspot/src/share/vm/gc_implementation/g1/collectionSetChooser.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/collectionSetChooser.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentG1RefineThread.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentG1RefineThread.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentG1RefineThread.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentG1RefineThread.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -452,13 +452,10 @@
_regionStack.allocate(G1MarkRegionStackSize);
// Create & start a ConcurrentMark thread.
- if (G1ConcMark) {
- _cmThread = new ConcurrentMarkThread(this);
- assert(cmThread() != NULL, "CM Thread should have been created");
- assert(cmThread()->cm() != NULL, "CM Thread should refer to this cm");
- } else {
- _cmThread = NULL;
- }
+ _cmThread = new ConcurrentMarkThread(this);
+ assert(cmThread() != NULL, "CM Thread should have been created");
+ assert(cmThread()->cm() != NULL, "CM Thread should refer to this cm");
+
_g1h = G1CollectedHeap::heap();
assert(CGC_lock != NULL, "Where's the CGC_lock?");
assert(_markBitMap1.covers(rs), "_markBitMap1 inconsistency");
@@ -783,18 +780,18 @@
bool do_barrier) : _cm(cm), _g1h(g1h),
_do_barrier(do_barrier) { }
- virtual void do_oop(narrowOop* p) {
- guarantee(false, "NYI");
- }
-
- virtual void do_oop(oop* p) {
- oop thisOop = *p;
- if (thisOop != NULL) {
- assert(thisOop->is_oop() || thisOop->mark() == NULL,
+ virtual void do_oop(narrowOop* p) { do_oop_work(p); }
+ virtual void do_oop( oop* p) { do_oop_work(p); }
+
+ template <class T> void do_oop_work(T* p) {
+ T heap_oop = oopDesc::load_heap_oop(p);
+ if (!oopDesc::is_null(heap_oop)) {
+ oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
+ assert(obj->is_oop() || obj->mark() == NULL,
"expected an oop, possibly with mark word displaced");
- HeapWord* addr = (HeapWord*)thisOop;
+ HeapWord* addr = (HeapWord*)obj;
if (_g1h->is_in_g1_reserved(addr)) {
- _cm->grayRoot(thisOop);
+ _cm->grayRoot(obj);
}
}
if (_do_barrier) {
@@ -850,16 +847,6 @@
double start = os::elapsedTime();
GCOverheadReporter::recordSTWStart(start);
- // If there has not been a GC[n-1] since last GC[n] cycle completed,
- // precede our marking with a collection of all
- // younger generations to keep floating garbage to a minimum.
- // YSR: we won't do this for now -- it's an optimization to be
- // done post-beta.
-
- // YSR: ignoring weak refs for now; will do at bug fixing stage
- // EVM: assert(discoveredRefsAreClear());
-
-
G1CollectorPolicy* g1p = G1CollectedHeap::heap()->g1_policy();
g1p->record_concurrent_mark_init_start();
checkpointRootsInitialPre();
@@ -1135,6 +1122,13 @@
return;
}
+ if (VerifyDuringGC) {
+ HandleMark hm; // handle scope
+ gclog_or_tty->print(" VerifyDuringGC:(before)");
+ Universe::heap()->prepare_for_verify();
+ Universe::verify(true, false, true);
+ }
+
G1CollectorPolicy* g1p = g1h->g1_policy();
g1p->record_concurrent_mark_remark_start();
@@ -1159,10 +1153,12 @@
JavaThread::satb_mark_queue_set().set_active_all_threads(false);
if (VerifyDuringGC) {
- g1h->prepare_for_verify();
- g1h->verify(/* allow_dirty */ true,
- /* silent */ false,
- /* use_prev_marking */ false);
+ HandleMark hm; // handle scope
+ gclog_or_tty->print(" VerifyDuringGC:(after)");
+ Universe::heap()->prepare_for_verify();
+ Universe::heap()->verify(/* allow_dirty */ true,
+ /* silent */ false,
+ /* use_prev_marking */ false);
}
}
@@ -1658,6 +1654,15 @@
return;
}
+ if (VerifyDuringGC) {
+ HandleMark hm; // handle scope
+ gclog_or_tty->print(" VerifyDuringGC:(before)");
+ Universe::heap()->prepare_for_verify();
+ Universe::verify(/* allow dirty */ true,
+ /* silent */ false,
+ /* prev marking */ true);
+ }
+
_cleanup_co_tracker.disable();
G1CollectorPolicy* g1p = G1CollectedHeap::heap()->g1_policy();
@@ -1790,10 +1795,12 @@
g1h->increment_total_collections();
if (VerifyDuringGC) {
- g1h->prepare_for_verify();
- g1h->verify(/* allow_dirty */ true,
- /* silent */ false,
- /* use_prev_marking */ true);
+ HandleMark hm; // handle scope
+ gclog_or_tty->print(" VerifyDuringGC:(after)");
+ Universe::heap()->prepare_for_verify();
+ Universe::verify(/* allow dirty */ true,
+ /* silent */ false,
+ /* prev marking */ true);
}
}
@@ -1852,12 +1859,11 @@
_g1(g1), _cm(cm),
_bitMap(bitMap) {}
- void do_oop(narrowOop* p) {
- guarantee(false, "NYI");
- }
-
- void do_oop(oop* p) {
- oop thisOop = *p;
+ virtual void do_oop(narrowOop* p) { do_oop_work(p); }
+ virtual void do_oop( oop* p) { do_oop_work(p); }
+
+ template <class T> void do_oop_work(T* p) {
+ oop thisOop = oopDesc::load_decode_heap_oop(p);
HeapWord* addr = (HeapWord*)thisOop;
if (_g1->is_in_g1_reserved(addr) && _g1->is_obj_ill(thisOop)) {
_bitMap->mark(addr);
@@ -2016,12 +2022,11 @@
ReachablePrinterOopClosure(CMBitMapRO* bitmap, outputStream* out) :
_bitmap(bitmap), _g1h(G1CollectedHeap::heap()), _out(out) { }
- void do_oop(narrowOop* p) {
- guarantee(false, "NYI");
- }
-
- void do_oop(oop* p) {
- oop obj = *p;
+ void do_oop(narrowOop* p) { do_oop_work(p); }
+ void do_oop( oop* p) { do_oop_work(p); }
+
+ template <class T> void do_oop_work(T* p) {
+ oop obj = oopDesc::load_decode_heap_oop(p);
const char* str = NULL;
const char* str2 = "";
@@ -2163,6 +2168,7 @@
HeapWord* objAddr = (HeapWord*) obj;
+ assert(obj->is_oop_or_null(true /* ignore mark word */), "Error");
if (_g1h->is_in_g1_reserved(objAddr)) {
tmp_guarantee_CM( obj != NULL, "is_in_g1_reserved should ensure this" );
HeapRegion* hr = _g1h->heap_region_containing(obj);
@@ -2380,7 +2386,7 @@
}
}
- bool drain() {
+ template <class T> bool drain() {
while (_ms_ind > 0) {
oop obj = pop();
assert(obj != NULL, "Since index was non-zero.");
@@ -2394,9 +2400,8 @@
}
// Now process this portion of this one.
int lim = MIN2(next_arr_ind, len);
- assert(!UseCompressedOops, "This needs to be fixed");
for (int j = arr_ind; j < lim; j++) {
- do_oop(aobj->obj_at_addr<oop>(j));
+ do_oop(aobj->obj_at_addr<T>(j));
}
} else {
@@ -2423,13 +2428,13 @@
FREE_C_HEAP_ARRAY(jint, _array_ind_stack);
}
- void do_oop(narrowOop* p) {
- guarantee(false, "NYI");
- }
-
- void do_oop(oop* p) {
- oop obj = *p;
- if (obj == NULL) return;
+ virtual void do_oop(narrowOop* p) { do_oop_work(p); }
+ virtual void do_oop( oop* p) { do_oop_work(p); }
+
+ template <class T> void do_oop_work(T* p) {
+ T heap_oop = oopDesc::load_heap_oop(p);
+ if (oopDesc::is_null(heap_oop)) return;
+ oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
if (obj->is_forwarded()) {
// If the object has already been forwarded, we have to make sure
// that it's marked. So follow the forwarding pointer. Note that
@@ -2478,7 +2483,11 @@
oop obj = oop(addr);
if (!obj->is_forwarded()) {
if (!_oop_cl.push(obj)) return false;
- if (!_oop_cl.drain()) return false;
+ if (UseCompressedOops) {
+ if (!_oop_cl.drain<narrowOop>()) return false;
+ } else {
+ if (!_oop_cl.drain<oop>()) return false;
+ }
}
// Otherwise...
return true;
@@ -2636,9 +2645,6 @@
// abandon current marking iteration due to a Full GC
void ConcurrentMark::abort() {
- // If we're not marking, nothing to do.
- if (!G1ConcMark) return;
-
// Clear all marks to force marking thread to do nothing
_nextMarkBitMap->clearAll();
// Empty mark stack
@@ -2814,14 +2820,14 @@
CMTask* _task;
public:
- void do_oop(narrowOop* p) {
- guarantee(false, "NYI");
- }
-
- void do_oop(oop* p) {
+ virtual void do_oop(narrowOop* p) { do_oop_work(p); }
+ virtual void do_oop( oop* p) { do_oop_work(p); }
+
+ template <class T> void do_oop_work(T* p) {
tmp_guarantee_CM( _g1h->is_in_g1_reserved((HeapWord*) p), "invariant" );
-
- oop obj = *p;
+ tmp_guarantee_CM( !_g1h->heap_region_containing((HeapWord*) p)->is_on_free_list(), "invariant" );
+
+ oop obj = oopDesc::load_decode_heap_oop(p);
if (_cm->verbose_high())
gclog_or_tty->print_cr("[%d] we're looking at location "
"*"PTR_FORMAT" = "PTR_FORMAT,
@@ -2967,6 +2973,7 @@
++_refs_reached;
HeapWord* objAddr = (HeapWord*) obj;
+ assert(obj->is_oop_or_null(true /* ignore mark word */), "Error");
if (_g1h->is_in_g1_reserved(objAddr)) {
tmp_guarantee_CM( obj != NULL, "is_in_g1_reserved should ensure this" );
HeapRegion* hr = _g1h->heap_region_containing(obj);
@@ -3030,6 +3037,7 @@
void CMTask::push(oop obj) {
HeapWord* objAddr = (HeapWord*) obj;
tmp_guarantee_CM( _g1h->is_in_g1_reserved(objAddr), "invariant" );
+ tmp_guarantee_CM( !_g1h->heap_region_containing(objAddr)->is_on_free_list(), "invariant" );
tmp_guarantee_CM( !_g1h->is_obj_ill(obj), "invariant" );
tmp_guarantee_CM( _nextMarkBitMap->isMarked(objAddr), "invariant" );
@@ -3275,6 +3283,8 @@
tmp_guarantee_CM( _g1h->is_in_g1_reserved((HeapWord*) obj),
"invariant" );
+ tmp_guarantee_CM( !_g1h->heap_region_containing(obj)->is_on_free_list(),
+ "invariant" );
scan_object(obj);
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -763,6 +763,7 @@
CMBitMap* _nextMarkBitMap;
// the task queue of this task
CMTaskQueue* _task_queue;
+private:
// the task queue set---needed for stealing
CMTaskQueueSet* _task_queues;
// indicates whether the task has been claimed---this is only for
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMarkThread.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMarkThread.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentZFThread.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentZFThread.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/gc_implementation/g1/dirtyCardQueue.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/dirtyCardQueue.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -424,7 +424,7 @@
while (n <= next_boundary) {
q = n;
oop obj = oop(q);
- if (obj->klass() == NULL) return q;
+ if (obj->klass_or_null() == NULL) return q;
n += obj->size();
}
assert(q <= next_boundary && n > next_boundary, "Consequence of loop");
@@ -436,7 +436,7 @@
while (n <= next_boundary) {
q = n;
oop obj = oop(q);
- if (obj->klass() == NULL) return q;
+ if (obj->klass_or_null() == NULL) return q;
n += _sp->block_size(q);
}
assert(q <= next_boundary && n > next_boundary, "Consequence of loop");
--- a/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.inline.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.inline.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -96,14 +96,14 @@
while (n <= addr) {
q = n;
oop obj = oop(q);
- if (obj->klass() == NULL) return q;
+ if (obj->klass_or_null() == NULL) return q;
n += obj->size();
}
} else {
while (n <= addr) {
q = n;
oop obj = oop(q);
- if (obj->klass() == NULL) return q;
+ if (obj->klass_or_null() == NULL) return q;
n += _sp->block_size(q);
}
}
@@ -115,7 +115,7 @@
inline HeapWord*
G1BlockOffsetArray::forward_to_block_containing_addr(HeapWord* q,
const void* addr) {
- if (oop(q)->klass() == NULL) return q;
+ if (oop(q)->klass_or_null() == NULL) return q;
HeapWord* n = q + _sp->block_size(q);
// In the normal case, where the query "addr" is a card boundary, and the
// offset table chunks are the same size as cards, the block starting at
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1658,8 +1658,15 @@
assert(Heap_lock->owner() != NULL,
"Should be owned on this thread's behalf.");
size_t result = _summary_bytes_used;
- if (_cur_alloc_region != NULL)
- result += _cur_alloc_region->used();
+ // Read only once in case it is set to NULL concurrently
+ HeapRegion* hr = _cur_alloc_region;
+ if (hr != NULL)
+ result += hr->used();
+ return result;
+}
+
+size_t G1CollectedHeap::used_unlocked() const {
+ size_t result = _summary_bytes_used;
return result;
}
@@ -2133,13 +2140,13 @@
VerifyLivenessOopClosure(G1CollectedHeap* _g1h) {
g1h = _g1h;
}
- void do_oop(narrowOop *p) {
- guarantee(false, "NYI");
- }
- void do_oop(oop *p) {
- oop obj = *p;
- assert(obj == NULL || !g1h->is_obj_dead(obj),
- "Dead object referenced by a not dead object");
+ void do_oop(narrowOop *p) { do_oop_work(p); }
+ void do_oop( oop *p) { do_oop_work(p); }
+
+ template <class T> void do_oop_work(T *p) {
+ oop obj = oopDesc::load_decode_heap_oop(p);
+ guarantee(obj == NULL || !g1h->is_obj_dead(obj),
+ "Dead object referenced by a not dead object");
}
};
@@ -2206,8 +2213,10 @@
// use_prev_marking == true -> use "prev" marking information,
// use_prev_marking == false -> use "next" marking information
VerifyRegionClosure(bool allow_dirty, bool par, bool use_prev_marking)
- : _allow_dirty(allow_dirty), _par(par),
+ : _allow_dirty(allow_dirty),
+ _par(par),
_use_prev_marking(use_prev_marking) {}
+
bool doHeapRegion(HeapRegion* r) {
guarantee(_par || r->claim_value() == HeapRegion::InitialClaimValue,
"Should be unclaimed at verify points.");
@@ -2231,18 +2240,16 @@
// use_prev_marking == true -> use "prev" marking information,
// use_prev_marking == false -> use "next" marking information
VerifyRootsClosure(bool use_prev_marking) :
- _g1h(G1CollectedHeap::heap()), _failures(false),
+ _g1h(G1CollectedHeap::heap()),
+ _failures(false),
_use_prev_marking(use_prev_marking) { }
bool failures() { return _failures; }
- void do_oop(narrowOop* p) {
- guarantee(false, "NYI");
- }
-
- void do_oop(oop* p) {
- oop obj = *p;
- if (obj != NULL) {
+ template <class T> void do_oop_nv(T* p) {
+ T heap_oop = oopDesc::load_heap_oop(p);
+ if (!oopDesc::is_null(heap_oop)) {
+ oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
if (_g1h->is_obj_dead_cond(obj, _use_prev_marking)) {
gclog_or_tty->print_cr("Root location "PTR_FORMAT" "
"points to dead obj "PTR_FORMAT, p, (void*) obj);
@@ -2251,6 +2258,9 @@
}
}
}
+
+ void do_oop(oop* p) { do_oop_nv(p); }
+ void do_oop(narrowOop* p) { do_oop_nv(p); }
};
// This is the task used for parallel heap verification.
@@ -2267,7 +2277,8 @@
G1ParVerifyTask(G1CollectedHeap* g1h, bool allow_dirty,
bool use_prev_marking) :
AbstractGangTask("Parallel verify task"),
- _g1h(g1h), _allow_dirty(allow_dirty),
+ _g1h(g1h),
+ _allow_dirty(allow_dirty),
_use_prev_marking(use_prev_marking) { }
void work(int worker_i) {
@@ -2342,7 +2353,7 @@
void G1CollectedHeap::print_on(outputStream* st, bool extended) const {
st->print(" %-20s", "garbage-first heap");
st->print(" total " SIZE_FORMAT "K, used " SIZE_FORMAT "K",
- capacity()/K, used()/K);
+ capacity()/K, used_unlocked()/K);
st->print(" [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " INTPTR_FORMAT ")",
_g1_storage.low_boundary(),
_g1_storage.high(),
@@ -2479,12 +2490,10 @@
void
G1CollectedHeap::doConcurrentMark() {
- if (G1ConcMark) {
- MutexLockerEx x(CGC_lock, Mutex::_no_safepoint_check_flag);
- if (!_cmThread->in_progress()) {
- _cmThread->set_started();
- CGC_lock->notify();
- }
+ MutexLockerEx x(CGC_lock, Mutex::_no_safepoint_check_flag);
+ if (!_cmThread->in_progress()) {
+ _cmThread->set_started();
+ CGC_lock->notify();
}
}
@@ -2561,9 +2570,11 @@
"Not enough space for young surv words summary.");
}
memset(_surviving_young_words, 0, array_length * sizeof(size_t));
+#ifdef ASSERT
for (size_t i = 0; i < array_length; ++i) {
- guarantee( _surviving_young_words[i] == 0, "invariant" );
- }
+ assert( _surviving_young_words[i] == 0, "memset above" );
+ }
+#endif // !ASSERT
}
void
@@ -2649,7 +2660,7 @@
COMPILER2_PRESENT(DerivedPointerTable::clear());
// We want to turn off ref discovery, if necessary, and turn it back on
- // on again later if we do.
+ // on again later if we do. XXX Dubious: why is discovery disabled?
bool was_enabled = ref_processor()->discovery_enabled();
if (was_enabled) ref_processor()->disable_discovery();
@@ -2662,9 +2673,6 @@
double start_time_sec = os::elapsedTime();
GCOverheadReporter::recordSTWStart(start_time_sec);
size_t start_used_bytes = used();
- if (!G1ConcMark) {
- do_sync_mark();
- }
g1_policy()->record_collection_pause_start(start_time_sec,
start_used_bytes);
@@ -2775,6 +2783,13 @@
g1_policy()->should_initiate_conc_mark()) {
concurrent_mark()->checkpointRootsInitialPost();
set_marking_started();
+ // CAUTION: after the doConcurrentMark() call below,
+ // the concurrent marking thread(s) could be running
+ // concurrently with us. Make sure that anything after
+ // this point does not assume that we are the only GC thread
+ // running. Note: of course, the actual marking work will
+ // not start until the safepoint itself is released in
+ // ConcurrentGCThread::safepoint_desynchronize().
doConcurrentMark();
}
@@ -2965,6 +2980,7 @@
for (int ap = 0; ap < GCAllocPurposeCount; ++ap) {
assert(_gc_alloc_regions[ap] == NULL, "invariant");
+ assert(_gc_alloc_region_counts[ap] == 0, "invariant");
// Create new GC alloc regions.
HeapRegion* alloc_region = _retained_gc_alloc_regions[ap];
@@ -2993,6 +3009,9 @@
if (alloc_region == NULL) {
// we will get a new GC alloc region
alloc_region = newAllocRegionWithExpansion(ap, 0);
+ } else {
+ // the region was retained from the last collection
+ ++_gc_alloc_region_counts[ap];
}
if (alloc_region != NULL) {
@@ -3031,11 +3050,11 @@
for (int ap = 0; ap < GCAllocPurposeCount; ++ap) {
HeapRegion* r = _gc_alloc_regions[ap];
_retained_gc_alloc_regions[ap] = NULL;
+ _gc_alloc_region_counts[ap] = 0;
if (r != NULL) {
// we retain nothing on _gc_alloc_regions between GCs
set_gc_alloc_region(ap, NULL);
- _gc_alloc_region_counts[ap] = 0;
if (r->is_empty()) {
// we didn't actually allocate anything in it; let's just put
@@ -3123,10 +3142,8 @@
G1CollectedHeap* _g1;
public:
G1KeepAliveClosure(G1CollectedHeap* g1) : _g1(g1) {}
- void do_oop(narrowOop* p) {
- guarantee(false, "NYI");
- }
- void do_oop(oop* p) {
+ void do_oop(narrowOop* p) { guarantee(false, "Not needed"); }
+ void do_oop( oop* p) {
oop obj = *p;
#ifdef G1_DEBUG
if (PrintGC && Verbose) {
@@ -3138,7 +3155,6 @@
if (_g1->obj_in_cs(obj)) {
assert( obj->is_forwarded(), "invariant" );
*p = obj->forwardee();
-
#ifdef G1_DEBUG
gclog_or_tty->print_cr(" in CSet: moved "PTR_FORMAT" -> "PTR_FORMAT,
(void*) obj, (void*) *p);
@@ -3155,12 +3171,12 @@
UpdateRSetImmediate(G1CollectedHeap* g1) :
_g1(g1), _g1_rem_set(g1->g1_rem_set()) {}
- void do_oop(narrowOop* p) {
- guarantee(false, "NYI");
- }
- void do_oop(oop* p) {
+ virtual void do_oop(narrowOop* p) { do_oop_work(p); }
+ virtual void do_oop( oop* p) { do_oop_work(p); }
+ template <class T> void do_oop_work(T* p) {
assert(_from->is_in_reserved(p), "paranoia");
- if (*p != NULL && !_from->is_survivor()) {
+ T heap_oop = oopDesc::load_heap_oop(p);
+ if (!oopDesc::is_null(heap_oop) && !_from->is_survivor()) {
_g1_rem_set->par_write_ref(_from, p, 0);
}
}
@@ -3176,12 +3192,12 @@
UpdateRSetDeferred(G1CollectedHeap* g1, DirtyCardQueue* dcq) :
_g1(g1), _ct_bs((CardTableModRefBS*)_g1->barrier_set()), _dcq(dcq) {}
- void do_oop(narrowOop* p) {
- guarantee(false, "NYI");
- }
- void do_oop(oop* p) {
+ virtual void do_oop(narrowOop* p) { do_oop_work(p); }
+ virtual void do_oop( oop* p) { do_oop_work(p); }
+ template <class T> void do_oop_work(T* p) {
assert(_from->is_in_reserved(p), "paranoia");
- if (!_from->is_in_reserved(*p) && !_from->is_survivor()) {
+ if (!_from->is_in_reserved(oopDesc::load_decode_heap_oop(p)) &&
+ !_from->is_survivor()) {
size_t card_index = _ct_bs->index_for(p);
if (_ct_bs->mark_card_deferred(card_index)) {
_dcq->enqueue((jbyte*)_ct_bs->byte_for_index(card_index));
@@ -3536,614 +3552,66 @@
fill_with_object(block, free_words);
}
-#define use_local_bitmaps 1
-#define verify_local_bitmaps 0
-
#ifndef PRODUCT
-
-class GCLabBitMap;
-class GCLabBitMapClosure: public BitMapClosure {
-private:
- ConcurrentMark* _cm;
- GCLabBitMap* _bitmap;
-
-public:
- GCLabBitMapClosure(ConcurrentMark* cm,
- GCLabBitMap* bitmap) {
- _cm = cm;
- _bitmap = bitmap;
- }
-
- virtual bool do_bit(size_t offset);
-};
-
-#endif // PRODUCT
-
-#define oop_buffer_length 256
-
-class GCLabBitMap: public BitMap {
-private:
- ConcurrentMark* _cm;
-
- int _shifter;
- size_t _bitmap_word_covers_words;
-
- // beginning of the heap
- HeapWord* _heap_start;
-
- // this is the actual start of the GCLab
- HeapWord* _real_start_word;
-
- // this is the actual end of the GCLab
- HeapWord* _real_end_word;
-
- // this is the first word, possibly located before the actual start
- // of the GCLab, that corresponds to the first bit of the bitmap
- HeapWord* _start_word;
-
- // size of a GCLab in words
- size_t _gclab_word_size;
-
- static int shifter() {
- return MinObjAlignment - 1;
- }
-
- // how many heap words does a single bitmap word corresponds to?
- static size_t bitmap_word_covers_words() {
- return BitsPerWord << shifter();
- }
-
- static size_t gclab_word_size() {
- return G1ParallelGCAllocBufferSize / HeapWordSize;
- }
-
- static size_t bitmap_size_in_bits() {
- size_t bits_in_bitmap = gclab_word_size() >> shifter();
- // We are going to ensure that the beginning of a word in this
- // bitmap also corresponds to the beginning of a word in the
- // global marking bitmap. To handle the case where a GCLab
- // starts from the middle of the bitmap, we need to add enough
- // space (i.e. up to a bitmap word) to ensure that we have
- // enough bits in the bitmap.
- return bits_in_bitmap + BitsPerWord - 1;
- }
-public:
- GCLabBitMap(HeapWord* heap_start)
- : BitMap(bitmap_size_in_bits()),
- _cm(G1CollectedHeap::heap()->concurrent_mark()),
- _shifter(shifter()),
- _bitmap_word_covers_words(bitmap_word_covers_words()),
- _heap_start(heap_start),
- _gclab_word_size(gclab_word_size()),
- _real_start_word(NULL),
- _real_end_word(NULL),
- _start_word(NULL)
- {
- guarantee( size_in_words() >= bitmap_size_in_words(),
- "just making sure");
- }
-
- inline unsigned heapWordToOffset(HeapWord* addr) {
- unsigned offset = (unsigned) pointer_delta(addr, _start_word) >> _shifter;
- assert(offset < size(), "offset should be within bounds");
- return offset;
- }
-
- inline HeapWord* offsetToHeapWord(size_t offset) {
- HeapWord* addr = _start_word + (offset << _shifter);
- assert(_real_start_word <= addr && addr < _real_end_word, "invariant");
- return addr;
- }
-
- bool fields_well_formed() {
- bool ret1 = (_real_start_word == NULL) &&
- (_real_end_word == NULL) &&
- (_start_word == NULL);
- if (ret1)
- return true;
-
- bool ret2 = _real_start_word >= _start_word &&
- _start_word < _real_end_word &&
- (_real_start_word + _gclab_word_size) == _real_end_word &&
- (_start_word + _gclab_word_size + _bitmap_word_covers_words)
- > _real_end_word;
- return ret2;
- }
-
- inline bool mark(HeapWord* addr) {
- guarantee(use_local_bitmaps, "invariant");
- assert(fields_well_formed(), "invariant");
-
- if (addr >= _real_start_word && addr < _real_end_word) {
- assert(!isMarked(addr), "should not have already been marked");
-
- // first mark it on the bitmap
- at_put(heapWordToOffset(addr), true);
-
- return true;
- } else {
- return false;
- }
- }
-
- inline bool isMarked(HeapWord* addr) {
- guarantee(use_local_bitmaps, "invariant");
- assert(fields_well_formed(), "invariant");
-
- return at(heapWordToOffset(addr));
- }
-
- void set_buffer(HeapWord* start) {
- guarantee(use_local_bitmaps, "invariant");
- clear();
-
- assert(start != NULL, "invariant");
- _real_start_word = start;
- _real_end_word = start + _gclab_word_size;
-
- size_t diff =
- pointer_delta(start, _heap_start) % _bitmap_word_covers_words;
- _start_word = start - diff;
-
- assert(fields_well_formed(), "invariant");
- }
-
-#ifndef PRODUCT
- void verify() {
- // verify that the marks have been propagated
- GCLabBitMapClosure cl(_cm, this);
- iterate(&cl);
- }
-#endif // PRODUCT
-
- void retire() {
- guarantee(use_local_bitmaps, "invariant");
- assert(fields_well_formed(), "invariant");
-
- if (_start_word != NULL) {
- CMBitMap* mark_bitmap = _cm->nextMarkBitMap();
-
- // this means that the bitmap was set up for the GCLab
- assert(_real_start_word != NULL && _real_end_word != NULL, "invariant");
-
- mark_bitmap->mostly_disjoint_range_union(this,
- 0, // always start from the start of the bitmap
- _start_word,
- size_in_words());
- _cm->grayRegionIfNecessary(MemRegion(_real_start_word, _real_end_word));
-
-#ifndef PRODUCT
- if (use_local_bitmaps && verify_local_bitmaps)
- verify();
-#endif // PRODUCT
- } else {
- assert(_real_start_word == NULL && _real_end_word == NULL, "invariant");
- }
- }
-
- static size_t bitmap_size_in_words() {
- return (bitmap_size_in_bits() + BitsPerWord - 1) / BitsPerWord;
- }
-};
-
-#ifndef PRODUCT
-
bool GCLabBitMapClosure::do_bit(size_t offset) {
HeapWord* addr = _bitmap->offsetToHeapWord(offset);
guarantee(_cm->isMarked(oop(addr)), "it should be!");
return true;
}
-
#endif // PRODUCT
-class G1ParGCAllocBuffer: public ParGCAllocBuffer {
-private:
- bool _retired;
- bool _during_marking;
- GCLabBitMap _bitmap;
-
-public:
- G1ParGCAllocBuffer() :
- ParGCAllocBuffer(G1ParallelGCAllocBufferSize / HeapWordSize),
- _during_marking(G1CollectedHeap::heap()->mark_in_progress()),
- _bitmap(G1CollectedHeap::heap()->reserved_region().start()),
- _retired(false)
- { }
-
- inline bool mark(HeapWord* addr) {
- guarantee(use_local_bitmaps, "invariant");
- assert(_during_marking, "invariant");
- return _bitmap.mark(addr);
- }
-
- inline void set_buf(HeapWord* buf) {
- if (use_local_bitmaps && _during_marking)
- _bitmap.set_buffer(buf);
- ParGCAllocBuffer::set_buf(buf);
- _retired = false;
- }
-
- inline void retire(bool end_of_gc, bool retain) {
- if (_retired)
- return;
- if (use_local_bitmaps && _during_marking) {
- _bitmap.retire();
- }
- ParGCAllocBuffer::retire(end_of_gc, retain);
- _retired = true;
- }
-};
-
-
-class G1ParScanThreadState : public StackObj {
-protected:
- G1CollectedHeap* _g1h;
- RefToScanQueue* _refs;
- DirtyCardQueue _dcq;
- CardTableModRefBS* _ct_bs;
- G1RemSet* _g1_rem;
-
- typedef GrowableArray<oop*> OverflowQueue;
- OverflowQueue* _overflowed_refs;
-
- G1ParGCAllocBuffer _alloc_buffers[GCAllocPurposeCount];
- ageTable _age_table;
-
- size_t _alloc_buffer_waste;
- size_t _undo_waste;
-
- OopsInHeapRegionClosure* _evac_failure_cl;
- G1ParScanHeapEvacClosure* _evac_cl;
- G1ParScanPartialArrayClosure* _partial_scan_cl;
-
- int _hash_seed;
- int _queue_num;
-
- int _term_attempts;
+G1ParScanThreadState::G1ParScanThreadState(G1CollectedHeap* g1h, int queue_num)
+ : _g1h(g1h),
+ _refs(g1h->task_queue(queue_num)),
+ _dcq(&g1h->dirty_card_queue_set()),
+ _ct_bs((CardTableModRefBS*)_g1h->barrier_set()),
+ _g1_rem(g1h->g1_rem_set()),
+ _hash_seed(17), _queue_num(queue_num),
+ _term_attempts(0),
+ _age_table(false),
#if G1_DETAILED_STATS
- int _pushes, _pops, _steals, _steal_attempts;
- int _overflow_pushes;
-#endif
-
- double _start;
- double _start_strong_roots;
- double _strong_roots_time;
- double _start_term;
- double _term_time;
-
- // Map from young-age-index (0 == not young, 1 is youngest) to
- // surviving words. base is what we get back from the malloc call
- size_t* _surviving_young_words_base;
- // this points into the array, as we use the first few entries for padding
- size_t* _surviving_young_words;
-
-#define PADDING_ELEM_NUM (64 / sizeof(size_t))
-
- void add_to_alloc_buffer_waste(size_t waste) { _alloc_buffer_waste += waste; }
-
- void add_to_undo_waste(size_t waste) { _undo_waste += waste; }
-
- DirtyCardQueue& dirty_card_queue() { return _dcq; }
- CardTableModRefBS* ctbs() { return _ct_bs; }
-
- void immediate_rs_update(HeapRegion* from, oop* p, int tid) {
- if (!from->is_survivor()) {
- _g1_rem->par_write_ref(from, p, tid);
- }
- }
-
- void deferred_rs_update(HeapRegion* from, oop* p, int tid) {
- // If the new value of the field points to the same region or
- // is the to-space, we don't need to include it in the Rset updates.
- if (!from->is_in_reserved(*p) && !from->is_survivor()) {
- size_t card_index = ctbs()->index_for(p);
- // If the card hasn't been added to the buffer, do it.
- if (ctbs()->mark_card_deferred(card_index)) {
- dirty_card_queue().enqueue((jbyte*)ctbs()->byte_for_index(card_index));
- }
- }
- }
-
-public:
- G1ParScanThreadState(G1CollectedHeap* g1h, int queue_num)
- : _g1h(g1h),
- _refs(g1h->task_queue(queue_num)),
- _dcq(&g1h->dirty_card_queue_set()),
- _ct_bs((CardTableModRefBS*)_g1h->barrier_set()),
- _g1_rem(g1h->g1_rem_set()),
- _hash_seed(17), _queue_num(queue_num),
- _term_attempts(0),
- _age_table(false),
-#if G1_DETAILED_STATS
- _pushes(0), _pops(0), _steals(0),
- _steal_attempts(0), _overflow_pushes(0),
+ _pushes(0), _pops(0), _steals(0),
+ _steal_attempts(0), _overflow_pushes(0),
#endif
- _strong_roots_time(0), _term_time(0),
- _alloc_buffer_waste(0), _undo_waste(0)
- {
- // we allocate G1YoungSurvRateNumRegions plus one entries, since
- // we "sacrifice" entry 0 to keep track of surviving bytes for
- // non-young regions (where the age is -1)
- // We also add a few elements at the beginning and at the end in
- // an attempt to eliminate cache contention
- size_t real_length = 1 + _g1h->g1_policy()->young_cset_length();
- size_t array_length = PADDING_ELEM_NUM +
- real_length +
- PADDING_ELEM_NUM;
- _surviving_young_words_base = NEW_C_HEAP_ARRAY(size_t, array_length);
- if (_surviving_young_words_base == NULL)
- vm_exit_out_of_memory(array_length * sizeof(size_t),
- "Not enough space for young surv histo.");
- _surviving_young_words = _surviving_young_words_base + PADDING_ELEM_NUM;
- memset(_surviving_young_words, 0, real_length * sizeof(size_t));
-
- _overflowed_refs = new OverflowQueue(10);
-
- _start = os::elapsedTime();
- }
-
- ~G1ParScanThreadState() {
- FREE_C_HEAP_ARRAY(size_t, _surviving_young_words_base);
- }
-
- RefToScanQueue* refs() { return _refs; }
- OverflowQueue* overflowed_refs() { return _overflowed_refs; }
- ageTable* age_table() { return &_age_table; }
-
- G1ParGCAllocBuffer* alloc_buffer(GCAllocPurpose purpose) {
- return &_alloc_buffers[purpose];
- }
-
- size_t alloc_buffer_waste() { return _alloc_buffer_waste; }
- size_t undo_waste() { return _undo_waste; }
-
- void push_on_queue(oop* ref) {
- assert(ref != NULL, "invariant");
- assert(has_partial_array_mask(ref) || _g1h->obj_in_cs(*ref), "invariant");
-
- if (!refs()->push(ref)) {
- overflowed_refs()->push(ref);
- IF_G1_DETAILED_STATS(note_overflow_push());
- } else {
- IF_G1_DETAILED_STATS(note_push());
- }
- }
-
- void pop_from_queue(oop*& ref) {
- if (!refs()->pop_local(ref)) {
- ref = NULL;
- } else {
- assert(ref != NULL, "invariant");
- assert(has_partial_array_mask(ref) || _g1h->obj_in_cs(*ref),
- "invariant");
-
- IF_G1_DETAILED_STATS(note_pop());
- }
- }
-
- void pop_from_overflow_queue(oop*& ref) {
- ref = overflowed_refs()->pop();
- }
-
- int refs_to_scan() { return refs()->size(); }
- int overflowed_refs_to_scan() { return overflowed_refs()->length(); }
-
- void update_rs(HeapRegion* from, oop* p, int tid) {
- if (G1DeferredRSUpdate) {
- deferred_rs_update(from, p, tid);
- } else {
- immediate_rs_update(from, p, tid);
- }
- }
-
- HeapWord* allocate_slow(GCAllocPurpose purpose, size_t word_sz) {
-
- HeapWord* obj = NULL;
- if (word_sz * 100 <
- (size_t)(G1ParallelGCAllocBufferSize / HeapWordSize) *
- ParallelGCBufferWastePct) {
- G1ParGCAllocBuffer* alloc_buf = alloc_buffer(purpose);
- add_to_alloc_buffer_waste(alloc_buf->words_remaining());
- alloc_buf->retire(false, false);
-
- HeapWord* buf =
- _g1h->par_allocate_during_gc(purpose, G1ParallelGCAllocBufferSize / HeapWordSize);
- if (buf == NULL) return NULL; // Let caller handle allocation failure.
- // Otherwise.
- alloc_buf->set_buf(buf);
-
- obj = alloc_buf->allocate(word_sz);
- assert(obj != NULL, "buffer was definitely big enough...");
- } else {
- obj = _g1h->par_allocate_during_gc(purpose, word_sz);
- }
- return obj;
- }
-
- HeapWord* allocate(GCAllocPurpose purpose, size_t word_sz) {
- HeapWord* obj = alloc_buffer(purpose)->allocate(word_sz);
- if (obj != NULL) return obj;
- return allocate_slow(purpose, word_sz);
- }
-
- void undo_allocation(GCAllocPurpose purpose, HeapWord* obj, size_t word_sz) {
- if (alloc_buffer(purpose)->contains(obj)) {
- guarantee(alloc_buffer(purpose)->contains(obj + word_sz - 1),
- "should contain whole object");
- alloc_buffer(purpose)->undo_allocation(obj, word_sz);
- } else {
- CollectedHeap::fill_with_object(obj, word_sz);
- add_to_undo_waste(word_sz);
- }
- }
-
- void set_evac_failure_closure(OopsInHeapRegionClosure* evac_failure_cl) {
- _evac_failure_cl = evac_failure_cl;
- }
- OopsInHeapRegionClosure* evac_failure_closure() {
- return _evac_failure_cl;
- }
-
- void set_evac_closure(G1ParScanHeapEvacClosure* evac_cl) {
- _evac_cl = evac_cl;
- }
-
- void set_partial_scan_closure(G1ParScanPartialArrayClosure* partial_scan_cl) {
- _partial_scan_cl = partial_scan_cl;
- }
-
- int* hash_seed() { return &_hash_seed; }
- int queue_num() { return _queue_num; }
-
- int term_attempts() { return _term_attempts; }
- void note_term_attempt() { _term_attempts++; }
-
-#if G1_DETAILED_STATS
- int pushes() { return _pushes; }
- int pops() { return _pops; }
- int steals() { return _steals; }
- int steal_attempts() { return _steal_attempts; }
- int overflow_pushes() { return _overflow_pushes; }
-
- void note_push() { _pushes++; }
- void note_pop() { _pops++; }
- void note_steal() { _steals++; }
- void note_steal_attempt() { _steal_attempts++; }
- void note_overflow_push() { _overflow_pushes++; }
-#endif
-
- void start_strong_roots() {
- _start_strong_roots = os::elapsedTime();
- }
- void end_strong_roots() {
- _strong_roots_time += (os::elapsedTime() - _start_strong_roots);
- }
- double strong_roots_time() { return _strong_roots_time; }
-
- void start_term_time() {
- note_term_attempt();
- _start_term = os::elapsedTime();
- }
- void end_term_time() {
- _term_time += (os::elapsedTime() - _start_term);
- }
- double term_time() { return _term_time; }
-
- double elapsed() {
- return os::elapsedTime() - _start;
- }
-
- size_t* surviving_young_words() {
- // We add on to hide entry 0 which accumulates surviving words for
- // age -1 regions (i.e. non-young ones)
- return _surviving_young_words;
- }
-
- void retire_alloc_buffers() {
- for (int ap = 0; ap < GCAllocPurposeCount; ++ap) {
- size_t waste = _alloc_buffers[ap].words_remaining();
- add_to_alloc_buffer_waste(waste);
- _alloc_buffers[ap].retire(true, false);
- }
- }
-
-private:
- void deal_with_reference(oop* ref_to_scan) {
- if (has_partial_array_mask(ref_to_scan)) {
- _partial_scan_cl->do_oop_nv(ref_to_scan);
- } else {
- // Note: we can use "raw" versions of "region_containing" because
- // "obj_to_scan" is definitely in the heap, and is not in a
- // humongous region.
- HeapRegion* r = _g1h->heap_region_containing_raw(ref_to_scan);
- _evac_cl->set_region(r);
- _evac_cl->do_oop_nv(ref_to_scan);
- }
- }
-
-public:
- void trim_queue() {
- // I've replicated the loop twice, first to drain the overflow
- // queue, second to drain the task queue. This is better than
- // having a single loop, which checks both conditions and, inside
- // it, either pops the overflow queue or the task queue, as each
- // loop is tighter. Also, the decision to drain the overflow queue
- // first is not arbitrary, as the overflow queue is not visible
- // to the other workers, whereas the task queue is. So, we want to
- // drain the "invisible" entries first, while allowing the other
- // workers to potentially steal the "visible" entries.
-
- while (refs_to_scan() > 0 || overflowed_refs_to_scan() > 0) {
- while (overflowed_refs_to_scan() > 0) {
- oop *ref_to_scan = NULL;
- pop_from_overflow_queue(ref_to_scan);
- assert(ref_to_scan != NULL, "invariant");
- // We shouldn't have pushed it on the queue if it was not
- // pointing into the CSet.
- assert(ref_to_scan != NULL, "sanity");
- assert(has_partial_array_mask(ref_to_scan) ||
- _g1h->obj_in_cs(*ref_to_scan), "sanity");
-
- deal_with_reference(ref_to_scan);
- }
-
- while (refs_to_scan() > 0) {
- oop *ref_to_scan = NULL;
- pop_from_queue(ref_to_scan);
-
- if (ref_to_scan != NULL) {
- // We shouldn't have pushed it on the queue if it was not
- // pointing into the CSet.
- assert(has_partial_array_mask(ref_to_scan) ||
- _g1h->obj_in_cs(*ref_to_scan), "sanity");
-
- deal_with_reference(ref_to_scan);
- }
- }
- }
- }
-};
+ _strong_roots_time(0), _term_time(0),
+ _alloc_buffer_waste(0), _undo_waste(0)
+{
+ // we allocate G1YoungSurvRateNumRegions plus one entries, since
+ // we "sacrifice" entry 0 to keep track of surviving bytes for
+ // non-young regions (where the age is -1)
+ // We also add a few elements at the beginning and at the end in
+ // an attempt to eliminate cache contention
+ size_t real_length = 1 + _g1h->g1_policy()->young_cset_length();
+ size_t array_length = PADDING_ELEM_NUM +
+ real_length +
+ PADDING_ELEM_NUM;
+ _surviving_young_words_base = NEW_C_HEAP_ARRAY(size_t, array_length);
+ if (_surviving_young_words_base == NULL)
+ vm_exit_out_of_memory(array_length * sizeof(size_t),
+ "Not enough space for young surv histo.");
+ _surviving_young_words = _surviving_young_words_base + PADDING_ELEM_NUM;
+ memset(_surviving_young_words, 0, real_length * sizeof(size_t));
+
+ _overflowed_refs = new OverflowQueue(10);
+
+ _start = os::elapsedTime();
+}
G1ParClosureSuper::G1ParClosureSuper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) :
_g1(g1), _g1_rem(_g1->g1_rem_set()), _cm(_g1->concurrent_mark()),
_par_scan_state(par_scan_state) { }
-// This closure is applied to the fields of the objects that have just been copied.
-// Should probably be made inline and moved in g1OopClosures.inline.hpp.
-void G1ParScanClosure::do_oop_nv(oop* p) {
- oop obj = *p;
-
- if (obj != NULL) {
- if (_g1->in_cset_fast_test(obj)) {
- // We're not going to even bother checking whether the object is
- // already forwarded or not, as this usually causes an immediate
- // stall. We'll try to prefetch the object (for write, given that
- // we might need to install the forwarding reference) and we'll
- // get back to it when pop it from the queue
- Prefetch::write(obj->mark_addr(), 0);
- Prefetch::read(obj->mark_addr(), (HeapWordSize*2));
-
- // slightly paranoid test; I'm trying to catch potential
- // problems before we go into push_on_queue to know where the
- // problem is coming from
- assert(obj == *p, "the value of *p should not have changed");
- _par_scan_state->push_on_queue(p);
- } else {
- _par_scan_state->update_rs(_from, p, _par_scan_state->queue_num());
- }
- }
-}
-
-void G1ParCopyHelper::mark_forwardee(oop* p) {
+template <class T> void G1ParCopyHelper::mark_forwardee(T* p) {
// This is called _after_ do_oop_work has been called, hence after
// the object has been relocated to its new location and *p points
// to its new location.
- oop thisOop = *p;
- if (thisOop != NULL) {
- assert((_g1->evacuation_failed()) || (!_g1->obj_in_cs(thisOop)),
+ T heap_oop = oopDesc::load_heap_oop(p);
+ if (!oopDesc::is_null(heap_oop)) {
+ oop obj = oopDesc::decode_heap_oop(heap_oop);
+ assert((_g1->evacuation_failed()) || (!_g1->obj_in_cs(obj)),
"shouldn't still be in the CSet if evacuation didn't fail.");
- HeapWord* addr = (HeapWord*)thisOop;
+ HeapWord* addr = (HeapWord*)obj;
if (_g1->is_in_g1_reserved(addr))
_cm->grayRoot(oop(addr));
}
@@ -4226,7 +3694,8 @@
if (obj->is_objArray() && arrayOop(obj)->length() >= ParGCArrayScanChunk) {
arrayOop(old)->set_length(0);
- _par_scan_state->push_on_queue(set_partial_array_mask(old));
+ oop* old_p = set_partial_array_mask(old);
+ _par_scan_state->push_on_queue(old_p);
} else {
// No point in using the slower heap_region_containing() method,
// given that we know obj is in the heap.
@@ -4240,11 +3709,11 @@
return obj;
}
-template<bool do_gen_barrier, G1Barrier barrier,
- bool do_mark_forwardee, bool skip_cset_test>
-void G1ParCopyClosure<do_gen_barrier, barrier,
- do_mark_forwardee, skip_cset_test>::do_oop_work(oop* p) {
- oop obj = *p;
+template <bool do_gen_barrier, G1Barrier barrier, bool do_mark_forwardee, bool skip_cset_test>
+template <class T>
+void G1ParCopyClosure <do_gen_barrier, barrier, do_mark_forwardee, skip_cset_test>
+::do_oop_work(T* p) {
+ oop obj = oopDesc::load_decode_heap_oop(p);
assert(barrier != G1BarrierRS || obj != NULL,
"Precondition: G1BarrierRS implies obj is nonNull");
@@ -4261,9 +3730,10 @@
"into CS.", p, (void*) obj);
#endif
if (obj->is_forwarded()) {
- *p = obj->forwardee();
+ oopDesc::encode_store_heap_oop(p, obj->forwardee());
} else {
- *p = copy_to_survivor_space(obj);
+ oop copy_oop = copy_to_survivor_space(obj);
+ oopDesc::encode_store_heap_oop(p, copy_oop);
}
// When scanning the RS, we only care about objs in CS.
if (barrier == G1BarrierRS) {
@@ -4282,21 +3752,9 @@
}
template void G1ParCopyClosure<false, G1BarrierEvac, false, true>::do_oop_work(oop* p);
-
-template<class T> void G1ParScanPartialArrayClosure::process_array_chunk(
- oop obj, int start, int end) {
- // process our set of indices (include header in first chunk)
- assert(start < end, "invariant");
- T* const base = (T*)objArrayOop(obj)->base();
- T* const start_addr = (start == 0) ? (T*) obj : base + start;
- T* const end_addr = base + end;
- MemRegion mr((HeapWord*)start_addr, (HeapWord*)end_addr);
- _scanner.set_region(_g1->heap_region_containing(obj));
- obj->oop_iterate(&_scanner, mr);
-}
-
-void G1ParScanPartialArrayClosure::do_oop_nv(oop* p) {
- assert(!UseCompressedOops, "Needs to be fixed to work with compressed oops");
+template void G1ParCopyClosure<false, G1BarrierEvac, false, true>::do_oop_work(narrowOop* p);
+
+template <class T> void G1ParScanPartialArrayClosure::do_oop_nv(T* p) {
assert(has_partial_array_mask(p), "invariant");
oop old = clear_partial_array_mask(p);
assert(old->is_objArray(), "must be obj array");
@@ -4316,19 +3774,19 @@
end = start + ParGCArrayScanChunk;
arrayOop(old)->set_length(end);
// Push remainder.
- _par_scan_state->push_on_queue(set_partial_array_mask(old));
+ oop* old_p = set_partial_array_mask(old);
+ assert(arrayOop(old)->length() < obj->length(), "Empty push?");
+ _par_scan_state->push_on_queue(old_p);
} else {
// Restore length so that the heap remains parsable in
// case of evacuation failure.
arrayOop(old)->set_length(end);
}
-
+ _scanner.set_region(_g1->heap_region_containing_raw(obj));
// process our set of indices (include header in first chunk)
- process_array_chunk<oop>(obj, start, end);
+ obj->oop_iterate_range(&_scanner, start, end);
}
-int G1ScanAndBalanceClosure::_nq = 0;
-
class G1ParEvacuateFollowersClosure : public VoidClosure {
protected:
G1CollectedHeap* _g1h;
@@ -4351,21 +3809,28 @@
void do_void() {
G1ParScanThreadState* pss = par_scan_state();
while (true) {
- oop* ref_to_scan;
pss->trim_queue();
IF_G1_DETAILED_STATS(pss->note_steal_attempt());
- if (queues()->steal(pss->queue_num(),
- pss->hash_seed(),
- ref_to_scan)) {
+
+ StarTask stolen_task;
+ if (queues()->steal(pss->queue_num(), pss->hash_seed(), stolen_task)) {
IF_G1_DETAILED_STATS(pss->note_steal());
// slightly paranoid tests; I'm trying to catch potential
// problems before we go into push_on_queue to know where the
// problem is coming from
- assert(ref_to_scan != NULL, "invariant");
- assert(has_partial_array_mask(ref_to_scan) ||
- _g1h->obj_in_cs(*ref_to_scan), "invariant");
- pss->push_on_queue(ref_to_scan);
+ assert((oop*)stolen_task != NULL, "Error");
+ if (stolen_task.is_narrow()) {
+ assert(UseCompressedOops, "Error");
+ narrowOop* p = (narrowOop*) stolen_task;
+ assert(has_partial_array_mask(p) ||
+ _g1h->obj_in_cs(oopDesc::load_decode_heap_oop(p)), "Error");
+ pss->push_on_queue(p);
+ } else {
+ oop* p = (oop*) stolen_task;
+ assert(has_partial_array_mask(p) || _g1h->obj_in_cs(*p), "Error");
+ pss->push_on_queue(p);
+ }
continue;
}
pss->start_term_time();
@@ -4382,6 +3847,7 @@
G1CollectedHeap* _g1h;
RefToScanQueueSet *_queues;
ParallelTaskTerminator _terminator;
+ int _n_workers;
Mutex _stats_lock;
Mutex* stats_lock() { return &_stats_lock; }
@@ -4397,7 +3863,8 @@
_g1h(g1h),
_queues(task_queues),
_terminator(workers, _queues),
- _stats_lock(Mutex::leaf, "parallel G1 stats lock", true)
+ _stats_lock(Mutex::leaf, "parallel G1 stats lock", true),
+ _n_workers(workers)
{}
RefToScanQueueSet* queues() { return _queues; }
@@ -4407,6 +3874,7 @@
}
void work(int i) {
+ if (i >= _n_workers) return; // no work needed this round
ResourceMark rm;
HandleMark hm;
@@ -4504,23 +3972,6 @@
// *** Common G1 Evacuation Stuff
-class G1CountClosure: public OopsInHeapRegionClosure {
-public:
- int n;
- G1CountClosure() : n(0) {}
- void do_oop(narrowOop* p) {
- guarantee(false, "NYI");
- }
- void do_oop(oop* p) {
- oop obj = *p;
- assert(obj != NULL && G1CollectedHeap::heap()->obj_in_cs(obj),
- "Rem set closure called on non-rem-set pointer.");
- n++;
- }
-};
-
-static G1CountClosure count_closure;
-
void
G1CollectedHeap::
g1_process_strong_roots(bool collecting_perm_gen,
@@ -5570,8 +5021,3 @@
void G1CollectedHeap::g1_unimplemented() {
// Unimplemented();
}
-
-
-// Local Variables: ***
-// c-indentation-style: gnu ***
-// End: ***
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -56,8 +56,8 @@
# define IF_G1_DETAILED_STATS(code)
#endif
-typedef GenericTaskQueue<oop*> RefToScanQueue;
-typedef GenericTaskQueueSet<oop*> RefToScanQueueSet;
+typedef GenericTaskQueue<StarTask> RefToScanQueue;
+typedef GenericTaskQueueSet<StarTask> RefToScanQueueSet;
typedef int RegionIdx_t; // needs to hold [ 0..max_regions() )
typedef int CardIdx_t; // needs to hold [ 0..CardsPerRegion )
@@ -700,6 +700,9 @@
size_t g1_reserved_obj_bytes() { return _g1_reserved.byte_size(); }
virtual size_t capacity() const;
virtual size_t used() const;
+ // This should be called when we're not holding the heap lock. The
+ // result might be a bit inaccurate.
+ size_t used_unlocked() const;
size_t recalculate_used() const;
#ifndef PRODUCT
size_t recalculate_used_regions() const;
@@ -1271,6 +1274,552 @@
};
-// Local Variables: ***
-// c-indentation-style: gnu ***
-// End: ***
+#define use_local_bitmaps 1
+#define verify_local_bitmaps 0
+#define oop_buffer_length 256
+
+#ifndef PRODUCT
+class GCLabBitMap;
+class GCLabBitMapClosure: public BitMapClosure {
+private:
+ ConcurrentMark* _cm;
+ GCLabBitMap* _bitmap;
+
+public:
+ GCLabBitMapClosure(ConcurrentMark* cm,
+ GCLabBitMap* bitmap) {
+ _cm = cm;
+ _bitmap = bitmap;
+ }
+
+ virtual bool do_bit(size_t offset);
+};
+#endif // !PRODUCT
+
+class GCLabBitMap: public BitMap {
+private:
+ ConcurrentMark* _cm;
+
+ int _shifter;
+ size_t _bitmap_word_covers_words;
+
+ // beginning of the heap
+ HeapWord* _heap_start;
+
+ // this is the actual start of the GCLab
+ HeapWord* _real_start_word;
+
+ // this is the actual end of the GCLab
+ HeapWord* _real_end_word;
+
+ // this is the first word, possibly located before the actual start
+ // of the GCLab, that corresponds to the first bit of the bitmap
+ HeapWord* _start_word;
+
+ // size of a GCLab in words
+ size_t _gclab_word_size;
+
+ static int shifter() {
+ return MinObjAlignment - 1;
+ }
+
+ // how many heap words does a single bitmap word corresponds to?
+ static size_t bitmap_word_covers_words() {
+ return BitsPerWord << shifter();
+ }
+
+ static size_t gclab_word_size() {
+ return G1ParallelGCAllocBufferSize / HeapWordSize;
+ }
+
+ static size_t bitmap_size_in_bits() {
+ size_t bits_in_bitmap = gclab_word_size() >> shifter();
+ // We are going to ensure that the beginning of a word in this
+ // bitmap also corresponds to the beginning of a word in the
+ // global marking bitmap. To handle the case where a GCLab
+ // starts from the middle of the bitmap, we need to add enough
+ // space (i.e. up to a bitmap word) to ensure that we have
+ // enough bits in the bitmap.
+ return bits_in_bitmap + BitsPerWord - 1;
+ }
+public:
+ GCLabBitMap(HeapWord* heap_start)
+ : BitMap(bitmap_size_in_bits()),
+ _cm(G1CollectedHeap::heap()->concurrent_mark()),
+ _shifter(shifter()),
+ _bitmap_word_covers_words(bitmap_word_covers_words()),
+ _heap_start(heap_start),
+ _gclab_word_size(gclab_word_size()),
+ _real_start_word(NULL),
+ _real_end_word(NULL),
+ _start_word(NULL)
+ {
+ guarantee( size_in_words() >= bitmap_size_in_words(),
+ "just making sure");
+ }
+
+ inline unsigned heapWordToOffset(HeapWord* addr) {
+ unsigned offset = (unsigned) pointer_delta(addr, _start_word) >> _shifter;
+ assert(offset < size(), "offset should be within bounds");
+ return offset;
+ }
+
+ inline HeapWord* offsetToHeapWord(size_t offset) {
+ HeapWord* addr = _start_word + (offset << _shifter);
+ assert(_real_start_word <= addr && addr < _real_end_word, "invariant");
+ return addr;
+ }
+
+ bool fields_well_formed() {
+ bool ret1 = (_real_start_word == NULL) &&
+ (_real_end_word == NULL) &&
+ (_start_word == NULL);
+ if (ret1)
+ return true;
+
+ bool ret2 = _real_start_word >= _start_word &&
+ _start_word < _real_end_word &&
+ (_real_start_word + _gclab_word_size) == _real_end_word &&
+ (_start_word + _gclab_word_size + _bitmap_word_covers_words)
+ > _real_end_word;
+ return ret2;
+ }
+
+ inline bool mark(HeapWord* addr) {
+ guarantee(use_local_bitmaps, "invariant");
+ assert(fields_well_formed(), "invariant");
+
+ if (addr >= _real_start_word && addr < _real_end_word) {
+ assert(!isMarked(addr), "should not have already been marked");
+
+ // first mark it on the bitmap
+ at_put(heapWordToOffset(addr), true);
+
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ inline bool isMarked(HeapWord* addr) {
+ guarantee(use_local_bitmaps, "invariant");
+ assert(fields_well_formed(), "invariant");
+
+ return at(heapWordToOffset(addr));
+ }
+
+ void set_buffer(HeapWord* start) {
+ guarantee(use_local_bitmaps, "invariant");
+ clear();
+
+ assert(start != NULL, "invariant");
+ _real_start_word = start;
+ _real_end_word = start + _gclab_word_size;
+
+ size_t diff =
+ pointer_delta(start, _heap_start) % _bitmap_word_covers_words;
+ _start_word = start - diff;
+
+ assert(fields_well_formed(), "invariant");
+ }
+
+#ifndef PRODUCT
+ void verify() {
+ // verify that the marks have been propagated
+ GCLabBitMapClosure cl(_cm, this);
+ iterate(&cl);
+ }
+#endif // PRODUCT
+
+ void retire() {
+ guarantee(use_local_bitmaps, "invariant");
+ assert(fields_well_formed(), "invariant");
+
+ if (_start_word != NULL) {
+ CMBitMap* mark_bitmap = _cm->nextMarkBitMap();
+
+ // this means that the bitmap was set up for the GCLab
+ assert(_real_start_word != NULL && _real_end_word != NULL, "invariant");
+
+ mark_bitmap->mostly_disjoint_range_union(this,
+ 0, // always start from the start of the bitmap
+ _start_word,
+ size_in_words());
+ _cm->grayRegionIfNecessary(MemRegion(_real_start_word, _real_end_word));
+
+#ifndef PRODUCT
+ if (use_local_bitmaps && verify_local_bitmaps)
+ verify();
+#endif // PRODUCT
+ } else {
+ assert(_real_start_word == NULL && _real_end_word == NULL, "invariant");
+ }
+ }
+
+ static size_t bitmap_size_in_words() {
+ return (bitmap_size_in_bits() + BitsPerWord - 1) / BitsPerWord;
+ }
+};
+
+class G1ParGCAllocBuffer: public ParGCAllocBuffer {
+private:
+ bool _retired;
+ bool _during_marking;
+ GCLabBitMap _bitmap;
+
+public:
+ G1ParGCAllocBuffer() :
+ ParGCAllocBuffer(G1ParallelGCAllocBufferSize / HeapWordSize),
+ _during_marking(G1CollectedHeap::heap()->mark_in_progress()),
+ _bitmap(G1CollectedHeap::heap()->reserved_region().start()),
+ _retired(false)
+ { }
+
+ inline bool mark(HeapWord* addr) {
+ guarantee(use_local_bitmaps, "invariant");
+ assert(_during_marking, "invariant");
+ return _bitmap.mark(addr);
+ }
+
+ inline void set_buf(HeapWord* buf) {
+ if (use_local_bitmaps && _during_marking)
+ _bitmap.set_buffer(buf);
+ ParGCAllocBuffer::set_buf(buf);
+ _retired = false;
+ }
+
+ inline void retire(bool end_of_gc, bool retain) {
+ if (_retired)
+ return;
+ if (use_local_bitmaps && _during_marking) {
+ _bitmap.retire();
+ }
+ ParGCAllocBuffer::retire(end_of_gc, retain);
+ _retired = true;
+ }
+};
+
+class G1ParScanThreadState : public StackObj {
+protected:
+ G1CollectedHeap* _g1h;
+ RefToScanQueue* _refs;
+ DirtyCardQueue _dcq;
+ CardTableModRefBS* _ct_bs;
+ G1RemSet* _g1_rem;
+
+ typedef GrowableArray<StarTask> OverflowQueue;
+ OverflowQueue* _overflowed_refs;
+
+ G1ParGCAllocBuffer _alloc_buffers[GCAllocPurposeCount];
+ ageTable _age_table;
+
+ size_t _alloc_buffer_waste;
+ size_t _undo_waste;
+
+ OopsInHeapRegionClosure* _evac_failure_cl;
+ G1ParScanHeapEvacClosure* _evac_cl;
+ G1ParScanPartialArrayClosure* _partial_scan_cl;
+
+ int _hash_seed;
+ int _queue_num;
+
+ int _term_attempts;
+#if G1_DETAILED_STATS
+ int _pushes, _pops, _steals, _steal_attempts;
+ int _overflow_pushes;
+#endif
+
+ double _start;
+ double _start_strong_roots;
+ double _strong_roots_time;
+ double _start_term;
+ double _term_time;
+
+ // Map from young-age-index (0 == not young, 1 is youngest) to
+ // surviving words. base is what we get back from the malloc call
+ size_t* _surviving_young_words_base;
+ // this points into the array, as we use the first few entries for padding
+ size_t* _surviving_young_words;
+
+#define PADDING_ELEM_NUM (64 / sizeof(size_t))
+
+ void add_to_alloc_buffer_waste(size_t waste) { _alloc_buffer_waste += waste; }
+
+ void add_to_undo_waste(size_t waste) { _undo_waste += waste; }
+
+ DirtyCardQueue& dirty_card_queue() { return _dcq; }
+ CardTableModRefBS* ctbs() { return _ct_bs; }
+
+ template <class T> void immediate_rs_update(HeapRegion* from, T* p, int tid) {
+ if (!from->is_survivor()) {
+ _g1_rem->par_write_ref(from, p, tid);
+ }
+ }
+
+ template <class T> void deferred_rs_update(HeapRegion* from, T* p, int tid) {
+ // If the new value of the field points to the same region or
+ // is the to-space, we don't need to include it in the Rset updates.
+ if (!from->is_in_reserved(oopDesc::load_decode_heap_oop(p)) && !from->is_survivor()) {
+ size_t card_index = ctbs()->index_for(p);
+ // If the card hasn't been added to the buffer, do it.
+ if (ctbs()->mark_card_deferred(card_index)) {
+ dirty_card_queue().enqueue((jbyte*)ctbs()->byte_for_index(card_index));
+ }
+ }
+ }
+
+public:
+ G1ParScanThreadState(G1CollectedHeap* g1h, int queue_num);
+
+ ~G1ParScanThreadState() {
+ FREE_C_HEAP_ARRAY(size_t, _surviving_young_words_base);
+ }
+
+ RefToScanQueue* refs() { return _refs; }
+ OverflowQueue* overflowed_refs() { return _overflowed_refs; }
+ ageTable* age_table() { return &_age_table; }
+
+ G1ParGCAllocBuffer* alloc_buffer(GCAllocPurpose purpose) {
+ return &_alloc_buffers[purpose];
+ }
+
+ size_t alloc_buffer_waste() { return _alloc_buffer_waste; }
+ size_t undo_waste() { return _undo_waste; }
+
+ template <class T> void push_on_queue(T* ref) {
+ assert(ref != NULL, "invariant");
+ assert(has_partial_array_mask(ref) ||
+ _g1h->obj_in_cs(oopDesc::load_decode_heap_oop(ref)), "invariant");
+#ifdef ASSERT
+ if (has_partial_array_mask(ref)) {
+ oop p = clear_partial_array_mask(ref);
+ // Verify that we point into the CS
+ assert(_g1h->obj_in_cs(p), "Should be in CS");
+ }
+#endif
+ if (!refs()->push(ref)) {
+ overflowed_refs()->push(ref);
+ IF_G1_DETAILED_STATS(note_overflow_push());
+ } else {
+ IF_G1_DETAILED_STATS(note_push());
+ }
+ }
+
+ void pop_from_queue(StarTask& ref) {
+ if (refs()->pop_local(ref)) {
+ assert((oop*)ref != NULL, "pop_local() returned true");
+ assert(UseCompressedOops || !ref.is_narrow(), "Error");
+ assert(has_partial_array_mask((oop*)ref) ||
+ _g1h->obj_in_cs(ref.is_narrow() ? oopDesc::load_decode_heap_oop((narrowOop*)ref)
+ : oopDesc::load_decode_heap_oop((oop*)ref)),
+ "invariant");
+ IF_G1_DETAILED_STATS(note_pop());
+ } else {
+ StarTask null_task;
+ ref = null_task;
+ }
+ }
+
+ void pop_from_overflow_queue(StarTask& ref) {
+ StarTask new_ref = overflowed_refs()->pop();
+ assert((oop*)new_ref != NULL, "pop() from a local non-empty stack");
+ assert(UseCompressedOops || !new_ref.is_narrow(), "Error");
+ assert(has_partial_array_mask((oop*)new_ref) ||
+ _g1h->obj_in_cs(new_ref.is_narrow() ? oopDesc::load_decode_heap_oop((narrowOop*)new_ref)
+ : oopDesc::load_decode_heap_oop((oop*)new_ref)),
+ "invariant");
+ ref = new_ref;
+ }
+
+ int refs_to_scan() { return refs()->size(); }
+ int overflowed_refs_to_scan() { return overflowed_refs()->length(); }
+
+ template <class T> void update_rs(HeapRegion* from, T* p, int tid) {
+ if (G1DeferredRSUpdate) {
+ deferred_rs_update(from, p, tid);
+ } else {
+ immediate_rs_update(from, p, tid);
+ }
+ }
+
+ HeapWord* allocate_slow(GCAllocPurpose purpose, size_t word_sz) {
+
+ HeapWord* obj = NULL;
+ if (word_sz * 100 <
+ (size_t)(G1ParallelGCAllocBufferSize / HeapWordSize) *
+ ParallelGCBufferWastePct) {
+ G1ParGCAllocBuffer* alloc_buf = alloc_buffer(purpose);
+ add_to_alloc_buffer_waste(alloc_buf->words_remaining());
+ alloc_buf->retire(false, false);
+
+ HeapWord* buf =
+ _g1h->par_allocate_during_gc(purpose, G1ParallelGCAllocBufferSize / HeapWordSize);
+ if (buf == NULL) return NULL; // Let caller handle allocation failure.
+ // Otherwise.
+ alloc_buf->set_buf(buf);
+
+ obj = alloc_buf->allocate(word_sz);
+ assert(obj != NULL, "buffer was definitely big enough...");
+ } else {
+ obj = _g1h->par_allocate_during_gc(purpose, word_sz);
+ }
+ return obj;
+ }
+
+ HeapWord* allocate(GCAllocPurpose purpose, size_t word_sz) {
+ HeapWord* obj = alloc_buffer(purpose)->allocate(word_sz);
+ if (obj != NULL) return obj;
+ return allocate_slow(purpose, word_sz);
+ }
+
+ void undo_allocation(GCAllocPurpose purpose, HeapWord* obj, size_t word_sz) {
+ if (alloc_buffer(purpose)->contains(obj)) {
+ assert(alloc_buffer(purpose)->contains(obj + word_sz - 1),
+ "should contain whole object");
+ alloc_buffer(purpose)->undo_allocation(obj, word_sz);
+ } else {
+ CollectedHeap::fill_with_object(obj, word_sz);
+ add_to_undo_waste(word_sz);
+ }
+ }
+
+ void set_evac_failure_closure(OopsInHeapRegionClosure* evac_failure_cl) {
+ _evac_failure_cl = evac_failure_cl;
+ }
+ OopsInHeapRegionClosure* evac_failure_closure() {
+ return _evac_failure_cl;
+ }
+
+ void set_evac_closure(G1ParScanHeapEvacClosure* evac_cl) {
+ _evac_cl = evac_cl;
+ }
+
+ void set_partial_scan_closure(G1ParScanPartialArrayClosure* partial_scan_cl) {
+ _partial_scan_cl = partial_scan_cl;
+ }
+
+ int* hash_seed() { return &_hash_seed; }
+ int queue_num() { return _queue_num; }
+
+ int term_attempts() { return _term_attempts; }
+ void note_term_attempt() { _term_attempts++; }
+
+#if G1_DETAILED_STATS
+ int pushes() { return _pushes; }
+ int pops() { return _pops; }
+ int steals() { return _steals; }
+ int steal_attempts() { return _steal_attempts; }
+ int overflow_pushes() { return _overflow_pushes; }
+
+ void note_push() { _pushes++; }
+ void note_pop() { _pops++; }
+ void note_steal() { _steals++; }
+ void note_steal_attempt() { _steal_attempts++; }
+ void note_overflow_push() { _overflow_pushes++; }
+#endif
+
+ void start_strong_roots() {
+ _start_strong_roots = os::elapsedTime();
+ }
+ void end_strong_roots() {
+ _strong_roots_time += (os::elapsedTime() - _start_strong_roots);
+ }
+ double strong_roots_time() { return _strong_roots_time; }
+
+ void start_term_time() {
+ note_term_attempt();
+ _start_term = os::elapsedTime();
+ }
+ void end_term_time() {
+ _term_time += (os::elapsedTime() - _start_term);
+ }
+ double term_time() { return _term_time; }
+
+ double elapsed() {
+ return os::elapsedTime() - _start;
+ }
+
+ size_t* surviving_young_words() {
+ // We add on to hide entry 0 which accumulates surviving words for
+ // age -1 regions (i.e. non-young ones)
+ return _surviving_young_words;
+ }
+
+ void retire_alloc_buffers() {
+ for (int ap = 0; ap < GCAllocPurposeCount; ++ap) {
+ size_t waste = _alloc_buffers[ap].words_remaining();
+ add_to_alloc_buffer_waste(waste);
+ _alloc_buffers[ap].retire(true, false);
+ }
+ }
+
+private:
+ template <class T> void deal_with_reference(T* ref_to_scan) {
+ if (has_partial_array_mask(ref_to_scan)) {
+ _partial_scan_cl->do_oop_nv(ref_to_scan);
+ } else {
+ // Note: we can use "raw" versions of "region_containing" because
+ // "obj_to_scan" is definitely in the heap, and is not in a
+ // humongous region.
+ HeapRegion* r = _g1h->heap_region_containing_raw(ref_to_scan);
+ _evac_cl->set_region(r);
+ _evac_cl->do_oop_nv(ref_to_scan);
+ }
+ }
+
+public:
+ void trim_queue() {
+ // I've replicated the loop twice, first to drain the overflow
+ // queue, second to drain the task queue. This is better than
+ // having a single loop, which checks both conditions and, inside
+ // it, either pops the overflow queue or the task queue, as each
+ // loop is tighter. Also, the decision to drain the overflow queue
+ // first is not arbitrary, as the overflow queue is not visible
+ // to the other workers, whereas the task queue is. So, we want to
+ // drain the "invisible" entries first, while allowing the other
+ // workers to potentially steal the "visible" entries.
+
+ while (refs_to_scan() > 0 || overflowed_refs_to_scan() > 0) {
+ while (overflowed_refs_to_scan() > 0) {
+ StarTask ref_to_scan;
+ assert((oop*)ref_to_scan == NULL, "Constructed above");
+ pop_from_overflow_queue(ref_to_scan);
+ // We shouldn't have pushed it on the queue if it was not
+ // pointing into the CSet.
+ assert((oop*)ref_to_scan != NULL, "Follows from inner loop invariant");
+ if (ref_to_scan.is_narrow()) {
+ assert(UseCompressedOops, "Error");
+ narrowOop* p = (narrowOop*)ref_to_scan;
+ assert(!has_partial_array_mask(p) &&
+ _g1h->obj_in_cs(oopDesc::load_decode_heap_oop(p)), "sanity");
+ deal_with_reference(p);
+ } else {
+ oop* p = (oop*)ref_to_scan;
+ assert((has_partial_array_mask(p) && _g1h->obj_in_cs(clear_partial_array_mask(p))) ||
+ _g1h->obj_in_cs(oopDesc::load_decode_heap_oop(p)), "sanity");
+ deal_with_reference(p);
+ }
+ }
+
+ while (refs_to_scan() > 0) {
+ StarTask ref_to_scan;
+ assert((oop*)ref_to_scan == NULL, "Constructed above");
+ pop_from_queue(ref_to_scan);
+ if ((oop*)ref_to_scan != NULL) {
+ if (ref_to_scan.is_narrow()) {
+ assert(UseCompressedOops, "Error");
+ narrowOop* p = (narrowOop*)ref_to_scan;
+ assert(!has_partial_array_mask(p) &&
+ _g1h->obj_in_cs(oopDesc::load_decode_heap_oop(p)), "sanity");
+ deal_with_reference(p);
+ } else {
+ oop* p = (oop*)ref_to_scan;
+ assert((has_partial_array_mask(p) && _g1h->obj_in_cs(clear_partial_array_mask(p))) ||
+ _g1h->obj_in_cs(oopDesc::load_decode_heap_oop(p)), "sanity");
+ deal_with_reference(p);
+ }
+ }
+ }
+ }
+ }
+};
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -293,10 +293,6 @@
if (G1SteadyStateUsed < 50) {
vm_exit_during_initialization("G1SteadyStateUsed must be at least 50%.");
}
- if (UseConcMarkSweepGC) {
- vm_exit_during_initialization("-XX:+UseG1GC is incompatible with "
- "-XX:+UseConcMarkSweepGC.");
- }
initialize_gc_policy_counters();
--- a/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -42,18 +42,6 @@
virtual void set_region(HeapRegion* from) { _from = from; }
};
-
-class G1ScanAndBalanceClosure : public OopClosure {
- G1CollectedHeap* _g1;
- static int _nq;
-public:
- G1ScanAndBalanceClosure(G1CollectedHeap* g1) : _g1(g1) { }
- inline void do_oop_nv(oop* p);
- inline void do_oop_nv(narrowOop* p) { guarantee(false, "NYI"); }
- virtual void do_oop(oop* p);
- virtual void do_oop(narrowOop* p) { guarantee(false, "NYI"); }
-};
-
class G1ParClosureSuper : public OopsInHeapRegionClosure {
protected:
G1CollectedHeap* _g1;
@@ -69,34 +57,32 @@
public:
G1ParScanClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) :
G1ParClosureSuper(g1, par_scan_state) { }
- void do_oop_nv(oop* p); // should be made inline
- inline void do_oop_nv(narrowOop* p) { guarantee(false, "NYI"); }
+ template <class T> void do_oop_nv(T* p);
virtual void do_oop(oop* p) { do_oop_nv(p); }
virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
};
-#define G1_PARTIAL_ARRAY_MASK 1
+#define G1_PARTIAL_ARRAY_MASK 0x2
-inline bool has_partial_array_mask(oop* ref) {
- return (intptr_t) ref & G1_PARTIAL_ARRAY_MASK;
+template <class T> inline bool has_partial_array_mask(T* ref) {
+ return ((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) == G1_PARTIAL_ARRAY_MASK;
}
-inline oop* set_partial_array_mask(oop obj) {
- return (oop*) ((intptr_t) obj | G1_PARTIAL_ARRAY_MASK);
+template <class T> inline T* set_partial_array_mask(T obj) {
+ assert(((uintptr_t)obj & G1_PARTIAL_ARRAY_MASK) == 0, "Information loss!");
+ return (T*) ((uintptr_t)obj | G1_PARTIAL_ARRAY_MASK);
}
-inline oop clear_partial_array_mask(oop* ref) {
- return oop((intptr_t) ref & ~G1_PARTIAL_ARRAY_MASK);
+template <class T> inline oop clear_partial_array_mask(T* ref) {
+ return oop((intptr_t)ref & ~G1_PARTIAL_ARRAY_MASK);
}
class G1ParScanPartialArrayClosure : public G1ParClosureSuper {
G1ParScanClosure _scanner;
- template <class T> void process_array_chunk(oop obj, int start, int end);
public:
G1ParScanPartialArrayClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) :
G1ParClosureSuper(g1, par_scan_state), _scanner(g1, par_scan_state) { }
- void do_oop_nv(oop* p);
- void do_oop_nv(narrowOop* p) { guarantee(false, "NYI"); }
+ template <class T> void do_oop_nv(T* p);
virtual void do_oop(oop* p) { do_oop_nv(p); }
virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
};
@@ -105,7 +91,7 @@
class G1ParCopyHelper : public G1ParClosureSuper {
G1ParScanClosure *_scanner;
protected:
- void mark_forwardee(oop* p);
+ template <class T> void mark_forwardee(T* p);
oop copy_to_survivor_space(oop obj);
public:
G1ParCopyHelper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state,
@@ -117,36 +103,35 @@
bool do_mark_forwardee, bool skip_cset_test>
class G1ParCopyClosure : public G1ParCopyHelper {
G1ParScanClosure _scanner;
- void do_oop_work(oop* p);
- void do_oop_work(narrowOop* p) { guarantee(false, "NYI"); }
+ template <class T> void do_oop_work(T* p);
public:
G1ParCopyClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) :
_scanner(g1, par_scan_state), G1ParCopyHelper(g1, par_scan_state, &_scanner) { }
- inline void do_oop_nv(oop* p) {
+ template <class T> void do_oop_nv(T* p) {
do_oop_work(p);
if (do_mark_forwardee)
mark_forwardee(p);
}
- inline void do_oop_nv(narrowOop* p) { guarantee(false, "NYI"); }
virtual void do_oop(oop* p) { do_oop_nv(p); }
virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
};
typedef G1ParCopyClosure<false, G1BarrierNone, false, false> G1ParScanExtRootClosure;
typedef G1ParCopyClosure<true, G1BarrierNone, false, false> G1ParScanPermClosure;
+typedef G1ParCopyClosure<false, G1BarrierRS, false, false> G1ParScanHeapRSClosure;
typedef G1ParCopyClosure<false, G1BarrierNone, true, false> G1ParScanAndMarkExtRootClosure;
typedef G1ParCopyClosure<true, G1BarrierNone, true, false> G1ParScanAndMarkPermClosure;
-typedef G1ParCopyClosure<false, G1BarrierRS, false, false> G1ParScanHeapRSClosure;
typedef G1ParCopyClosure<false, G1BarrierRS, true, false> G1ParScanAndMarkHeapRSClosure;
// This is the only case when we set skip_cset_test. Basically, this
// closure is (should?) only be called directly while we're draining
// the overflow and task queues. In that case we know that the
// reference in question points into the collection set, otherwise we
-// would not have pushed it on the queue.
-typedef G1ParCopyClosure<false, G1BarrierEvac, false, true> G1ParScanHeapEvacClosure;
+// would not have pushed it on the queue. The following is defined in
+// g1_specialized_oop_closures.hpp.
+// typedef G1ParCopyClosure<false, G1BarrierEvac, false, true> G1ParScanHeapEvacClosure;
// We need a separate closure to handle references during evacuation
-// failure processing, as it cannot asume that the reference already
- // points to the collection set (like G1ParScanHeapEvacClosure does).
+// failure processing, as we cannot asume that the reference already
+// points into the collection set (like G1ParScanHeapEvacClosure does).
typedef G1ParCopyClosure<false, G1BarrierEvac, false, false> G1ParScanHeapEvacFailureClosure;
class FilterIntoCSClosure: public OopClosure {
@@ -158,10 +143,9 @@
G1CollectedHeap* g1, OopClosure* oc) :
_dcto_cl(dcto_cl), _g1(g1), _oc(oc)
{}
- inline void do_oop_nv(oop* p);
- inline void do_oop_nv(narrowOop* p) { guarantee(false, "NYI"); }
- virtual void do_oop(oop* p);
- virtual void do_oop(narrowOop* p) { guarantee(false, "NYI"); }
+ template <class T> void do_oop_nv(T* p);
+ virtual void do_oop(oop* p) { do_oop_nv(p); }
+ virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
bool apply_to_weak_ref_discovered_field() { return true; }
bool do_header() { return false; }
};
@@ -174,10 +158,9 @@
OopsInHeapRegionClosure* oc) :
_g1(g1), _oc(oc)
{}
- inline void do_oop_nv(oop* p);
- inline void do_oop_nv(narrowOop* p) { guarantee(false, "NYI"); }
- virtual void do_oop(oop* p);
- virtual void do_oop(narrowOop* p) { guarantee(false, "NYI"); }
+ template <class T> void do_oop_nv(T* p);
+ virtual void do_oop(oop* p) { do_oop_nv(p); }
+ virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
bool apply_to_weak_ref_discovered_field() { return true; }
bool do_header() { return false; }
void set_region(HeapRegion* from) {
@@ -195,10 +178,9 @@
ConcurrentMark* cm)
: _g1(g1), _oc(oc), _cm(cm) { }
- inline void do_oop_nv(oop* p);
- inline void do_oop_nv(narrowOop* p) { guarantee(false, "NYI"); }
- virtual void do_oop(oop* p);
- virtual void do_oop(narrowOop* p) { guarantee(false, "NYI"); }
+ template <class T> void do_oop_nv(T* p);
+ virtual void do_oop(oop* p) { do_oop_nv(p); }
+ virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
bool apply_to_weak_ref_discovered_field() { return true; }
bool do_header() { return false; }
void set_region(HeapRegion* from) {
@@ -213,10 +195,9 @@
int _out_of_region;
public:
FilterOutOfRegionClosure(HeapRegion* r, OopClosure* oc);
- inline void do_oop_nv(oop* p);
- inline void do_oop_nv(narrowOop* p) { guarantee(false, "NYI"); }
- virtual void do_oop(oop* p);
- virtual void do_oop(narrowOop* p) { guarantee(false, "NYI"); }
+ template <class T> void do_oop_nv(T* p);
+ virtual void do_oop(oop* p) { do_oop_nv(p); }
+ virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
bool apply_to_weak_ref_discovered_field() { return true; }
bool do_header() { return false; }
int out_of_region() { return _out_of_region; }
--- a/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.inline.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.inline.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -31,9 +31,10 @@
// perf-critical inner loop.
#define FILTERINTOCSCLOSURE_DOHISTOGRAMCOUNT 0
-inline void FilterIntoCSClosure::do_oop_nv(oop* p) {
- oop obj = *p;
- if (obj != NULL && _g1->obj_in_cs(obj)) {
+template <class T> inline void FilterIntoCSClosure::do_oop_nv(T* p) {
+ T heap_oop = oopDesc::load_heap_oop(p);
+ if (!oopDesc::is_null(heap_oop) &&
+ _g1->obj_in_cs(oopDesc::decode_heap_oop_not_null(heap_oop))) {
_oc->do_oop(p);
#if FILTERINTOCSCLOSURE_DOHISTOGRAMCOUNT
_dcto_cl->incr_count();
@@ -41,44 +42,32 @@
}
}
-inline void FilterIntoCSClosure::do_oop(oop* p)
-{
- do_oop_nv(p);
-}
-
#define FILTEROUTOFREGIONCLOSURE_DOHISTOGRAMCOUNT 0
-inline void FilterOutOfRegionClosure::do_oop_nv(oop* p) {
- oop obj = *p;
- HeapWord* obj_hw = (HeapWord*)obj;
- if (obj_hw != NULL && (obj_hw < _r_bottom || obj_hw >= _r_end)) {
- _oc->do_oop(p);
+template <class T> inline void FilterOutOfRegionClosure::do_oop_nv(T* p) {
+ T heap_oop = oopDesc::load_heap_oop(p);
+ if (!oopDesc::is_null(heap_oop)) {
+ HeapWord* obj_hw = (HeapWord*)oopDesc::decode_heap_oop_not_null(heap_oop);
+ if (obj_hw < _r_bottom || obj_hw >= _r_end) {
+ _oc->do_oop(p);
#if FILTEROUTOFREGIONCLOSURE_DOHISTOGRAMCOUNT
- _out_of_region++;
+ _out_of_region++;
#endif
+ }
}
}
-inline void FilterOutOfRegionClosure::do_oop(oop* p)
-{
- do_oop_nv(p);
-}
-
-inline void FilterInHeapRegionAndIntoCSClosure::do_oop_nv(oop* p) {
- oop obj = *p;
- if (obj != NULL && _g1->obj_in_cs(obj))
+template <class T> inline void FilterInHeapRegionAndIntoCSClosure::do_oop_nv(T* p) {
+ T heap_oop = oopDesc::load_heap_oop(p);
+ if (!oopDesc::is_null(heap_oop) &&
+ _g1->obj_in_cs(oopDesc::decode_heap_oop_not_null(heap_oop)))
_oc->do_oop(p);
}
-inline void FilterInHeapRegionAndIntoCSClosure::do_oop(oop* p)
-{
- do_oop_nv(p);
-}
-
-
-inline void FilterAndMarkInHeapRegionAndIntoCSClosure::do_oop_nv(oop* p) {
- oop obj = *p;
- if (obj != NULL) {
+template <class T> inline void FilterAndMarkInHeapRegionAndIntoCSClosure::do_oop_nv(T* p) {
+ T heap_oop = oopDesc::load_heap_oop(p);
+ if (!oopDesc::is_null(heap_oop)) {
+ oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
HeapRegion* hr = _g1->heap_region_containing((HeapWord*) obj);
if (hr != NULL) {
if (hr->in_collection_set())
@@ -89,24 +78,29 @@
}
}
-inline void FilterAndMarkInHeapRegionAndIntoCSClosure::do_oop(oop* p)
-{
- do_oop_nv(p);
-}
+// This closure is applied to the fields of the objects that have just been copied.
+template <class T> inline void G1ParScanClosure::do_oop_nv(T* p) {
+ T heap_oop = oopDesc::load_heap_oop(p);
-inline void G1ScanAndBalanceClosure::do_oop_nv(oop* p) {
- RefToScanQueue* q;
- if (ParallelGCThreads > 0) {
- // Deal the work out equally.
- _nq = (_nq + 1) % ParallelGCThreads;
- q = _g1->task_queue(_nq);
- } else {
- q = _g1->task_queue(0);
+ if (!oopDesc::is_null(heap_oop)) {
+ oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
+ if (_g1->in_cset_fast_test(obj)) {
+ // We're not going to even bother checking whether the object is
+ // already forwarded or not, as this usually causes an immediate
+ // stall. We'll try to prefetch the object (for write, given that
+ // we might need to install the forwarding reference) and we'll
+ // get back to it when pop it from the queue
+ Prefetch::write(obj->mark_addr(), 0);
+ Prefetch::read(obj->mark_addr(), (HeapWordSize*2));
+
+ // slightly paranoid test; I'm trying to catch potential
+ // problems before we go into push_on_queue to know where the
+ // problem is coming from
+ assert(obj == oopDesc::load_decode_heap_oop(p),
+ "p should still be pointing to obj");
+ _par_scan_state->push_on_queue(p);
+ } else {
+ _par_scan_state->update_rs(_from, p, _par_scan_state->queue_num());
+ }
}
- bool nooverflow = q->push(p);
- guarantee(nooverflow, "Overflow during poplularity region processing");
}
-
-inline void G1ScanAndBalanceClosure::do_oop(oop* p) {
- do_oop_nv(p);
-}
--- a/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -65,11 +65,10 @@
void set_region(HeapRegion* from) {
_blk->set_region(from);
}
- virtual void do_oop(narrowOop* p) {
- guarantee(false, "NYI");
- }
- virtual void do_oop(oop* p) {
- oop obj = *p;
+ virtual void do_oop(narrowOop* p) { do_oop_work(p); }
+ virtual void do_oop( oop* p) { do_oop_work(p); }
+ template <class T> void do_oop_work(T* p) {
+ oop obj = oopDesc::load_decode_heap_oop(p);
if (_g1->obj_in_cs(obj)) _blk->do_oop(p);
}
bool apply_to_weak_ref_discovered_field() { return true; }
@@ -110,11 +109,10 @@
public:
VerifyRSCleanCardOopClosure(G1CollectedHeap* g1) : _g1(g1) {}
- virtual void do_oop(narrowOop* p) {
- guarantee(false, "NYI");
- }
- virtual void do_oop(oop* p) {
- oop obj = *p;
+ virtual void do_oop(narrowOop* p) { do_oop_work(p); }
+ virtual void do_oop( oop* p) { do_oop_work(p); }
+ template <class T> void do_oop_work(T* p) {
+ oop obj = oopDesc::load_decode_heap_oop(p);
HeapRegion* to = _g1->heap_region_containing(obj);
guarantee(to == NULL || !to->in_collection_set(),
"Missed a rem set member.");
@@ -129,9 +127,9 @@
{
_seq_task = new SubTasksDone(NumSeqTasks);
guarantee(n_workers() > 0, "There should be some workers");
- _new_refs = NEW_C_HEAP_ARRAY(GrowableArray<oop*>*, n_workers());
+ _new_refs = NEW_C_HEAP_ARRAY(GrowableArray<OopOrNarrowOopStar>*, n_workers());
for (uint i = 0; i < n_workers(); i++) {
- _new_refs[i] = new (ResourceObj::C_HEAP) GrowableArray<oop*>(8192,true);
+ _new_refs[i] = new (ResourceObj::C_HEAP) GrowableArray<OopOrNarrowOopStar>(8192,true);
}
}
@@ -140,7 +138,7 @@
for (uint i = 0; i < n_workers(); i++) {
delete _new_refs[i];
}
- FREE_C_HEAP_ARRAY(GrowableArray<oop*>*, _new_refs);
+ FREE_C_HEAP_ARRAY(GrowableArray<OopOrNarrowOopStar>*, _new_refs);
}
void CountNonCleanMemRegionClosure::do_MemRegion(MemRegion mr) {
@@ -428,15 +426,15 @@
}
};
-void
-HRInto_G1RemSet::scanNewRefsRS(OopsInHeapRegionClosure* oc,
- int worker_i) {
+template <class T> void
+HRInto_G1RemSet::scanNewRefsRS_work(OopsInHeapRegionClosure* oc,
+ int worker_i) {
double scan_new_refs_start_sec = os::elapsedTime();
G1CollectedHeap* g1h = G1CollectedHeap::heap();
CardTableModRefBS* ct_bs = (CardTableModRefBS*) (g1h->barrier_set());
for (int i = 0; i < _new_refs[worker_i]->length(); i++) {
- oop* p = _new_refs[worker_i]->at(i);
- oop obj = *p;
+ T* p = (T*) _new_refs[worker_i]->at(i);
+ oop obj = oopDesc::load_decode_heap_oop(p);
// *p was in the collection set when p was pushed on "_new_refs", but
// another thread may have processed this location from an RS, so it
// might not point into the CS any longer. If so, it's obviously been
@@ -549,11 +547,10 @@
G1CollectedHeap* _g1;
public:
UpdateRSetOopsIntoCSImmediate(G1CollectedHeap* g1) : _g1(g1) { }
- virtual void do_oop(narrowOop* p) {
- guarantee(false, "NYI");
- }
- virtual void do_oop(oop* p) {
- HeapRegion* to = _g1->heap_region_containing(*p);
+ virtual void do_oop(narrowOop* p) { do_oop_work(p); }
+ virtual void do_oop( oop* p) { do_oop_work(p); }
+ template <class T> void do_oop_work(T* p) {
+ HeapRegion* to = _g1->heap_region_containing(oopDesc::load_decode_heap_oop(p));
if (to->in_collection_set()) {
to->rem_set()->add_reference(p, 0);
}
@@ -567,11 +564,10 @@
public:
UpdateRSetOopsIntoCSDeferred(G1CollectedHeap* g1, DirtyCardQueue* dcq) :
_g1(g1), _ct_bs((CardTableModRefBS*)_g1->barrier_set()), _dcq(dcq) { }
- virtual void do_oop(narrowOop* p) {
- guarantee(false, "NYI");
- }
- virtual void do_oop(oop* p) {
- oop obj = *p;
+ virtual void do_oop(narrowOop* p) { do_oop_work(p); }
+ virtual void do_oop( oop* p) { do_oop_work(p); }
+ template <class T> void do_oop_work(T* p) {
+ oop obj = oopDesc::load_decode_heap_oop(p);
if (_g1->obj_in_cs(obj)) {
size_t card_index = _ct_bs->index_for(p);
if (_ct_bs->mark_card_deferred(card_index)) {
@@ -581,10 +577,10 @@
}
};
-void HRInto_G1RemSet::new_refs_iterate(OopClosure* cl) {
+template <class T> void HRInto_G1RemSet::new_refs_iterate_work(OopClosure* cl) {
for (size_t i = 0; i < n_workers(); i++) {
for (int j = 0; j < _new_refs[i]->length(); j++) {
- oop* p = _new_refs[i]->at(j);
+ T* p = (T*) _new_refs[i]->at(j);
cl->do_oop(p);
}
}
--- a/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -62,10 +62,12 @@
// If "this" is of the given subtype, return "this", else "NULL".
virtual HRInto_G1RemSet* as_HRInto_G1RemSet() { return NULL; }
- // Record, if necessary, the fact that *p (where "p" is in region "from")
- // has changed to its new value.
+ // Record, if necessary, the fact that *p (where "p" is in region "from",
+ // and is, a fortiori, required to be non-NULL) has changed to its new value.
virtual void write_ref(HeapRegion* from, oop* p) = 0;
+ virtual void write_ref(HeapRegion* from, narrowOop* p) = 0;
virtual void par_write_ref(HeapRegion* from, oop* p, int tid) = 0;
+ virtual void par_write_ref(HeapRegion* from, narrowOop* p, int tid) = 0;
// Requires "region_bm" and "card_bm" to be bitmaps with 1 bit per region
// or card, respectively, such that a region or card with a corresponding
@@ -105,7 +107,9 @@
// Nothing is necessary in the version below.
void write_ref(HeapRegion* from, oop* p) {}
+ void write_ref(HeapRegion* from, narrowOop* p) {}
void par_write_ref(HeapRegion* from, oop* p, int tid) {}
+ void par_write_ref(HeapRegion* from, narrowOop* p, int tid) {}
void scrub(BitMap* region_bm, BitMap* card_bm) {}
void scrub_par(BitMap* region_bm, BitMap* card_bm,
@@ -143,8 +147,19 @@
// their references into the collection summarized in "_new_refs".
bool _par_traversal_in_progress;
void set_par_traversal(bool b) { _par_traversal_in_progress = b; }
- GrowableArray<oop*>** _new_refs;
- void new_refs_iterate(OopClosure* cl);
+ GrowableArray<OopOrNarrowOopStar>** _new_refs;
+ template <class T> void new_refs_iterate_work(OopClosure* cl);
+ void new_refs_iterate(OopClosure* cl) {
+ if (UseCompressedOops) {
+ new_refs_iterate_work<narrowOop>(cl);
+ } else {
+ new_refs_iterate_work<oop>(cl);
+ }
+ }
+
+protected:
+ template <class T> void write_ref_nv(HeapRegion* from, T* p);
+ template <class T> void par_write_ref_nv(HeapRegion* from, T* p, int tid);
public:
// This is called to reset dual hash tables after the gc pause
@@ -161,7 +176,14 @@
void prepare_for_oops_into_collection_set_do();
void cleanup_after_oops_into_collection_set_do();
void scanRS(OopsInHeapRegionClosure* oc, int worker_i);
- void scanNewRefsRS(OopsInHeapRegionClosure* oc, int worker_i);
+ template <class T> void scanNewRefsRS_work(OopsInHeapRegionClosure* oc, int worker_i);
+ void scanNewRefsRS(OopsInHeapRegionClosure* oc, int worker_i) {
+ if (UseCompressedOops) {
+ scanNewRefsRS_work<narrowOop>(oc, worker_i);
+ } else {
+ scanNewRefsRS_work<oop>(oc, worker_i);
+ }
+ }
void updateRS(int worker_i);
HeapRegion* calculateStartRegion(int i);
@@ -172,12 +194,22 @@
// Record, if necessary, the fact that *p (where "p" is in region "from",
// which is required to be non-NULL) has changed to a new non-NULL value.
- inline void write_ref(HeapRegion* from, oop* p);
- // The "_nv" version is the same; it exists just so that it is not virtual.
- inline void write_ref_nv(HeapRegion* from, oop* p);
+ // [Below the virtual version calls a non-virtual protected
+ // workhorse that is templatified for narrow vs wide oop.]
+ inline void write_ref(HeapRegion* from, oop* p) {
+ write_ref_nv(from, p);
+ }
+ inline void write_ref(HeapRegion* from, narrowOop* p) {
+ write_ref_nv(from, p);
+ }
+ inline void par_write_ref(HeapRegion* from, oop* p, int tid) {
+ par_write_ref_nv(from, p, tid);
+ }
+ inline void par_write_ref(HeapRegion* from, narrowOop* p, int tid) {
+ par_write_ref_nv(from, p, tid);
+ }
- inline bool self_forwarded(oop obj);
- inline void par_write_ref(HeapRegion* from, oop* p, int tid);
+ bool self_forwarded(oop obj);
void scrub(BitMap* region_bm, BitMap* card_bm);
void scrub_par(BitMap* region_bm, BitMap* card_bm,
@@ -208,6 +240,9 @@
HeapRegion* _from;
HRInto_G1RemSet* _rs;
int _worker_i;
+
+ template <class T> void do_oop_work(T* p);
+
public:
UpdateRSOopClosure(HRInto_G1RemSet* rs, int worker_i = 0) :
_from(NULL), _rs(rs), _worker_i(worker_i) {
@@ -219,11 +254,10 @@
_from = from;
}
- virtual void do_oop(narrowOop* p);
- virtual void do_oop(oop* p);
+ virtual void do_oop(narrowOop* p) { do_oop_work(p); }
+ virtual void do_oop(oop* p) { do_oop_work(p); }
// Override: this closure is idempotent.
// bool idempotent() { return true; }
bool apply_to_weak_ref_discovered_field() { return true; }
};
-
--- a/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.inline.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.inline.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,12 +30,8 @@
}
}
-inline void HRInto_G1RemSet::write_ref_nv(HeapRegion* from, oop* p) {
- par_write_ref(from, p, 0);
-}
-
-inline void HRInto_G1RemSet::write_ref(HeapRegion* from, oop* p) {
- write_ref_nv(from, p);
+template <class T> inline void HRInto_G1RemSet::write_ref_nv(HeapRegion* from, T* p) {
+ par_write_ref_nv(from, p, 0);
}
inline bool HRInto_G1RemSet::self_forwarded(oop obj) {
@@ -43,8 +39,8 @@
return result;
}
-inline void HRInto_G1RemSet::par_write_ref(HeapRegion* from, oop* p, int tid) {
- oop obj = *p;
+template <class T> inline void HRInto_G1RemSet::par_write_ref_nv(HeapRegion* from, T* p, int tid) {
+ oop obj = oopDesc::load_decode_heap_oop(p);
#ifdef ASSERT
// can't do because of races
// assert(obj == NULL || obj->is_oop(), "expected an oop");
@@ -71,7 +67,7 @@
// false during the evacuation failure handing.
if (_par_traversal_in_progress &&
to->in_collection_set() && !self_forwarded(obj)) {
- _new_refs[tid]->push(p);
+ _new_refs[tid]->push((void*)p);
// Deferred updates to the Cset are either discarded (in the normal case),
// or processed (if an evacuation failure occurs) at the end
// of the collection.
@@ -89,11 +85,7 @@
}
}
-inline void UpdateRSOopClosure::do_oop(narrowOop* p) {
- guarantee(false, "NYI");
-}
-
-inline void UpdateRSOopClosure::do_oop(oop* p) {
+template <class T> inline void UpdateRSOopClosure::do_oop_work(T* p) {
assert(_from != NULL, "from region must be non-NULL");
_rs->par_write_ref(_from, p, _worker_i);
}
--- a/hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -34,6 +34,7 @@
void G1SATBCardTableModRefBS::enqueue(oop pre_val) {
+ assert(pre_val->is_oop_or_null(true), "Error");
if (!JavaThread::satb_mark_queue_set().active()) return;
Thread* thr = Thread::current();
if (thr->is_Java_thread()) {
@@ -46,32 +47,31 @@
}
// When we know the current java thread:
-void
-G1SATBCardTableModRefBS::write_ref_field_pre_static(void* field,
- oop newVal,
+template <class T> void
+G1SATBCardTableModRefBS::write_ref_field_pre_static(T* field,
+ oop new_val,
JavaThread* jt) {
if (!JavaThread::satb_mark_queue_set().active()) return;
- assert(!UseCompressedOops, "Else will need to modify this to deal with narrowOop");
- oop preVal = *(oop*)field;
- if (preVal != NULL) {
- jt->satb_mark_queue().enqueue(preVal);
+ T heap_oop = oopDesc::load_heap_oop(field);
+ if (!oopDesc::is_null(heap_oop)) {
+ oop pre_val = oopDesc::decode_heap_oop_not_null(heap_oop);
+ assert(pre_val->is_oop(true /* ignore mark word */), "Error");
+ jt->satb_mark_queue().enqueue(pre_val);
}
}
-void
-G1SATBCardTableModRefBS::write_ref_array_pre(MemRegion mr) {
+template <class T> void
+G1SATBCardTableModRefBS::write_ref_array_pre_work(T* dst, int count) {
if (!JavaThread::satb_mark_queue_set().active()) return;
- assert(!UseCompressedOops, "Else will need to modify this to deal with narrowOop");
- oop* elem_ptr = (oop*)mr.start();
- while ((HeapWord*)elem_ptr < mr.end()) {
- oop elem = *elem_ptr;
- if (elem != NULL) enqueue(elem);
- elem_ptr++;
+ T* elem_ptr = dst;
+ for (int i = 0; i < count; i++, elem_ptr++) {
+ T heap_oop = oopDesc::load_heap_oop(elem_ptr);
+ if (!oopDesc::is_null(heap_oop)) {
+ enqueue(oopDesc::decode_heap_oop_not_null(heap_oop));
+ }
}
}
-
-
G1SATBCardTableLoggingModRefBS::
G1SATBCardTableLoggingModRefBS(MemRegion whole_heap,
int max_covered_regions) :
--- a/hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -47,31 +47,41 @@
// This notes that we don't need to access any BarrierSet data
// structures, so this can be called from a static context.
- static void write_ref_field_pre_static(void* field, oop newVal) {
- assert(!UseCompressedOops, "Else needs to be templatized");
- oop preVal = *((oop*)field);
- if (preVal != NULL) {
- enqueue(preVal);
+ template <class T> static void write_ref_field_pre_static(T* field, oop newVal) {
+ T heap_oop = oopDesc::load_heap_oop(field);
+ if (!oopDesc::is_null(heap_oop)) {
+ enqueue(oopDesc::decode_heap_oop(heap_oop));
}
}
// When we know the current java thread:
- static void write_ref_field_pre_static(void* field, oop newVal,
- JavaThread* jt);
+ template <class T> static void write_ref_field_pre_static(T* field, oop newVal,
+ JavaThread* jt);
// We export this to make it available in cases where the static
// type of the barrier set is known. Note that it is non-virtual.
- inline void inline_write_ref_field_pre(void* field, oop newVal) {
+ template <class T> inline void inline_write_ref_field_pre(T* field, oop newVal) {
write_ref_field_pre_static(field, newVal);
}
- // This is the more general virtual version.
- void write_ref_field_pre_work(void* field, oop new_val) {
+ // These are the more general virtual versions.
+ virtual void write_ref_field_pre_work(oop* field, oop new_val) {
+ inline_write_ref_field_pre(field, new_val);
+ }
+ virtual void write_ref_field_pre_work(narrowOop* field, oop new_val) {
inline_write_ref_field_pre(field, new_val);
}
+ virtual void write_ref_field_pre_work(void* field, oop new_val) {
+ guarantee(false, "Not needed");
+ }
- virtual void write_ref_array_pre(MemRegion mr);
-
+ template <class T> void write_ref_array_pre_work(T* dst, int count);
+ virtual void write_ref_array_pre(oop* dst, int count) {
+ write_ref_array_pre_work(dst, count);
+ }
+ virtual void write_ref_array_pre(narrowOop* dst, int count) {
+ write_ref_array_pre_work(dst, count);
+ }
};
// Adds card-table logging to the post-barrier.
--- a/hotspot/src/share/vm/gc_implementation/g1/g1_globals.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1_globals.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -80,9 +80,6 @@
develop(bool, G1TraceConcurrentRefinement, false, \
"Trace G1 concurrent refinement") \
\
- develop(bool, G1ConcMark, true, \
- "If true, run concurrent marking for G1") \
- \
product(intx, G1MarkStackSize, 2 * 1024 * 1024, \
"Size of the mark stack for concurrent marking.") \
\
--- a/hotspot/src/share/vm/gc_implementation/g1/g1_specialized_oop_closures.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1_specialized_oop_closures.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -37,14 +37,12 @@
class G1ParCopyClosure;
class G1ParScanClosure;
-typedef G1ParCopyClosure<false, G1BarrierEvac, false, true>
- G1ParScanHeapEvacClosure;
+typedef G1ParCopyClosure<false, G1BarrierEvac, false, true> G1ParScanHeapEvacClosure;
class FilterIntoCSClosure;
class FilterOutOfRegionClosure;
class FilterInHeapRegionAndIntoCSClosure;
class FilterAndMarkInHeapRegionAndIntoCSClosure;
-class G1ScanAndBalanceClosure;
#ifdef FURTHER_SPECIALIZED_OOP_OOP_ITERATE_CLOSURES
#error "FURTHER_SPECIALIZED_OOP_OOP_ITERATE_CLOSURES already defined."
@@ -56,8 +54,7 @@
f(FilterIntoCSClosure,_nv) \
f(FilterOutOfRegionClosure,_nv) \
f(FilterInHeapRegionAndIntoCSClosure,_nv) \
- f(FilterAndMarkInHeapRegionAndIntoCSClosure,_nv) \
- f(G1ScanAndBalanceClosure,_nv)
+ f(FilterAndMarkInHeapRegionAndIntoCSClosure,_nv)
#ifdef FURTHER_SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES
#error "FURTHER_SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES already defined."
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -66,16 +66,16 @@
bool failures() { return _failures; }
int n_failures() { return _n_failures; }
- virtual void do_oop(narrowOop* p) {
- guarantee(false, "NYI");
- }
+ virtual void do_oop(narrowOop* p) { do_oop_work(p); }
+ virtual void do_oop( oop* p) { do_oop_work(p); }
- void do_oop(oop* p) {
+ template <class T> void do_oop_work(T* p) {
assert(_containing_obj != NULL, "Precondition");
assert(!_g1h->is_obj_dead_cond(_containing_obj, _use_prev_marking),
"Precondition");
- oop obj = *p;
- if (obj != NULL) {
+ T heap_oop = oopDesc::load_heap_oop(p);
+ if (!oopDesc::is_null(heap_oop)) {
+ oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
bool failed = false;
if (!_g1h->is_in_closed_subset(obj) ||
_g1h->is_obj_dead_cond(obj, _use_prev_marking)) {
@@ -106,8 +106,8 @@
}
if (!_g1h->full_collection()) {
- HeapRegion* from = _g1h->heap_region_containing(p);
- HeapRegion* to = _g1h->heap_region_containing(*p);
+ HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p);
+ HeapRegion* to = _g1h->heap_region_containing(obj);
if (from != NULL && to != NULL &&
from != to &&
!to->isHumongous()) {
@@ -534,13 +534,13 @@
// Otherwise, find the obj that extends onto mr.start().
assert(cur <= mr.start()
- && (oop(cur)->klass() == NULL ||
+ && (oop(cur)->klass_or_null() == NULL ||
cur + oop(cur)->size() > mr.start()),
"postcondition of block_start");
oop obj;
while (cur < mr.end()) {
obj = oop(cur);
- if (obj->klass() == NULL) {
+ if (obj->klass_or_null() == NULL) {
// Ran into an unparseable point.
return cur;
} else if (!g1h->is_obj_dead(obj)) {
@@ -577,7 +577,7 @@
assert(cur <= mr.start(), "Postcondition");
while (cur <= mr.start()) {
- if (oop(cur)->klass() == NULL) {
+ if (oop(cur)->klass_or_null() == NULL) {
// Ran into an unparseable point.
return cur;
}
@@ -591,7 +591,7 @@
obj = oop(cur);
// If we finish this loop...
assert(cur <= mr.start()
- && obj->klass() != NULL
+ && obj->klass_or_null() != NULL
&& cur + obj->size() > mr.start(),
"Loop postcondition");
if (!g1h->is_obj_dead(obj)) {
@@ -601,7 +601,7 @@
HeapWord* next;
while (cur < mr.end()) {
obj = oop(cur);
- if (obj->klass() == NULL) {
+ if (obj->klass_or_null() == NULL) {
// Ran into an unparseable point.
return cur;
};
@@ -781,8 +781,13 @@
// will pick up the right saved_mark_word() as the high water mark
// of the region. Either way, the behaviour will be correct.
ContiguousSpace::set_saved_mark();
+ OrderAccess::storestore();
_gc_time_stamp = curr_gc_time_stamp;
- OrderAccess::fence();
+ // The following fence is to force a flush of the writes above, but
+ // is strictly not needed because when an allocating worker thread
+ // calls set_saved_mark() it does so under the ParGCRareEvent_lock;
+ // when the lock is released, the write will be flushed.
+ // OrderAccess::fence();
}
}
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -126,7 +126,7 @@
}
}
- void add_reference_work(oop* from, bool par) {
+ void add_reference_work(OopOrNarrowOopStar from, bool par) {
// Must make this robust in case "from" is not in "_hr", because of
// concurrency.
@@ -173,11 +173,11 @@
_bm.clear();
}
- void add_reference(oop* from) {
+ void add_reference(OopOrNarrowOopStar from) {
add_reference_work(from, /*parallel*/ true);
}
- void seq_add_reference(oop* from) {
+ void seq_add_reference(OopOrNarrowOopStar from) {
add_reference_work(from, /*parallel*/ false);
}
@@ -220,7 +220,7 @@
}
// Requires "from" to be in "hr()".
- bool contains_reference(oop* from) const {
+ bool contains_reference(OopOrNarrowOopStar from) const {
assert(hr()->is_in_reserved(from), "Precondition.");
size_t card_ind = pointer_delta(from, hr()->bottom(),
CardTableModRefBS::card_size);
@@ -394,7 +394,7 @@
void set_next(PosParPRT* nxt) { _next = nxt; }
PosParPRT** next_addr() { return &_next; }
- void add_reference(oop* from, int tid) {
+ void add_reference(OopOrNarrowOopStar from, int tid) {
// Expand if necessary.
PerRegionTable** pt = par_tables();
if (par_tables() == NULL && tid > 0 && hr()->is_gc_alloc_region()) {
@@ -447,7 +447,7 @@
return res;
}
- bool contains_reference(oop* from) const {
+ bool contains_reference(OopOrNarrowOopStar from) const {
if (PerRegionTable::contains_reference(from)) return true;
if (_par_tables != NULL) {
for (int i = 0; i < HeapRegionRemSet::num_par_rem_sets()-1; i++) {
@@ -564,12 +564,15 @@
}
#endif
-void OtherRegionsTable::add_reference(oop* from, int tid) {
+void OtherRegionsTable::add_reference(OopOrNarrowOopStar from, int tid) {
size_t cur_hrs_ind = hr()->hrs_index();
#if HRRS_VERBOSE
gclog_or_tty->print_cr("ORT::add_reference_work(" PTR_FORMAT "->" PTR_FORMAT ").",
- from, *from);
+ from,
+ UseCompressedOops
+ ? oopDesc::load_decode_heap_oop((narrowOop*)from)
+ : oopDesc::load_decode_heap_oop((oop*)from));
#endif
int from_card = (int)(uintptr_t(from) >> CardTableModRefBS::card_shift);
@@ -1021,13 +1024,13 @@
}
}
-bool OtherRegionsTable::contains_reference(oop* from) const {
+bool OtherRegionsTable::contains_reference(OopOrNarrowOopStar from) const {
// Cast away const in this case.
MutexLockerEx x((Mutex*)&_m, Mutex::_no_safepoint_check_flag);
return contains_reference_locked(from);
}
-bool OtherRegionsTable::contains_reference_locked(oop* from) const {
+bool OtherRegionsTable::contains_reference_locked(OopOrNarrowOopStar from) const {
HeapRegion* hr = _g1h->heap_region_containing_raw(from);
if (hr == NULL) return false;
RegionIdx_t hr_ind = (RegionIdx_t) hr->hrs_index();
@@ -1288,24 +1291,24 @@
-oop** HeapRegionRemSet::_recorded_oops = NULL;
-HeapWord** HeapRegionRemSet::_recorded_cards = NULL;
-HeapRegion** HeapRegionRemSet::_recorded_regions = NULL;
-int HeapRegionRemSet::_n_recorded = 0;
+OopOrNarrowOopStar* HeapRegionRemSet::_recorded_oops = NULL;
+HeapWord** HeapRegionRemSet::_recorded_cards = NULL;
+HeapRegion** HeapRegionRemSet::_recorded_regions = NULL;
+int HeapRegionRemSet::_n_recorded = 0;
HeapRegionRemSet::Event* HeapRegionRemSet::_recorded_events = NULL;
int* HeapRegionRemSet::_recorded_event_index = NULL;
int HeapRegionRemSet::_n_recorded_events = 0;
-void HeapRegionRemSet::record(HeapRegion* hr, oop* f) {
+void HeapRegionRemSet::record(HeapRegion* hr, OopOrNarrowOopStar f) {
if (_recorded_oops == NULL) {
assert(_n_recorded == 0
&& _recorded_cards == NULL
&& _recorded_regions == NULL,
"Inv");
- _recorded_oops = NEW_C_HEAP_ARRAY(oop*, MaxRecorded);
- _recorded_cards = NEW_C_HEAP_ARRAY(HeapWord*, MaxRecorded);
- _recorded_regions = NEW_C_HEAP_ARRAY(HeapRegion*, MaxRecorded);
+ _recorded_oops = NEW_C_HEAP_ARRAY(OopOrNarrowOopStar, MaxRecorded);
+ _recorded_cards = NEW_C_HEAP_ARRAY(HeapWord*, MaxRecorded);
+ _recorded_regions = NEW_C_HEAP_ARRAY(HeapRegion*, MaxRecorded);
}
if (_n_recorded == MaxRecorded) {
gclog_or_tty->print_cr("Filled up 'recorded' (%d).", MaxRecorded);
@@ -1408,21 +1411,21 @@
HeapRegionRemSet* hrrs = hr0->rem_set();
// Make three references from region 0x101...
- hrrs->add_reference((oop*)hr1_start);
- hrrs->add_reference((oop*)hr1_mid);
- hrrs->add_reference((oop*)hr1_last);
+ hrrs->add_reference((OopOrNarrowOopStar)hr1_start);
+ hrrs->add_reference((OopOrNarrowOopStar)hr1_mid);
+ hrrs->add_reference((OopOrNarrowOopStar)hr1_last);
- hrrs->add_reference((oop*)hr2_start);
- hrrs->add_reference((oop*)hr2_mid);
- hrrs->add_reference((oop*)hr2_last);
+ hrrs->add_reference((OopOrNarrowOopStar)hr2_start);
+ hrrs->add_reference((OopOrNarrowOopStar)hr2_mid);
+ hrrs->add_reference((OopOrNarrowOopStar)hr2_last);
- hrrs->add_reference((oop*)hr3_start);
- hrrs->add_reference((oop*)hr3_mid);
- hrrs->add_reference((oop*)hr3_last);
+ hrrs->add_reference((OopOrNarrowOopStar)hr3_start);
+ hrrs->add_reference((OopOrNarrowOopStar)hr3_mid);
+ hrrs->add_reference((OopOrNarrowOopStar)hr3_last);
// Now cause a coarsening.
- hrrs->add_reference((oop*)hr4->bottom());
- hrrs->add_reference((oop*)hr5->bottom());
+ hrrs->add_reference((OopOrNarrowOopStar)hr4->bottom());
+ hrrs->add_reference((OopOrNarrowOopStar)hr5->bottom());
// Now, does iteration yield these three?
HeapRegionRemSetIterator iter;
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -116,9 +116,9 @@
// For now. Could "expand" some tables in the future, so that this made
// sense.
- void add_reference(oop* from, int tid);
+ void add_reference(OopOrNarrowOopStar from, int tid);
- void add_reference(oop* from) {
+ void add_reference(OopOrNarrowOopStar from) {
return add_reference(from, 0);
}
@@ -140,8 +140,8 @@
static size_t static_mem_size();
static size_t fl_mem_size();
- bool contains_reference(oop* from) const;
- bool contains_reference_locked(oop* from) const;
+ bool contains_reference(OopOrNarrowOopStar from) const;
+ bool contains_reference_locked(OopOrNarrowOopStar from) const;
void clear();
@@ -192,10 +192,10 @@
// Unused unless G1RecordHRRSOops is true.
static const int MaxRecorded = 1000000;
- static oop** _recorded_oops;
- static HeapWord** _recorded_cards;
- static HeapRegion** _recorded_regions;
- static int _n_recorded;
+ static OopOrNarrowOopStar* _recorded_oops;
+ static HeapWord** _recorded_cards;
+ static HeapRegion** _recorded_regions;
+ static int _n_recorded;
static const int MaxRecordedEvents = 1000;
static Event* _recorded_events;
@@ -231,13 +231,13 @@
/* Used in the sequential case. Returns "true" iff this addition causes
the size limit to be reached. */
- void add_reference(oop* from) {
+ void add_reference(OopOrNarrowOopStar from) {
_other_regions.add_reference(from);
}
/* Used in the parallel case. Returns "true" iff this addition causes
the size limit to be reached. */
- void add_reference(oop* from, int tid) {
+ void add_reference(OopOrNarrowOopStar from, int tid) {
_other_regions.add_reference(from, tid);
}
@@ -301,7 +301,7 @@
return OtherRegionsTable::fl_mem_size();
}
- bool contains_reference(oop* from) const {
+ bool contains_reference(OopOrNarrowOopStar from) const {
return _other_regions.contains_reference(from);
}
void print() const;
@@ -329,7 +329,7 @@
}
#endif
- static void record(HeapRegion* hr, oop* f);
+ static void record(HeapRegion* hr, OopOrNarrowOopStar f);
static void print_recorded();
static void record_event(Event evnt);
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionSeq.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionSeq.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/gc_implementation/g1/ptrQueue.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/ptrQueue.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/gc_implementation/g1/satbQueue.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/satbQueue.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -43,6 +43,18 @@
}
}
}
+
+#ifdef ASSERT
+void ObjPtrQueue::verify_oops_in_buffer() {
+ if (_buf == NULL) return;
+ for (size_t i = _index; i < _sz; i += oopSize) {
+ oop obj = (oop)_buf[byte_index_to_index((int)i)];
+ assert(obj != NULL && obj->is_oop(true /* ignore mark word */),
+ "Not an oop");
+ }
+}
+#endif
+
#ifdef _MSC_VER // the use of 'this' below gets a warning, make it go away
#pragma warning( disable:4355 ) // 'this' : used in base member initializer list
#endif // _MSC_VER
@@ -66,6 +78,7 @@
void SATBMarkQueueSet::handle_zero_index_for_thread(JavaThread* t) {
+ DEBUG_ONLY(t->satb_mark_queue().verify_oops_in_buffer();)
t->satb_mark_queue().handle_zero_index();
}
@@ -143,7 +156,7 @@
}
_completed_buffers_tail = NULL;
_n_completed_buffers = 0;
- debug_only(assert_completed_buffer_list_len_correct_locked());
+ DEBUG_ONLY(assert_completed_buffer_list_len_correct_locked());
}
while (buffers_to_delete != NULL) {
CompletedBufferNode* nd = buffers_to_delete;
--- a/hotspot/src/share/vm/gc_implementation/g1/satbQueue.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/satbQueue.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -39,6 +39,7 @@
static void apply_closure_to_buffer(ObjectClosure* cl,
void** buf, size_t index, size_t sz);
+ void verify_oops_in_buffer() NOT_DEBUG_RETURN;
};
--- a/hotspot/src/share/vm/gc_implementation/g1/sparsePRT.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/sparsePRT.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/gc_implementation/g1/vm_operations_g1.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/vm_operations_g1.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/gc_implementation/g1/vm_operations_g1.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/vm_operations_g1.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/gc_implementation/includeDB_gc_g1 Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/includeDB_gc_g1 Tue Aug 04 08:01:03 2009 -0700
@@ -27,6 +27,7 @@
bufferingOopClosure.hpp genOopClosures.hpp
bufferingOopClosure.hpp generation.hpp
bufferingOopClosure.hpp os.hpp
+bufferingOopClosure.hpp taskqueue.hpp
cardTableRS.cpp concurrentMark.hpp
cardTableRS.cpp g1SATBCardTableModRefBS.hpp
@@ -139,7 +140,7 @@
g1CollectedHeap.cpp g1CollectedHeap.inline.hpp
g1CollectedHeap.cpp g1CollectorPolicy.hpp
g1CollectedHeap.cpp g1MarkSweep.hpp
-g1CollectedHeap.cpp g1RemSet.hpp
+g1CollectedHeap.cpp g1RemSet.inline.hpp
g1CollectedHeap.cpp g1OopClosures.inline.hpp
g1CollectedHeap.cpp genOopClosures.inline.hpp
g1CollectedHeap.cpp gcLocker.inline.hpp
@@ -151,13 +152,14 @@
g1CollectedHeap.cpp isGCActiveMark.hpp
g1CollectedHeap.cpp oop.inline.hpp
g1CollectedHeap.cpp oop.pcgc.inline.hpp
-g1CollectedHeap.cpp parGCAllocBuffer.hpp
g1CollectedHeap.cpp vm_operations_g1.hpp
g1CollectedHeap.cpp vmThread.hpp
g1CollectedHeap.hpp barrierSet.hpp
+g1CollectedHeap.hpp g1RemSet.hpp
g1CollectedHeap.hpp heapRegion.hpp
g1CollectedHeap.hpp memRegion.hpp
+g1CollectedHeap.hpp parGCAllocBuffer.hpp
g1CollectedHeap.hpp sharedHeap.hpp
g1CollectedHeap.inline.hpp concurrentMark.hpp
@@ -245,6 +247,7 @@
g1RemSet.cpp iterator.hpp
g1RemSet.cpp oop.inline.hpp
+g1RemSet.inline.hpp oop.inline.hpp
g1RemSet.inline.hpp g1RemSet.hpp
g1RemSet.inline.hpp heapRegionRemSet.hpp
@@ -255,6 +258,7 @@
g1SATBCardTableModRefBS.cpp thread_<os_family>.inline.hpp
g1SATBCardTableModRefBS.cpp satbQueue.hpp
+g1SATBCardTableModRefBS.hpp oop.inline.hpp
g1SATBCardTableModRefBS.hpp cardTableModRefBS.hpp
g1SATBCardTableModRefBS.hpp memRegion.hpp
--- a/hotspot/src/share/vm/gc_implementation/parNew/parCardTableModRefBS.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parNew/parCardTableModRefBS.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -31,9 +31,10 @@
bool clear,
int n_threads) {
if (n_threads > 0) {
- assert(n_threads == (int)ParallelGCThreads, "# worker threads != # requested!");
-
- // Make sure the LNC array is valid for the space.
+ assert((n_threads == 1 && ParallelGCThreads == 0) ||
+ n_threads <= (int)ParallelGCThreads,
+ "# worker threads != # requested!");
+ // Make sure the LNC array is valid for the space.
jbyte** lowest_non_clean;
uintptr_t lowest_non_clean_base_chunk_index;
size_t lowest_non_clean_chunk_size;
--- a/hotspot/src/share/vm/gc_implementation/parNew/parGCAllocBuffer.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parNew/parGCAllocBuffer.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -885,7 +885,7 @@
}
-void ParallelScavengeHeap::verify(bool allow_dirty, bool silent) {
+void ParallelScavengeHeap::verify(bool allow_dirty, bool silent, bool option /* ignored */) {
// Why do we need the total_collections()-filter below?
if (total_collections() > 0) {
if (!silent) {
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -217,7 +217,7 @@
virtual void gc_threads_do(ThreadClosure* tc) const;
virtual void print_tracing_info() const;
- void verify(bool allow_dirty, bool silent);
+ void verify(bool allow_dirty, bool silent, bool /* option */);
void print_heap_change(size_t prev_used);
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -117,6 +117,7 @@
process_array_chunk(old);
} else {
if (p.is_narrow()) {
+ assert(UseCompressedOops, "Error");
PSScavenge::copy_and_push_safe_barrier(this, (narrowOop*)p);
} else {
PSScavenge::copy_and_push_safe_barrier(this, (oop*)p);
--- a/hotspot/src/share/vm/gc_implementation/shared/concurrentGCThread.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/shared/concurrentGCThread.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/gc_implementation/shared/concurrentGCThread.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/shared/concurrentGCThread.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/gc_interface/collectedHeap.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_interface/collectedHeap.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -533,7 +533,7 @@
virtual void print_tracing_info() const = 0;
// Heap verification
- virtual void verify(bool allow_dirty, bool silent) = 0;
+ virtual void verify(bool allow_dirty, bool silent, bool option) = 0;
// Non product verification and debugging.
#ifndef PRODUCT
--- a/hotspot/src/share/vm/gc_interface/gcCause.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/gc_interface/gcCause.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2002-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/includeDB_compiler1 Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/includeDB_compiler1 Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
//
-// Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
+// Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
//
// This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/includeDB_core Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/includeDB_core Tue Aug 04 08:01:03 2009 -0700
@@ -554,7 +554,6 @@
ciEnv.cpp linkResolver.hpp
ciEnv.cpp methodDataOop.hpp
ciEnv.cpp objArrayKlass.hpp
-ciEnv.cpp oop.hpp
ciEnv.cpp oop.inline.hpp
ciEnv.cpp oop.inline2.hpp
ciEnv.cpp oopFactory.hpp
@@ -785,7 +784,6 @@
ciSignature.cpp allocation.inline.hpp
ciSignature.cpp ciSignature.hpp
ciSignature.cpp ciUtilities.hpp
-ciSignature.cpp oop.hpp
ciSignature.cpp oop.inline.hpp
ciSignature.cpp signature.hpp
@@ -950,7 +948,6 @@
classify.cpp classify.hpp
classify.cpp systemDictionary.hpp
-classify.hpp oop.hpp
classify.hpp oop.inline.hpp
codeBlob.cpp allocation.inline.hpp
@@ -1185,7 +1182,6 @@
compilerOracle.cpp jniHandles.hpp
compilerOracle.cpp klass.hpp
compilerOracle.cpp methodOop.hpp
-compilerOracle.cpp oop.hpp
compilerOracle.cpp oop.inline.hpp
compilerOracle.cpp oopFactory.hpp
compilerOracle.cpp resourceArea.hpp
@@ -1629,7 +1625,6 @@
frame.cpp methodOop.hpp
frame.cpp monitorChunk.hpp
frame.cpp nativeInst_<arch>.hpp
-frame.cpp oop.hpp
frame.cpp oop.inline.hpp
frame.cpp oop.inline2.hpp
frame.cpp oopMapCache.hpp
@@ -1797,7 +1792,6 @@
generation.cpp generation.hpp
generation.cpp generation.inline.hpp
generation.cpp java.hpp
-generation.cpp oop.hpp
generation.cpp oop.inline.hpp
generation.cpp spaceDecorator.hpp
generation.cpp space.inline.hpp
@@ -2270,7 +2264,6 @@
java.cpp memprofiler.hpp
java.cpp methodOop.hpp
java.cpp objArrayOop.hpp
-java.cpp oop.hpp
java.cpp oop.inline.hpp
java.cpp oopFactory.hpp
java.cpp sharedRuntime.hpp
@@ -2947,7 +2940,7 @@
nativeInst_<arch>.cpp assembler_<arch>.inline.hpp
nativeInst_<arch>.cpp handles.hpp
nativeInst_<arch>.cpp nativeInst_<arch>.hpp
-nativeInst_<arch>.cpp oop.hpp
+nativeInst_<arch>.cpp oop.inline.hpp
nativeInst_<arch>.cpp ostream.hpp
nativeInst_<arch>.cpp resourceArea.hpp
nativeInst_<arch>.cpp sharedRuntime.hpp
@@ -3842,7 +3835,7 @@
stackValue.cpp debugInfo.hpp
stackValue.cpp frame.inline.hpp
stackValue.cpp handles.inline.hpp
-stackValue.cpp oop.hpp
+stackValue.cpp oop.inline.hpp
stackValue.cpp stackValue.hpp
stackValue.hpp handles.hpp
@@ -4329,7 +4322,6 @@
unhandledOops.cpp collectedHeap.hpp
unhandledOops.cpp gcLocker.inline.hpp
unhandledOops.cpp globalDefinitions.hpp
-unhandledOops.cpp oop.hpp
unhandledOops.cpp oop.inline.hpp
unhandledOops.cpp thread.hpp
unhandledOops.cpp unhandledOops.hpp
@@ -4465,7 +4457,6 @@
vframe.cpp nmethod.hpp
vframe.cpp objectMonitor.hpp
vframe.cpp objectMonitor.inline.hpp
-vframe.cpp oop.hpp
vframe.cpp oop.inline.hpp
vframe.cpp oopMapCache.hpp
vframe.cpp pcDesc.hpp
@@ -4577,7 +4568,6 @@
vmThread.cpp interfaceSupport.hpp
vmThread.cpp methodOop.hpp
vmThread.cpp mutexLocker.hpp
-vmThread.cpp oop.hpp
vmThread.cpp oop.inline.hpp
vmThread.cpp os.hpp
vmThread.cpp resourceArea.hpp
--- a/hotspot/src/share/vm/includeDB_features Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/includeDB_features Tue Aug 04 08:01:03 2009 -0700
@@ -47,7 +47,7 @@
dump.cpp javaClasses.hpp
dump.cpp loaderConstraints.hpp
dump.cpp methodDataOop.hpp
-dump.cpp oop.hpp
+dump.cpp oop.inline.hpp
dump.cpp oopFactory.hpp
dump.cpp resourceArea.hpp
dump.cpp signature.hpp
@@ -237,7 +237,7 @@
serialize.cpp compiledICHolderOop.hpp
serialize.cpp methodDataOop.hpp
serialize.cpp objArrayOop.hpp
-serialize.cpp oop.hpp
+serialize.cpp oop.inline.hpp
serialize.cpp symbolTable.hpp
serialize.cpp systemDictionary.hpp
@@ -295,7 +295,7 @@
vmStructs.cpp objArrayKlass.hpp
vmStructs.cpp objArrayKlassKlass.hpp
vmStructs.cpp objArrayOop.hpp
-vmStructs.cpp oop.hpp
+vmStructs.cpp oop.inline.hpp
vmStructs.cpp oopMap.hpp
vmStructs.cpp pcDesc.hpp
vmStructs.cpp perfMemory.hpp
--- a/hotspot/src/share/vm/includeDB_jvmti Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/includeDB_jvmti Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
//
-// Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
+// Copyright 2007-2009 Sun Microsystems, Inc. All Rights Reserved.
// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
//
// This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/interpreter/bytecode.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/interpreter/bytecode.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2002 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/interpreter/bytecode.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/interpreter/bytecode.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2002 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/interpreter/bytecodeStream.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/interpreter/bytecodeStream.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/interpreter/bytecodeTracer.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/interpreter/bytecodeTracer.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/interpreter/bytecodes.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/interpreter/bytecodes.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/interpreter/bytecodes.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/interpreter/bytecodes.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/interpreter/invocationCounter.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/interpreter/invocationCounter.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/interpreter/rewriter.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/interpreter/rewriter.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -273,6 +273,7 @@
compute_index_maps();
if (RegisterFinalizersAtInit && _klass->name() == vmSymbols::java_lang_Object()) {
+ bool did_rewrite = false;
int i = _methods->length();
while (i-- > 0) {
methodOop method = (methodOop)_methods->obj_at(i);
@@ -281,9 +282,11 @@
// object for finalization if needed.
methodHandle m(THREAD, method);
rewrite_Object_init(m, CHECK);
+ did_rewrite = true;
break;
}
}
+ assert(did_rewrite, "must find Object::<init> to rewrite it");
}
// rewrite methods, in two passes
--- a/hotspot/src/share/vm/interpreter/rewriter.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/interpreter/rewriter.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/interpreter/templateTable.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/interpreter/templateTable.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/interpreter/templateTable.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/interpreter/templateTable.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/memory/barrierSet.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/memory/barrierSet.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -25,12 +25,27 @@
# include "incls/_precompiled.incl"
# include "incls/_barrierSet.cpp.incl"
-// count is in HeapWord's
+// count is number of array elements being written
void BarrierSet::static_write_ref_array_pre(HeapWord* start, size_t count) {
- Universe::heap()->barrier_set()->write_ref_array_pre(MemRegion(start, start + count));
+ assert(count <= (size_t)max_intx, "count too large");
+#if 0
+ warning("Pre: \t" INTPTR_FORMAT "[" SIZE_FORMAT "]\t",
+ start, count);
+#endif
+ if (UseCompressedOops) {
+ Universe::heap()->barrier_set()->write_ref_array_pre((narrowOop*)start, (int)count);
+ } else {
+ Universe::heap()->barrier_set()->write_ref_array_pre( (oop*)start, (int)count);
+ }
}
-// count is in HeapWord's
+// count is number of array elements being written
void BarrierSet::static_write_ref_array_post(HeapWord* start, size_t count) {
- Universe::heap()->barrier_set()->write_ref_array_work(MemRegion(start, start + count));
+ assert(count <= (size_t)max_intx, "count too large");
+ HeapWord* end = start + objArrayOopDesc::array_size((int)count);
+#if 0
+ warning("Post:\t" INTPTR_FORMAT "[" SIZE_FORMAT "] : [" INTPTR_FORMAT","INTPTR_FORMAT")\t",
+ start, count, start, end);
+#endif
+ Universe::heap()->barrier_set()->write_ref_array_work(MemRegion(start, end));
}
--- a/hotspot/src/share/vm/memory/barrierSet.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/memory/barrierSet.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -81,9 +81,13 @@
// barrier types. Semantically, it should be thought of as a call to the
// virtual "_work" function below, which must implement the barrier.)
// First the pre-write versions...
- inline void write_ref_field_pre(void* field, oop new_val);
+ template <class T> inline void write_ref_field_pre(T* field, oop new_val);
+private:
+ // Keep this private so as to catch violations at build time.
+ virtual void write_ref_field_pre_work( void* field, oop new_val) { guarantee(false, "Not needed"); };
protected:
- virtual void write_ref_field_pre_work(void* field, oop new_val) {};
+ virtual void write_ref_field_pre_work( oop* field, oop new_val) {};
+ virtual void write_ref_field_pre_work(narrowOop* field, oop new_val) {};
public:
// ...then the post-write version.
@@ -117,12 +121,17 @@
virtual void read_ref_array(MemRegion mr) = 0;
virtual void read_prim_array(MemRegion mr) = 0;
- virtual void write_ref_array_pre(MemRegion mr) {}
+ virtual void write_ref_array_pre( oop* dst, int length) {}
+ virtual void write_ref_array_pre(narrowOop* dst, int length) {}
inline void write_ref_array(MemRegion mr);
// Static versions, suitable for calling from generated code.
static void static_write_ref_array_pre(HeapWord* start, size_t count);
static void static_write_ref_array_post(HeapWord* start, size_t count);
+ // Narrow oop versions of the above; count is # of array elements being written,
+ // starting with "start", which is HeapWord-aligned.
+ static void static_write_ref_array_pre_narrow(HeapWord* start, size_t count);
+ static void static_write_ref_array_post_narrow(HeapWord* start, size_t count);
protected:
virtual void write_ref_array_work(MemRegion mr) = 0;
--- a/hotspot/src/share/vm/memory/barrierSet.inline.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/memory/barrierSet.inline.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -23,10 +23,10 @@
*/
// Inline functions of BarrierSet, which de-virtualize certain
-// performance-critical calls when when the barrier is the most common
+// performance-critical calls when the barrier is the most common
// card-table kind.
-void BarrierSet::write_ref_field_pre(void* field, oop new_val) {
+template <class T> void BarrierSet::write_ref_field_pre(T* field, oop new_val) {
if (kind() == CardTableModRef) {
((CardTableModRefBS*)this)->inline_write_ref_field_pre(field, new_val);
} else {
--- a/hotspot/src/share/vm/memory/blockOffsetTable.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/memory/blockOffsetTable.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/memory/cardTableModRefBS.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/memory/cardTableModRefBS.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -287,7 +287,7 @@
// these functions here for performance.
protected:
void write_ref_field_work(oop obj, size_t offset, oop newVal);
- void write_ref_field_work(void* field, oop newVal);
+ virtual void write_ref_field_work(void* field, oop newVal);
public:
bool has_write_ref_array_opt() { return true; }
@@ -317,10 +317,10 @@
// *** Card-table-barrier-specific things.
- inline void inline_write_ref_field_pre(void* field, oop newVal) {}
+ template <class T> inline void inline_write_ref_field_pre(T* field, oop newVal) {}
- inline void inline_write_ref_field(void* field, oop newVal) {
- jbyte* byte = byte_for(field);
+ template <class T> inline void inline_write_ref_field(T* field, oop newVal) {
+ jbyte* byte = byte_for((void*)field);
*byte = dirty_card;
}
--- a/hotspot/src/share/vm/memory/cardTableRS.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/memory/cardTableRS.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/memory/gcLocker.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/memory/gcLocker.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/memory/genCollectedHeap.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/memory/genCollectedHeap.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1194,7 +1194,7 @@
return _gens[level]->gc_stats();
}
-void GenCollectedHeap::verify(bool allow_dirty, bool silent) {
+void GenCollectedHeap::verify(bool allow_dirty, bool silent, bool option /* ignored */) {
if (!silent) {
gclog_or_tty->print("permgen ");
}
--- a/hotspot/src/share/vm/memory/genCollectedHeap.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/memory/genCollectedHeap.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -325,7 +325,7 @@
void prepare_for_verify();
// Override.
- void verify(bool allow_dirty, bool silent);
+ void verify(bool allow_dirty, bool silent, bool /* option */);
// Override.
void print() const;
--- a/hotspot/src/share/vm/memory/genOopClosures.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/memory/genOopClosures.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -57,7 +57,7 @@
template <class T> void do_barrier(T* p);
// Version for use by closures that may be called in parallel code.
- void par_do_barrier(oop* p);
+ template <class T> void par_do_barrier(T* p);
public:
OopsInGenClosure() : OopClosure(NULL),
--- a/hotspot/src/share/vm/memory/genOopClosures.inline.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/memory/genOopClosures.inline.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -40,18 +40,20 @@
template <class T> inline void OopsInGenClosure::do_barrier(T* p) {
assert(generation()->is_in_reserved(p), "expected ref in generation");
- assert(!oopDesc::is_null(*p), "expected non-null object");
- oop obj = oopDesc::load_decode_heap_oop_not_null(p);
+ T heap_oop = oopDesc::load_heap_oop(p);
+ assert(!oopDesc::is_null(heap_oop), "expected non-null oop");
+ oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
// If p points to a younger generation, mark the card.
if ((HeapWord*)obj < _gen_boundary) {
_rs->inline_write_ref_field_gc(p, obj);
}
}
-inline void OopsInGenClosure::par_do_barrier(oop* p) {
+template <class T> inline void OopsInGenClosure::par_do_barrier(T* p) {
assert(generation()->is_in_reserved(p), "expected ref in generation");
- oop obj = *p;
- assert(obj != NULL, "expected non-null object");
+ T heap_oop = oopDesc::load_heap_oop(p);
+ assert(!oopDesc::is_null(heap_oop), "expected non-null oop");
+ oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
// If p points to a younger generation, mark the card.
if ((HeapWord*)obj < gen_boundary()) {
rs()->write_ref_field_gc_par(p, obj);
--- a/hotspot/src/share/vm/memory/heap.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/memory/heap.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/memory/referenceProcessor.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/memory/referenceProcessor.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1013,12 +1013,19 @@
// discovered_addr.
oop current_head = refs_list.head();
- // Note: In the case of G1, this pre-barrier is strictly
+ // Note: In the case of G1, this specific pre-barrier is strictly
// not necessary because the only case we are interested in
- // here is when *discovered_addr is NULL, so this will expand to
- // nothing. As a result, I am just manually eliding this out for G1.
+ // here is when *discovered_addr is NULL (see the CAS further below),
+ // so this will expand to nothing. As a result, we have manually
+ // elided this out for G1, but left in the test for some future
+ // collector that might have need for a pre-barrier here.
if (_discovered_list_needs_barrier && !UseG1GC) {
- _bs->write_ref_field_pre((void*)discovered_addr, current_head); guarantee(false, "Needs to be fixed: YSR");
+ if (UseCompressedOops) {
+ _bs->write_ref_field_pre((narrowOop*)discovered_addr, current_head);
+ } else {
+ _bs->write_ref_field_pre((oop*)discovered_addr, current_head);
+ }
+ guarantee(false, "Need to check non-G1 collector");
}
oop retest = oopDesc::atomic_compare_exchange_oop(current_head, discovered_addr,
NULL);
@@ -1029,9 +1036,8 @@
refs_list.set_head(obj);
refs_list.inc_length(1);
if (_discovered_list_needs_barrier) {
- _bs->write_ref_field((void*)discovered_addr, current_head); guarantee(false, "Needs to be fixed: YSR");
+ _bs->write_ref_field((void*)discovered_addr, current_head);
}
-
} else {
// If retest was non NULL, another thread beat us to it:
// The reference has already been discovered...
@@ -1177,11 +1183,16 @@
// pre-value, we can safely elide the pre-barrier here for the case of G1.
assert(discovered == NULL, "control point invariant");
if (_discovered_list_needs_barrier && !UseG1GC) { // safe to elide for G1
- _bs->write_ref_field_pre((oop*)discovered_addr, current_head);
+ if (UseCompressedOops) {
+ _bs->write_ref_field_pre((narrowOop*)discovered_addr, current_head);
+ } else {
+ _bs->write_ref_field_pre((oop*)discovered_addr, current_head);
+ }
+ guarantee(false, "Need to check non-G1 collector");
}
oop_store_raw(discovered_addr, current_head);
if (_discovered_list_needs_barrier) {
- _bs->write_ref_field((oop*)discovered_addr, current_head);
+ _bs->write_ref_field((void*)discovered_addr, current_head);
}
list->set_head(obj);
list->inc_length(1);
--- a/hotspot/src/share/vm/memory/space.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/memory/space.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -106,6 +106,7 @@
virtual void set_end(HeapWord* value) { _end = value; }
virtual HeapWord* saved_mark_word() const { return _saved_mark_word; }
+
void set_saved_mark_word(HeapWord* p) { _saved_mark_word = p; }
MemRegionClosure* preconsumptionDirtyCardClosure() const {
--- a/hotspot/src/share/vm/memory/universe.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/memory/universe.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1170,7 +1170,7 @@
st->print_cr("}");
}
-void Universe::verify(bool allow_dirty, bool silent) {
+void Universe::verify(bool allow_dirty, bool silent, bool option) {
if (SharedSkipVerify) {
return;
}
@@ -1194,7 +1194,7 @@
if (!silent) gclog_or_tty->print("[Verifying ");
if (!silent) gclog_or_tty->print("threads ");
Threads::verify();
- heap()->verify(allow_dirty, silent);
+ heap()->verify(allow_dirty, silent, option);
if (!silent) gclog_or_tty->print("syms ");
SymbolTable::verify();
--- a/hotspot/src/share/vm/memory/universe.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/memory/universe.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -343,6 +343,7 @@
// For UseCompressedOops
static address* narrow_oop_base_addr() { return &_narrow_oop._base; }
static address narrow_oop_base() { return _narrow_oop._base; }
+ static bool is_narrow_oop_base(void* addr) { return (narrow_oop_base() == (address)addr); }
static int narrow_oop_shift() { return _narrow_oop._shift; }
static void set_narrow_oop_base(address base) { _narrow_oop._base = base; }
static void set_narrow_oop_shift(int shift) { _narrow_oop._shift = shift; }
@@ -398,7 +399,7 @@
// Debugging
static bool verify_in_progress() { return _verify_in_progress; }
- static void verify(bool allow_dirty = true, bool silent = false);
+ static void verify(bool allow_dirty = true, bool silent = false, bool option = true);
static int verify_count() { return _verify_count; }
static void print();
static void print_on(outputStream* st);
--- a/hotspot/src/share/vm/oops/cpCacheOop.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/oops/cpCacheOop.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/oops/generateOopMap.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/oops/generateOopMap.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/oops/instanceRefKlass.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/oops/instanceRefKlass.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -28,13 +28,14 @@
template <class T>
static void specialized_oop_follow_contents(instanceRefKlass* ref, oop obj) {
T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj);
- oop referent = oopDesc::load_decode_heap_oop(referent_addr);
+ T heap_oop = oopDesc::load_heap_oop(referent_addr);
debug_only(
if(TraceReferenceGC && PrintGCDetails) {
gclog_or_tty->print_cr("instanceRefKlass::oop_follow_contents " INTPTR_FORMAT, obj);
}
)
- if (referent != NULL) {
+ if (!oopDesc::is_null(heap_oop)) {
+ oop referent = oopDesc::decode_heap_oop_not_null(heap_oop);
if (!referent->is_gc_marked() &&
MarkSweep::ref_processor()->
discover_reference(obj, ref->reference_type())) {
@@ -81,13 +82,14 @@
ParCompactionManager* cm,
oop obj) {
T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj);
- oop referent = oopDesc::load_decode_heap_oop(referent_addr);
+ T heap_oop = oopDesc::load_heap_oop(referent_addr);
debug_only(
if(TraceReferenceGC && PrintGCDetails) {
gclog_or_tty->print_cr("instanceRefKlass::oop_follow_contents " INTPTR_FORMAT, obj);
}
)
- if (referent != NULL) {
+ if (!oopDesc::is_null(heap_oop)) {
+ oop referent = oopDesc::decode_heap_oop_not_null(heap_oop);
if (PSParallelCompact::mark_bitmap()->is_unmarked(referent) &&
PSParallelCompact::ref_processor()->
discover_reference(obj, ref->reference_type())) {
@@ -182,9 +184,10 @@
} \
\
T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj); \
- oop referent = oopDesc::load_decode_heap_oop(referent_addr); \
- if (referent != NULL && contains(referent_addr)) { \
+ T heap_oop = oopDesc::load_heap_oop(referent_addr); \
+ if (!oopDesc::is_null(heap_oop) && contains(referent_addr)) { \
ReferenceProcessor* rp = closure->_ref_processor; \
+ oop referent = oopDesc::decode_heap_oop_not_null(heap_oop); \
if (!referent->is_gc_marked() && (rp != NULL) && \
rp->discover_reference(obj, reference_type())) { \
return size; \
--- a/hotspot/src/share/vm/oops/methodDataOop.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/oops/methodDataOop.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/oops/methodKlass.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/oops/methodKlass.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -68,7 +68,7 @@
m->set_constants(NULL);
m->set_max_stack(0);
m->set_max_locals(0);
- m->clear_intrinsic_id_cache();
+ m->set_intrinsic_id(vmIntrinsics::_none);
m->set_method_data(NULL);
m->set_interpreter_throwout_count(0);
m->set_vtable_index(methodOopDesc::garbage_vtable_index);
--- a/hotspot/src/share/vm/oops/methodOop.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/oops/methodOop.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -962,26 +962,39 @@
return newm;
}
-vmIntrinsics::ID methodOopDesc::compute_intrinsic_id() const {
- assert(vmIntrinsics::_none == 0, "correct coding of default case");
- const uintptr_t max_cache_uint = right_n_bits((int)(sizeof(_intrinsic_id_cache) * BitsPerByte));
- assert((uintptr_t)vmIntrinsics::ID_LIMIT <= max_cache_uint, "else fix cache size");
+vmSymbols::SID methodOopDesc::klass_id_for_intrinsics(klassOop holder) {
// if loader is not the default loader (i.e., != NULL), we can't know the intrinsics
// because we are not loading from core libraries
- if (instanceKlass::cast(method_holder())->class_loader() != NULL) return vmIntrinsics::_none;
+ if (instanceKlass::cast(holder)->class_loader() != NULL)
+ return vmSymbols::NO_SID; // regardless of name, no intrinsics here
// see if the klass name is well-known:
- symbolOop klass_name = instanceKlass::cast(method_holder())->name();
- vmSymbols::SID klass_id = vmSymbols::find_sid(klass_name);
- if (klass_id == vmSymbols::NO_SID) return vmIntrinsics::_none;
+ symbolOop klass_name = instanceKlass::cast(holder)->name();
+ return vmSymbols::find_sid(klass_name);
+}
+
+void methodOopDesc::init_intrinsic_id() {
+ assert(_intrinsic_id == vmIntrinsics::_none, "do this just once");
+ const uintptr_t max_id_uint = right_n_bits((int)(sizeof(_intrinsic_id) * BitsPerByte));
+ assert((uintptr_t)vmIntrinsics::ID_LIMIT <= max_id_uint, "else fix size");
+
+ // the klass name is well-known:
+ vmSymbols::SID klass_id = klass_id_for_intrinsics(method_holder());
+ assert(klass_id != vmSymbols::NO_SID, "caller responsibility");
// ditto for method and signature:
vmSymbols::SID name_id = vmSymbols::find_sid(name());
- if (name_id == vmSymbols::NO_SID) return vmIntrinsics::_none;
+ if (name_id == vmSymbols::NO_SID) return;
vmSymbols::SID sig_id = vmSymbols::find_sid(signature());
- if (sig_id == vmSymbols::NO_SID) return vmIntrinsics::_none;
+ if (sig_id == vmSymbols::NO_SID) return;
jshort flags = access_flags().as_short();
+ vmIntrinsics::ID id = vmIntrinsics::find_id(klass_id, name_id, sig_id, flags);
+ if (id != vmIntrinsics::_none) {
+ set_intrinsic_id(id);
+ return;
+ }
+
// A few slightly irregular cases:
switch (klass_id) {
case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_StrictMath):
@@ -992,15 +1005,18 @@
case vmSymbols::VM_SYMBOL_ENUM_NAME(sqrt_name):
// pretend it is the corresponding method in the non-strict class:
klass_id = vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_Math);
+ id = vmIntrinsics::find_id(klass_id, name_id, sig_id, flags);
break;
}
}
- // return intrinsic id if any
- return vmIntrinsics::find_id(klass_id, name_id, sig_id, flags);
+ if (id != vmIntrinsics::_none) {
+ // Set up its iid. It is an alias method.
+ set_intrinsic_id(id);
+ return;
+ }
}
-
// These two methods are static since a GC may move the methodOopDesc
bool methodOopDesc::load_signature_classes(methodHandle m, TRAPS) {
bool sig_is_loaded = true;
--- a/hotspot/src/share/vm/oops/methodOop.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/oops/methodOop.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -104,7 +104,7 @@
u2 _max_stack; // Maximum number of entries on the expression stack
u2 _max_locals; // Number of local variables used by this method
u2 _size_of_parameters; // size of the parameter block (receiver + arguments) in words
- u1 _intrinsic_id_cache; // Cache for intrinsic_id; 0 or 1+vmInt::ID
+ u1 _intrinsic_id; // vmSymbols::intrinsic_id (0 == _none)
u1 _highest_tier_compile; // Highest compile level this method has ever seen.
u2 _interpreter_throwout_count; // Count of times method was exited via exception while interpreting
u2 _number_of_breakpoints; // fullspeed debugging support
@@ -224,8 +224,6 @@
int highest_tier_compile() { return _highest_tier_compile;}
void set_highest_tier_compile(int level) { _highest_tier_compile = level;}
- void clear_intrinsic_id_cache() { _intrinsic_id_cache = 0; }
-
// Count of times method was exited via exception while interpreting
void interpreter_throwout_increment() {
if (_interpreter_throwout_count < 65534) {
@@ -571,18 +569,12 @@
void set_cached_itable_index(int index) { instanceKlass::cast(method_holder())->set_cached_itable_index(method_idnum(), index); }
// Support for inlining of intrinsic methods
- vmIntrinsics::ID intrinsic_id() const { // returns zero if not an intrinsic
- const u1& cache = _intrinsic_id_cache;
- if (cache != 0) {
- return (vmIntrinsics::ID)(cache - 1);
- } else {
- vmIntrinsics::ID id = compute_intrinsic_id();
- *(u1*)&cache = ((u1) id) + 1; // force the cache to be non-const
- vmIntrinsics::verify_method(id, (methodOop) this);
- assert((vmIntrinsics::ID)(cache - 1) == id, "proper conversion");
- return id;
- }
- }
+ vmIntrinsics::ID intrinsic_id() const { return (vmIntrinsics::ID) _intrinsic_id; }
+ void set_intrinsic_id(vmIntrinsics::ID id) { _intrinsic_id = (u1) id; }
+
+ // Helper routines for intrinsic_id() and vmIntrinsics::method().
+ void init_intrinsic_id(); // updates from _none if a match
+ static vmSymbols::SID klass_id_for_intrinsics(klassOop holder);
// On-stack replacement support
bool has_osr_nmethod() { return instanceKlass::cast(method_holder())->lookup_osr_nmethod(this, InvocationEntryBci) != NULL; }
@@ -635,9 +627,6 @@
void set_size_of_parameters(int size) { _size_of_parameters = size; }
private:
- // Helper routine for intrinsic_id().
- vmIntrinsics::ID compute_intrinsic_id() const;
-
// Inlined elements
address* native_function_addr() const { assert(is_native(), "must be native"); return (address*) (this+1); }
address* signature_handler_addr() const { return native_function_addr() + 1; }
--- a/hotspot/src/share/vm/oops/objArrayKlass.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/oops/objArrayKlass.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -84,8 +84,6 @@
template <class T> void objArrayKlass::do_copy(arrayOop s, T* src,
arrayOop d, T* dst, int length, TRAPS) {
- const size_t word_len = objArrayOopDesc::array_size(length);
-
BarrierSet* bs = Universe::heap()->barrier_set();
// For performance reasons, we assume we are that the write barrier we
// are using has optimized modes for arrays of references. At least one
@@ -93,11 +91,10 @@
assert(bs->has_write_ref_array_opt(), "Barrier set must have ref array opt");
assert(bs->has_write_ref_array_pre_opt(), "For pre-barrier as well.");
- MemRegion dst_mr = MemRegion((HeapWord*)dst, word_len);
if (s == d) {
// since source and destination are equal we do not need conversion checks.
assert(length > 0, "sanity check");
- bs->write_ref_array_pre(dst_mr);
+ bs->write_ref_array_pre(dst, length);
Copy::conjoint_oops_atomic(src, dst, length);
} else {
// We have to make sure all elements conform to the destination array
@@ -105,7 +102,7 @@
klassOop stype = objArrayKlass::cast(s->klass())->element_klass();
if (stype == bound || Klass::cast(stype)->is_subtype_of(bound)) {
// elements are guaranteed to be subtypes, so no check necessary
- bs->write_ref_array_pre(dst_mr);
+ bs->write_ref_array_pre(dst, length);
Copy::conjoint_oops_atomic(src, dst, length);
} else {
// slow case: need individual subtype checks
@@ -137,6 +134,7 @@
}
}
}
+ const size_t word_len = objArrayOopDesc::array_size(length);
bs->write_ref_array(MemRegion((HeapWord*)dst, word_len));
}
--- a/hotspot/src/share/vm/oops/oop.inline.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/oops/oop.inline.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -148,12 +148,14 @@
inline narrowOop oopDesc::encode_heap_oop_not_null(oop v) {
assert(!is_null(v), "oop value can never be zero");
+ assert(Universe::heap()->is_in_reserved(v), "Address not in heap");
address base = Universe::narrow_oop_base();
int shift = Universe::narrow_oop_shift();
uint64_t pd = (uint64_t)(pointer_delta((void*)v, (void*)base, 1));
assert(OopEncodingHeapMax > pd, "change encoding max if new encoding");
uint64_t result = pd >> shift;
assert((result & CONST64(0xffffffff00000000)) == 0, "narrow oop overflow");
+ assert(decode_heap_oop(result) == v, "reversibility");
return (narrowOop)result;
}
@@ -449,7 +451,7 @@
oopDesc::bs()->write_ref_field(p, v);
}
-inline void update_barrier_set_pre(void* p, oop v) {
+template <class T> inline void update_barrier_set_pre(T* p, oop v) {
oopDesc::bs()->write_ref_field_pre(p, v);
}
@@ -459,15 +461,15 @@
} else {
update_barrier_set_pre(p, v);
oopDesc::encode_store_heap_oop(p, v);
- update_barrier_set(p, v);
+ update_barrier_set((void*)p, v); // cast away type
}
}
template <class T> inline void oop_store(volatile T* p, oop v) {
- update_barrier_set_pre((void*)p, v);
+ update_barrier_set_pre((T*)p, v); // cast away volatile
// Used by release_obj_field_put, so use release_store_ptr.
oopDesc::release_encode_store_heap_oop(p, v);
- update_barrier_set((void*)p, v);
+ update_barrier_set((void*)p, v); // cast away type
}
template <class T> inline void oop_store_without_check(T* p, oop v) {
--- a/hotspot/src/share/vm/oops/oopsHierarchy.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/oops/oopsHierarchy.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -29,6 +29,7 @@
typedef juint narrowOop; // Offset instead of address for an oop within a java object
typedef class klassOopDesc* wideKlassOop; // to keep SA happy and unhandled oop
// detector happy.
+typedef void* OopOrNarrowOopStar;
#ifndef CHECK_UNHANDLED_OOPS
--- a/hotspot/src/share/vm/opto/addnode.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/addnode.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/opto/block.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/block.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/opto/buildOopMap.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/buildOopMap.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2002-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/opto/bytecodeInfo.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/bytecodeInfo.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/opto/c2compiler.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/c2compiler.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/opto/callnode.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/callnode.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/opto/callnode.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/callnode.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/opto/cfgnode.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/cfgnode.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1796,8 +1796,12 @@
for (uint i=1; i<req(); ++i) {// For all paths in
Node *ii = in(i);
if (ii->is_DecodeN() && ii->bottom_type() == bottom_type()) {
- has_decodeN = true;
- in_decodeN = ii->in(1);
+ // Note: in_decodeN is used only to define the type of new phi.
+ // Find a non dead path otherwise phi type will be wrong.
+ if (ii->in(1)->bottom_type() != Type::TOP) {
+ has_decodeN = true;
+ in_decodeN = ii->in(1);
+ }
} else if (!ii->is_Phi()) {
may_push = false;
}
@@ -1805,7 +1809,6 @@
if (has_decodeN && may_push) {
PhaseIterGVN *igvn = phase->is_IterGVN();
- // Note: in_decodeN is used only to define the type of new phi here.
PhiNode *new_phi = PhiNode::make_blank(in(0), in_decodeN);
uint orig_cnt = req();
for (uint i=1; i<req(); ++i) {// For all paths in
--- a/hotspot/src/share/vm/opto/coalesce.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/coalesce.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/opto/compile.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/compile.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -101,7 +101,8 @@
}
}
// Lazily create intrinsics for intrinsic IDs well-known in the runtime.
- if (m->intrinsic_id() != vmIntrinsics::_none) {
+ if (m->intrinsic_id() != vmIntrinsics::_none &&
+ m->intrinsic_id() <= vmIntrinsics::LAST_COMPILER_INLINE) {
CallGenerator* cg = make_vm_intrinsic(m, is_virtual);
if (cg != NULL) {
// Save it for next time:
@@ -440,6 +441,8 @@
_orig_pc_slot_offset_in_bytes(0),
_node_bundling_limit(0),
_node_bundling_base(NULL),
+ _java_calls(0),
+ _inner_loops(0),
#ifndef PRODUCT
_trace_opto_output(TraceOptoOutput || method()->has_option("TraceOptoOutput")),
_printer(IdealGraphPrinter::printer()),
@@ -710,6 +713,8 @@
_code_buffer("Compile::Fill_buffer"),
_node_bundling_limit(0),
_node_bundling_base(NULL),
+ _java_calls(0),
+ _inner_loops(0),
#ifndef PRODUCT
_trace_opto_output(TraceOptoOutput),
_printer(NULL),
@@ -1850,22 +1855,26 @@
int _float_count; // count float ops requiring 24-bit precision
int _double_count; // count double ops requiring more precision
int _java_call_count; // count non-inlined 'java' calls
+ int _inner_loop_count; // count loops which need alignment
VectorSet _visited; // Visitation flags
Node_List _tests; // Set of IfNodes & PCTableNodes
Final_Reshape_Counts() :
- _call_count(0), _float_count(0), _double_count(0), _java_call_count(0),
+ _call_count(0), _float_count(0), _double_count(0),
+ _java_call_count(0), _inner_loop_count(0),
_visited( Thread::current()->resource_area() ) { }
void inc_call_count () { _call_count ++; }
void inc_float_count () { _float_count ++; }
void inc_double_count() { _double_count++; }
void inc_java_call_count() { _java_call_count++; }
+ void inc_inner_loop_count() { _inner_loop_count++; }
int get_call_count () const { return _call_count ; }
int get_float_count () const { return _float_count ; }
int get_double_count() const { return _double_count; }
int get_java_call_count() const { return _java_call_count; }
+ int get_inner_loop_count() const { return _inner_loop_count; }
};
static bool oop_offset_is_sane(const TypeInstPtr* tp) {
@@ -1877,7 +1886,7 @@
//------------------------------final_graph_reshaping_impl----------------------
// Implement items 1-5 from final_graph_reshaping below.
-static void final_graph_reshaping_impl( Node *n, Final_Reshape_Counts &fpu ) {
+static void final_graph_reshaping_impl( Node *n, Final_Reshape_Counts &frc ) {
if ( n->outcnt() == 0 ) return; // dead node
uint nop = n->Opcode();
@@ -1919,13 +1928,13 @@
case Op_CmpF:
case Op_CmpF3:
// case Op_ConvL2F: // longs are split into 32-bit halves
- fpu.inc_float_count();
+ frc.inc_float_count();
break;
case Op_ConvF2D:
case Op_ConvD2F:
- fpu.inc_float_count();
- fpu.inc_double_count();
+ frc.inc_float_count();
+ frc.inc_double_count();
break;
// Count all double operations that may use FPU
@@ -1942,7 +1951,7 @@
case Op_ConD:
case Op_CmpD:
case Op_CmpD3:
- fpu.inc_double_count();
+ frc.inc_double_count();
break;
case Op_Opaque1: // Remove Opaque Nodes before matching
case Op_Opaque2: // Remove Opaque Nodes before matching
@@ -1951,7 +1960,7 @@
case Op_CallStaticJava:
case Op_CallJava:
case Op_CallDynamicJava:
- fpu.inc_java_call_count(); // Count java call site;
+ frc.inc_java_call_count(); // Count java call site;
case Op_CallRuntime:
case Op_CallLeaf:
case Op_CallLeafNoFP: {
@@ -1962,7 +1971,7 @@
// uncommon_trap, _complete_monitor_locking, _complete_monitor_unlocking,
// _new_Java, _new_typeArray, _new_objArray, _rethrow_Java, ...
if( !call->is_CallStaticJava() || !call->as_CallStaticJava()->_name ) {
- fpu.inc_call_count(); // Count the call site
+ frc.inc_call_count(); // Count the call site
} else { // See if uncommon argument is shared
Node *n = call->in(TypeFunc::Parms);
int nop = n->Opcode();
@@ -1983,11 +1992,11 @@
case Op_StoreD:
case Op_LoadD:
case Op_LoadD_unaligned:
- fpu.inc_double_count();
+ frc.inc_double_count();
goto handle_mem;
case Op_StoreF:
case Op_LoadF:
- fpu.inc_float_count();
+ frc.inc_float_count();
goto handle_mem;
case Op_StoreB:
@@ -2324,6 +2333,12 @@
n->subsume_by(btp);
}
break;
+ case Op_Loop:
+ case Op_CountedLoop:
+ if (n->as_Loop()->is_inner_loop()) {
+ frc.inc_inner_loop_count();
+ }
+ break;
default:
assert( !n->is_Call(), "" );
assert( !n->is_Mem(), "" );
@@ -2332,17 +2347,17 @@
// Collect CFG split points
if (n->is_MultiBranch())
- fpu._tests.push(n);
+ frc._tests.push(n);
}
//------------------------------final_graph_reshaping_walk---------------------
// Replacing Opaque nodes with their input in final_graph_reshaping_impl(),
// requires that the walk visits a node's inputs before visiting the node.
-static void final_graph_reshaping_walk( Node_Stack &nstack, Node *root, Final_Reshape_Counts &fpu ) {
+static void final_graph_reshaping_walk( Node_Stack &nstack, Node *root, Final_Reshape_Counts &frc ) {
ResourceArea *area = Thread::current()->resource_area();
Unique_Node_List sfpt(area);
- fpu._visited.set(root->_idx); // first, mark node as visited
+ frc._visited.set(root->_idx); // first, mark node as visited
uint cnt = root->req();
Node *n = root;
uint i = 0;
@@ -2351,7 +2366,7 @@
// Place all non-visited non-null inputs onto stack
Node* m = n->in(i);
++i;
- if (m != NULL && !fpu._visited.test_set(m->_idx)) {
+ if (m != NULL && !frc._visited.test_set(m->_idx)) {
if (m->is_SafePoint() && m->as_SafePoint()->jvms() != NULL)
sfpt.push(m);
cnt = m->req();
@@ -2361,7 +2376,7 @@
}
} else {
// Now do post-visit work
- final_graph_reshaping_impl( n, fpu );
+ final_graph_reshaping_impl( n, frc );
if (nstack.is_empty())
break; // finished
n = nstack.node(); // Get node from stack
@@ -2442,16 +2457,16 @@
return true;
}
- Final_Reshape_Counts fpu;
+ Final_Reshape_Counts frc;
// Visit everybody reachable!
// Allocate stack of size C->unique()/2 to avoid frequent realloc
Node_Stack nstack(unique() >> 1);
- final_graph_reshaping_walk(nstack, root(), fpu);
+ final_graph_reshaping_walk(nstack, root(), frc);
// Check for unreachable (from below) code (i.e., infinite loops).
- for( uint i = 0; i < fpu._tests.size(); i++ ) {
- MultiBranchNode *n = fpu._tests[i]->as_MultiBranch();
+ for( uint i = 0; i < frc._tests.size(); i++ ) {
+ MultiBranchNode *n = frc._tests[i]->as_MultiBranch();
// Get number of CFG targets.
// Note that PCTables include exception targets after calls.
uint required_outcnt = n->required_outcnt();
@@ -2497,7 +2512,7 @@
// Check that I actually visited all kids. Unreached kids
// must be infinite loops.
for (DUIterator_Fast jmax, j = n->fast_outs(jmax); j < jmax; j++)
- if (!fpu._visited.test(n->fast_out(j)->_idx)) {
+ if (!frc._visited.test(n->fast_out(j)->_idx)) {
record_method_not_compilable("infinite loop");
return true; // Found unvisited kid; must be unreach
}
@@ -2506,13 +2521,14 @@
// If original bytecodes contained a mixture of floats and doubles
// check if the optimizer has made it homogenous, item (3).
if( Use24BitFPMode && Use24BitFP &&
- fpu.get_float_count() > 32 &&
- fpu.get_double_count() == 0 &&
- (10 * fpu.get_call_count() < fpu.get_float_count()) ) {
+ frc.get_float_count() > 32 &&
+ frc.get_double_count() == 0 &&
+ (10 * frc.get_call_count() < frc.get_float_count()) ) {
set_24_bit_selection_and_mode( false, true );
}
- set_has_java_calls(fpu.get_java_call_count() > 0);
+ set_java_calls(frc.get_java_call_count());
+ set_inner_loops(frc.get_inner_loop_count());
// No infinite loops, no reason to bail out.
return false;
--- a/hotspot/src/share/vm/opto/compile.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/compile.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -223,7 +223,8 @@
PhaseCFG* _cfg; // Results of CFG finding
bool _select_24_bit_instr; // We selected an instruction with a 24-bit result
bool _in_24_bit_fp_mode; // We are emitting instructions with 24-bit results
- bool _has_java_calls; // True if the method has java calls
+ int _java_calls; // Number of java calls in the method
+ int _inner_loops; // Number of inner loops in the method
Matcher* _matcher; // Engine to map ideal to machine instructions
PhaseRegAlloc* _regalloc; // Results of register allocation.
int _frame_slots; // Size of total frame in stack slots
@@ -505,7 +506,9 @@
PhaseCFG* cfg() { return _cfg; }
bool select_24_bit_instr() const { return _select_24_bit_instr; }
bool in_24_bit_fp_mode() const { return _in_24_bit_fp_mode; }
- bool has_java_calls() const { return _has_java_calls; }
+ bool has_java_calls() const { return _java_calls > 0; }
+ int java_calls() const { return _java_calls; }
+ int inner_loops() const { return _inner_loops; }
Matcher* matcher() { return _matcher; }
PhaseRegAlloc* regalloc() { return _regalloc; }
int frame_slots() const { return _frame_slots; }
@@ -532,7 +535,8 @@
_in_24_bit_fp_mode = mode;
}
- void set_has_java_calls(bool z) { _has_java_calls = z; }
+ void set_java_calls(int z) { _java_calls = z; }
+ void set_inner_loops(int z) { _inner_loops = z; }
// Instruction bits passed off to the VM
int code_size() { return _method_size; }
--- a/hotspot/src/share/vm/opto/connode.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/connode.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/opto/doCall.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/doCall.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/opto/escape.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/escape.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -578,11 +578,24 @@
if (phi_alias_idx == alias_idx) {
return orig_phi;
}
- // have we already created a Phi for this alias index?
+ // Have we recently created a Phi for this alias index?
PhiNode *result = get_map_phi(orig_phi->_idx);
if (result != NULL && C->get_alias_index(result->adr_type()) == alias_idx) {
return result;
}
+ // Previous check may fail when the same wide memory Phi was split into Phis
+ // for different memory slices. Search all Phis for this region.
+ if (result != NULL) {
+ Node* region = orig_phi->in(0);
+ for (DUIterator_Fast imax, i = region->fast_outs(imax); i < imax; i++) {
+ Node* phi = region->fast_out(i);
+ if (phi->is_Phi() &&
+ C->get_alias_index(phi->as_Phi()->adr_type()) == alias_idx) {
+ assert(phi->_idx >= nodes_size(), "only new Phi per instance memory slice");
+ return phi->as_Phi();
+ }
+ }
+ }
if ((int)C->unique() + 2*NodeLimitFudgeFactor > MaxNodeLimit) {
if (C->do_escape_analysis() == true && !C->failing()) {
// Retry compilation without escape analysis.
@@ -595,6 +608,7 @@
orig_phi_worklist.append_if_missing(orig_phi);
const TypePtr *atype = C->get_adr_type(alias_idx);
result = PhiNode::make(orig_phi->in(0), NULL, Type::MEMORY, atype);
+ C->copy_node_notes_to(result, orig_phi);
set_map_phi(orig_phi->_idx, result);
igvn->set_type(result, result->bottom_type());
record_for_optimizer(result);
--- a/hotspot/src/share/vm/opto/graphKit.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/graphKit.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1373,11 +1373,12 @@
return st;
}
+
void GraphKit::pre_barrier(Node* ctl,
Node* obj,
Node* adr,
- uint adr_idx,
- Node *val,
+ uint adr_idx,
+ Node* val,
const TypeOopPtr* val_type,
BasicType bt) {
BarrierSet* bs = Universe::heap()->barrier_set();
@@ -1385,7 +1386,7 @@
switch (bs->kind()) {
case BarrierSet::G1SATBCT:
case BarrierSet::G1SATBCTLogging:
- g1_write_barrier_pre(obj, adr, adr_idx, val, val_type, bt);
+ g1_write_barrier_pre(obj, adr, adr_idx, val, val_type, bt);
break;
case BarrierSet::CardTableModRef:
@@ -1404,8 +1405,8 @@
Node* store,
Node* obj,
Node* adr,
- uint adr_idx,
- Node *val,
+ uint adr_idx,
+ Node* val,
BasicType bt,
bool use_precise) {
BarrierSet* bs = Universe::heap()->barrier_set();
@@ -1413,7 +1414,7 @@
switch (bs->kind()) {
case BarrierSet::G1SATBCT:
case BarrierSet::G1SATBCTLogging:
- g1_write_barrier_post(store, obj, adr, adr_idx, val, bt, use_precise);
+ g1_write_barrier_post(store, obj, adr, adr_idx, val, bt, use_precise);
break;
case BarrierSet::CardTableModRef:
@@ -1431,42 +1432,36 @@
}
}
-Node* GraphKit::store_oop_to_object(Node* ctl,
- Node* obj,
- Node* adr,
- const TypePtr* adr_type,
- Node *val,
- const TypeOopPtr* val_type,
- BasicType bt) {
+Node* GraphKit::store_oop(Node* ctl,
+ Node* obj,
+ Node* adr,
+ const TypePtr* adr_type,
+ Node* val,
+ const TypeOopPtr* val_type,
+ BasicType bt,
+ bool use_precise) {
+
+ set_control(ctl);
+ if (stopped()) return top(); // Dead path ?
+
+ assert(bt == T_OBJECT, "sanity");
+ assert(val != NULL, "not dead path");
uint adr_idx = C->get_alias_index(adr_type);
- Node* store;
- pre_barrier(ctl, obj, adr, adr_idx, val, val_type, bt);
- store = store_to_memory(control(), adr, val, bt, adr_idx);
- post_barrier(control(), store, obj, adr, adr_idx, val, bt, false);
+ assert(adr_idx != Compile::AliasIdxTop, "use other store_to_memory factory" );
+
+ pre_barrier(control(), obj, adr, adr_idx, val, val_type, bt);
+ Node* store = store_to_memory(control(), adr, val, bt, adr_idx);
+ post_barrier(control(), store, obj, adr, adr_idx, val, bt, use_precise);
return store;
}
-Node* GraphKit::store_oop_to_array(Node* ctl,
- Node* obj,
- Node* adr,
- const TypePtr* adr_type,
- Node *val,
- const TypeOopPtr* val_type,
- BasicType bt) {
- uint adr_idx = C->get_alias_index(adr_type);
- Node* store;
- pre_barrier(ctl, obj, adr, adr_idx, val, val_type, bt);
- store = store_to_memory(control(), adr, val, bt, adr_idx);
- post_barrier(control(), store, obj, adr, adr_idx, val, bt, true);
- return store;
-}
-
+// Could be an array or object we don't know at compile time (unsafe ref.)
Node* GraphKit::store_oop_to_unknown(Node* ctl,
- Node* obj,
- Node* adr,
- const TypePtr* adr_type,
- Node *val,
- BasicType bt) {
+ Node* obj, // containing obj
+ Node* adr, // actual adress to store val at
+ const TypePtr* adr_type,
+ Node* val,
+ BasicType bt) {
Compile::AliasType* at = C->alias_type(adr_type);
const TypeOopPtr* val_type = NULL;
if (adr_type->isa_instptr()) {
@@ -1485,12 +1480,7 @@
if (val_type == NULL) {
val_type = TypeInstPtr::BOTTOM;
}
-
- uint adr_idx = at->index();
- pre_barrier(ctl, obj, adr, adr_idx, val, val_type, bt);
- Node* store = store_to_memory(control(), adr, val, bt, adr_idx);
- post_barrier(control(), store, obj, adr, adr_idx, val, bt, true);
- return store;
+ return store_oop(ctl, obj, adr, adr_type, val, val_type, bt, true);
}
@@ -1804,93 +1794,6 @@
}
-//------------------------------store_barrier----------------------------------
-// Insert a write-barrier store. This is to let generational GC work; we have
-// to flag all oop-stores before the next GC point.
-void GraphKit::write_barrier_post(Node* oop_store, Node* obj, Node* adr,
- Node* val, bool use_precise) {
- // No store check needed if we're storing a NULL or an old object
- // (latter case is probably a string constant). The concurrent
- // mark sweep garbage collector, however, needs to have all nonNull
- // oop updates flagged via card-marks.
- if (val != NULL && val->is_Con()) {
- // must be either an oop or NULL
- const Type* t = val->bottom_type();
- if (t == TypePtr::NULL_PTR || t == Type::TOP)
- // stores of null never (?) need barriers
- return;
- ciObject* con = t->is_oopptr()->const_oop();
- if (con != NULL
- && con->is_perm()
- && Universe::heap()->can_elide_permanent_oop_store_barriers())
- // no store barrier needed, because no old-to-new ref created
- return;
- }
-
- if (use_ReduceInitialCardMarks()
- && obj == just_allocated_object(control())) {
- // We can skip marks on a freshly-allocated object.
- // Keep this code in sync with do_eager_card_mark in runtime.cpp.
- // That routine eagerly marks the occasional object which is produced
- // by the slow path, so that we don't have to do it here.
- return;
- }
-
- if (!use_precise) {
- // All card marks for a (non-array) instance are in one place:
- adr = obj;
- }
- // (Else it's an array (or unknown), and we want more precise card marks.)
- assert(adr != NULL, "");
-
- // Get the alias_index for raw card-mark memory
- int adr_type = Compile::AliasIdxRaw;
- // Convert the pointer to an int prior to doing math on it
- Node* cast = _gvn.transform(new (C, 2) CastP2XNode(control(), adr));
- // Divide by card size
- assert(Universe::heap()->barrier_set()->kind() == BarrierSet::CardTableModRef,
- "Only one we handle so far.");
- CardTableModRefBS* ct =
- (CardTableModRefBS*)(Universe::heap()->barrier_set());
- Node *b = _gvn.transform(new (C, 3) URShiftXNode( cast, _gvn.intcon(CardTableModRefBS::card_shift) ));
- // We store into a byte array, so do not bother to left-shift by zero
- Node *c = byte_map_base_node();
- // Combine
- Node *sb_ctl = control();
- Node *sb_adr = _gvn.transform(new (C, 4) AddPNode( top()/*no base ptr*/, c, b ));
- Node *sb_val = _gvn.intcon(0);
- // Smash zero into card
- if( !UseConcMarkSweepGC ) {
- BasicType bt = T_BYTE;
- store_to_memory(sb_ctl, sb_adr, sb_val, bt, adr_type);
- } else {
- // Specialized path for CM store barrier
- cms_card_mark( sb_ctl, sb_adr, sb_val, oop_store);
- }
-}
-
-// Specialized path for CMS store barrier
-void GraphKit::cms_card_mark(Node* ctl, Node* adr, Node* val, Node *oop_store) {
- BasicType bt = T_BYTE;
- int adr_idx = Compile::AliasIdxRaw;
- Node* mem = memory(adr_idx);
-
- // The type input is NULL in PRODUCT builds
- const TypePtr* type = NULL;
- debug_only(type = C->get_adr_type(adr_idx));
-
- // Add required edge to oop_store, optimizer does not support precedence edges.
- // Convert required edge to precedence edge before allocation.
- Node *store = _gvn.transform( new (C, 5) StoreCMNode(ctl, mem, adr, type, val, oop_store) );
- set_memory(store, adr_idx);
-
- // For CMS, back-to-back card-marks can only remove the first one
- // and this requires DU info. Push on worklist for optimizer.
- if (mem->req() > MemNode::Address && adr == mem->in(MemNode::Address))
- record_for_igvn(store);
-}
-
-
void GraphKit::round_double_arguments(ciMethod* dest_method) {
// (Note: TypeFunc::make has a cache that makes this fast.)
const TypeFunc* tf = TypeFunc::make(dest_method);
@@ -3215,6 +3118,79 @@
return NULL;
}
+//----------------------------- store barriers ----------------------------
+#define __ ideal.
+
+void GraphKit::sync_kit(IdealKit& ideal) {
+ // Final sync IdealKit and graphKit.
+ __ drain_delay_transform();
+ set_all_memory(__ merged_memory());
+ set_control(__ ctrl());
+}
+
+// vanilla/CMS post barrier
+// Insert a write-barrier store. This is to let generational GC work; we have
+// to flag all oop-stores before the next GC point.
+void GraphKit::write_barrier_post(Node* oop_store,
+ Node* obj,
+ Node* adr,
+ Node* val,
+ bool use_precise) {
+ // No store check needed if we're storing a NULL or an old object
+ // (latter case is probably a string constant). The concurrent
+ // mark sweep garbage collector, however, needs to have all nonNull
+ // oop updates flagged via card-marks.
+ if (val != NULL && val->is_Con()) {
+ // must be either an oop or NULL
+ const Type* t = val->bottom_type();
+ if (t == TypePtr::NULL_PTR || t == Type::TOP)
+ // stores of null never (?) need barriers
+ return;
+ ciObject* con = t->is_oopptr()->const_oop();
+ if (con != NULL
+ && con->is_perm()
+ && Universe::heap()->can_elide_permanent_oop_store_barriers())
+ // no store barrier needed, because no old-to-new ref created
+ return;
+ }
+
+ if (!use_precise) {
+ // All card marks for a (non-array) instance are in one place:
+ adr = obj;
+ }
+ // (Else it's an array (or unknown), and we want more precise card marks.)
+ assert(adr != NULL, "");
+
+ IdealKit ideal(gvn(), control(), merged_memory(), true);
+
+ // Convert the pointer to an int prior to doing math on it
+ Node* cast = __ CastPX(__ ctrl(), adr);
+
+ // Divide by card size
+ assert(Universe::heap()->barrier_set()->kind() == BarrierSet::CardTableModRef,
+ "Only one we handle so far.");
+ Node* card_offset = __ URShiftX( cast, __ ConI(CardTableModRefBS::card_shift) );
+
+ // Combine card table base and card offset
+ Node* card_adr = __ AddP(__ top(), byte_map_base_node(), card_offset );
+
+ // Get the alias_index for raw card-mark memory
+ int adr_type = Compile::AliasIdxRaw;
+ // Smash zero into card
+ Node* zero = __ ConI(0);
+ BasicType bt = T_BYTE;
+ if( !UseConcMarkSweepGC ) {
+ __ store(__ ctrl(), card_adr, zero, bt, adr_type);
+ } else {
+ // Specialized path for CM store barrier
+ __ storeCM(__ ctrl(), card_adr, zero, oop_store, bt, adr_type);
+ }
+
+ // Final sync IdealKit and GraphKit.
+ sync_kit(ideal);
+}
+
+// G1 pre/post barriers
void GraphKit::g1_write_barrier_pre(Node* obj,
Node* adr,
uint alias_idx,
@@ -3222,10 +3198,8 @@
const TypeOopPtr* val_type,
BasicType bt) {
IdealKit ideal(gvn(), control(), merged_memory(), true);
-#define __ ideal.
- __ declares_done();
-
- Node* thread = __ thread();
+
+ Node* tls = __ thread(); // ThreadLocalStorage
Node* no_ctrl = NULL;
Node* no_base = __ top();
@@ -3248,9 +3222,9 @@
// set_control( ctl);
- Node* marking_adr = __ AddP(no_base, thread, __ ConX(marking_offset));
- Node* buffer_adr = __ AddP(no_base, thread, __ ConX(buffer_offset));
- Node* index_adr = __ AddP(no_base, thread, __ ConX(index_offset));
+ Node* marking_adr = __ AddP(no_base, tls, __ ConX(marking_offset));
+ Node* buffer_adr = __ AddP(no_base, tls, __ ConX(buffer_offset));
+ Node* index_adr = __ AddP(no_base, tls, __ ConX(index_offset));
// Now some of the values
@@ -3278,55 +3252,52 @@
Node* next_index = __ SubI(index, __ ConI(sizeof(intptr_t)));
Node* next_indexX = next_index;
#ifdef _LP64
- // We could refine the type for what it's worth
- // const TypeLong* lidxtype = TypeLong::make(CONST64(0), get_size_from_queue);
- next_indexX = _gvn.transform( new (C, 2) ConvI2LNode(next_index, TypeLong::make(0, max_jlong, Type::WidenMax)) );
-#endif // _LP64
+ // We could refine the type for what it's worth
+ // const TypeLong* lidxtype = TypeLong::make(CONST64(0), get_size_from_queue);
+ next_indexX = _gvn.transform( new (C, 2) ConvI2LNode(next_index, TypeLong::make(0, max_jlong, Type::WidenMax)) );
+#endif
// Now get the buffer location we will log the original value into and store it
-
Node *log_addr = __ AddP(no_base, buffer, next_indexX);
- // __ store(__ ctrl(), log_addr, orig, T_OBJECT, C->get_alias_index(TypeOopPtr::BOTTOM));
__ store(__ ctrl(), log_addr, orig, T_OBJECT, Compile::AliasIdxRaw);
-
// update the index
- // __ store(__ ctrl(), index_adr, next_index, T_INT, Compile::AliasIdxRaw);
- // This is a hack to force this store to occur before the oop store that is coming up
- __ store(__ ctrl(), index_adr, next_index, T_INT, C->get_alias_index(TypeOopPtr::BOTTOM));
+ __ store(__ ctrl(), index_adr, next_index, T_INT, Compile::AliasIdxRaw);
} __ else_(); {
// logging buffer is full, call the runtime
const TypeFunc *tf = OptoRuntime::g1_wb_pre_Type();
- // __ make_leaf_call(tf, OptoRuntime::g1_wb_pre_Java(), "g1_wb_pre", orig, thread);
- __ make_leaf_call(tf, CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), "g1_wb_pre", orig, thread);
- } __ end_if();
- } __ end_if();
- } __ end_if();
-
- __ drain_delay_transform();
- set_control( __ ctrl());
- set_all_memory( __ merged_memory());
-
-#undef __
+ __ make_leaf_call(tf, CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), "g1_wb_pre", orig, tls);
+ } __ end_if(); // (!index)
+ } __ end_if(); // (orig != NULL)
+ } __ end_if(); // (!marking)
+
+ // Final sync IdealKit and GraphKit.
+ sync_kit(ideal);
}
//
// Update the card table and add card address to the queue
//
-void GraphKit::g1_mark_card(IdealKit* ideal, Node* card_adr, Node* store, Node* index, Node* index_adr, Node* buffer, const TypeFunc* tf) {
-#define __ ideal->
+void GraphKit::g1_mark_card(IdealKit& ideal,
+ Node* card_adr,
+ Node* oop_store,
+ Node* index,
+ Node* index_adr,
+ Node* buffer,
+ const TypeFunc* tf) {
+
Node* zero = __ ConI(0);
Node* no_base = __ top();
BasicType card_bt = T_BYTE;
// Smash zero into card. MUST BE ORDERED WRT TO STORE
- __ storeCM(__ ctrl(), card_adr, zero, store, card_bt, Compile::AliasIdxRaw);
+ __ storeCM(__ ctrl(), card_adr, zero, oop_store, card_bt, Compile::AliasIdxRaw);
// Now do the queue work
__ if_then(index, BoolTest::ne, zero); {
- Node* next_index = __ SubI(index, __ ConI(sizeof(intptr_t)));
+ Node* next_index = __ SubI(index, __ ConI(sizeof(intptr_t)));
Node* next_indexX = next_index;
#ifdef _LP64
// We could refine the type for what it's worth
@@ -3341,10 +3312,10 @@
} __ else_(); {
__ make_leaf_call(tf, CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_post), "g1_wb_post", card_adr, __ thread());
} __ end_if();
-#undef __
+
}
-void GraphKit::g1_write_barrier_post(Node* store,
+void GraphKit::g1_write_barrier_post(Node* oop_store,
Node* obj,
Node* adr,
uint alias_idx,
@@ -3369,10 +3340,8 @@
assert(adr != NULL, "");
IdealKit ideal(gvn(), control(), merged_memory(), true);
-#define __ ideal.
- __ declares_done();
-
- Node* thread = __ thread();
+
+ Node* tls = __ thread(); // ThreadLocalStorage
Node* no_ctrl = NULL;
Node* no_base = __ top();
@@ -3394,8 +3363,8 @@
// Pointers into the thread
- Node* buffer_adr = __ AddP(no_base, thread, __ ConX(buffer_offset));
- Node* index_adr = __ AddP(no_base, thread, __ ConX(index_offset));
+ Node* buffer_adr = __ AddP(no_base, tls, __ ConX(buffer_offset));
+ Node* index_adr = __ AddP(no_base, tls, __ ConX(index_offset));
// Now some values
@@ -3404,18 +3373,14 @@
// Convert the store obj pointer to an int prior to doing math on it
- // Use addr not obj gets accurate card marks
-
- // Node* cast = __ CastPX(no_ctrl, adr /* obj */);
-
// Must use ctrl to prevent "integerized oop" existing across safepoint
- Node* cast = __ CastPX(__ ctrl(), ( use_precise ? adr : obj ));
+ Node* cast = __ CastPX(__ ctrl(), adr);
// Divide pointer by card size
Node* card_offset = __ URShiftX( cast, __ ConI(CardTableModRefBS::card_shift) );
// Combine card table base and card offset
- Node *card_adr = __ AddP(no_base, byte_map_base_node(), card_offset );
+ Node* card_adr = __ AddP(no_base, byte_map_base_node(), card_offset );
// If we know the value being stored does it cross regions?
@@ -3439,18 +3404,17 @@
Node* card_val = __ load(__ ctrl(), card_adr, TypeInt::INT, T_BYTE, Compile::AliasIdxRaw);
__ if_then(card_val, BoolTest::ne, zero); {
- g1_mark_card(&ideal, card_adr, store, index, index_adr, buffer, tf);
+ g1_mark_card(ideal, card_adr, oop_store, index, index_adr, buffer, tf);
} __ end_if();
} __ end_if();
} __ end_if();
} else {
- g1_mark_card(&ideal, card_adr, store, index, index_adr, buffer, tf);
+ // Object.clone() instrinsic uses this path.
+ g1_mark_card(ideal, card_adr, oop_store, index, index_adr, buffer, tf);
}
-
- __ drain_delay_transform();
- set_control( __ ctrl());
- set_all_memory( __ merged_memory());
+ // Final sync IdealKit and GraphKit.
+ sync_kit(ideal);
+}
#undef __
-}
--- a/hotspot/src/share/vm/opto/graphKit.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/graphKit.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -449,13 +449,24 @@
//
// If val==NULL, it is taken to be a completely unknown value. QQQ
+ Node* store_oop(Node* ctl,
+ Node* obj, // containing obj
+ Node* adr, // actual adress to store val at
+ const TypePtr* adr_type,
+ Node* val,
+ const TypeOopPtr* val_type,
+ BasicType bt,
+ bool use_precise);
+
Node* store_oop_to_object(Node* ctl,
Node* obj, // containing obj
Node* adr, // actual adress to store val at
const TypePtr* adr_type,
Node* val,
const TypeOopPtr* val_type,
- BasicType bt);
+ BasicType bt) {
+ return store_oop(ctl, obj, adr, adr_type, val, val_type, bt, false);
+ }
Node* store_oop_to_array(Node* ctl,
Node* obj, // containing obj
@@ -463,7 +474,9 @@
const TypePtr* adr_type,
Node* val,
const TypeOopPtr* val_type,
- BasicType bt);
+ BasicType bt) {
+ return store_oop(ctl, obj, adr, adr_type, val, val_type, bt, true);
+ }
// Could be an array or object we don't know at compile time (unsafe ref.)
Node* store_oop_to_unknown(Node* ctl,
@@ -488,9 +501,6 @@
// Return a load of array element at idx.
Node* load_array_element(Node* ctl, Node* ary, Node* idx, const TypeAryPtr* arytype);
- // CMS card-marks have an input from the corresponding oop_store
- void cms_card_mark(Node* ctl, Node* adr, Node* val, Node* oop_store);
-
//---------------- Dtrace support --------------------
void make_dtrace_method_entry_exit(ciMethod* method, bool is_entry);
void make_dtrace_method_entry(ciMethod* method) {
@@ -582,9 +592,6 @@
return C->too_many_recompiles(method(), bci(), reason);
}
- // vanilla/CMS post barrier
- void write_barrier_post(Node *store, Node* obj, Node* adr, Node* val, bool use_precise);
-
// Returns the object (if any) which was created the moment before.
Node* just_allocated_object(Node* current_control);
@@ -593,6 +600,11 @@
&& Universe::heap()->can_elide_tlab_store_barriers());
}
+ void sync_kit(IdealKit& ideal);
+
+ // vanilla/CMS post barrier
+ void write_barrier_post(Node *store, Node* obj, Node* adr, Node* val, bool use_precise);
+
// G1 pre/post barriers
void g1_write_barrier_pre(Node* obj,
Node* adr,
@@ -610,7 +622,7 @@
bool use_precise);
// Helper function for g1
private:
- void g1_mark_card(IdealKit* ideal, Node* card_adr, Node* store, Node* index, Node* index_adr,
+ void g1_mark_card(IdealKit& ideal, Node* card_adr, Node* store, Node* index, Node* index_adr,
Node* buffer, const TypeFunc* tf);
public:
--- a/hotspot/src/share/vm/opto/idealKit.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/idealKit.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -34,7 +34,7 @@
const uint IdealKit::first_var = TypeFunc::Parms + 1;
//----------------------------IdealKit-----------------------------------------
-IdealKit::IdealKit(PhaseGVN &gvn, Node* control, Node* mem, bool delay_all_transforms) :
+IdealKit::IdealKit(PhaseGVN &gvn, Node* control, Node* mem, bool delay_all_transforms, bool has_declarations) :
_gvn(gvn), C(gvn.C) {
_initial_ctrl = control;
_initial_memory = mem;
@@ -47,6 +47,9 @@
_pending_cvstates = new (C->node_arena()) GrowableArray<Node*>(C->node_arena(), init_size, 0, 0);
_delay_transform = new (C->node_arena()) GrowableArray<Node*>(C->node_arena(), init_size, 0, 0);
DEBUG_ONLY(_state = new (C->node_arena()) GrowableArray<int>(C->node_arena(), init_size, 0, 0));
+ if (!has_declarations) {
+ declarations_done();
+ }
}
//-------------------------------if_then-------------------------------------
@@ -97,7 +100,7 @@
//-------------------------------end_if-------------------------------------
// Merge the "then" and "else" cvstates.
//
-// The if_then() pushed the current state for later use
+// The if_then() pushed a copy of the current state for later use
// as the initial state for a future "else" clause. The
// current state then became the initial state for the
// then clause. If an "else" clause was encountered, it will
@@ -258,8 +261,8 @@
return delay_transform(PhiNode::make(reg, n, ct));
}
-//-----------------------------declares_done-----------------------------------
-void IdealKit::declares_done() {
+//-----------------------------declarations_done-------------------------------
+void IdealKit::declarations_done() {
_cvstate = new_cvstate(); // initialize current cvstate
set_ctrl(_initial_ctrl); // initialize control in current cvstate
set_all_memory(_initial_memory);// initialize memory in current cvstate
@@ -277,7 +280,9 @@
//-----------------------------delay_transform-----------------------------------
Node* IdealKit::delay_transform(Node* n) {
- gvn().set_type(n, n->bottom_type());
+ if (!gvn().is_IterGVN() || !gvn().is_IterGVN()->delay_transform()) {
+ gvn().set_type(n, n->bottom_type());
+ }
_delay_transform->push(n);
return n;
}
@@ -321,7 +326,9 @@
Node* IdealKit::memory(uint alias_idx) {
MergeMemNode* mem = merged_memory();
Node* p = mem->memory_at(alias_idx);
- _gvn.set_type(p, Type::MEMORY); // must be mapped
+ if (!gvn().is_IterGVN() || !gvn().is_IterGVN()->delay_transform()) {
+ _gvn.set_type(p, Type::MEMORY); // must be mapped
+ }
return p;
}
@@ -462,9 +469,6 @@
const TypePtr* adr_type = TypeRawPtr::BOTTOM;
uint adr_idx = C->get_alias_index(adr_type);
- // Clone initial memory
- MergeMemNode* cloned_mem = MergeMemNode::make(C, merged_memory());
-
// Slow-path leaf call
int size = slow_call_type->domain()->cnt();
CallNode *call = (CallNode*)new (C, size) CallLeafNode( slow_call_type, slow_call, leaf_name, adr_type);
@@ -489,9 +493,6 @@
set_ctrl(transform( new (C, 1) ProjNode(call,TypeFunc::Control) ));
- // Set the incoming clone of memory as current memory
- set_all_memory(cloned_mem);
-
// Make memory for the call
Node* mem = _gvn.transform( new (C, 1) ProjNode(call, TypeFunc::Memory) );
--- a/hotspot/src/share/vm/opto/idealKit.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/idealKit.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -49,7 +49,7 @@
// Example:
// Node* limit = ??
// IdealVariable i(kit), j(kit);
-// declares_done();
+// declarations_done();
// Node* exit = make_label(1); // 1 goto
// set(j, ConI(0));
// loop(i, ConI(0), BoolTest::lt, limit); {
@@ -101,10 +101,7 @@
Node* new_cvstate(); // Create a new cvstate
Node* cvstate() { return _cvstate; } // current cvstate
Node* copy_cvstate(); // copy current cvstate
- void set_ctrl(Node* ctrl) { _cvstate->set_req(TypeFunc::Control, ctrl); }
- // Should this assert this is a MergeMem???
- void set_all_memory(Node* mem){ _cvstate->set_req(TypeFunc::Memory, mem); }
void set_memory(Node* mem, uint alias_idx );
void do_memory_merge(Node* merging, Node* join);
void clear(Node* m); // clear a cvstate
@@ -132,15 +129,17 @@
Node* memory(uint alias_idx);
public:
- IdealKit(PhaseGVN &gvn, Node* control, Node* memory, bool delay_all_transforms = false);
+ IdealKit(PhaseGVN &gvn, Node* control, Node* memory, bool delay_all_transforms = false, bool has_declarations = false);
~IdealKit() {
stop();
drain_delay_transform();
}
// Control
Node* ctrl() { return _cvstate->in(TypeFunc::Control); }
+ void set_ctrl(Node* ctrl) { _cvstate->set_req(TypeFunc::Control, ctrl); }
Node* top() { return C->top(); }
MergeMemNode* merged_memory() { return _cvstate->in(TypeFunc::Memory)->as_MergeMem(); }
+ void set_all_memory(Node* mem) { _cvstate->set_req(TypeFunc::Memory, mem); }
void set(IdealVariable& v, Node* rhs) { _cvstate->set_req(first_var + v.id(), rhs); }
Node* value(IdealVariable& v) { return _cvstate->in(first_var + v.id()); }
void dead(IdealVariable& v) { set(v, (Node*)NULL); }
@@ -155,7 +154,7 @@
Node* make_label(int goto_ct);
void bind(Node* lab);
void goto_(Node* lab, bool bind = false);
- void declares_done();
+ void declarations_done();
void drain_delay_transform();
Node* IfTrue(IfNode* iff) { return transform(new (C,1) IfTrueNode(iff)); }
--- a/hotspot/src/share/vm/opto/ifnode.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/ifnode.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -378,7 +378,18 @@
// Force the original merge dead
igvn->hash_delete(r);
- r->set_req_X(0,NULL,igvn);
+ // First, remove region's dead users.
+ for (DUIterator_Last lmin, l = r->last_outs(lmin); l >= lmin;) {
+ Node* u = r->last_out(l);
+ if( u == r ) {
+ r->set_req(0, NULL);
+ } else {
+ assert(u->outcnt() == 0, "only dead users");
+ igvn->remove_dead_node(u);
+ }
+ l -= 1;
+ }
+ igvn->remove_dead_node(r);
// Now remove the bogus extra edges used to keep things alive
igvn->remove_dead_node( hook );
--- a/hotspot/src/share/vm/opto/library_call.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/library_call.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -310,11 +310,6 @@
if (!InlineAtomicLong) return NULL;
break;
- case vmIntrinsics::_Object_init:
- case vmIntrinsics::_invoke:
- // We do not intrinsify these; they are marked for other purposes.
- return NULL;
-
case vmIntrinsics::_getCallerClass:
if (!UseNewReflection) return NULL;
if (!InlineReflectionGetCallerClass) return NULL;
@@ -327,6 +322,8 @@
break;
default:
+ assert(id <= vmIntrinsics::LAST_COMPILER_INLINE, "caller responsibility");
+ assert(id != vmIntrinsics::_Object_init && id != vmIntrinsics::_invoke, "enum out of order?");
break;
}
@@ -394,18 +391,11 @@
}
if (PrintIntrinsics) {
- switch (intrinsic_id()) {
- case vmIntrinsics::_invoke:
- case vmIntrinsics::_Object_init:
- // We do not expect to inline these, so do not produce any noise about them.
- break;
- default:
- tty->print("Did not inline intrinsic %s%s at bci:%d in",
- vmIntrinsics::name_at(intrinsic_id()),
- (is_virtual() ? " (virtual)" : ""), kit.bci());
- kit.caller()->print_short_name(tty);
- tty->print_cr(" (%d bytes)", kit.caller()->code_size());
- }
+ tty->print("Did not inline intrinsic %s%s at bci:%d in",
+ vmIntrinsics::name_at(intrinsic_id()),
+ (is_virtual() ? " (virtual)" : ""), kit.bci());
+ kit.caller()->print_short_name(tty);
+ tty->print_cr(" (%d bytes)", kit.caller()->code_size());
}
C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_failed);
return NULL;
@@ -1030,7 +1020,7 @@
const TypeAry* target_array_type = TypeAry::make(TypeInt::CHAR, TypeInt::make(0, target_length, Type::WidenMin));
const TypeAryPtr* target_type = TypeAryPtr::make(TypePtr::BotPTR, target_array_type, target_array->klass(), true, Type::OffsetBot);
- IdealKit kit(gvn(), control(), merged_memory());
+ IdealKit kit(gvn(), control(), merged_memory(), false, true);
#define __ kit.
Node* zero = __ ConI(0);
Node* one = __ ConI(1);
@@ -1042,7 +1032,7 @@
Node* targetOffset = __ ConI(targetOffset_i);
Node* sourceEnd = __ SubI(__ AddI(sourceOffset, sourceCount), targetCountLess1);
- IdealVariable rtn(kit), i(kit), j(kit); __ declares_done();
+ IdealVariable rtn(kit), i(kit), j(kit); __ declarations_done();
Node* outer_loop = __ make_label(2 /* goto */);
Node* return_ = __ make_label(1);
@@ -1079,9 +1069,9 @@
__ bind(outer_loop);
}__ end_loop(); __ dead(i);
__ bind(return_);
- __ drain_delay_transform();
-
- set_control(__ ctrl());
+
+ // Final sync IdealKit and GraphKit.
+ sync_kit(kit);
Node* result = __ value(rtn);
#undef __
C->set_has_loops(true);
@@ -2183,14 +2173,23 @@
// of it. So we need to emit code to conditionally do the proper type of
// store.
- IdealKit kit(gvn(), control(), merged_memory());
- kit.declares_done();
+ IdealKit ideal(gvn(), control(), merged_memory());
+#define __ ideal.
// QQQ who knows what probability is here??
- kit.if_then(heap_base_oop, BoolTest::ne, null(), PROB_UNLIKELY(0.999)); {
- (void) store_oop_to_unknown(control(), heap_base_oop, adr, adr_type, val, type);
- } kit.else_(); {
- (void) store_to_memory(control(), adr, val, type, adr_type, is_volatile);
- } kit.end_if();
+ __ if_then(heap_base_oop, BoolTest::ne, null(), PROB_UNLIKELY(0.999)); {
+ // Sync IdealKit and graphKit.
+ set_all_memory( __ merged_memory());
+ set_control(__ ctrl());
+ Node* st = store_oop_to_unknown(control(), heap_base_oop, adr, adr_type, val, type);
+ // Update IdealKit memory.
+ __ set_all_memory(merged_memory());
+ __ set_ctrl(control());
+ } __ else_(); {
+ __ store(__ ctrl(), adr, val, type, alias_type->index(), is_volatile);
+ } __ end_if();
+ // Final sync IdealKit and GraphKit.
+ sync_kit(ideal);
+#undef __
}
}
}
--- a/hotspot/src/share/vm/opto/loopTransform.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/loopTransform.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/opto/loopopts.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/loopopts.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -346,7 +346,10 @@
// Yes! Reshape address expression!
Node *inv_scale = new (C, 3) LShiftINode( add_invar, scale );
- register_new_node( inv_scale, add_invar_ctrl );
+ Node *inv_scale_ctrl =
+ dom_depth(add_invar_ctrl) > dom_depth(scale_ctrl) ?
+ add_invar_ctrl : scale_ctrl;
+ register_new_node( inv_scale, inv_scale_ctrl );
Node *var_scale = new (C, 3) LShiftINode( add_var, scale );
register_new_node( var_scale, n_ctrl );
Node *var_add = new (C, 3) AddINode( var_scale, inv_scale );
--- a/hotspot/src/share/vm/opto/machnode.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/machnode.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -300,6 +300,12 @@
}
}
adr_type = t_disp->add_offset(offset);
+ } else if( base == NULL && offset != 0 && offset != Type::OffsetBot ) {
+ // Use ideal type if it is oop ptr.
+ const TypePtr *tp = oper->type()->isa_ptr();
+ if( tp != NULL) {
+ adr_type = tp;
+ }
}
}
--- a/hotspot/src/share/vm/opto/macro.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/macro.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -198,14 +198,79 @@
}
// Eliminate a card mark sequence. p2x is a ConvP2XNode
-void PhaseMacroExpand::eliminate_card_mark(Node *p2x) {
+void PhaseMacroExpand::eliminate_card_mark(Node* p2x) {
assert(p2x->Opcode() == Op_CastP2X, "ConvP2XNode required");
- Node *shift = p2x->unique_out();
- Node *addp = shift->unique_out();
- for (DUIterator_Last jmin, j = addp->last_outs(jmin); j >= jmin; --j) {
- Node *st = addp->last_out(j);
- assert(st->is_Store(), "store required");
- _igvn.replace_node(st, st->in(MemNode::Memory));
+ if (!UseG1GC) {
+ // vanilla/CMS post barrier
+ Node *shift = p2x->unique_out();
+ Node *addp = shift->unique_out();
+ for (DUIterator_Last jmin, j = addp->last_outs(jmin); j >= jmin; --j) {
+ Node *st = addp->last_out(j);
+ assert(st->is_Store(), "store required");
+ _igvn.replace_node(st, st->in(MemNode::Memory));
+ }
+ } else {
+ // G1 pre/post barriers
+ assert(p2x->outcnt() == 2, "expects 2 users: Xor and URShift nodes");
+ // It could be only one user, URShift node, in Object.clone() instrinsic
+ // but the new allocation is passed to arraycopy stub and it could not
+ // be scalar replaced. So we don't check the case.
+
+ // Remove G1 post barrier.
+
+ // Search for CastP2X->Xor->URShift->Cmp path which
+ // checks if the store done to a different from the value's region.
+ // And replace Cmp with #0 (false) to collapse G1 post barrier.
+ Node* xorx = NULL;
+ for (DUIterator_Fast imax, i = p2x->fast_outs(imax); i < imax; i++) {
+ Node* u = p2x->fast_out(i);
+ if (u->Opcode() == Op_XorX) {
+ xorx = u;
+ break;
+ }
+ }
+ assert(xorx != NULL, "missing G1 post barrier");
+ Node* shift = xorx->unique_out();
+ Node* cmpx = shift->unique_out();
+ assert(cmpx->is_Cmp() && cmpx->unique_out()->is_Bool() &&
+ cmpx->unique_out()->as_Bool()->_test._test == BoolTest::ne,
+ "missing region check in G1 post barrier");
+ _igvn.replace_node(cmpx, makecon(TypeInt::CC_EQ));
+
+ // Remove G1 pre barrier.
+
+ // Search "if (marking != 0)" check and set it to "false".
+ Node* this_region = p2x->in(0);
+ assert(this_region != NULL, "");
+ // There is no G1 pre barrier if previous stored value is NULL
+ // (for example, after initialization).
+ if (this_region->is_Region() && this_region->req() == 3) {
+ int ind = 1;
+ if (!this_region->in(ind)->is_IfFalse()) {
+ ind = 2;
+ }
+ if (this_region->in(ind)->is_IfFalse()) {
+ Node* bol = this_region->in(ind)->in(0)->in(1);
+ assert(bol->is_Bool(), "");
+ cmpx = bol->in(1);
+ if (bol->as_Bool()->_test._test == BoolTest::ne &&
+ cmpx->is_Cmp() && cmpx->in(2) == intcon(0) &&
+ cmpx->in(1)->is_Load()) {
+ Node* adr = cmpx->in(1)->as_Load()->in(MemNode::Address);
+ const int marking_offset = in_bytes(JavaThread::satb_mark_queue_offset() +
+ PtrQueue::byte_offset_of_active());
+ if (adr->is_AddP() && adr->in(AddPNode::Base) == top() &&
+ adr->in(AddPNode::Address)->Opcode() == Op_ThreadLocal &&
+ adr->in(AddPNode::Offset) == MakeConX(marking_offset)) {
+ _igvn.replace_node(cmpx, makecon(TypeInt::CC_EQ));
+ }
+ }
+ }
+ }
+ // Now CastP2X can be removed since it is used only on dead path
+ // which currently still alive until igvn optimize it.
+ assert(p2x->unique_out()->Opcode() == Op_URShiftX, "");
+ _igvn.replace_node(p2x, top());
}
}
@@ -760,14 +825,11 @@
if (n->is_Store()) {
_igvn.replace_node(n, n->in(MemNode::Memory));
} else {
- assert( n->Opcode() == Op_CastP2X, "CastP2X required");
eliminate_card_mark(n);
}
k -= (oc2 - use->outcnt());
}
} else {
- assert( !use->is_SafePoint(), "safepoint uses must have been already elimiated");
- assert( use->Opcode() == Op_CastP2X, "CastP2X required");
eliminate_card_mark(use);
}
j -= (oc1 - res->outcnt());
--- a/hotspot/src/share/vm/opto/matcher.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/matcher.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1489,8 +1489,7 @@
#ifdef ASSERT
// Verify adr type after matching memory operation
const MachOper* oper = mach->memory_operand();
- if (oper != NULL && oper != (MachOper*)-1 &&
- mach->adr_type() != TypeRawPtr::BOTTOM) { // non-direct addressing mode
+ if (oper != NULL && oper != (MachOper*)-1) {
// It has a unique memory operand. Find corresponding ideal mem node.
Node* m = NULL;
if (leaf->is_Mem()) {
--- a/hotspot/src/share/vm/opto/matcher.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/matcher.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/opto/output.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/output.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -50,6 +50,13 @@
init_scratch_buffer_blob();
if (failing()) return; // Out of memory
+ // The number of new nodes (mostly MachNop) is proportional to
+ // the number of java calls and inner loops which are aligned.
+ if ( C->check_node_count((NodeLimitFudgeFactor + C->java_calls()*3 +
+ C->inner_loops()*(OptoLoopAlignment-1)),
+ "out of nodes before code generation" ) ) {
+ return;
+ }
// Make sure I can find the Start Node
Block_Array& bbs = _cfg->_bbs;
Block *entry = _cfg->_blocks[1];
@@ -1105,7 +1112,7 @@
uint *call_returns = NEW_RESOURCE_ARRAY(uint, _cfg->_num_blocks+1);
uint return_offset = 0;
- MachNode *nop = new (this) MachNopNode();
+ int nop_size = (new (this) MachNopNode())->size(_regalloc);
int previous_offset = 0;
int current_offset = 0;
@@ -1188,7 +1195,6 @@
}
// align the instruction if necessary
- int nop_size = nop->size(_regalloc);
int padding = mach->compute_padding(current_offset);
// Make sure safepoint node for polling is distinct from a call's
// return by adding a nop if needed.
@@ -1372,7 +1378,6 @@
// If the next block is the top of a loop, pad this block out to align
// the loop top a little. Helps prevent pipe stalls at loop back branches.
- int nop_size = (new (this) MachNopNode())->size(_regalloc);
if( i<_cfg->_num_blocks-1 ) {
Block *nb = _cfg->_blocks[i+1];
uint padding = nb->alignment_padding(current_offset);
--- a/hotspot/src/share/vm/opto/parse.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/parse.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/opto/parse1.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/parse1.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/opto/parse2.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/parse2.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/opto/parse3.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/parse3.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/opto/parseHelper.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/parseHelper.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/opto/phaseX.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/phaseX.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -450,6 +450,8 @@
subsume_node(old, nn);
}
+ bool delay_transform() const { return _delay_transform; }
+
void set_delay_transform(bool delay) {
_delay_transform = delay;
}
--- a/hotspot/src/share/vm/opto/subnode.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/subnode.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/opto/superword.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/superword.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2007-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/opto/type.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/opto/type.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1216,6 +1216,8 @@
#define Op_AndX Op_AndL
#define Op_AddX Op_AddL
#define Op_SubX Op_SubL
+#define Op_XorX Op_XorL
+#define Op_URShiftX Op_URShiftL
// conversions
#define ConvI2X(x) ConvI2L(x)
#define ConvL2X(x) (x)
@@ -1258,6 +1260,8 @@
#define Op_AndX Op_AndI
#define Op_AddX Op_AddI
#define Op_SubX Op_SubI
+#define Op_XorX Op_XorI
+#define Op_URShiftX Op_URShiftI
// conversions
#define ConvI2X(x) (x)
#define ConvL2X(x) ConvL2I(x)
--- a/hotspot/src/share/vm/prims/jvm_misc.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/prims/jvm_misc.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/prims/jvmtiEnvBase.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/prims/jvmtiEnvBase.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/prims/methodComparator.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/prims/methodComparator.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/prims/unsafe.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/prims/unsafe.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1048,7 +1048,11 @@
oop e = JNIHandles::resolve(e_h);
oop p = JNIHandles::resolve(obj);
HeapWord* addr = (HeapWord *)index_oop_from_field_offset_long(p, offset);
- update_barrier_set_pre((void*)addr, e);
+ if (UseCompressedOops) {
+ update_barrier_set_pre((narrowOop*)addr, e);
+ } else {
+ update_barrier_set_pre((oop*)addr, e);
+ }
oop res = oopDesc::atomic_compare_exchange_oop(x, addr, e);
jboolean success = (res == e);
if (success)
--- a/hotspot/src/share/vm/runtime/arguments.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/runtime/arguments.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1202,18 +1202,13 @@
}
#ifdef _LP64
- // Compressed Headers do not work with CMS, which uses a bit in the klass
- // field offset to determine free list chunk markers.
// Check that UseCompressedOops can be set with the max heap size allocated
// by ergonomics.
if (MaxHeapSize <= max_heap_for_compressed_oops()) {
- if (FLAG_IS_DEFAULT(UseCompressedOops) && !UseG1GC) {
+ if (FLAG_IS_DEFAULT(UseCompressedOops)) {
// Turn off until bug is fixed.
// the following line to return it to default status.
// FLAG_SET_ERGO(bool, UseCompressedOops, true);
- } else if (UseCompressedOops && UseG1GC) {
- warning(" UseCompressedOops does not currently work with UseG1GC; switching off UseCompressedOops. ");
- FLAG_SET_DEFAULT(UseCompressedOops, false);
}
#ifdef _WIN64
if (UseLargePages && UseCompressedOops) {
@@ -1454,6 +1449,7 @@
if (UseSerialGC) i++;
if (UseConcMarkSweepGC || UseParNewGC) i++;
if (UseParallelGC || UseParallelOldGC) i++;
+ if (UseG1GC) i++;
if (i > 1) {
jio_fprintf(defaultStream::error_stream(),
"Conflicting collector combinations in option list; "
@@ -2603,22 +2599,6 @@
return result;
}
- // These are hacks until G1 is fully supported and tested
- // but lets you force -XX:+UseG1GC in PRT and get it where it (mostly) works
- if (UseG1GC) {
- if (UseConcMarkSweepGC || UseParNewGC || UseParallelGC || UseParallelOldGC || UseSerialGC) {
-#ifndef PRODUCT
- tty->print_cr("-XX:+UseG1GC is incompatible with other collectors, using UseG1GC");
-#endif // PRODUCT
- UseConcMarkSweepGC = false;
- UseParNewGC = false;
- UseParallelGC = false;
- UseParallelOldGC = false;
- UseSerialGC = false;
- }
- no_shared_spaces();
- }
-
#ifndef PRODUCT
if (TraceBytecodesAt != 0) {
TraceBytecodes = true;
@@ -2676,10 +2656,7 @@
} else if (UseParNewGC) {
// Set some flags for ParNew
set_parnew_gc_flags();
- }
- // Temporary; make the "if" an "else-if" before
- // we integrate G1. XXX
- if (UseG1GC) {
+ } else if (UseG1GC) {
// Set some flags for garbage-first, if needed.
set_g1_gc_flags();
}
--- a/hotspot/src/share/vm/runtime/biasedLocking.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/runtime/biasedLocking.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/runtime/deoptimization.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/runtime/deoptimization.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/runtime/dtraceJSDT.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/runtime/dtraceJSDT.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/runtime/frame.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/runtime/frame.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/runtime/hpi.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/runtime/hpi.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/runtime/interfaceSupport.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/runtime/interfaceSupport.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/runtime/mutexLocker.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/runtime/mutexLocker.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/runtime/mutexLocker.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/runtime/mutexLocker.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/runtime/orderAccess.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/runtime/orderAccess.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/runtime/orderAccess.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/runtime/orderAccess.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/runtime/safepoint.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/runtime/safepoint.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -49,7 +49,7 @@
// In the future we should investigate whether CMS can use the
// more-general mechanism below. DLD (01/05).
ConcurrentMarkSweepThread::synchronize(false);
- } else {
+ } else if (UseG1GC) {
ConcurrentGCThread::safepoint_synchronize();
}
#endif // SERIALGC
@@ -400,7 +400,7 @@
// If there are any concurrent GC threads resume them.
if (UseConcMarkSweepGC) {
ConcurrentMarkSweepThread::desynchronize(false);
- } else {
+ } else if (UseG1GC) {
ConcurrentGCThread::safepoint_desynchronize();
}
#endif // SERIALGC
--- a/hotspot/src/share/vm/runtime/sharedRuntime.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/runtime/sharedRuntime.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -119,6 +119,7 @@
assert(false, "should be optimized out");
return;
}
+ assert(orig->is_oop(true /* ignore mark word */), "Error");
// store the original value that was in the field reference
thread->satb_mark_queue().enqueue(orig);
JRT_END
--- a/hotspot/src/share/vm/runtime/stackValue.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/runtime/stackValue.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -104,7 +104,17 @@
}
#endif
case Location::oop: {
- Handle h(*(oop *)value_addr); // Wrap a handle around the oop
+ oop val = *(oop *)value_addr;
+#ifdef _LP64
+ if (Universe::is_narrow_oop_base(val)) {
+ // Compiled code may produce decoded oop = narrow_oop_base
+ // when a narrow oop implicit null check is used.
+ // The narrow_oop_base could be NULL or be the address
+ // of the page below heap. Use NULL value for both cases.
+ val = (oop)NULL;
+ }
+#endif
+ Handle h(val); // Wrap a handle around the oop
return new StackValue(h);
}
case Location::addr: {
--- a/hotspot/src/share/vm/runtime/stackValue.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/runtime/stackValue.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/runtime/thread.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/runtime/thread.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/runtime/thread.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/runtime/thread.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/runtime/vframe.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/runtime/vframe.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/runtime/vframe.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/runtime/vframe.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/runtime/vframeArray.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/runtime/vframeArray.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/runtime/vframe_hp.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/runtime/vframe_hp.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/runtime/virtualspace.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/runtime/virtualspace.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/runtime/virtualspace.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/runtime/virtualspace.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/runtime/vmStructs.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/runtime/vmStructs.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/runtime/vmThread.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/runtime/vmThread.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/runtime/vm_operations.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/runtime/vm_operations.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/runtime/vm_version.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/runtime/vm_version.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/utilities/bitMap.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/utilities/bitMap.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/utilities/bitMap.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/utilities/bitMap.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/utilities/bitMap.inline.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/utilities/bitMap.inline.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/utilities/exceptions.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/utilities/exceptions.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/utilities/globalDefinitions_visCPP.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/utilities/globalDefinitions_visCPP.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/utilities/macros.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/utilities/macros.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/share/vm/utilities/taskqueue.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/utilities/taskqueue.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -64,15 +64,18 @@
}
void ParallelTaskTerminator::yield() {
+ assert(_offered_termination <= _n_threads, "Invariant");
os::yield();
}
void ParallelTaskTerminator::sleep(uint millis) {
+ assert(_offered_termination <= _n_threads, "Invariant");
os::sleep(Thread::current(), millis, false);
}
bool
ParallelTaskTerminator::offer_termination(TerminatorTerminator* terminator) {
+ assert(_offered_termination < _n_threads, "Invariant");
Atomic::inc(&_offered_termination);
uint yield_count = 0;
@@ -96,6 +99,7 @@
// Loop waiting for all threads to offer termination or
// more work.
while (true) {
+ assert(_offered_termination <= _n_threads, "Invariant");
// Are all threads offering termination?
if (_offered_termination == _n_threads) {
return true;
@@ -151,6 +155,7 @@
if (peek_in_queue_set() ||
(terminator != NULL && terminator->should_exit_termination())) {
Atomic::dec(&_offered_termination);
+ assert(_offered_termination < _n_threads, "Invariant");
return false;
}
}
--- a/hotspot/src/share/vm/utilities/taskqueue.hpp Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/src/share/vm/utilities/taskqueue.hpp Tue Aug 04 08:01:03 2009 -0700
@@ -560,8 +560,14 @@
class StarTask {
void* _holder; // either union oop* or narrowOop*
public:
- StarTask(narrowOop *p) { _holder = (void *)((uintptr_t)p | COMPRESSED_OOP_MASK); }
- StarTask(oop *p) { _holder = (void*)p; }
+ StarTask(narrowOop* p) {
+ assert(((uintptr_t)p & COMPRESSED_OOP_MASK) == 0, "Information loss!");
+ _holder = (void *)((uintptr_t)p | COMPRESSED_OOP_MASK);
+ }
+ StarTask(oop* p) {
+ assert(((uintptr_t)p & COMPRESSED_OOP_MASK) == 0, "Information loss!");
+ _holder = (void*)p;
+ }
StarTask() { _holder = NULL; }
operator oop*() { return (oop*)_holder; }
operator narrowOop*() {
--- a/hotspot/test/compiler/6772683/InterruptedTest.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/test/compiler/6772683/InterruptedTest.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/6826736/Test.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+/**
+ * @test
+ * @bug 6826736
+ * @summary CMS: core dump with -XX:+UseCompressedOops
+ *
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -Xbatch -XX:+ScavengeALot -XX:+UseCompressedOops -XX:HeapBaseMinAddress=32g -XX:CompileThreshold=100 -XX:CompileOnly=Test.test -XX:-BlockLayoutRotateLoops -XX:LoopUnrollLimit=0 Test
+ */
+
+public class Test {
+ int[] arr;
+ int[] arr2;
+ int test(int r) {
+ for (int i = 0; i < 100; i++) {
+ for (int j = i; j < 100; j++) {
+ int a = 0;
+ for (long k = 0; k < 100; k++) {
+ a += k;
+ }
+ if (arr != null)
+ a = arr[j];
+ r += a;
+ }
+ }
+ return r;
+ }
+
+ public static void main(String[] args) {
+ int r = 0;
+ Test t = new Test();
+ for (int i = 0; i < 100; i++) {
+ t.arr = new int[100];
+ r = t.test(r);
+ }
+ System.out.println("Warmup 1 is done.");
+ for (int i = 0; i < 100; i++) {
+ t.arr = null;
+ r = t.test(r);
+ }
+ System.out.println("Warmup 2 is done.");
+ for (int i = 0; i < 100; i++) {
+ t.arr = new int[100];
+ r = t.test(r);
+ }
+ System.out.println("Warmup is done.");
+ for (int i = 0; i < 100; i++) {
+ t.arr = new int[1000000];
+ t.arr = null;
+ r = t.test(r);
+ }
+ }
+}
--- a/hotspot/test/compiler/6832293/Test.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/test/compiler/6832293/Test.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/hotspot/test/compiler/6837094/Test.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/test/compiler/6837094/Test.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2009 Google Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/6851282/Test.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+/**
+ * @test
+ * @bug 6851282
+ * @summary JIT miscompilation results in null entry in array when using CompressedOops
+ *
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops Test
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Test {
+ void foo(A a, A[] as) {
+ for (A a1 : as) {
+ B[] filtered = a.c(a1);
+ for (B b : filtered) {
+ if (b == null) {
+ System.out.println("bug: b == null");
+ System.exit(97);
+ }
+ }
+ }
+ }
+
+ public static void main(String[] args) {
+ List<A> as = new ArrayList<A>();
+ for (int i = 0; i < 5000; i++) {
+ List<B> bs = new ArrayList<B>();
+ for (int j = i; j < i + 1000; j++)
+ bs.add(new B(j));
+ as.add(new A(bs.toArray(new B[0])));
+ }
+ new Test().foo(as.get(0), as.subList(1, as.size()).toArray(new A[0]));
+ }
+}
+
+class A {
+ final B[] bs;
+
+ public A(B[] bs) {
+ this.bs = bs;
+ }
+
+ final B[] c(final A a) {
+ return new BoxedArray<B>(bs).filter(new Function<B, Boolean>() {
+ public Boolean apply(B arg) {
+ for (B b : a.bs) {
+ if (b.d == arg.d)
+ return true;
+ }
+ return false;
+ }
+ });
+ }
+}
+
+class BoxedArray<T> {
+
+ private final T[] array;
+
+ BoxedArray(T[] array) {
+ this.array = array;
+ }
+
+ public T[] filter(Function<T, Boolean> function) {
+ boolean[] include = new boolean[array.length];
+ int len = 0;
+ int i = 0;
+ while (i < array.length) {
+ if (function.apply(array[i])) {
+ include[i] = true;
+ len += 1;
+ }
+ i += 1;
+ }
+ T[] result = (T[]) java.lang.reflect.Array.newInstance(array.getClass().getComponentType(), len);
+ len = 0;
+ i = 0;
+ while (len < result.length) {
+ if (include[i]) {
+ result[len] = array[i];
+ len += 1;
+ }
+ i += 1;
+ }
+ return result;
+ }
+}
+
+interface Function<T, R> {
+ R apply(T arg);
+}
+
+class B {
+ final int d;
+ public B(int d) {
+ this.d = d;
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/6857159/Test6857159.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+/**
+ * @test
+ * @bug 6857159
+ * @summary local schedule failed with checkcast of Thread.currentThread()
+ *
+ * @run shell Test6857159.sh
+ */
+
+public class Test6857159 extends Thread {
+ static class ct0 extends Test6857159 {
+ public void message() {
+ // System.out.println("message");
+ }
+
+ public void run() {
+ message();
+ ct0 ct = (ct0) Thread.currentThread();
+ ct.message();
+ }
+ }
+ static class ct1 extends ct0 {
+ public void message() {
+ // System.out.println("message");
+ }
+ }
+ static class ct2 extends ct0 {
+ public void message() {
+ // System.out.println("message");
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ for (int i = 0; i < 100000; i++) {
+ Thread t = null;
+ switch (i % 3) {
+ case 0: t = new ct0(); break;
+ case 1: t = new ct1(); break;
+ case 2: t = new ct2(); break;
+ }
+ t.start();
+ t.join();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/6857159/Test6857159.sh Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,65 @@
+#!/bin/sh
+#
+# Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+#
+
+if [ "${TESTSRC}" = "" ]
+then
+ echo "TESTSRC not set. Test cannot execute. Failed."
+ exit 1
+fi
+echo "TESTSRC=${TESTSRC}"
+if [ "${TESTJAVA}" = "" ]
+then
+ echo "TESTJAVA not set. Test cannot execute. Failed."
+ exit 1
+fi
+echo "TESTJAVA=${TESTJAVA}"
+if [ "${TESTCLASSES}" = "" ]
+then
+ echo "TESTCLASSES not set. Test cannot execute. Failed."
+ exit 1
+fi
+echo "TESTCLASSES=${TESTCLASSES}"
+echo "CLASSPATH=${CLASSPATH}"
+
+set -x
+
+cp ${TESTSRC}/Test6857159.java .
+cp ${TESTSRC}/Test6857159.sh .
+
+${TESTJAVA}/bin/javac -d . Test6857159.java
+
+${TESTJAVA}/bin/java ${TESTVMOPTS} -Xbatch -XX:+PrintCompilation -XX:CompileOnly=Test6857159\$ct.run Test6857159 > test.out 2>&1
+
+grep "COMPILE SKIPPED" test.out
+
+result=$?
+if [ $result -eq 1 ]
+then
+ echo "Passed"
+ exit 0
+else
+ echo "Failed"
+ exit 1
+fi
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/6859338/Test6859338.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+/**
+ * @test
+ * @bug 6859338
+ * @summary Assertion failure in sharedRuntime.cpp
+ *
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-InlineObjectHash -Xbatch -XX:-ProfileInterpreter Test6859338
+ */
+
+public class Test6859338 {
+ static Object[] o = new Object[] { new Object(), null };
+ public static void main(String[] args) {
+ int total = 0;
+ try {
+ // Exercise the implicit null check in the unverified entry point
+ for (int i = 0; i < 40000; i++) {
+ int limit = o.length;
+ if (i < 20000) limit = 1;
+ for (int j = 0; j < limit; j++) {
+ total += o[j].hashCode();
+ }
+ }
+
+ } catch (NullPointerException e) {
+ // this is expected. A true failure causes a crash
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/6860469/Test.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2009 Google Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+/**
+ * @test
+ * @bug 6860469
+ * @summary remix_address_expressions reshapes address expression with bad control
+ *
+ * @run main/othervm -Xcomp -XX:CompileOnly=Test.C Test
+ */
+
+public class Test {
+
+ private static final int H = 16;
+ private static final int F = 9;
+
+ static int[] fl = new int[1 << F];
+
+ static int C(int ll, int f) {
+ int max = -1;
+ int min = H + 1;
+
+ if (ll != 0) {
+ if (ll < min) {
+ min = ll;
+ }
+ if (ll > max) {
+ max = ll;
+ }
+ }
+
+ if (f > max) {
+ f = max;
+ }
+ if (min > f) {
+ min = f;
+ }
+
+ for (int mc = 1 >> max - f; mc <= 0; mc++) {
+ int i = mc << (32 - f);
+ fl[i] = max;
+ }
+
+ return min;
+ }
+
+ public static void main(String argv[]) {
+ C(0, 10);
+ }
+}
--- a/hotspot/test/runtime/6819213/TestBootNativeLibraryPath.java Mon Jul 27 22:28:29 2009 -0700
+++ b/hotspot/test/runtime/6819213/TestBootNativeLibraryPath.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/jaxp/.hgtags Mon Jul 27 22:28:29 2009 -0700
+++ b/jaxp/.hgtags Tue Aug 04 08:01:03 2009 -0700
@@ -39,3 +39,5 @@
a97dd57a62604c35c79bc2fa77a612ed547f6135 jdk7-b62
ae449e9c04c1fe651bd30f0f4d4cc24ba794e0c4 jdk7-b63
a10eec7a1edf536f39b5828d8623054dbc62c2b7 jdk7-b64
+008c662e0ee9a91aebb75e46b97de979083d5c1c jdk7-b65
+22f9d5d5b5fe0f47048f41e6c6e54fee5edad0ec jdk7-b66
--- a/jaxp/make/build.properties Mon Jul 27 22:28:29 2009 -0700
+++ b/jaxp/make/build.properties Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2007-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/jaxp/make/build.xml Mon Jul 27 22:28:29 2009 -0700
+++ b/jaxp/make/build.xml Tue Aug 04 08:01:03 2009 -0700
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<!--
- Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
+ Copyright 2007-2009 Sun Microsystems, Inc. All Rights Reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
--- a/jaxp/make/jprt.properties Mon Jul 27 22:28:29 2009 -0700
+++ b/jaxp/make/jprt.properties Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2006-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/jaxp/src/share/classes/com/sun/org/apache/xerces/internal/impl/PropertyManager.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jaxp/src/share/classes/com/sun/org/apache/xerces/internal/impl/PropertyManager.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/jaxp/src/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jaxp/src/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Portions Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Portions Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
*/
/*
--- a/jaxp/src/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentScannerImpl.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jaxp/src/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentScannerImpl.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Portions Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Portions Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
*/
/*
--- a/jaxp/src/share/classes/com/sun/org/apache/xerces/internal/impl/XMLStreamFilterImpl.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jaxp/src/share/classes/com/sun/org/apache/xerces/internal/impl/XMLStreamFilterImpl.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/jaxp/src/share/classes/com/sun/xml/internal/stream/events/XMLEventAllocatorImpl.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jaxp/src/share/classes/com/sun/xml/internal/stream/events/XMLEventAllocatorImpl.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/jaxws/.hgtags Mon Jul 27 22:28:29 2009 -0700
+++ b/jaxws/.hgtags Tue Aug 04 08:01:03 2009 -0700
@@ -39,3 +39,5 @@
75c801c13ea1ddebc58b1a8c8da9318d72750e62 jdk7-b62
b8a6e883c0a6708f6d818815040525d472262495 jdk7-b63
aaa25dfd3de68c6f1a1d3ef8c45fd99f76bca6dd jdk7-b64
+aa22a1be5866a6608ba17a7a443945559409ae0f jdk7-b65
+fa8712c099edd5c9a6b3ed9729353738004d388f jdk7-b66
--- a/jaxws/make/Makefile Mon Jul 27 22:28:29 2009 -0700
+++ b/jaxws/make/Makefile Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2007-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/jaxws/make/build.properties Mon Jul 27 22:28:29 2009 -0700
+++ b/jaxws/make/build.properties Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2007-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/jaxws/make/build.xml Mon Jul 27 22:28:29 2009 -0700
+++ b/jaxws/make/build.xml Tue Aug 04 08:01:03 2009 -0700
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<!--
- Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
+ Copyright 2007-2009 Sun Microsystems, Inc. All Rights Reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
--- a/jdk/.hgtags Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/.hgtags Tue Aug 04 08:01:03 2009 -0700
@@ -40,3 +40,5 @@
2ed6ed6b5bfc7dd724925b90dbb31223df59c25d jdk7-b63
a50217eb3ee10b9f9547e0708e5c9625405083ef jdk7-b64
382a27aa78d3236fa123c60577797a887fe93e09 jdk7-b65
+bd31b30a5b21f20e42965b1633f18a5c7946d398 jdk7-b66
+a952aafd5181af953b0ef3010dbd2fcc28460e8a jdk7-b67
--- a/jdk/make/com/sun/crypto/provider/Makefile Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/make/com/sun/crypto/provider/Makefile Tue Aug 04 08:01:03 2009 -0700
@@ -267,6 +267,7 @@
# supports up to v49 class file format. Force v49 classfiles in our
# builds for now.
#
+SOURCE_LANGUAGE_VERSION = 5
TARGET_CLASS_VERSION = 5
--- a/jdk/make/common/Defs-linux.gmk Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/make/common/Defs-linux.gmk Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/jdk/make/common/Release.gmk Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/make/common/Release.gmk Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/jdk/make/common/shared/Defs-windows.gmk Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/make/common/shared/Defs-windows.gmk Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/jdk/make/common/shared/Defs.gmk Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/make/common/shared/Defs.gmk Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/jdk/make/common/shared/Sanity.gmk Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/make/common/shared/Sanity.gmk Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/jdk/make/java/java/FILES_java.gmk Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/make/java/java/FILES_java.gmk Tue Aug 04 08:01:03 2009 -0700
@@ -250,6 +250,8 @@
java/util/IdentityHashMap.java \
java/util/EnumMap.java \
java/util/Arrays.java \
+ java/util/TimSort.java \
+ java/util/ComparableTimSort.java \
java/util/ConcurrentModificationException.java \
java/util/ServiceLoader.java \
java/util/ServiceConfigurationError.java \
--- a/jdk/make/java/redist/Makefile Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/make/java/redist/Makefile Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/jdk/make/javax/crypto/Makefile Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/make/javax/crypto/Makefile Tue Aug 04 08:01:03 2009 -0700
@@ -416,6 +416,7 @@
# supports up to v49 class file format. Force v49 classfiles in our
# builds for now.
#
+SOURCE_LANGUAGE_VERSION = 5
TARGET_CLASS_VERSION = 5
--- a/jdk/make/sun/Makefile Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/make/sun/Makefile Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 1995-2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 1995-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/jdk/src/share/classes/com/sun/awt/AWTUtilities.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/com/sun/awt/AWTUtilities.java Tue Aug 04 08:01:03 2009 -0700
@@ -374,7 +374,7 @@
"The window argument should not be null.");
}
- return AWTAccessor.getWindowAccessor().isOpaque(window);
+ return window.isOpaque();
}
/**
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/com/sun/beans/finder/BeanInfoFinder.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+package com.sun.beans.finder;
+
+import java.beans.BeanDescriptor;
+import java.beans.BeanInfo;
+import java.beans.MethodDescriptor;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Method;
+
+/**
+ * This is utility class that provides functionality
+ * to find a {@link BeanInfo} for a JavaBean specified by its type.
+ *
+ * @since 1.7
+ *
+ * @author Sergey A. Malenkov
+ */
+public final class BeanInfoFinder
+ extends InstanceFinder<BeanInfo> {
+
+ private static final String DEFAULT = "sun.beans.infos";
+
+ public BeanInfoFinder() {
+ super(BeanInfo.class, true, "BeanInfo", DEFAULT);
+ }
+
+ private static boolean isValid(Class<?> type, Method method) {
+ return (method != null) && type.equals(method.getDeclaringClass());
+ }
+
+ @Override
+ protected BeanInfo instantiate(Class<?> type, String name) {
+ BeanInfo info = super.instantiate(type, name);
+ if (info != null) {
+ // make sure that the returned BeanInfo matches the class
+ BeanDescriptor bd = info.getBeanDescriptor();
+ if (bd != null) {
+ if (type.equals(bd.getBeanClass())) {
+ return info;
+ }
+ }
+ else {
+ PropertyDescriptor[] pds = info.getPropertyDescriptors();
+ if (pds != null) {
+ for (PropertyDescriptor pd : pds) {
+ Method method = pd.getReadMethod();
+ if (method == null) {
+ method = pd.getWriteMethod();
+ }
+ if (isValid(type, method)) {
+ return info;
+ }
+ }
+ }
+ else {
+ MethodDescriptor[] mds = info.getMethodDescriptors();
+ if (mds != null) {
+ for (MethodDescriptor md : mds) {
+ if (isValid(type, md.getMethod())) {
+ return info;
+ }
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ protected BeanInfo instantiate(Class<?> type, String prefix, String name) {
+ // this optimization will only use the BeanInfo search path
+ // if is has changed from the original
+ // or trying to get the ComponentBeanInfo
+ return !DEFAULT.equals(prefix) || "ComponentBeanInfo".equals(name)
+ ? super.instantiate(type, prefix, name)
+ : null;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/com/sun/beans/finder/InstanceFinder.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+package com.sun.beans.finder;
+
+/**
+ * This is utility class that provides basic functionality
+ * to find an auxiliary class for a JavaBean specified by its type.
+ *
+ * @since 1.7
+ *
+ * @author Sergey A. Malenkov
+ */
+class InstanceFinder<T> {
+
+ private static final String[] EMPTY = { };
+
+ private final Class<? extends T> type;
+ private final boolean allow;
+ private final String suffix;
+ private String[] packages;
+
+ InstanceFinder(Class<? extends T> type, boolean allow, String suffix, String... packages) {
+ this.type = type;
+ this.allow = allow;
+ this.suffix = suffix;
+ this.packages = packages.clone();
+ }
+
+ public String[] getPackages() {
+ return (this.packages.length > 0)
+ ? this.packages.clone()
+ : this.packages;
+ }
+
+ public void setPackages(String... packages) {
+ this.packages = (packages != null) && (packages.length > 0)
+ ? packages.clone()
+ : EMPTY;
+ }
+
+ public T find(Class<?> type) {
+ if (type == null) {
+ return null;
+ }
+ String name = type.getName() + this.suffix;
+ T object = instantiate(type, name);
+ if (object != null) {
+ return object;
+ }
+ if (this.allow) {
+ object = instantiate(type, null);
+ if (object != null) {
+ return object;
+ }
+ }
+ int index = name.lastIndexOf('.') + 1;
+ if (index > 0) {
+ name = name.substring(index);
+ }
+ for (String prefix : this.packages) {
+ object = instantiate(type, prefix, name);
+ if (object != null) {
+ return object;
+ }
+ }
+ return null;
+ }
+
+ protected T instantiate(Class<?> type, String name) {
+ if (type != null) {
+ try {
+ if (name != null) {
+ type = ClassFinder.findClass(name, type.getClassLoader());
+ }
+ if (this.type.isAssignableFrom(type)) {
+ return (T) type.newInstance();
+ }
+ }
+ catch (Exception exception) {
+ // ignore any exceptions
+ }
+ }
+ return null;
+ }
+
+ protected T instantiate(Class<?> type, String prefix, String name) {
+ return instantiate(type, prefix + '.' + name);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/com/sun/beans/finder/PersistenceDelegateFinder.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+package com.sun.beans.finder;
+
+import java.beans.PersistenceDelegate;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * This is utility class that provides functionality
+ * to find a {@link PersistenceDelegate} for a JavaBean specified by its type.
+ *
+ * @since 1.7
+ *
+ * @author Sergey A. Malenkov
+ */
+public final class PersistenceDelegateFinder
+ extends InstanceFinder<PersistenceDelegate> {
+
+ private final Map<Class<?>, PersistenceDelegate> registry;
+
+ public PersistenceDelegateFinder() {
+ super(PersistenceDelegate.class, true, "PersistenceDelegate");
+ this.registry = new HashMap<Class<?>, PersistenceDelegate>();
+ }
+
+ public void register(Class<?> type, PersistenceDelegate delegate) {
+ if (delegate != null) {
+ this.registry.put(type, delegate);
+ }
+ else {
+ this.registry.remove(type);
+ }
+ }
+
+ @Override
+ public PersistenceDelegate find(Class<?> type) {
+ PersistenceDelegate delegate = this.registry.get(type);
+ return (delegate != null) ? delegate : super.find(type);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/com/sun/beans/finder/PropertyEditorFinder.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+package com.sun.beans.finder;
+
+import com.sun.beans.WeakCache;
+
+import java.beans.PropertyEditor;
+
+import sun.beans.editors.BooleanEditor;
+import sun.beans.editors.ByteEditor;
+import sun.beans.editors.DoubleEditor;
+import sun.beans.editors.EnumEditor;
+import sun.beans.editors.FloatEditor;
+import sun.beans.editors.IntegerEditor;
+import sun.beans.editors.LongEditor;
+import sun.beans.editors.ShortEditor;
+
+/**
+ * This is utility class that provides functionality
+ * to find a {@link PropertyEditor} for a JavaBean specified by its type.
+ *
+ * @since 1.7
+ *
+ * @author Sergey A. Malenkov
+ */
+public final class PropertyEditorFinder
+ extends InstanceFinder<PropertyEditor> {
+
+ private final WeakCache<Class<?>, Class<?>> registry;
+
+ public PropertyEditorFinder() {
+ super(PropertyEditor.class, false, "Editor", "sun.beans.editors");
+
+ this.registry = new WeakCache<Class<?>, Class<?>>();
+ this.registry.put(Byte.TYPE, ByteEditor.class);
+ this.registry.put(Short.TYPE, ShortEditor.class);
+ this.registry.put(Integer.TYPE, IntegerEditor.class);
+ this.registry.put(Long.TYPE, LongEditor.class);
+ this.registry.put(Boolean.TYPE, BooleanEditor.class);
+ this.registry.put(Float.TYPE, FloatEditor.class);
+ this.registry.put(Double.TYPE, DoubleEditor.class);
+ }
+
+ public void register(Class<?> type, Class<?> editor) {
+ this.registry.put(type, editor);
+ }
+
+ @Override
+ public PropertyEditor find(Class<?> type) {
+ PropertyEditor editor = instantiate(this.registry.get(type), null);
+ if (editor == null) {
+ editor = super.find(type);
+ if ((editor == null) && (null != type.getEnumConstants())) {
+ editor = new EnumEditor(type);
+ }
+ }
+ return editor;
+ }
+}
--- a/jdk/src/share/classes/com/sun/jndi/toolkit/ctx/PartialCompositeContext.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/com/sun/jndi/toolkit/ctx/PartialCompositeContext.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2004 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/jdk/src/share/classes/java/awt/Component.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/java/awt/Component.java Tue Aug 04 08:01:03 2009 -0700
@@ -2370,12 +2370,10 @@
* rectangular region. A non-opaque component paints only some of
* its pixels, allowing the pixels underneath it to "show through".
* A component that does not fully paint its pixels therefore
- * provides a degree of transparency. Only lightweight
- * components can be transparent.
+ * provides a degree of transparency.
* <p>
* Subclasses that guarantee to always completely paint their
- * contents should override this method and return true. All
- * of the "heavyweight" AWT components are opaque.
+ * contents should override this method and return true.
*
* @return true if this component is completely opaque
* @see #isLightweight
--- a/jdk/src/share/classes/java/awt/GraphicsDevice.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/java/awt/GraphicsDevice.java Tue Aug 04 08:01:03 2009 -0700
@@ -281,8 +281,8 @@
if (w.getOpacity() < 1.0f) {
w.setOpacity(1.0f);
}
- Color bgColor = w.getBackground();
- if ((bgColor != null) && (bgColor.getAlpha() < 255)) {
+ if (!w.isOpaque()) {
+ Color bgColor = w.getBackground();
bgColor = new Color(bgColor.getRed(), bgColor.getGreen(),
bgColor.getBlue(), 255);
w.setBackground(bgColor);
--- a/jdk/src/share/classes/java/awt/Robot.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/java/awt/Robot.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -70,7 +70,7 @@
private RobotPeer peer;
private boolean isAutoWaitForIdle = false;
private int autoDelay = 0;
- private static int LEGAL_BUTTON_MASK;
+ private static int LEGAL_BUTTON_MASK = 0;
// location of robot's GC, used in mouseMove(), getPixelColor() and captureScreenImage()
private Point gdLoc;
@@ -95,23 +95,6 @@
}
init(GraphicsEnvironment.getLocalGraphicsEnvironment()
.getDefaultScreenDevice());
- int tmpMask = 0;
-
- if (Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()){
- if (Toolkit.getDefaultToolkit() instanceof SunToolkit) {
- final int buttonsNumber = ((SunToolkit)(Toolkit.getDefaultToolkit())).getNumberOfButtons();
- for (int i = 0; i < buttonsNumber; i++){
- tmpMask |= InputEvent.getMaskForButton(i+1);
- }
- }
- }
- tmpMask |= InputEvent.BUTTON1_MASK|
- InputEvent.BUTTON2_MASK|
- InputEvent.BUTTON3_MASK|
- InputEvent.BUTTON1_DOWN_MASK|
- InputEvent.BUTTON2_DOWN_MASK|
- InputEvent.BUTTON3_DOWN_MASK;
- LEGAL_BUTTON_MASK = tmpMask;
}
/**
@@ -156,6 +139,28 @@
disposer = new RobotDisposer(peer);
sun.java2d.Disposer.addRecord(anchor, disposer);
}
+ initLegalButtonMask();
+ }
+
+ private static synchronized void initLegalButtonMask() {
+ if (LEGAL_BUTTON_MASK != 0) return;
+
+ int tmpMask = 0;
+ if (Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()){
+ if (Toolkit.getDefaultToolkit() instanceof SunToolkit) {
+ final int buttonsNumber = ((SunToolkit)(Toolkit.getDefaultToolkit())).getNumberOfButtons();
+ for (int i = 0; i < buttonsNumber; i++){
+ tmpMask |= InputEvent.getMaskForButton(i+1);
+ }
+ }
+ }
+ tmpMask |= InputEvent.BUTTON1_MASK|
+ InputEvent.BUTTON2_MASK|
+ InputEvent.BUTTON3_MASK|
+ InputEvent.BUTTON1_DOWN_MASK|
+ InputEvent.BUTTON2_DOWN_MASK|
+ InputEvent.BUTTON3_DOWN_MASK;
+ LEGAL_BUTTON_MASK = tmpMask;
}
/* determine if the security policy allows Robot's to be created */
--- a/jdk/src/share/classes/java/awt/TrayIcon.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/java/awt/TrayIcon.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -143,6 +143,9 @@
*/
public TrayIcon(Image image) {
this();
+ if (image == null) {
+ throw new IllegalArgumentException("creating TrayIcon with null Image");
+ }
setImage(image);
}
--- a/jdk/src/share/classes/java/awt/Window.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/java/awt/Window.java Tue Aug 04 08:01:03 2009 -0700
@@ -3521,6 +3521,7 @@
* @return this component's background color
*
* @see Window#setBackground
+ * @see Window#isOpaque
* @see GraphicsDevice.WindowTranslucency
*/
@Override
@@ -3583,6 +3584,7 @@
* PERPIXEL_TRANSLUCENT} translucency is not supported
*
* @see Window#getBackground
+ * @see Window#isOpaque
* @see Window#setOpacity()
* @see Window#setShape()
* @see GraphicsDevice.WindowTranslucency
@@ -3597,7 +3599,7 @@
return;
}
int oldAlpha = oldBg != null ? oldBg.getAlpha() : 255;
- int alpha = bgColor.getAlpha();
+ int alpha = bgColor != null ? bgColor.getAlpha() : 255;
if ((oldAlpha == 255) && (alpha < 255)) { // non-opaque window
GraphicsConfiguration gc = getGraphicsConfiguration();
GraphicsDevice gd = gc.getDevice();
@@ -3623,6 +3625,25 @@
}
}
+ /**
+ * Indicates if the window is currently opaque.
+ * <p>
+ * The method returns {@code false} if the background color of the window
+ * is not {@code null} and the alpha component of the color is less than
+ * 1.0f. The method returns {@code true} otherwise.
+ *
+ * @return {@code true} if the window is opaque, {@code false} otherwise
+ *
+ * @see Window#getBackground
+ * @see Window#setBackground
+ * @since 1.7
+ */
+ @Override
+ public boolean isOpaque() {
+ Color bg = getBackground();
+ return bg != null ? bg.getAlpha() == 255 : true;
+ }
+
private void updateWindow() {
synchronized (getTreeLock()) {
WindowPeer peer = (WindowPeer)getPeer();
@@ -3639,12 +3660,11 @@
*/
@Override
public void paint(Graphics g) {
- Color bgColor = getBackground();
- if ((bgColor != null) && (bgColor.getAlpha() < 255)) {
+ if (!isOpaque()) {
Graphics gg = g.create();
try {
if (gg instanceof Graphics2D) {
- gg.setColor(bgColor);
+ gg.setColor(getBackground());
((Graphics2D)gg).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC));
gg.fillRect(0, 0, getWidth(), getHeight());
}
@@ -3791,10 +3811,6 @@
public void setShape(Window window, Shape shape) {
window.setShape(shape);
}
- public boolean isOpaque(Window window) {
- Color bg = window.getBackground();
- return (bg != null) ? bg.getAlpha() == 255 : true;
- }
public void setOpaque(Window window, boolean opaque) {
Color bg = window.getBackground();
if (bg == null) {
--- a/jdk/src/share/classes/java/awt/color/ICC_Profile.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/java/awt/color/ICC_Profile.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Portions Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Portions Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/jdk/src/share/classes/java/beans/Encoder.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/java/beans/Encoder.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,7 +24,8 @@
*/
package java.beans;
-import java.util.Collections;
+import com.sun.beans.finder.PersistenceDelegateFinder;
+
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.Map;
@@ -45,8 +46,7 @@
*/
public class Encoder {
- private final Map<Class<?>, PersistenceDelegate> delegates
- = Collections.synchronizedMap(new HashMap<Class<?>, PersistenceDelegate>());
+ private final PersistenceDelegateFinder finder = new PersistenceDelegateFinder();
private Map bindings = new IdentityHashMap();
private ExceptionListener exceptionListener;
boolean executeStatements = true;
@@ -166,8 +166,13 @@
* @see java.beans.BeanInfo#getBeanDescriptor
*/
public PersistenceDelegate getPersistenceDelegate(Class<?> type) {
- PersistenceDelegate pd = this.delegates.get(type);
- return (pd != null) ? pd : MetaData.getPersistenceDelegate(type);
+ synchronized (this.finder) {
+ PersistenceDelegate pd = this.finder.find(type);
+ if (pd != null) {
+ return pd;
+ }
+ }
+ return MetaData.getPersistenceDelegate(type);
}
/**
@@ -184,10 +189,8 @@
public void setPersistenceDelegate(Class<?> type,
PersistenceDelegate persistenceDelegate)
{
- if (persistenceDelegate != null) {
- this.delegates.put(type, persistenceDelegate);
- } else {
- this.delegates.remove(type);
+ synchronized (this.finder) {
+ this.finder.register(type, persistenceDelegate);
}
}
@@ -243,12 +246,11 @@
for (int i = 0; i < oldArgs.length; i++) {
newArgs[i] = writeObject1(oldArgs[i]);
}
- if (oldExp.getClass() == Statement.class) {
- return new Statement(newTarget, oldExp.getMethodName(), newArgs);
- }
- else {
- return new Expression(newTarget, oldExp.getMethodName(), newArgs);
- }
+ Statement newExp = Statement.class.equals(oldExp.getClass())
+ ? new Statement(newTarget, oldExp.getMethodName(), newArgs)
+ : new Expression(newTarget, oldExp.getMethodName(), newArgs);
+ newExp.loader = oldExp.loader;
+ return newExp;
}
/**
--- a/jdk/src/share/classes/java/beans/IndexedPropertyDescriptor.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/java/beans/IndexedPropertyDescriptor.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -274,6 +274,11 @@
}
indexedWriteMethod = Introspector.findMethod(cls, indexedWriteMethodName,
2, (type == null) ? null : new Class[] { int.class, type });
+ if (indexedWriteMethod != null) {
+ if (!indexedWriteMethod.getReturnType().equals(void.class)) {
+ indexedWriteMethod = null;
+ }
+ }
setIndexedWriteMethod0(indexedWriteMethod);
}
return indexedWriteMethod;
--- a/jdk/src/share/classes/java/beans/Introspector.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/java/beans/Introspector.java Tue Aug 04 08:01:03 2009 -0700
@@ -25,6 +25,7 @@
package java.beans;
+import com.sun.beans.finder.BeanInfoFinder;
import com.sun.beans.finder.ClassFinder;
import java.lang.ref.Reference;
@@ -45,6 +46,7 @@
import java.util.List;
import java.util.WeakHashMap;
import java.util.TreeMap;
+
import sun.awt.AppContext;
import sun.reflect.misc.ReflectUtil;
@@ -138,10 +140,6 @@
// events maps from String names to EventSetDescriptors
private Map events;
- private final static String DEFAULT_INFO_PATH = "sun.beans.infos";
-
- private static String[] searchPath = { DEFAULT_INFO_PATH };
-
private final static EventSetDescriptor[] EMPTY_EVENTSETDESCRIPTORS = new EventSetDescriptor[0];
static final String ADD_PREFIX = "add";
@@ -150,7 +148,7 @@
static final String SET_PREFIX = "set";
static final String IS_PREFIX = "is";
- private static final String BEANINFO_SUFFIX = "BeanInfo";
+ private static final Object FINDER_KEY = new Object();
//======================================================================
// Public methods
@@ -318,13 +316,11 @@
* Sun implementation initially sets to {"sun.beans.infos"}.
*/
- public static synchronized String[] getBeanInfoSearchPath() {
- // Return a copy of the searchPath.
- String result[] = new String[searchPath.length];
- for (int i = 0; i < searchPath.length; i++) {
- result[i] = searchPath[i];
+ public static String[] getBeanInfoSearchPath() {
+ BeanInfoFinder finder = getFinder();
+ synchronized (finder) {
+ return finder.getPackages();
}
- return result;
}
/**
@@ -343,12 +339,15 @@
* @see SecurityManager#checkPropertiesAccess
*/
- public static synchronized void setBeanInfoSearchPath(String path[]) {
+ public static void setBeanInfoSearchPath(String[] path) {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPropertiesAccess();
}
- searchPath = path;
+ BeanInfoFinder finder = getFinder();
+ synchronized (finder) {
+ finder.setPackages(path);
+ }
}
@@ -462,67 +461,14 @@
* then it checks to see if the class is its own BeanInfo. Finally,
* the BeanInfo search path is prepended to the class and searched.
*
+ * @param beanClass the class type of the bean
* @return Instance of an explicit BeanInfo class or null if one isn't found.
*/
- private static synchronized BeanInfo findExplicitBeanInfo(Class beanClass) {
- String name = beanClass.getName() + BEANINFO_SUFFIX;
- try {
- return (java.beans.BeanInfo)instantiate(beanClass, name);
- } catch (Exception ex) {
- // Just drop through
-
- }
- // Now try checking if the bean is its own BeanInfo.
- try {
- if (isSubclass(beanClass, java.beans.BeanInfo.class)) {
- return (java.beans.BeanInfo)beanClass.newInstance();
- }
- } catch (Exception ex) {
- // Just drop through
+ private static BeanInfo findExplicitBeanInfo(Class beanClass) {
+ BeanInfoFinder finder = getFinder();
+ synchronized (finder) {
+ return finder.find(beanClass);
}
- // Now try looking for <searchPath>.fooBeanInfo
- name = name.substring(name.lastIndexOf('.')+1);
-
- for (int i = 0; i < searchPath.length; i++) {
- // This optimization will only use the BeanInfo search path if is has changed
- // from the original or trying to get the ComponentBeanInfo.
- if (!DEFAULT_INFO_PATH.equals(searchPath[i]) ||
- DEFAULT_INFO_PATH.equals(searchPath[i]) && "ComponentBeanInfo".equals(name)) {
- try {
- String fullName = searchPath[i] + "." + name;
- java.beans.BeanInfo bi = (java.beans.BeanInfo)instantiate(beanClass, fullName);
-
- // Make sure that the returned BeanInfo matches the class.
- if (bi.getBeanDescriptor() != null) {
- if (bi.getBeanDescriptor().getBeanClass() == beanClass) {
- return bi;
- }
- } else if (bi.getPropertyDescriptors() != null) {
- PropertyDescriptor[] pds = bi.getPropertyDescriptors();
- for (int j = 0; j < pds.length; j++) {
- Method method = pds[j].getReadMethod();
- if (method == null) {
- method = pds[j].getWriteMethod();
- }
- if (method != null && method.getDeclaringClass() == beanClass) {
- return bi;
- }
- }
- } else if (bi.getMethodDescriptors() != null) {
- MethodDescriptor[] mds = bi.getMethodDescriptors();
- for (int j = 0; j < mds.length; j++) {
- Method method = mds[j].getMethod();
- if (method != null && method.getDeclaringClass() == beanClass) {
- return bi;
- }
- }
- }
- } catch (Exception ex) {
- // Silently ignore any errors.
- }
- }
- }
- return null;
}
/**
@@ -592,9 +538,9 @@
pd = new PropertyDescriptor(this.beanClass, name.substring(2), method, null);
}
} else if (argCount == 1) {
- if (argTypes[0] == int.class && name.startsWith(GET_PREFIX)) {
+ if (int.class.equals(argTypes[0]) && name.startsWith(GET_PREFIX)) {
pd = new IndexedPropertyDescriptor(this.beanClass, name.substring(3), null, null, method, null);
- } else if (resultType == void.class && name.startsWith(SET_PREFIX)) {
+ } else if (void.class.equals(resultType) && name.startsWith(SET_PREFIX)) {
// Simple setter
pd = new PropertyDescriptor(this.beanClass, name.substring(3), null, method);
if (throwsException(method, PropertyVetoException.class)) {
@@ -602,7 +548,7 @@
}
}
} else if (argCount == 2) {
- if (argTypes[0] == int.class && name.startsWith(SET_PREFIX)) {
+ if (void.class.equals(resultType) && int.class.equals(argTypes[0]) && name.startsWith(SET_PREFIX)) {
pd = new IndexedPropertyDescriptor(this.beanClass, name.substring(3), null, null, null, method);
if (throwsException(method, PropertyVetoException.class)) {
pd.setConstrained(true);
@@ -1498,6 +1444,16 @@
return false;
}
+ private static BeanInfoFinder getFinder() {
+ AppContext context = AppContext.getAppContext();
+ Object object = context.get(FINDER_KEY);
+ if (object instanceof BeanInfoFinder) {
+ return (BeanInfoFinder) object;
+ }
+ BeanInfoFinder finder = new BeanInfoFinder();
+ context.put(FINDER_KEY, finder);
+ return finder;
+ }
/**
* Try to create an instance of a named class.
--- a/jdk/src/share/classes/java/beans/MetaData.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/java/beans/MetaData.java Tue Aug 04 08:01:03 2009 -0700
@@ -219,7 +219,9 @@
return new Expression(oldInstance, String.class, "getClass", new Object[]{});
}
else {
- return new Expression(oldInstance, Class.class, "forName", new Object[]{c.getName()});
+ Expression newInstance = new Expression(oldInstance, Class.class, "forName", new Object[] { c.getName() });
+ newInstance.loader = c.getClassLoader();
+ return newInstance;
}
}
}
--- a/jdk/src/share/classes/java/beans/PropertyDescriptor.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/java/beans/PropertyDescriptor.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -294,6 +294,11 @@
writeMethod = Introspector.findMethod(cls, writeMethodName, 1,
(type == null) ? null : new Class[] { type });
+ if (writeMethod != null) {
+ if (!writeMethod.getReturnType().equals(void.class)) {
+ writeMethod = null;
+ }
+ }
try {
setWriteMethod(writeMethod);
} catch (IntrospectionException ex) {
--- a/jdk/src/share/classes/java/beans/PropertyEditorManager.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/java/beans/PropertyEditorManager.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,8 +25,8 @@
package java.beans;
-import com.sun.beans.WeakCache;
-import sun.beans.editors.*;
+import com.sun.beans.finder.PropertyEditorFinder;
+import sun.awt.AppContext;
/**
* The PropertyEditorManager can be used to locate a property editor for
@@ -55,6 +55,8 @@
public class PropertyEditorManager {
+ private static final Object FINDER_KEY = new Object();
+
/**
* Registers an editor class to edit values of the given target class.
* If the editor class is {@code null},
@@ -74,12 +76,15 @@
*
* @see SecurityManager#checkPropertiesAccess
*/
- public static synchronized void registerEditor(Class<?> targetType, Class<?> editorClass) {
+ public static void registerEditor(Class<?> targetType, Class<?> editorClass) {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPropertiesAccess();
}
- registry.put(targetType, editorClass);
+ PropertyEditorFinder finder = getFinder();
+ synchronized (finder) {
+ finder.register(targetType, editorClass);
+ }
}
/**
@@ -89,46 +94,11 @@
* @return An editor object for the given target class.
* The result is null if no suitable editor can be found.
*/
- public static synchronized PropertyEditor findEditor(Class<?> targetType) {
- Class editorClass = registry.get(targetType);
- if (editorClass != null) {
- try {
- Object o = editorClass.newInstance();
- return (PropertyEditor)o;
- } catch (Exception ex) {
- System.err.println("Couldn't instantiate type editor \"" +
- editorClass.getName() + "\" : " + ex);
- }
- }
-
- // Now try adding "Editor" to the class name.
-
- String editorName = targetType.getName() + "Editor";
- try {
- return (PropertyEditor) Introspector.instantiate(targetType, editorName);
- } catch (Exception ex) {
- // Silently ignore any errors.
+ public static PropertyEditor findEditor(Class<?> targetType) {
+ PropertyEditorFinder finder = getFinder();
+ synchronized (finder) {
+ return finder.find(targetType);
}
-
- // Now try looking for <searchPath>.fooEditor
- int index = editorName.lastIndexOf('.') + 1;
- if (index > 0) {
- editorName = editorName.substring(index);
- }
- for (String path : searchPath) {
- String name = path + '.' + editorName;
- try {
- return (PropertyEditor) Introspector.instantiate(targetType, name);
- } catch (Exception ex) {
- // Silently ignore any errors.
- }
- }
-
- if (null != targetType.getEnumConstants()) {
- return new EnumEditor(targetType);
- }
- // We couldn't find a suitable Editor.
- return null;
}
/**
@@ -139,8 +109,11 @@
* <p> The default value for this array is implementation-dependent,
* e.g. Sun implementation initially sets to {"sun.beans.editors"}.
*/
- public static synchronized String[] getEditorSearchPath() {
- return searchPath.clone();
+ public static String[] getEditorSearchPath() {
+ PropertyEditorFinder finder = getFinder();
+ synchronized (finder) {
+ return finder.getPackages();
+ }
}
/**
@@ -156,28 +129,25 @@
* of system properties.
* @see SecurityManager#checkPropertiesAccess
*/
- public static synchronized void setEditorSearchPath(String[] path) {
+ public static void setEditorSearchPath(String[] path) {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPropertiesAccess();
}
- searchPath = (path != null)
- ? path.clone()
- : EMPTY;
+ PropertyEditorFinder finder = getFinder();
+ synchronized (finder) {
+ finder.setPackages(path);
+ }
}
- private static String[] searchPath = { "sun.beans.editors" };
- private static final String[] EMPTY = {};
- private static final WeakCache<Class<?>, Class<?>> registry;
-
- static {
- registry = new WeakCache<Class<?>, Class<?>>();
- registry.put(Byte.TYPE, ByteEditor.class);
- registry.put(Short.TYPE, ShortEditor.class);
- registry.put(Integer.TYPE, IntegerEditor.class);
- registry.put(Long.TYPE, LongEditor.class);
- registry.put(Boolean.TYPE, BooleanEditor.class);
- registry.put(Float.TYPE, FloatEditor.class);
- registry.put(Double.TYPE, DoubleEditor.class);
+ private static PropertyEditorFinder getFinder() {
+ AppContext context = AppContext.getAppContext();
+ Object object = context.get(FINDER_KEY);
+ if (object instanceof PropertyEditorFinder) {
+ return (PropertyEditorFinder) object;
+ }
+ PropertyEditorFinder finder = new PropertyEditorFinder();
+ context.put(FINDER_KEY, finder);
+ return finder;
}
}
--- a/jdk/src/share/classes/java/beans/Statement.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/java/beans/Statement.java Tue Aug 04 08:01:03 2009 -0700
@@ -66,6 +66,7 @@
Object target;
String methodName;
Object[] arguments;
+ ClassLoader loader;
/**
* Creates a new <code>Statement</code> object with a <code>target</code>,
@@ -157,7 +158,7 @@
// of core from a class inside core. Special
// case this method.
if (target == Class.class && methodName.equals("forName")) {
- return ClassFinder.resolveClass((String)arguments[0]);
+ return ClassFinder.resolveClass((String)arguments[0], this.loader);
}
Class[] argClasses = new Class[arguments.length];
for(int i = 0; i < arguments.length; i++) {
--- a/jdk/src/share/classes/java/lang/Byte.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/java/lang/Byte.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/jdk/src/share/classes/java/lang/Integer.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/java/lang/Integer.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1994-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1994-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/jdk/src/share/classes/java/lang/Long.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/java/lang/Long.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1994-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1994-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/jdk/src/share/classes/java/lang/Short.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/java/lang/Short.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/jdk/src/share/classes/java/lang/System.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/java/lang/System.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1994-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1994-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/jdk/src/share/classes/java/nio/channels/DatagramChannel.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/java/nio/channels/DatagramChannel.java Tue Aug 04 08:01:03 2009 -0700
@@ -421,7 +421,7 @@
* invocation of this method will block until the first operation is
* complete. If this channel's socket is not bound then this method will
* first cause the socket to be bound to an address that is assigned
- * automatically, as if by invoking the {@link #bind bind) method with a
+ * automatically, as if by invoking the {@link #bind bind} method with a
* parameter of {@code null}. </p>
*
* @param src
--- a/jdk/src/share/classes/java/nio/channels/package-info.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/java/nio/channels/package-info.java Tue Aug 04 08:01:03 2009 -0700
@@ -115,8 +115,8 @@
* <td>Reads, writes, maps, and manipulates files</td></tr>
* <tr><td valign=top><tt>{@link java.nio.channels.FileLock}</tt></td>
* <td>A lock on a (region of a) file</td></tr>
- * <tr><td valign=top><tt>{@link java.nio.MappedByteBuffer}/{@link java.nio.MappedBigByteBuffer} </tt></td>
- * <td>A direct byte buffer or big byte buffer mapped to a region of a file</td></tr>
+ * <tr><td valign=top><tt>{@link java.nio.MappedByteBuffer} </tt></td>
+ * <td>A direct byte buffer mapped to a region of a file</td></tr>
* </table></blockquote>
*
* <p> The {@link java.nio.channels.FileChannel} class supports the usual
--- a/jdk/src/share/classes/java/nio/file/DirectoryStream.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/java/nio/file/DirectoryStream.java Tue Aug 04 08:01:03 2009 -0700
@@ -53,7 +53,7 @@
* invoking the {@link #close close} method. Closing the directory stream
* releases any resources associated with the stream. Once a directory stream
* is closed, all further method invocations on the iterator throw {@link
- * java.util.concurrent.ConcurrentModificationException} with cause {@link
+ * java.util.ConcurrentModificationException} with cause {@link
* ClosedDirectoryStreamException}.
*
* <p> A directory stream is not required to be <i>asynchronously closeable</i>.
--- a/jdk/src/share/classes/java/nio/file/Path.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/java/nio/file/Path.java Tue Aug 04 08:01:03 2009 -0700
@@ -987,7 +987,7 @@
* exception then it is propogated to the iterator's {@link Iterator#hasNext()
* hasNext} or {@link Iterator#next() next} method. Where an {@code
* IOException} is thrown, it is propogated as a {@link
- * java.util.concurrent.ConcurrentModificationException} with the {@code
+ * java.util.ConcurrentModificationException} with the {@code
* IOException} as the cause.
*
* <p> When an implementation supports operations on entries in the
--- a/jdk/src/share/classes/java/nio/file/attribute/package-info.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/java/nio/file/attribute/package-info.java Tue Aug 04 08:01:03 2009 -0700
@@ -102,9 +102,9 @@
* <p><li> The {@link java.nio.file.attribute.UserPrincipalLookupService}
* interface defines methods to lookup user or group principals. </li>
*
- * <p><li> The {@link java.nio.file.attribute.Attribute} interface
+ * <p><li> The {@link java.nio.file.attribute.FileAttribute} interface
* represents the value of an attribute for cases where the attribute value is
- * require to be set atomically when creating an object in the file system. </li>
+ * required to be set atomically when creating an object in the file system. </li>
*
* </ul>
*
--- a/jdk/src/share/classes/java/util/Arrays.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/java/util/Arrays.java Tue Aug 04 08:01:03 2009 -0700
@@ -1065,29 +1065,103 @@
(x[b] > x[c] ? b : x[a] > x[c] ? c : a));
}
+ /**
+ * Old merge sort implementation can be selected (for
+ * compatibility with broken comparators) using a system property.
+ * Cannot be a static boolean in the enclosing class due to
+ * circular dependencies. To be removed in a future release.
+ */
+ static final class LegacyMergeSort {
+ private static final boolean userRequested =
+ java.security.AccessController.doPrivileged(
+ new sun.security.action.GetBooleanAction(
+ "java.util.Arrays.useLegacyMergeSort")).booleanValue();
+ }
+
+ /*
+ * If this platform has an optimizing VM, check whether ComparableTimSort
+ * offers any performance benefit over TimSort in conjunction with a
+ * comparator that returns:
+ * {@code ((Comparable)first).compareTo(Second)}.
+ * If not, you are better off deleting ComparableTimSort to
+ * eliminate the code duplication. In other words, the commented
+ * out code below is the preferable implementation for sorting
+ * arrays of Comparables if it offers sufficient performance.
+ */
+
+// /**
+// * A comparator that implements the natural ordering of a group of
+// * mutually comparable elements. Using this comparator saves us
+// * from duplicating most of the code in this file (one version for
+// * Comparables, one for explicit Comparators).
+// */
+// private static final Comparator<Object> NATURAL_ORDER =
+// new Comparator<Object>() {
+// @SuppressWarnings("unchecked")
+// public int compare(Object first, Object second) {
+// return ((Comparable<Object>)first).compareTo(second);
+// }
+// };
+//
+// public static void sort(Object[] a) {
+// sort(a, 0, a.length, NATURAL_ORDER);
+// }
+//
+// public static void sort(Object[] a, int fromIndex, int toIndex) {
+// sort(a, fromIndex, toIndex, NATURAL_ORDER);
+// }
/**
- * Sorts the specified array of objects into ascending order, according to
- * the {@linkplain Comparable natural ordering}
- * of its elements. All elements in the array
- * must implement the {@link Comparable} interface. Furthermore, all
- * elements in the array must be <i>mutually comparable</i> (that is,
- * <tt>e1.compareTo(e2)</tt> must not throw a <tt>ClassCastException</tt>
- * for any elements <tt>e1</tt> and <tt>e2</tt> in the array).<p>
+ * Sorts the specified array of objects into ascending order, according
+ * to the {@linkplain Comparable natural ordering} of its elements.
+ * All elements in the array must implement the {@link Comparable}
+ * interface. Furthermore, all elements in the array must be
+ * <i>mutually comparable</i> (that is, {@code e1.compareTo(e2)} must
+ * not throw a {@code ClassCastException} for any elements {@code e1}
+ * and {@code e2} in the array).
+ *
+ * <p>This sort is guaranteed to be <i>stable</i>: equal elements will
+ * not be reordered as a result of the sort.
*
- * This sort is guaranteed to be <i>stable</i>: equal elements will
- * not be reordered as a result of the sort.<p>
+ * <p>Implementation note: This implementation is a stable, adaptive,
+ * iterative mergesort that requires far fewer than n lg(n) comparisons
+ * when the input array is partially sorted, while offering the
+ * performance of a traditional mergesort when the input array is
+ * randomly ordered. If the input array is nearly sorted, the
+ * implementation requires approximately n comparisons. Temporary
+ * storage requirements vary from a small constant for nearly sorted
+ * input arrays to n/2 object references for randomly ordered input
+ * arrays.
*
- * The sorting algorithm is a modified mergesort (in which the merge is
- * omitted if the highest element in the low sublist is less than the
- * lowest element in the high sublist). This algorithm offers guaranteed
- * n*log(n) performance.
+ * <p>The implementation takes equal advantage of ascending and
+ * descending order in its input array, and can take advantage of
+ * ascending and descending order in different parts of the the same
+ * input array. It is well-suited to merging two or more sorted arrays:
+ * simply concatenate the arrays and sort the resulting array.
+ *
+ * <p>The implementation was adapted from Tim Peters's list sort for Python
+ * (<a href="http://svn.python.org/projects/python/trunk/Objects/listsort.txt">
+ * TimSort</a>). It uses techiques from Peter McIlroy's "Optimistic
+ * Sorting and Information Theoretic Complexity", in Proceedings of the
+ * Fourth Annual ACM-SIAM Symposium on Discrete Algorithms, pp 467-474,
+ * January 1993.
*
* @param a the array to be sorted
- * @throws ClassCastException if the array contains elements that are not
- * <i>mutually comparable</i> (for example, strings and integers).
+ * @throws ClassCastException if the array contains elements that are not
+ * <i>mutually comparable</i> (for example, strings and integers)
+ * @throws IllegalArgumentException (optional) if the natural
+ * ordering of the array elements is found to violate the
+ * {@link Comparable} contract
*/
public static void sort(Object[] a) {
+ if (LegacyMergeSort.userRequested)
+ legacyMergeSort(a);
+ else
+ ComparableTimSort.sort(a);
+ }
+
+ /** To be removed in a future release. */
+ private static void legacyMergeSort(Object[] a) {
Object[] aux = a.clone();
mergeSort(aux, a, 0, a.length, 0);
}
@@ -1097,34 +1171,63 @@
* ascending order, according to the
* {@linkplain Comparable natural ordering} of its
* elements. The range to be sorted extends from index
- * <tt>fromIndex</tt>, inclusive, to index <tt>toIndex</tt>, exclusive.
- * (If <tt>fromIndex==toIndex</tt>, the range to be sorted is empty.) All
+ * {@code fromIndex}, inclusive, to index {@code toIndex}, exclusive.
+ * (If {@code fromIndex==toIndex}, the range to be sorted is empty.) All
* elements in this range must implement the {@link Comparable}
* interface. Furthermore, all elements in this range must be <i>mutually
- * comparable</i> (that is, <tt>e1.compareTo(e2)</tt> must not throw a
- * <tt>ClassCastException</tt> for any elements <tt>e1</tt> and
- * <tt>e2</tt> in the array).<p>
+ * comparable</i> (that is, {@code e1.compareTo(e2)} must not throw a
+ * {@code ClassCastException} for any elements {@code e1} and
+ * {@code e2} in the array).
+ *
+ * <p>This sort is guaranteed to be <i>stable</i>: equal elements will
+ * not be reordered as a result of the sort.
*
- * This sort is guaranteed to be <i>stable</i>: equal elements will
- * not be reordered as a result of the sort.<p>
+ * <p>Implementation note: This implementation is a stable, adaptive,
+ * iterative mergesort that requires far fewer than n lg(n) comparisons
+ * when the input array is partially sorted, while offering the
+ * performance of a traditional mergesort when the input array is
+ * randomly ordered. If the input array is nearly sorted, the
+ * implementation requires approximately n comparisons. Temporary
+ * storage requirements vary from a small constant for nearly sorted
+ * input arrays to n/2 object references for randomly ordered input
+ * arrays.
*
- * The sorting algorithm is a modified mergesort (in which the merge is
- * omitted if the highest element in the low sublist is less than the
- * lowest element in the high sublist). This algorithm offers guaranteed
- * n*log(n) performance.
+ * <p>The implementation takes equal advantage of ascending and
+ * descending order in its input array, and can take advantage of
+ * ascending and descending order in different parts of the the same
+ * input array. It is well-suited to merging two or more sorted arrays:
+ * simply concatenate the arrays and sort the resulting array.
+ *
+ * <p>The implementation was adapted from Tim Peters's list sort for Python
+ * (<a href="http://svn.python.org/projects/python/trunk/Objects/listsort.txt">
+ * TimSort</a>). It uses techiques from Peter McIlroy's "Optimistic
+ * Sorting and Information Theoretic Complexity", in Proceedings of the
+ * Fourth Annual ACM-SIAM Symposium on Discrete Algorithms, pp 467-474,
+ * January 1993.
*
* @param a the array to be sorted
* @param fromIndex the index of the first element (inclusive) to be
* sorted
* @param toIndex the index of the last element (exclusive) to be sorted
- * @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt>
- * @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or
- * <tt>toIndex > a.length</tt>
- * @throws ClassCastException if the array contains elements that are
- * not <i>mutually comparable</i> (for example, strings and
- * integers).
+ * @throws IllegalArgumentException if {@code fromIndex > toIndex} or
+ * (optional) if the natural ordering of the array elements is
+ * found to violate the {@link Comparable} contract
+ * @throws ArrayIndexOutOfBoundsException if {@code fromIndex < 0} or
+ * {@code toIndex > a.length}
+ * @throws ClassCastException if the array contains elements that are
+ * not <i>mutually comparable</i> (for example, strings and
+ * integers).
*/
public static void sort(Object[] a, int fromIndex, int toIndex) {
+ if (LegacyMergeSort.userRequested)
+ legacyMergeSort(a, fromIndex, toIndex);
+ else
+ ComparableTimSort.sort(a, fromIndex, toIndex);
+ }
+
+ /** To be removed in a future release. */
+ private static void legacyMergeSort(Object[] a,
+ int fromIndex, int toIndex) {
rangeCheck(a.length, fromIndex, toIndex);
Object[] aux = copyOfRange(a, fromIndex, toIndex);
mergeSort(aux, a, fromIndex, toIndex, -fromIndex);
@@ -1133,6 +1236,7 @@
/**
* Tuning parameter: list size at or below which insertion sort will be
* used in preference to mergesort or quicksort.
+ * To be removed in a future release.
*/
private static final int INSERTIONSORT_THRESHOLD = 7;
@@ -1142,6 +1246,7 @@
* low is the index in dest to start sorting
* high is the end index in dest to end sorting
* off is the offset to generate corresponding low, high in src
+ * To be removed in a future release.
*/
private static void mergeSort(Object[] src,
Object[] dest,
@@ -1197,25 +1302,53 @@
* Sorts the specified array of objects according to the order induced by
* the specified comparator. All elements in the array must be
* <i>mutually comparable</i> by the specified comparator (that is,
- * <tt>c.compare(e1, e2)</tt> must not throw a <tt>ClassCastException</tt>
- * for any elements <tt>e1</tt> and <tt>e2</tt> in the array).<p>
+ * {@code c.compare(e1, e2)} must not throw a {@code ClassCastException}
+ * for any elements {@code e1} and {@code e2} in the array).
+ *
+ * <p>This sort is guaranteed to be <i>stable</i>: equal elements will
+ * not be reordered as a result of the sort.
*
- * This sort is guaranteed to be <i>stable</i>: equal elements will
- * not be reordered as a result of the sort.<p>
+ * <p>Implementation note: This implementation is a stable, adaptive,
+ * iterative mergesort that requires far fewer than n lg(n) comparisons
+ * when the input array is partially sorted, while offering the
+ * performance of a traditional mergesort when the input array is
+ * randomly ordered. If the input array is nearly sorted, the
+ * implementation requires approximately n comparisons. Temporary
+ * storage requirements vary from a small constant for nearly sorted
+ * input arrays to n/2 object references for randomly ordered input
+ * arrays.
*
- * The sorting algorithm is a modified mergesort (in which the merge is
- * omitted if the highest element in the low sublist is less than the
- * lowest element in the high sublist). This algorithm offers guaranteed
- * n*log(n) performance.
+ * <p>The implementation takes equal advantage of ascending and
+ * descending order in its input array, and can take advantage of
+ * ascending and descending order in different parts of the the same
+ * input array. It is well-suited to merging two or more sorted arrays:
+ * simply concatenate the arrays and sort the resulting array.
+ *
+ * <p>The implementation was adapted from Tim Peters's list sort for Python
+ * (<a href="http://svn.python.org/projects/python/trunk/Objects/listsort.txt">
+ * TimSort</a>). It uses techiques from Peter McIlroy's "Optimistic
+ * Sorting and Information Theoretic Complexity", in Proceedings of the
+ * Fourth Annual ACM-SIAM Symposium on Discrete Algorithms, pp 467-474,
+ * January 1993.
*
* @param a the array to be sorted
* @param c the comparator to determine the order of the array. A
- * <tt>null</tt> value indicates that the elements'
+ * {@code null} value indicates that the elements'
* {@linkplain Comparable natural ordering} should be used.
- * @throws ClassCastException if the array contains elements that are
- * not <i>mutually comparable</i> using the specified comparator.
+ * @throws ClassCastException if the array contains elements that are
+ * not <i>mutually comparable</i> using the specified comparator
+ * @throws IllegalArgumentException (optional) if the comparator is
+ * found to violate the {@link Comparator} contract
*/
public static <T> void sort(T[] a, Comparator<? super T> c) {
+ if (LegacyMergeSort.userRequested)
+ legacyMergeSort(a, c);
+ else
+ TimSort.sort(a, c);
+ }
+
+ /** To be removed in a future release. */
+ private static <T> void legacyMergeSort(T[] a, Comparator<? super T> c) {
T[] aux = a.clone();
if (c==null)
mergeSort(aux, a, 0, a.length, 0);
@@ -1226,36 +1359,65 @@
/**
* Sorts the specified range of the specified array of objects according
* to the order induced by the specified comparator. The range to be
- * sorted extends from index <tt>fromIndex</tt>, inclusive, to index
- * <tt>toIndex</tt>, exclusive. (If <tt>fromIndex==toIndex</tt>, the
+ * sorted extends from index {@code fromIndex}, inclusive, to index
+ * {@code toIndex}, exclusive. (If {@code fromIndex==toIndex}, the
* range to be sorted is empty.) All elements in the range must be
* <i>mutually comparable</i> by the specified comparator (that is,
- * <tt>c.compare(e1, e2)</tt> must not throw a <tt>ClassCastException</tt>
- * for any elements <tt>e1</tt> and <tt>e2</tt> in the range).<p>
+ * {@code c.compare(e1, e2)} must not throw a {@code ClassCastException}
+ * for any elements {@code e1} and {@code e2} in the range).
+ *
+ * <p>This sort is guaranteed to be <i>stable</i>: equal elements will
+ * not be reordered as a result of the sort.
*
- * This sort is guaranteed to be <i>stable</i>: equal elements will
- * not be reordered as a result of the sort.<p>
+ * <p>Implementation note: This implementation is a stable, adaptive,
+ * iterative mergesort that requires far fewer than n lg(n) comparisons
+ * when the input array is partially sorted, while offering the
+ * performance of a traditional mergesort when the input array is
+ * randomly ordered. If the input array is nearly sorted, the
+ * implementation requires approximately n comparisons. Temporary
+ * storage requirements vary from a small constant for nearly sorted
+ * input arrays to n/2 object references for randomly ordered input
+ * arrays.
*
- * The sorting algorithm is a modified mergesort (in which the merge is
- * omitted if the highest element in the low sublist is less than the
- * lowest element in the high sublist). This algorithm offers guaranteed
- * n*log(n) performance.
+ * <p>The implementation takes equal advantage of ascending and
+ * descending order in its input array, and can take advantage of
+ * ascending and descending order in different parts of the the same
+ * input array. It is well-suited to merging two or more sorted arrays:
+ * simply concatenate the arrays and sort the resulting array.
+ *
+ * <p>The implementation was adapted from Tim Peters's list sort for Python
+ * (<a href="http://svn.python.org/projects/python/trunk/Objects/listsort.txt">
+ * TimSort</a>). It uses techiques from Peter McIlroy's "Optimistic
+ * Sorting and Information Theoretic Complexity", in Proceedings of the
+ * Fourth Annual ACM-SIAM Symposium on Discrete Algorithms, pp 467-474,
+ * January 1993.
*
* @param a the array to be sorted
* @param fromIndex the index of the first element (inclusive) to be
* sorted
* @param toIndex the index of the last element (exclusive) to be sorted
* @param c the comparator to determine the order of the array. A
- * <tt>null</tt> value indicates that the elements'
+ * {@code null} value indicates that the elements'
* {@linkplain Comparable natural ordering} should be used.
* @throws ClassCastException if the array contains elements that are not
* <i>mutually comparable</i> using the specified comparator.
- * @throws IllegalArgumentException if <tt>fromIndex > toIndex</tt>
- * @throws ArrayIndexOutOfBoundsException if <tt>fromIndex < 0</tt> or
- * <tt>toIndex > a.length</tt>
+ * @throws IllegalArgumentException if {@code fromIndex > toIndex} or
+ * (optional) if the comparator is found to violate the
+ * {@link Comparator} contract
+ * @throws ArrayIndexOutOfBoundsException if {@code fromIndex < 0} or
+ * {@code toIndex > a.length}
*/
public static <T> void sort(T[] a, int fromIndex, int toIndex,
Comparator<? super T> c) {
+ if (LegacyMergeSort.userRequested)
+ legacyMergeSort(a, fromIndex, toIndex, c);
+ else
+ TimSort.sort(a, fromIndex, toIndex, c);
+ }
+
+ /** To be removed in a future release. */
+ private static <T> void legacyMergeSort(T[] a, int fromIndex, int toIndex,
+ Comparator<? super T> c) {
rangeCheck(a.length, fromIndex, toIndex);
T[] aux = copyOfRange(a, fromIndex, toIndex);
if (c==null)
@@ -1270,6 +1432,7 @@
* low is the index in dest to start sorting
* high is the end index in dest to end sorting
* off is the offset into src corresponding to low in dest
+ * To be removed in a future release.
*/
private static void mergeSort(Object[] src,
Object[] dest,
--- a/jdk/src/share/classes/java/util/Collections.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/java/util/Collections.java Tue Aug 04 08:01:03 2009 -0700
@@ -100,23 +100,42 @@
/**
* Sorts the specified list into ascending order, according to the
- * <i>natural ordering</i> of its elements. All elements in the list must
- * implement the <tt>Comparable</tt> interface. Furthermore, all elements
- * in the list must be <i>mutually comparable</i> (that is,
- * <tt>e1.compareTo(e2)</tt> must not throw a <tt>ClassCastException</tt>
- * for any elements <tt>e1</tt> and <tt>e2</tt> in the list).<p>
+ * {@linkplain Comparable natural ordering} of its elements.
+ * All elements in the list must implement the {@link Comparable}
+ * interface. Furthermore, all elements in the list must be
+ * <i>mutually comparable</i> (that is, {@code e1.compareTo(e2)}
+ * must not throw a {@code ClassCastException} for any elements
+ * {@code e1} and {@code e2} in the list).
*
- * This sort is guaranteed to be <i>stable</i>: equal elements will
- * not be reordered as a result of the sort.<p>
+ * <p>This sort is guaranteed to be <i>stable</i>: equal elements will
+ * not be reordered as a result of the sort.
+ *
+ * <p>The specified list must be modifiable, but need not be resizable.
*
- * The specified list must be modifiable, but need not be resizable.<p>
+ * <p>Implementation note: This implementation is a stable, adaptive,
+ * iterative mergesort that requires far fewer than n lg(n) comparisons
+ * when the input array is partially sorted, while offering the
+ * performance of a traditional mergesort when the input array is
+ * randomly ordered. If the input array is nearly sorted, the
+ * implementation requires approximately n comparisons. Temporary
+ * storage requirements vary from a small constant for nearly sorted
+ * input arrays to n/2 object references for randomly ordered input
+ * arrays.
*
- * The sorting algorithm is a modified mergesort (in which the merge is
- * omitted if the highest element in the low sublist is less than the
- * lowest element in the high sublist). This algorithm offers guaranteed
- * n log(n) performance.
+ * <p>The implementation takes equal advantage of ascending and
+ * descending order in its input array, and can take advantage of
+ * ascending and descending order in different parts of the the same
+ * input array. It is well-suited to merging two or more sorted arrays:
+ * simply concatenate the arrays and sort the resulting array.
*
- * This implementation dumps the specified list into an array, sorts
+ * <p>The implementation was adapted from Tim Peters's list sort for Python
+ * (<a href="http://svn.python.org/projects/python/trunk/Objects/listsort.txt">
+ * TimSort</a>). It uses techiques from Peter McIlroy's "Optimistic
+ * Sorting and Information Theoretic Complexity", in Proceedings of the
+ * Fourth Annual ACM-SIAM Symposium on Discrete Algorithms, pp 467-474,
+ * January 1993.
+ *
+ * <p>This implementation dumps the specified list into an array, sorts
* the array, and iterates over the list resetting each element
* from the corresponding position in the array. This avoids the
* n<sup>2</sup> log(n) performance that would result from attempting
@@ -126,8 +145,10 @@
* @throws ClassCastException if the list contains elements that are not
* <i>mutually comparable</i> (for example, strings and integers).
* @throws UnsupportedOperationException if the specified list's
- * list-iterator does not support the <tt>set</tt> operation.
- * @see Comparable
+ * list-iterator does not support the {@code set} operation.
+ * @throws IllegalArgumentException (optional) if the implementation
+ * detects that the natural ordering of the list elements is
+ * found to violate the {@link Comparable} contract
*/
public static <T extends Comparable<? super T>> void sort(List<T> list) {
Object[] a = list.toArray();
@@ -143,19 +164,38 @@
* Sorts the specified list according to the order induced by the
* specified comparator. All elements in the list must be <i>mutually
* comparable</i> using the specified comparator (that is,
- * <tt>c.compare(e1, e2)</tt> must not throw a <tt>ClassCastException</tt>
- * for any elements <tt>e1</tt> and <tt>e2</tt> in the list).<p>
+ * {@code c.compare(e1, e2)} must not throw a {@code ClassCastException}
+ * for any elements {@code e1} and {@code e2} in the list).
*
- * This sort is guaranteed to be <i>stable</i>: equal elements will
- * not be reordered as a result of the sort.<p>
+ * <p>This sort is guaranteed to be <i>stable</i>: equal elements will
+ * not be reordered as a result of the sort.
+ *
+ * <p>The specified list must be modifiable, but need not be resizable.
*
- * The sorting algorithm is a modified mergesort (in which the merge is
- * omitted if the highest element in the low sublist is less than the
- * lowest element in the high sublist). This algorithm offers guaranteed
- * n log(n) performance.
+ * <p>Implementation note: This implementation is a stable, adaptive,
+ * iterative mergesort that requires far fewer than n lg(n) comparisons
+ * when the input array is partially sorted, while offering the
+ * performance of a traditional mergesort when the input array is
+ * randomly ordered. If the input array is nearly sorted, the
+ * implementation requires approximately n comparisons. Temporary
+ * storage requirements vary from a small constant for nearly sorted
+ * input arrays to n/2 object references for randomly ordered input
+ * arrays.
*
- * The specified list must be modifiable, but need not be resizable.
- * This implementation dumps the specified list into an array, sorts
+ * <p>The implementation takes equal advantage of ascending and
+ * descending order in its input array, and can take advantage of
+ * ascending and descending order in different parts of the the same
+ * input array. It is well-suited to merging two or more sorted arrays:
+ * simply concatenate the arrays and sort the resulting array.
+ *
+ * <p>The implementation was adapted from Tim Peters's list sort for Python
+ * (<a href="http://svn.python.org/projects/python/trunk/Objects/listsort.txt">
+ * TimSort</a>). It uses techiques from Peter McIlroy's "Optimistic
+ * Sorting and Information Theoretic Complexity", in Proceedings of the
+ * Fourth Annual ACM-SIAM Symposium on Discrete Algorithms, pp 467-474,
+ * January 1993.
+ *
+ * <p>This implementation dumps the specified list into an array, sorts
* the array, and iterates over the list resetting each element
* from the corresponding position in the array. This avoids the
* n<sup>2</sup> log(n) performance that would result from attempting
@@ -163,13 +203,14 @@
*
* @param list the list to be sorted.
* @param c the comparator to determine the order of the list. A
- * <tt>null</tt> value indicates that the elements' <i>natural
+ * {@code null} value indicates that the elements' <i>natural
* ordering</i> should be used.
* @throws ClassCastException if the list contains elements that are not
* <i>mutually comparable</i> using the specified comparator.
* @throws UnsupportedOperationException if the specified list's
- * list-iterator does not support the <tt>set</tt> operation.
- * @see Comparator
+ * list-iterator does not support the {@code set} operation.
+ * @throws IllegalArgumentException (optional) if the comparator is
+ * found to violate the {@link Comparator} contract
*/
public static <T> void sort(List<T> list, Comparator<? super T> c) {
Object[] a = list.toArray();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/util/ComparableTimSort.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,895 @@
+/*
+ * Copyright 2009 Google Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package java.util;
+
+/**
+ * This is a near duplicate of {@link TimSort}, modified for use with
+ * arrays of objects that implement {@link Comparable}, instead of using
+ * explicit comparators.
+ *
+ * <p>If you are using an optimizing VM, you may find that ComparableTimSort
+ * offers no performance benefit over TimSort in conjunction with a
+ * comparator that simply returns {@code ((Comparable)first).compareTo(Second)}.
+ * If this is the case, you are better off deleting ComparableTimSort to
+ * eliminate the code duplication. (See Arrays.java for details.)
+ *
+ * @author Josh Bloch
+ */
+class ComparableTimSort {
+ /**
+ * This is the minimum sized sequence that will be merged. Shorter
+ * sequences will be lengthened by calling binarySort. If the entire
+ * array is less than this length, no merges will be performed.
+ *
+ * This constant should be a power of two. It was 64 in Tim Peter's C
+ * implementation, but 32 was empirically determined to work better in
+ * this implementation. In the unlikely event that you set this constant
+ * to be a number that's not a power of two, you'll need to change the
+ * {@link #minRunLength} computation.
+ *
+ * If you decrease this constant, you must change the stackLen
+ * computation in the TimSort constructor, or you risk an
+ * ArrayOutOfBounds exception. See listsort.txt for a discussion
+ * of the minimum stack length required as a function of the length
+ * of the array being sorted and the minimum merge sequence length.
+ */
+ private static final int MIN_MERGE = 32;
+
+ /**
+ * The array being sorted.
+ */
+ private final Object[] a;
+
+ /**
+ * When we get into galloping mode, we stay there until both runs win less
+ * often than MIN_GALLOP consecutive times.
+ */
+ private static final int MIN_GALLOP = 7;
+
+ /**
+ * This controls when we get *into* galloping mode. It is initialized
+ * to MIN_GALLOP. The mergeLo and mergeHi methods nudge it higher for
+ * random data, and lower for highly structured data.
+ */
+ private int minGallop = MIN_GALLOP;
+
+ /**
+ * Maximum initial size of tmp array, which is used for merging. The array
+ * can grow to accommodate demand.
+ *
+ * Unlike Tim's original C version, we do not allocate this much storage
+ * when sorting smaller arrays. This change was required for performance.
+ */
+ private static final int INITIAL_TMP_STORAGE_LENGTH = 256;
+
+ /**
+ * Temp storage for merges.
+ */
+ private Object[] tmp;
+
+ /**
+ * A stack of pending runs yet to be merged. Run i starts at
+ * address base[i] and extends for len[i] elements. It's always
+ * true (so long as the indices are in bounds) that:
+ *
+ * runBase[i] + runLen[i] == runBase[i + 1]
+ *
+ * so we could cut the storage for this, but it's a minor amount,
+ * and keeping all the info explicit simplifies the code.
+ */
+ private int stackSize = 0; // Number of pending runs on stack
+ private final int[] runBase;
+ private final int[] runLen;
+
+ /**
+ * Creates a TimSort instance to maintain the state of an ongoing sort.
+ *
+ * @param a the array to be sorted
+ */
+ private ComparableTimSort(Object[] a) {
+ this.a = a;
+
+ // Allocate temp storage (which may be increased later if necessary)
+ int len = a.length;
+ @SuppressWarnings({"unchecked", "UnnecessaryLocalVariable"})
+ Object[] newArray = new Object[len < 2 * INITIAL_TMP_STORAGE_LENGTH ?
+ len >>> 1 : INITIAL_TMP_STORAGE_LENGTH];
+ tmp = newArray;
+
+ /*
+ * Allocate runs-to-be-merged stack (which cannot be expanded). The
+ * stack length requirements are described in listsort.txt. The C
+ * version always uses the same stack length (85), but this was
+ * measured to be too expensive when sorting "mid-sized" arrays (e.g.,
+ * 100 elements) in Java. Therefore, we use smaller (but sufficiently
+ * large) stack lengths for smaller arrays. The "magic numbers" in the
+ * computation below must be changed if MIN_MERGE is decreased. See
+ * the MIN_MERGE declaration above for more information.
+ */
+ int stackLen = (len < 120 ? 5 :
+ len < 1542 ? 10 :
+ len < 119151 ? 19 : 40);
+ runBase = new int[stackLen];
+ runLen = new int[stackLen];
+ }
+
+ /*
+ * The next two methods (which are package private and static) constitute
+ * the entire API of this class. Each of these methods obeys the contract
+ * of the public method with the same signature in java.util.Arrays.
+ */
+
+ static void sort(Object[] a) {
+ sort(a, 0, a.length);
+ }
+
+ static void sort(Object[] a, int lo, int hi) {
+ rangeCheck(a.length, lo, hi);
+ int nRemaining = hi - lo;
+ if (nRemaining < 2)
+ return; // Arrays of size 0 and 1 are always sorted
+
+ // If array is small, do a "mini-TimSort" with no merges
+ if (nRemaining < MIN_MERGE) {
+ int initRunLen = countRunAndMakeAscending(a, lo, hi);
+ binarySort(a, lo, hi, lo + initRunLen);
+ return;
+ }
+
+ /**
+ * March over the array once, left to right, finding natural runs,
+ * extending short natural runs to minRun elements, and merging runs
+ * to maintain stack invariant.
+ */
+ ComparableTimSort ts = new ComparableTimSort(a);
+ int minRun = minRunLength(nRemaining);
+ do {
+ // Identify next run
+ int runLen = countRunAndMakeAscending(a, lo, hi);
+
+ // If run is short, extend to min(minRun, nRemaining)
+ if (runLen < minRun) {
+ int force = nRemaining <= minRun ? nRemaining : minRun;
+ binarySort(a, lo, lo + force, lo + runLen);
+ runLen = force;
+ }
+
+ // Push run onto pending-run stack, and maybe merge
+ ts.pushRun(lo, runLen);
+ ts.mergeCollapse();
+
+ // Advance to find next run
+ lo += runLen;
+ nRemaining -= runLen;
+ } while (nRemaining != 0);
+
+ // Merge all remaining runs to complete sort
+ assert lo == hi;
+ ts.mergeForceCollapse();
+ assert ts.stackSize == 1;
+ }
+
+ /**
+ * Sorts the specified portion of the specified array using a binary
+ * insertion sort. This is the best method for sorting small numbers
+ * of elements. It requires O(n log n) compares, but O(n^2) data
+ * movement (worst case).
+ *
+ * If the initial part of the specified range is already sorted,
+ * this method can take advantage of it: the method assumes that the
+ * elements from index {@code lo}, inclusive, to {@code start},
+ * exclusive are already sorted.
+ *
+ * @param a the array in which a range is to be sorted
+ * @param lo the index of the first element in the range to be sorted
+ * @param hi the index after the last element in the range to be sorted
+ * @param start the index of the first element in the range that is
+ * not already known to be sorted (@code lo <= start <= hi}
+ */
+ @SuppressWarnings("fallthrough")
+ private static void binarySort(Object[] a, int lo, int hi, int start) {
+ assert lo <= start && start <= hi;
+ if (start == lo)
+ start++;
+ for ( ; start < hi; start++) {
+ @SuppressWarnings("unchecked")
+ Comparable<Object> pivot = (Comparable) a[start];
+
+ // Set left (and right) to the index where a[start] (pivot) belongs
+ int left = lo;
+ int right = start;
+ assert left <= right;
+ /*
+ * Invariants:
+ * pivot >= all in [lo, left).
+ * pivot < all in [right, start).
+ */
+ while (left < right) {
+ int mid = (left + right) >>> 1;
+ if (pivot.compareTo(a[mid]) < 0)
+ right = mid;
+ else
+ left = mid + 1;
+ }
+ assert left == right;
+
+ /*
+ * The invariants still hold: pivot >= all in [lo, left) and
+ * pivot < all in [left, start), so pivot belongs at left. Note
+ * that if there are elements equal to pivot, left points to the
+ * first slot after them -- that's why this sort is stable.
+ * Slide elements over to make room to make room for pivot.
+ */
+ int n = start - left; // The number of elements to move
+ // Switch is just an optimization for arraycopy in default case
+ switch(n) {
+ case 2: a[left + 2] = a[left + 1];
+ case 1: a[left + 1] = a[left];
+ break;
+ default: System.arraycopy(a, left, a, left + 1, n);
+ }
+ a[left] = pivot;
+ }
+ }
+
+ /**
+ * Returns the length of the run beginning at the specified position in
+ * the specified array and reverses the run if it is descending (ensuring
+ * that the run will always be ascending when the method returns).
+ *
+ * A run is the longest ascending sequence with:
+ *
+ * a[lo] <= a[lo + 1] <= a[lo + 2] <= ...
+ *
+ * or the longest descending sequence with:
+ *
+ * a[lo] > a[lo + 1] > a[lo + 2] > ...
+ *
+ * For its intended use in a stable mergesort, the strictness of the
+ * definition of "descending" is needed so that the call can safely
+ * reverse a descending sequence without violating stability.
+ *
+ * @param a the array in which a run is to be counted and possibly reversed
+ * @param lo index of the first element in the run
+ * @param hi index after the last element that may be contained in the run.
+ It is required that @code{lo < hi}.
+ * @return the length of the run beginning at the specified position in
+ * the specified array
+ */
+ @SuppressWarnings("unchecked")
+ private static int countRunAndMakeAscending(Object[] a, int lo, int hi) {
+ assert lo < hi;
+ int runHi = lo + 1;
+ if (runHi == hi)
+ return 1;
+
+ // Find end of run, and reverse range if descending
+ if (((Comparable) a[runHi++]).compareTo(a[lo]) < 0) { // Descending
+ while(runHi < hi && ((Comparable) a[runHi]).compareTo(a[runHi - 1]) < 0)
+ runHi++;
+ reverseRange(a, lo, runHi);
+ } else { // Ascending
+ while (runHi < hi && ((Comparable) a[runHi]).compareTo(a[runHi - 1]) >= 0)
+ runHi++;
+ }
+
+ return runHi - lo;
+ }
+
+ /**
+ * Reverse the specified range of the specified array.
+ *
+ * @param a the array in which a range is to be reversed
+ * @param lo the index of the first element in the range to be reversed
+ * @param hi the index after the last element in the range to be reversed
+ */
+ private static void reverseRange(Object[] a, int lo, int hi) {
+ hi--;
+ while (lo < hi) {
+ Object t = a[lo];
+ a[lo++] = a[hi];
+ a[hi--] = t;
+ }
+ }
+
+ /**
+ * Returns the minimum acceptable run length for an array of the specified
+ * length. Natural runs shorter than this will be extended with
+ * {@link #binarySort}.
+ *
+ * Roughly speaking, the computation is:
+ *
+ * If n < MIN_MERGE, return n (it's too small to bother with fancy stuff).
+ * Else if n is an exact power of 2, return MIN_MERGE/2.
+ * Else return an int k, MIN_MERGE/2 <= k <= MIN_MERGE, such that n/k
+ * is close to, but strictly less than, an exact power of 2.
+ *
+ * For the rationale, see listsort.txt.
+ *
+ * @param n the length of the array to be sorted
+ * @return the length of the minimum run to be merged
+ */
+ private static int minRunLength(int n) {
+ assert n >= 0;
+ int r = 0; // Becomes 1 if any 1 bits are shifted off
+ while (n >= MIN_MERGE) {
+ r |= (n & 1);
+ n >>= 1;
+ }
+ return n + r;
+ }
+
+ /**
+ * Pushes the specified run onto the pending-run stack.
+ *
+ * @param runBase index of the first element in the run
+ * @param runLen the number of elements in the run
+ */
+ private void pushRun(int runBase, int runLen) {
+ this.runBase[stackSize] = runBase;
+ this.runLen[stackSize] = runLen;
+ stackSize++;
+ }
+
+ /**
+ * Examines the stack of runs waiting to be merged and merges adjacent runs
+ * until the stack invariants are reestablished:
+ *
+ * 1. runLen[i - 3] > runLen[i - 2] + runLen[i - 1]
+ * 2. runLen[i - 2] > runLen[i - 1]
+ *
+ * This method is called each time a new run is pushed onto the stack,
+ * so the invariants are guaranteed to hold for i < stackSize upon
+ * entry to the method.
+ */
+ private void mergeCollapse() {
+ while (stackSize > 1) {
+ int n = stackSize - 2;
+ if (n > 0 && runLen[n-1] <= runLen[n] + runLen[n+1]) {
+ if (runLen[n - 1] < runLen[n + 1])
+ n--;
+ mergeAt(n);
+ } else if (runLen[n] <= runLen[n + 1]) {
+ mergeAt(n);
+ } else {
+ break; // Invariant is established
+ }
+ }
+ }
+
+ /**
+ * Merges all runs on the stack until only one remains. This method is
+ * called once, to complete the sort.
+ */
+ private void mergeForceCollapse() {
+ while (stackSize > 1) {
+ int n = stackSize - 2;
+ if (n > 0 && runLen[n - 1] < runLen[n + 1])
+ n--;
+ mergeAt(n);
+ }
+ }
+
+ /**
+ * Merges the two runs at stack indices i and i+1. Run i must be
+ * the penultimate or antepenultimate run on the stack. In other words,
+ * i must be equal to stackSize-2 or stackSize-3.
+ *
+ * @param i stack index of the first of the two runs to merge
+ */
+ @SuppressWarnings("unchecked")
+ private void mergeAt(int i) {
+ assert stackSize >= 2;
+ assert i >= 0;
+ assert i == stackSize - 2 || i == stackSize - 3;
+
+ int base1 = runBase[i];
+ int len1 = runLen[i];
+ int base2 = runBase[i + 1];
+ int len2 = runLen[i + 1];
+ assert len1 > 0 && len2 > 0;
+ assert base1 + len1 == base2;
+
+ /*
+ * Record the length of the combined runs; if i is the 3rd-last
+ * run now, also slide over the last run (which isn't involved
+ * in this merge). The current run (i+1) goes away in any case.
+ */
+ runLen[i] = len1 + len2;
+ if (i == stackSize - 3) {
+ runBase[i + 1] = runBase[i + 2];
+ runLen[i + 1] = runLen[i + 2];
+ }
+ stackSize--;
+
+ /*
+ * Find where the first element of run2 goes in run1. Prior elements
+ * in run1 can be ignored (because they're already in place).
+ */
+ int k = gallopRight((Comparable<Object>) a[base2], a, base1, len1, 0);
+ assert k >= 0;
+ base1 += k;
+ len1 -= k;
+ if (len1 == 0)
+ return;
+
+ /*
+ * Find where the last element of run1 goes in run2. Subsequent elements
+ * in run2 can be ignored (because they're already in place).
+ */
+ len2 = gallopLeft((Comparable<Object>) a[base1 + len1 - 1], a,
+ base2, len2, len2 - 1);
+ assert len2 >= 0;
+ if (len2 == 0)
+ return;
+
+ // Merge remaining runs, using tmp array with min(len1, len2) elements
+ if (len1 <= len2)
+ mergeLo(base1, len1, base2, len2);
+ else
+ mergeHi(base1, len1, base2, len2);
+ }
+
+ /**
+ * Locates the position at which to insert the specified key into the
+ * specified sorted range; if the range contains an element equal to key,
+ * returns the index of the leftmost equal element.
+ *
+ * @param key the key whose insertion point to search for
+ * @param a the array in which to search
+ * @param base the index of the first element in the range
+ * @param len the length of the range; must be > 0
+ * @param hint the index at which to begin the search, 0 <= hint < n.
+ * The closer hint is to the result, the faster this method will run.
+ * @return the int k, 0 <= k <= n such that a[b + k - 1] < key <= a[b + k],
+ * pretending that a[b - 1] is minus infinity and a[b + n] is infinity.
+ * In other words, key belongs at index b + k; or in other words,
+ * the first k elements of a should precede key, and the last n - k
+ * should follow it.
+ */
+ private static int gallopLeft(Comparable<Object> key, Object[] a,
+ int base, int len, int hint) {
+ assert len > 0 && hint >= 0 && hint < len;
+
+ int lastOfs = 0;
+ int ofs = 1;
+ if (key.compareTo(a[base + hint]) > 0) {
+ // Gallop right until a[base+hint+lastOfs] < key <= a[base+hint+ofs]
+ int maxOfs = len - hint;
+ while (ofs < maxOfs && key.compareTo(a[base + hint + ofs]) > 0) {
+ lastOfs = ofs;
+ ofs = (ofs << 1) + 1;
+ if (ofs <= 0) // int overflow
+ ofs = maxOfs;
+ }
+ if (ofs > maxOfs)
+ ofs = maxOfs;
+
+ // Make offsets relative to base
+ lastOfs += hint;
+ ofs += hint;
+ } else { // key <= a[base + hint]
+ // Gallop left until a[base+hint-ofs] < key <= a[base+hint-lastOfs]
+ final int maxOfs = hint + 1;
+ while (ofs < maxOfs && key.compareTo(a[base + hint - ofs]) <= 0) {
+ lastOfs = ofs;
+ ofs = (ofs << 1) + 1;
+ if (ofs <= 0) // int overflow
+ ofs = maxOfs;
+ }
+ if (ofs > maxOfs)
+ ofs = maxOfs;
+
+ // Make offsets relative to base
+ int tmp = lastOfs;
+ lastOfs = hint - ofs;
+ ofs = hint - tmp;
+ }
+ assert -1 <= lastOfs && lastOfs < ofs && ofs <= len;
+
+ /*
+ * Now a[base+lastOfs] < key <= a[base+ofs], so key belongs somewhere
+ * to the right of lastOfs but no farther right than ofs. Do a binary
+ * search, with invariant a[base + lastOfs - 1] < key <= a[base + ofs].
+ */
+ lastOfs++;
+ while (lastOfs < ofs) {
+ int m = lastOfs + ((ofs - lastOfs) >>> 1);
+
+ if (key.compareTo(a[base + m]) > 0)
+ lastOfs = m + 1; // a[base + m] < key
+ else
+ ofs = m; // key <= a[base + m]
+ }
+ assert lastOfs == ofs; // so a[base + ofs - 1] < key <= a[base + ofs]
+ return ofs;
+ }
+
+ /**
+ * Like gallopLeft, except that if the range contains an element equal to
+ * key, gallopRight returns the index after the rightmost equal element.
+ *
+ * @param key the key whose insertion point to search for
+ * @param a the array in which to search
+ * @param base the index of the first element in the range
+ * @param len the length of the range; must be > 0
+ * @param hint the index at which to begin the search, 0 <= hint < n.
+ * The closer hint is to the result, the faster this method will run.
+ * @return the int k, 0 <= k <= n such that a[b + k - 1] <= key < a[b + k]
+ */
+ private static int gallopRight(Comparable<Object> key, Object[] a,
+ int base, int len, int hint) {
+ assert len > 0 && hint >= 0 && hint < len;
+
+ int ofs = 1;
+ int lastOfs = 0;
+ if (key.compareTo(a[base + hint]) < 0) {
+ // Gallop left until a[b+hint - ofs] <= key < a[b+hint - lastOfs]
+ int maxOfs = hint + 1;
+ while (ofs < maxOfs && key.compareTo(a[base + hint - ofs]) < 0) {
+ lastOfs = ofs;
+ ofs = (ofs << 1) + 1;
+ if (ofs <= 0) // int overflow
+ ofs = maxOfs;
+ }
+ if (ofs > maxOfs)
+ ofs = maxOfs;
+
+ // Make offsets relative to b
+ int tmp = lastOfs;
+ lastOfs = hint - ofs;
+ ofs = hint - tmp;
+ } else { // a[b + hint] <= key
+ // Gallop right until a[b+hint + lastOfs] <= key < a[b+hint + ofs]
+ int maxOfs = len - hint;
+ while (ofs < maxOfs && key.compareTo(a[base + hint + ofs]) >= 0) {
+ lastOfs = ofs;
+ ofs = (ofs << 1) + 1;
+ if (ofs <= 0) // int overflow
+ ofs = maxOfs;
+ }
+ if (ofs > maxOfs)
+ ofs = maxOfs;
+
+ // Make offsets relative to b
+ lastOfs += hint;
+ ofs += hint;
+ }
+ assert -1 <= lastOfs && lastOfs < ofs && ofs <= len;
+
+ /*
+ * Now a[b + lastOfs] <= key < a[b + ofs], so key belongs somewhere to
+ * the right of lastOfs but no farther right than ofs. Do a binary
+ * search, with invariant a[b + lastOfs - 1] <= key < a[b + ofs].
+ */
+ lastOfs++;
+ while (lastOfs < ofs) {
+ int m = lastOfs + ((ofs - lastOfs) >>> 1);
+
+ if (key.compareTo(a[base + m]) < 0)
+ ofs = m; // key < a[b + m]
+ else
+ lastOfs = m + 1; // a[b + m] <= key
+ }
+ assert lastOfs == ofs; // so a[b + ofs - 1] <= key < a[b + ofs]
+ return ofs;
+ }
+
+ /**
+ * Merges two adjacent runs in place, in a stable fashion. The first
+ * element of the first run must be greater than the first element of the
+ * second run (a[base1] > a[base2]), and the last element of the first run
+ * (a[base1 + len1-1]) must be greater than all elements of the second run.
+ *
+ * For performance, this method should be called only when len1 <= len2;
+ * its twin, mergeHi should be called if len1 >= len2. (Either method
+ * may be called if len1 == len2.)
+ *
+ * @param base1 index of first element in first run to be merged
+ * @param len1 length of first run to be merged (must be > 0)
+ * @param base2 index of first element in second run to be merged
+ * (must be aBase + aLen)
+ * @param len2 length of second run to be merged (must be > 0)
+ */
+ @SuppressWarnings("unchecked")
+ private void mergeLo(int base1, int len1, int base2, int len2) {
+ assert len1 > 0 && len2 > 0 && base1 + len1 == base2;
+
+ // Copy first run into temp array
+ Object[] a = this.a; // For performance
+ Object[] tmp = ensureCapacity(len1);
+ System.arraycopy(a, base1, tmp, 0, len1);
+
+ int cursor1 = 0; // Indexes into tmp array
+ int cursor2 = base2; // Indexes int a
+ int dest = base1; // Indexes int a
+
+ // Move first element of second run and deal with degenerate cases
+ a[dest++] = a[cursor2++];
+ if (--len2 == 0) {
+ System.arraycopy(tmp, cursor1, a, dest, len1);
+ return;
+ }
+ if (len1 == 1) {
+ System.arraycopy(a, cursor2, a, dest, len2);
+ a[dest + len2] = tmp[cursor1]; // Last elt of run 1 to end of merge
+ return;
+ }
+
+ int minGallop = this.minGallop; // Use local variable for performance
+ outer:
+ while (true) {
+ int count1 = 0; // Number of times in a row that first run won
+ int count2 = 0; // Number of times in a row that second run won
+
+ /*
+ * Do the straightforward thing until (if ever) one run starts
+ * winning consistently.
+ */
+ do {
+ assert len1 > 1 && len2 > 0;
+ if (((Comparable) a[cursor2]).compareTo(tmp[cursor1]) < 0) {
+ a[dest++] = a[cursor2++];
+ count2++;
+ count1 = 0;
+ if (--len2 == 0)
+ break outer;
+ } else {
+ a[dest++] = tmp[cursor1++];
+ count1++;
+ count2 = 0;
+ if (--len1 == 1)
+ break outer;
+ }
+ } while ((count1 | count2) < minGallop);
+
+ /*
+ * One run is winning so consistently that galloping may be a
+ * huge win. So try that, and continue galloping until (if ever)
+ * neither run appears to be winning consistently anymore.
+ */
+ do {
+ assert len1 > 1 && len2 > 0;
+ count1 = gallopRight((Comparable) a[cursor2], tmp, cursor1, len1, 0);
+ if (count1 != 0) {
+ System.arraycopy(tmp, cursor1, a, dest, count1);
+ dest += count1;
+ cursor1 += count1;
+ len1 -= count1;
+ if (len1 <= 1) // len1 == 1 || len1 == 0
+ break outer;
+ }
+ a[dest++] = a[cursor2++];
+ if (--len2 == 0)
+ break outer;
+
+ count2 = gallopLeft((Comparable) tmp[cursor1], a, cursor2, len2, 0);
+ if (count2 != 0) {
+ System.arraycopy(a, cursor2, a, dest, count2);
+ dest += count2;
+ cursor2 += count2;
+ len2 -= count2;
+ if (len2 == 0)
+ break outer;
+ }
+ a[dest++] = tmp[cursor1++];
+ if (--len1 == 1)
+ break outer;
+ minGallop--;
+ } while (count1 >= MIN_GALLOP | count2 >= MIN_GALLOP);
+ if (minGallop < 0)
+ minGallop = 0;
+ minGallop += 2; // Penalize for leaving gallop mode
+ } // End of "outer" loop
+ this.minGallop = minGallop < 1 ? 1 : minGallop; // Write back to field
+
+ if (len1 == 1) {
+ assert len2 > 0;
+ System.arraycopy(a, cursor2, a, dest, len2);
+ a[dest + len2] = tmp[cursor1]; // Last elt of run 1 to end of merge
+ } else if (len1 == 0) {
+ throw new IllegalArgumentException(
+ "Comparison method violates its general contract!");
+ } else {
+ assert len2 == 0;
+ assert len1 > 1;
+ System.arraycopy(tmp, cursor1, a, dest, len1);
+ }
+ }
+
+ /**
+ * Like mergeLo, except that this method should be called only if
+ * len1 >= len2; mergeLo should be called if len1 <= len2. (Either method
+ * may be called if len1 == len2.)
+ *
+ * @param base1 index of first element in first run to be merged
+ * @param len1 length of first run to be merged (must be > 0)
+ * @param base2 index of first element in second run to be merged
+ * (must be aBase + aLen)
+ * @param len2 length of second run to be merged (must be > 0)
+ */
+ @SuppressWarnings("unchecked")
+ private void mergeHi(int base1, int len1, int base2, int len2) {
+ assert len1 > 0 && len2 > 0 && base1 + len1 == base2;
+
+ // Copy second run into temp array
+ Object[] a = this.a; // For performance
+ Object[] tmp = ensureCapacity(len2);
+ System.arraycopy(a, base2, tmp, 0, len2);
+
+ int cursor1 = base1 + len1 - 1; // Indexes into a
+ int cursor2 = len2 - 1; // Indexes into tmp array
+ int dest = base2 + len2 - 1; // Indexes into a
+
+ // Move last element of first run and deal with degenerate cases
+ a[dest--] = a[cursor1--];
+ if (--len1 == 0) {
+ System.arraycopy(tmp, 0, a, dest - (len2 - 1), len2);
+ return;
+ }
+ if (len2 == 1) {
+ dest -= len1;
+ cursor1 -= len1;
+ System.arraycopy(a, cursor1 + 1, a, dest + 1, len1);
+ a[dest] = tmp[cursor2];
+ return;
+ }
+
+ int minGallop = this.minGallop; // Use local variable for performance
+ outer:
+ while (true) {
+ int count1 = 0; // Number of times in a row that first run won
+ int count2 = 0; // Number of times in a row that second run won
+
+ /*
+ * Do the straightforward thing until (if ever) one run
+ * appears to win consistently.
+ */
+ do {
+ assert len1 > 0 && len2 > 1;
+ if (((Comparable) tmp[cursor2]).compareTo(a[cursor1]) < 0) {
+ a[dest--] = a[cursor1--];
+ count1++;
+ count2 = 0;
+ if (--len1 == 0)
+ break outer;
+ } else {
+ a[dest--] = tmp[cursor2--];
+ count2++;
+ count1 = 0;
+ if (--len2 == 1)
+ break outer;
+ }
+ } while ((count1 | count2) < minGallop);
+
+ /*
+ * One run is winning so consistently that galloping may be a
+ * huge win. So try that, and continue galloping until (if ever)
+ * neither run appears to be winning consistently anymore.
+ */
+ do {
+ assert len1 > 0 && len2 > 1;
+ count1 = len1 - gallopRight((Comparable) tmp[cursor2], a, base1, len1, len1 - 1);
+ if (count1 != 0) {
+ dest -= count1;
+ cursor1 -= count1;
+ len1 -= count1;
+ System.arraycopy(a, cursor1 + 1, a, dest + 1, count1);
+ if (len1 == 0)
+ break outer;
+ }
+ a[dest--] = tmp[cursor2--];
+ if (--len2 == 1)
+ break outer;
+
+ count2 = len2 - gallopLeft((Comparable) a[cursor1], tmp, 0, len2, len2 - 1);
+ if (count2 != 0) {
+ dest -= count2;
+ cursor2 -= count2;
+ len2 -= count2;
+ System.arraycopy(tmp, cursor2 + 1, a, dest + 1, count2);
+ if (len2 <= 1)
+ break outer; // len2 == 1 || len2 == 0
+ }
+ a[dest--] = a[cursor1--];
+ if (--len1 == 0)
+ break outer;
+ minGallop--;
+ } while (count1 >= MIN_GALLOP | count2 >= MIN_GALLOP);
+ if (minGallop < 0)
+ minGallop = 0;
+ minGallop += 2; // Penalize for leaving gallop mode
+ } // End of "outer" loop
+ this.minGallop = minGallop < 1 ? 1 : minGallop; // Write back to field
+
+ if (len2 == 1) {
+ assert len1 > 0;
+ dest -= len1;
+ cursor1 -= len1;
+ System.arraycopy(a, cursor1 + 1, a, dest + 1, len1);
+ a[dest] = tmp[cursor2]; // Move first elt of run2 to front of merge
+ } else if (len2 == 0) {
+ throw new IllegalArgumentException(
+ "Comparison method violates its general contract!");
+ } else {
+ assert len1 == 0;
+ assert len2 > 0;
+ System.arraycopy(tmp, 0, a, dest - (len2 - 1), len2);
+ }
+ }
+
+ /**
+ * Ensures that the external array tmp has at least the specified
+ * number of elements, increasing its size if necessary. The size
+ * increases exponentially to ensure amortized linear time complexity.
+ *
+ * @param minCapacity the minimum required capacity of the tmp array
+ * @return tmp, whether or not it grew
+ */
+ private Object[] ensureCapacity(int minCapacity) {
+ if (tmp.length < minCapacity) {
+ // Compute smallest power of 2 > minCapacity
+ int newSize = minCapacity;
+ newSize |= newSize >> 1;
+ newSize |= newSize >> 2;
+ newSize |= newSize >> 4;
+ newSize |= newSize >> 8;
+ newSize |= newSize >> 16;
+ newSize++;
+
+ if (newSize < 0) // Not bloody likely!
+ newSize = minCapacity;
+ else
+ newSize = Math.min(newSize, a.length >>> 1);
+
+ @SuppressWarnings({"unchecked", "UnnecessaryLocalVariable"})
+ Object[] newArray = new Object[newSize];
+ tmp = newArray;
+ }
+ return tmp;
+ }
+
+ /**
+ * Checks that fromIndex and toIndex are in range, and throws an
+ * appropriate exception if they aren't.
+ *
+ * @param arrayLen the length of the array
+ * @param fromIndex the index of the first element of the range
+ * @param toIndex the index after the last element of the range
+ * @throws IllegalArgumentException if fromIndex > toIndex
+ * @throws ArrayIndexOutOfBoundsException if fromIndex < 0
+ * or toIndex > arrayLen
+ */
+ private static void rangeCheck(int arrayLen, int fromIndex, int toIndex) {
+ if (fromIndex > toIndex)
+ throw new IllegalArgumentException("fromIndex(" + fromIndex +
+ ") > toIndex(" + toIndex+")");
+ if (fromIndex < 0)
+ throw new ArrayIndexOutOfBoundsException(fromIndex);
+ if (toIndex > arrayLen)
+ throw new ArrayIndexOutOfBoundsException(toIndex);
+ }
+}
--- a/jdk/src/share/classes/java/util/Formatter.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/java/util/Formatter.java Tue Aug 04 08:01:03 2009 -0700
@@ -2818,15 +2818,18 @@
}
private void printString(Object arg, Locale l) throws IOException {
- if (arg == null) {
- print("null");
- } else if (arg instanceof Formattable) {
+ if (arg instanceof Formattable) {
Formatter fmt = formatter;
if (formatter.locale() != l)
fmt = new Formatter(formatter.out(), l);
((Formattable)arg).formatTo(fmt, f.valueOf(), width, precision);
} else {
- print(arg.toString());
+ if (f.contains(Flags.ALTERNATE))
+ failMismatch(Flags.ALTERNATE, 's');
+ if (arg == null)
+ print("null");
+ else
+ print(arg.toString());
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/util/TimSort.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,928 @@
+/*
+ * Copyright 2009 Google Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package java.util;
+
+/**
+ * A stable, adaptive, iterative mergesort that requires far fewer than
+ * n lg(n) comparisons when running on partially sorted arrays, while
+ * offering performance comparable to a traditional mergesort when run
+ * on random arrays. Like all proper mergesorts, this sort is stable and
+ * runs O(n log n) time (worst case). In the worst case, this sort requires
+ * temporary storage space for n/2 object references; in the best case,
+ * it requires only a small constant amount of space.
+ *
+ * This implementation was adapted from Tim Peters's list sort for
+ * Python, which is described in detail here:
+ *
+ * http://svn.python.org/projects/python/trunk/Objects/listsort.txt
+ *
+ * Tim's C code may be found here:
+ *
+ * http://svn.python.org/projects/python/trunk/Objects/listobject.c
+ *
+ * The underlying techniques are described in this paper (and may have
+ * even earlier origins):
+ *
+ * "Optimistic Sorting and Information Theoretic Complexity"
+ * Peter McIlroy
+ * SODA (Fourth Annual ACM-SIAM Symposium on Discrete Algorithms),
+ * pp 467-474, Austin, Texas, 25-27 January 1993.
+ *
+ * While the API to this class consists solely of static methods, it is
+ * (privately) instantiable; a TimSort instance holds the state of an ongoing
+ * sort, assuming the input array is large enough to warrant the full-blown
+ * TimSort. Small arrays are sorted in place, using a binary insertion sort.
+ *
+ * @author Josh Bloch
+ */
+class TimSort<T> {
+ /**
+ * This is the minimum sized sequence that will be merged. Shorter
+ * sequences will be lengthened by calling binarySort. If the entire
+ * array is less than this length, no merges will be performed.
+ *
+ * This constant should be a power of two. It was 64 in Tim Peter's C
+ * implementation, but 32 was empirically determined to work better in
+ * this implementation. In the unlikely event that you set this constant
+ * to be a number that's not a power of two, you'll need to change the
+ * {@link #minRunLength} computation.
+ *
+ * If you decrease this constant, you must change the stackLen
+ * computation in the TimSort constructor, or you risk an
+ * ArrayOutOfBounds exception. See listsort.txt for a discussion
+ * of the minimum stack length required as a function of the length
+ * of the array being sorted and the minimum merge sequence length.
+ */
+ private static final int MIN_MERGE = 32;
+
+ /**
+ * The array being sorted.
+ */
+ private final T[] a;
+
+ /**
+ * The comparator for this sort.
+ */
+ private final Comparator<? super T> c;
+
+ /**
+ * When we get into galloping mode, we stay there until both runs win less
+ * often than MIN_GALLOP consecutive times.
+ */
+ private static final int MIN_GALLOP = 7;
+
+ /**
+ * This controls when we get *into* galloping mode. It is initialized
+ * to MIN_GALLOP. The mergeLo and mergeHi methods nudge it higher for
+ * random data, and lower for highly structured data.
+ */
+ private int minGallop = MIN_GALLOP;
+
+ /**
+ * Maximum initial size of tmp array, which is used for merging. The array
+ * can grow to accommodate demand.
+ *
+ * Unlike Tim's original C version, we do not allocate this much storage
+ * when sorting smaller arrays. This change was required for performance.
+ */
+ private static final int INITIAL_TMP_STORAGE_LENGTH = 256;
+
+ /**
+ * Temp storage for merges.
+ */
+ private T[] tmp; // Actual runtime type will be Object[], regardless of T
+
+ /**
+ * A stack of pending runs yet to be merged. Run i starts at
+ * address base[i] and extends for len[i] elements. It's always
+ * true (so long as the indices are in bounds) that:
+ *
+ * runBase[i] + runLen[i] == runBase[i + 1]
+ *
+ * so we could cut the storage for this, but it's a minor amount,
+ * and keeping all the info explicit simplifies the code.
+ */
+ private int stackSize = 0; // Number of pending runs on stack
+ private final int[] runBase;
+ private final int[] runLen;
+
+ /**
+ * Creates a TimSort instance to maintain the state of an ongoing sort.
+ *
+ * @param a the array to be sorted
+ * @param c the comparator to determine the order of the sort
+ */
+ private TimSort(T[] a, Comparator<? super T> c) {
+ this.a = a;
+ this.c = c;
+
+ // Allocate temp storage (which may be increased later if necessary)
+ int len = a.length;
+ @SuppressWarnings({"unchecked", "UnnecessaryLocalVariable"})
+ T[] newArray = (T[]) new Object[len < 2 * INITIAL_TMP_STORAGE_LENGTH ?
+ len >>> 1 : INITIAL_TMP_STORAGE_LENGTH];
+ tmp = newArray;
+
+ /*
+ * Allocate runs-to-be-merged stack (which cannot be expanded). The
+ * stack length requirements are described in listsort.txt. The C
+ * version always uses the same stack length (85), but this was
+ * measured to be too expensive when sorting "mid-sized" arrays (e.g.,
+ * 100 elements) in Java. Therefore, we use smaller (but sufficiently
+ * large) stack lengths for smaller arrays. The "magic numbers" in the
+ * computation below must be changed if MIN_MERGE is decreased. See
+ * the MIN_MERGE declaration above for more information.
+ */
+ int stackLen = (len < 120 ? 5 :
+ len < 1542 ? 10 :
+ len < 119151 ? 19 : 40);
+ runBase = new int[stackLen];
+ runLen = new int[stackLen];
+ }
+
+ /*
+ * The next two methods (which are package private and static) constitute
+ * the entire API of this class. Each of these methods obeys the contract
+ * of the public method with the same signature in java.util.Arrays.
+ */
+
+ static <T> void sort(T[] a, Comparator<? super T> c) {
+ sort(a, 0, a.length, c);
+ }
+
+ static <T> void sort(T[] a, int lo, int hi, Comparator<? super T> c) {
+ if (c == null) {
+ Arrays.sort(a, lo, hi);
+ return;
+ }
+
+ rangeCheck(a.length, lo, hi);
+ int nRemaining = hi - lo;
+ if (nRemaining < 2)
+ return; // Arrays of size 0 and 1 are always sorted
+
+ // If array is small, do a "mini-TimSort" with no merges
+ if (nRemaining < MIN_MERGE) {
+ int initRunLen = countRunAndMakeAscending(a, lo, hi, c);
+ binarySort(a, lo, hi, lo + initRunLen, c);
+ return;
+ }
+
+ /**
+ * March over the array once, left to right, finding natural runs,
+ * extending short natural runs to minRun elements, and merging runs
+ * to maintain stack invariant.
+ */
+ TimSort<T> ts = new TimSort<T>(a, c);
+ int minRun = minRunLength(nRemaining);
+ do {
+ // Identify next run
+ int runLen = countRunAndMakeAscending(a, lo, hi, c);
+
+ // If run is short, extend to min(minRun, nRemaining)
+ if (runLen < minRun) {
+ int force = nRemaining <= minRun ? nRemaining : minRun;
+ binarySort(a, lo, lo + force, lo + runLen, c);
+ runLen = force;
+ }
+
+ // Push run onto pending-run stack, and maybe merge
+ ts.pushRun(lo, runLen);
+ ts.mergeCollapse();
+
+ // Advance to find next run
+ lo += runLen;
+ nRemaining -= runLen;
+ } while (nRemaining != 0);
+
+ // Merge all remaining runs to complete sort
+ assert lo == hi;
+ ts.mergeForceCollapse();
+ assert ts.stackSize == 1;
+ }
+
+ /**
+ * Sorts the specified portion of the specified array using a binary
+ * insertion sort. This is the best method for sorting small numbers
+ * of elements. It requires O(n log n) compares, but O(n^2) data
+ * movement (worst case).
+ *
+ * If the initial part of the specified range is already sorted,
+ * this method can take advantage of it: the method assumes that the
+ * elements from index {@code lo}, inclusive, to {@code start},
+ * exclusive are already sorted.
+ *
+ * @param a the array in which a range is to be sorted
+ * @param lo the index of the first element in the range to be sorted
+ * @param hi the index after the last element in the range to be sorted
+ * @param start the index of the first element in the range that is
+ * not already known to be sorted (@code lo <= start <= hi}
+ * @param c comparator to used for the sort
+ */
+ @SuppressWarnings("fallthrough")
+ private static <T> void binarySort(T[] a, int lo, int hi, int start,
+ Comparator<? super T> c) {
+ assert lo <= start && start <= hi;
+ if (start == lo)
+ start++;
+ for ( ; start < hi; start++) {
+ T pivot = a[start];
+
+ // Set left (and right) to the index where a[start] (pivot) belongs
+ int left = lo;
+ int right = start;
+ assert left <= right;
+ /*
+ * Invariants:
+ * pivot >= all in [lo, left).
+ * pivot < all in [right, start).
+ */
+ while (left < right) {
+ int mid = (left + right) >>> 1;
+ if (c.compare(pivot, a[mid]) < 0)
+ right = mid;
+ else
+ left = mid + 1;
+ }
+ assert left == right;
+
+ /*
+ * The invariants still hold: pivot >= all in [lo, left) and
+ * pivot < all in [left, start), so pivot belongs at left. Note
+ * that if there are elements equal to pivot, left points to the
+ * first slot after them -- that's why this sort is stable.
+ * Slide elements over to make room to make room for pivot.
+ */
+ int n = start - left; // The number of elements to move
+ // Switch is just an optimization for arraycopy in default case
+ switch(n) {
+ case 2: a[left + 2] = a[left + 1];
+ case 1: a[left + 1] = a[left];
+ break;
+ default: System.arraycopy(a, left, a, left + 1, n);
+ }
+ a[left] = pivot;
+ }
+ }
+
+ /**
+ * Returns the length of the run beginning at the specified position in
+ * the specified array and reverses the run if it is descending (ensuring
+ * that the run will always be ascending when the method returns).
+ *
+ * A run is the longest ascending sequence with:
+ *
+ * a[lo] <= a[lo + 1] <= a[lo + 2] <= ...
+ *
+ * or the longest descending sequence with:
+ *
+ * a[lo] > a[lo + 1] > a[lo + 2] > ...
+ *
+ * For its intended use in a stable mergesort, the strictness of the
+ * definition of "descending" is needed so that the call can safely
+ * reverse a descending sequence without violating stability.
+ *
+ * @param a the array in which a run is to be counted and possibly reversed
+ * @param lo index of the first element in the run
+ * @param hi index after the last element that may be contained in the run.
+ It is required that @code{lo < hi}.
+ * @param c the comparator to used for the sort
+ * @return the length of the run beginning at the specified position in
+ * the specified array
+ */
+ private static <T> int countRunAndMakeAscending(T[] a, int lo, int hi,
+ Comparator<? super T> c) {
+ assert lo < hi;
+ int runHi = lo + 1;
+ if (runHi == hi)
+ return 1;
+
+ // Find end of run, and reverse range if descending
+ if (c.compare(a[runHi++], a[lo]) < 0) { // Descending
+ while(runHi < hi && c.compare(a[runHi], a[runHi - 1]) < 0)
+ runHi++;
+ reverseRange(a, lo, runHi);
+ } else { // Ascending
+ while (runHi < hi && c.compare(a[runHi], a[runHi - 1]) >= 0)
+ runHi++;
+ }
+
+ return runHi - lo;
+ }
+
+ /**
+ * Reverse the specified range of the specified array.
+ *
+ * @param a the array in which a range is to be reversed
+ * @param lo the index of the first element in the range to be reversed
+ * @param hi the index after the last element in the range to be reversed
+ */
+ private static void reverseRange(Object[] a, int lo, int hi) {
+ hi--;
+ while (lo < hi) {
+ Object t = a[lo];
+ a[lo++] = a[hi];
+ a[hi--] = t;
+ }
+ }
+
+ /**
+ * Returns the minimum acceptable run length for an array of the specified
+ * length. Natural runs shorter than this will be extended with
+ * {@link #binarySort}.
+ *
+ * Roughly speaking, the computation is:
+ *
+ * If n < MIN_MERGE, return n (it's too small to bother with fancy stuff).
+ * Else if n is an exact power of 2, return MIN_MERGE/2.
+ * Else return an int k, MIN_MERGE/2 <= k <= MIN_MERGE, such that n/k
+ * is close to, but strictly less than, an exact power of 2.
+ *
+ * For the rationale, see listsort.txt.
+ *
+ * @param n the length of the array to be sorted
+ * @return the length of the minimum run to be merged
+ */
+ private static int minRunLength(int n) {
+ assert n >= 0;
+ int r = 0; // Becomes 1 if any 1 bits are shifted off
+ while (n >= MIN_MERGE) {
+ r |= (n & 1);
+ n >>= 1;
+ }
+ return n + r;
+ }
+
+ /**
+ * Pushes the specified run onto the pending-run stack.
+ *
+ * @param runBase index of the first element in the run
+ * @param runLen the number of elements in the run
+ */
+ private void pushRun(int runBase, int runLen) {
+ this.runBase[stackSize] = runBase;
+ this.runLen[stackSize] = runLen;
+ stackSize++;
+ }
+
+ /**
+ * Examines the stack of runs waiting to be merged and merges adjacent runs
+ * until the stack invariants are reestablished:
+ *
+ * 1. runLen[i - 3] > runLen[i - 2] + runLen[i - 1]
+ * 2. runLen[i - 2] > runLen[i - 1]
+ *
+ * This method is called each time a new run is pushed onto the stack,
+ * so the invariants are guaranteed to hold for i < stackSize upon
+ * entry to the method.
+ */
+ private void mergeCollapse() {
+ while (stackSize > 1) {
+ int n = stackSize - 2;
+ if (n > 0 && runLen[n-1] <= runLen[n] + runLen[n+1]) {
+ if (runLen[n - 1] < runLen[n + 1])
+ n--;
+ mergeAt(n);
+ } else if (runLen[n] <= runLen[n + 1]) {
+ mergeAt(n);
+ } else {
+ break; // Invariant is established
+ }
+ }
+ }
+
+ /**
+ * Merges all runs on the stack until only one remains. This method is
+ * called once, to complete the sort.
+ */
+ private void mergeForceCollapse() {
+ while (stackSize > 1) {
+ int n = stackSize - 2;
+ if (n > 0 && runLen[n - 1] < runLen[n + 1])
+ n--;
+ mergeAt(n);
+ }
+ }
+
+ /**
+ * Merges the two runs at stack indices i and i+1. Run i must be
+ * the penultimate or antepenultimate run on the stack. In other words,
+ * i must be equal to stackSize-2 or stackSize-3.
+ *
+ * @param i stack index of the first of the two runs to merge
+ */
+ private void mergeAt(int i) {
+ assert stackSize >= 2;
+ assert i >= 0;
+ assert i == stackSize - 2 || i == stackSize - 3;
+
+ int base1 = runBase[i];
+ int len1 = runLen[i];
+ int base2 = runBase[i + 1];
+ int len2 = runLen[i + 1];
+ assert len1 > 0 && len2 > 0;
+ assert base1 + len1 == base2;
+
+ /*
+ * Record the length of the combined runs; if i is the 3rd-last
+ * run now, also slide over the last run (which isn't involved
+ * in this merge). The current run (i+1) goes away in any case.
+ */
+ runLen[i] = len1 + len2;
+ if (i == stackSize - 3) {
+ runBase[i + 1] = runBase[i + 2];
+ runLen[i + 1] = runLen[i + 2];
+ }
+ stackSize--;
+
+ /*
+ * Find where the first element of run2 goes in run1. Prior elements
+ * in run1 can be ignored (because they're already in place).
+ */
+ int k = gallopRight(a[base2], a, base1, len1, 0, c);
+ assert k >= 0;
+ base1 += k;
+ len1 -= k;
+ if (len1 == 0)
+ return;
+
+ /*
+ * Find where the last element of run1 goes in run2. Subsequent elements
+ * in run2 can be ignored (because they're already in place).
+ */
+ len2 = gallopLeft(a[base1 + len1 - 1], a, base2, len2, len2 - 1, c);
+ assert len2 >= 0;
+ if (len2 == 0)
+ return;
+
+ // Merge remaining runs, using tmp array with min(len1, len2) elements
+ if (len1 <= len2)
+ mergeLo(base1, len1, base2, len2);
+ else
+ mergeHi(base1, len1, base2, len2);
+ }
+
+ /**
+ * Locates the position at which to insert the specified key into the
+ * specified sorted range; if the range contains an element equal to key,
+ * returns the index of the leftmost equal element.
+ *
+ * @param key the key whose insertion point to search for
+ * @param a the array in which to search
+ * @param base the index of the first element in the range
+ * @param len the length of the range; must be > 0
+ * @param hint the index at which to begin the search, 0 <= hint < n.
+ * The closer hint is to the result, the faster this method will run.
+ * @param c the comparator used to order the range, and to search
+ * @return the int k, 0 <= k <= n such that a[b + k - 1] < key <= a[b + k],
+ * pretending that a[b - 1] is minus infinity and a[b + n] is infinity.
+ * In other words, key belongs at index b + k; or in other words,
+ * the first k elements of a should precede key, and the last n - k
+ * should follow it.
+ */
+ private static <T> int gallopLeft(T key, T[] a, int base, int len, int hint,
+ Comparator<? super T> c) {
+ assert len > 0 && hint >= 0 && hint < len;
+ int lastOfs = 0;
+ int ofs = 1;
+ if (c.compare(key, a[base + hint]) > 0) {
+ // Gallop right until a[base+hint+lastOfs] < key <= a[base+hint+ofs]
+ int maxOfs = len - hint;
+ while (ofs < maxOfs && c.compare(key, a[base + hint + ofs]) > 0) {
+ lastOfs = ofs;
+ ofs = (ofs << 1) + 1;
+ if (ofs <= 0) // int overflow
+ ofs = maxOfs;
+ }
+ if (ofs > maxOfs)
+ ofs = maxOfs;
+
+ // Make offsets relative to base
+ lastOfs += hint;
+ ofs += hint;
+ } else { // key <= a[base + hint]
+ // Gallop left until a[base+hint-ofs] < key <= a[base+hint-lastOfs]
+ final int maxOfs = hint + 1;
+ while (ofs < maxOfs && c.compare(key, a[base + hint - ofs]) <= 0) {
+ lastOfs = ofs;
+ ofs = (ofs << 1) + 1;
+ if (ofs <= 0) // int overflow
+ ofs = maxOfs;
+ }
+ if (ofs > maxOfs)
+ ofs = maxOfs;
+
+ // Make offsets relative to base
+ int tmp = lastOfs;
+ lastOfs = hint - ofs;
+ ofs = hint - tmp;
+ }
+ assert -1 <= lastOfs && lastOfs < ofs && ofs <= len;
+
+ /*
+ * Now a[base+lastOfs] < key <= a[base+ofs], so key belongs somewhere
+ * to the right of lastOfs but no farther right than ofs. Do a binary
+ * search, with invariant a[base + lastOfs - 1] < key <= a[base + ofs].
+ */
+ lastOfs++;
+ while (lastOfs < ofs) {
+ int m = lastOfs + ((ofs - lastOfs) >>> 1);
+
+ if (c.compare(key, a[base + m]) > 0)
+ lastOfs = m + 1; // a[base + m] < key
+ else
+ ofs = m; // key <= a[base + m]
+ }
+ assert lastOfs == ofs; // so a[base + ofs - 1] < key <= a[base + ofs]
+ return ofs;
+ }
+
+ /**
+ * Like gallopLeft, except that if the range contains an element equal to
+ * key, gallopRight returns the index after the rightmost equal element.
+ *
+ * @param key the key whose insertion point to search for
+ * @param a the array in which to search
+ * @param base the index of the first element in the range
+ * @param len the length of the range; must be > 0
+ * @param hint the index at which to begin the search, 0 <= hint < n.
+ * The closer hint is to the result, the faster this method will run.
+ * @param c the comparator used to order the range, and to search
+ * @return the int k, 0 <= k <= n such that a[b + k - 1] <= key < a[b + k]
+ */
+ private static <T> int gallopRight(T key, T[] a, int base, int len,
+ int hint, Comparator<? super T> c) {
+ assert len > 0 && hint >= 0 && hint < len;
+
+ int ofs = 1;
+ int lastOfs = 0;
+ if (c.compare(key, a[base + hint]) < 0) {
+ // Gallop left until a[b+hint - ofs] <= key < a[b+hint - lastOfs]
+ int maxOfs = hint + 1;
+ while (ofs < maxOfs && c.compare(key, a[base + hint - ofs]) < 0) {
+ lastOfs = ofs;
+ ofs = (ofs << 1) + 1;
+ if (ofs <= 0) // int overflow
+ ofs = maxOfs;
+ }
+ if (ofs > maxOfs)
+ ofs = maxOfs;
+
+ // Make offsets relative to b
+ int tmp = lastOfs;
+ lastOfs = hint - ofs;
+ ofs = hint - tmp;
+ } else { // a[b + hint] <= key
+ // Gallop right until a[b+hint + lastOfs] <= key < a[b+hint + ofs]
+ int maxOfs = len - hint;
+ while (ofs < maxOfs && c.compare(key, a[base + hint + ofs]) >= 0) {
+ lastOfs = ofs;
+ ofs = (ofs << 1) + 1;
+ if (ofs <= 0) // int overflow
+ ofs = maxOfs;
+ }
+ if (ofs > maxOfs)
+ ofs = maxOfs;
+
+ // Make offsets relative to b
+ lastOfs += hint;
+ ofs += hint;
+ }
+ assert -1 <= lastOfs && lastOfs < ofs && ofs <= len;
+
+ /*
+ * Now a[b + lastOfs] <= key < a[b + ofs], so key belongs somewhere to
+ * the right of lastOfs but no farther right than ofs. Do a binary
+ * search, with invariant a[b + lastOfs - 1] <= key < a[b + ofs].
+ */
+ lastOfs++;
+ while (lastOfs < ofs) {
+ int m = lastOfs + ((ofs - lastOfs) >>> 1);
+
+ if (c.compare(key, a[base + m]) < 0)
+ ofs = m; // key < a[b + m]
+ else
+ lastOfs = m + 1; // a[b + m] <= key
+ }
+ assert lastOfs == ofs; // so a[b + ofs - 1] <= key < a[b + ofs]
+ return ofs;
+ }
+
+ /**
+ * Merges two adjacent runs in place, in a stable fashion. The first
+ * element of the first run must be greater than the first element of the
+ * second run (a[base1] > a[base2]), and the last element of the first run
+ * (a[base1 + len1-1]) must be greater than all elements of the second run.
+ *
+ * For performance, this method should be called only when len1 <= len2;
+ * its twin, mergeHi should be called if len1 >= len2. (Either method
+ * may be called if len1 == len2.)
+ *
+ * @param base1 index of first element in first run to be merged
+ * @param len1 length of first run to be merged (must be > 0)
+ * @param base2 index of first element in second run to be merged
+ * (must be aBase + aLen)
+ * @param len2 length of second run to be merged (must be > 0)
+ */
+ private void mergeLo(int base1, int len1, int base2, int len2) {
+ assert len1 > 0 && len2 > 0 && base1 + len1 == base2;
+
+ // Copy first run into temp array
+ T[] a = this.a; // For performance
+ T[] tmp = ensureCapacity(len1);
+ System.arraycopy(a, base1, tmp, 0, len1);
+
+ int cursor1 = 0; // Indexes into tmp array
+ int cursor2 = base2; // Indexes int a
+ int dest = base1; // Indexes int a
+
+ // Move first element of second run and deal with degenerate cases
+ a[dest++] = a[cursor2++];
+ if (--len2 == 0) {
+ System.arraycopy(tmp, cursor1, a, dest, len1);
+ return;
+ }
+ if (len1 == 1) {
+ System.arraycopy(a, cursor2, a, dest, len2);
+ a[dest + len2] = tmp[cursor1]; // Last elt of run 1 to end of merge
+ return;
+ }
+
+ Comparator<? super T> c = this.c; // Use local variable for performance
+ int minGallop = this.minGallop; // " " " " "
+ outer:
+ while (true) {
+ int count1 = 0; // Number of times in a row that first run won
+ int count2 = 0; // Number of times in a row that second run won
+
+ /*
+ * Do the straightforward thing until (if ever) one run starts
+ * winning consistently.
+ */
+ do {
+ assert len1 > 1 && len2 > 0;
+ if (c.compare(a[cursor2], tmp[cursor1]) < 0) {
+ a[dest++] = a[cursor2++];
+ count2++;
+ count1 = 0;
+ if (--len2 == 0)
+ break outer;
+ } else {
+ a[dest++] = tmp[cursor1++];
+ count1++;
+ count2 = 0;
+ if (--len1 == 1)
+ break outer;
+ }
+ } while ((count1 | count2) < minGallop);
+
+ /*
+ * One run is winning so consistently that galloping may be a
+ * huge win. So try that, and continue galloping until (if ever)
+ * neither run appears to be winning consistently anymore.
+ */
+ do {
+ assert len1 > 1 && len2 > 0;
+ count1 = gallopRight(a[cursor2], tmp, cursor1, len1, 0, c);
+ if (count1 != 0) {
+ System.arraycopy(tmp, cursor1, a, dest, count1);
+ dest += count1;
+ cursor1 += count1;
+ len1 -= count1;
+ if (len1 <= 1) // len1 == 1 || len1 == 0
+ break outer;
+ }
+ a[dest++] = a[cursor2++];
+ if (--len2 == 0)
+ break outer;
+
+ count2 = gallopLeft(tmp[cursor1], a, cursor2, len2, 0, c);
+ if (count2 != 0) {
+ System.arraycopy(a, cursor2, a, dest, count2);
+ dest += count2;
+ cursor2 += count2;
+ len2 -= count2;
+ if (len2 == 0)
+ break outer;
+ }
+ a[dest++] = tmp[cursor1++];
+ if (--len1 == 1)
+ break outer;
+ minGallop--;
+ } while (count1 >= MIN_GALLOP | count2 >= MIN_GALLOP);
+ if (minGallop < 0)
+ minGallop = 0;
+ minGallop += 2; // Penalize for leaving gallop mode
+ } // End of "outer" loop
+ this.minGallop = minGallop < 1 ? 1 : minGallop; // Write back to field
+
+ if (len1 == 1) {
+ assert len2 > 0;
+ System.arraycopy(a, cursor2, a, dest, len2);
+ a[dest + len2] = tmp[cursor1]; // Last elt of run 1 to end of merge
+ } else if (len1 == 0) {
+ throw new IllegalArgumentException(
+ "Comparison method violates its general contract!");
+ } else {
+ assert len2 == 0;
+ assert len1 > 1;
+ System.arraycopy(tmp, cursor1, a, dest, len1);
+ }
+ }
+
+ /**
+ * Like mergeLo, except that this method should be called only if
+ * len1 >= len2; mergeLo should be called if len1 <= len2. (Either method
+ * may be called if len1 == len2.)
+ *
+ * @param base1 index of first element in first run to be merged
+ * @param len1 length of first run to be merged (must be > 0)
+ * @param base2 index of first element in second run to be merged
+ * (must be aBase + aLen)
+ * @param len2 length of second run to be merged (must be > 0)
+ */
+ private void mergeHi(int base1, int len1, int base2, int len2) {
+ assert len1 > 0 && len2 > 0 && base1 + len1 == base2;
+
+ // Copy second run into temp array
+ T[] a = this.a; // For performance
+ T[] tmp = ensureCapacity(len2);
+ System.arraycopy(a, base2, tmp, 0, len2);
+
+ int cursor1 = base1 + len1 - 1; // Indexes into a
+ int cursor2 = len2 - 1; // Indexes into tmp array
+ int dest = base2 + len2 - 1; // Indexes into a
+
+ // Move last element of first run and deal with degenerate cases
+ a[dest--] = a[cursor1--];
+ if (--len1 == 0) {
+ System.arraycopy(tmp, 0, a, dest - (len2 - 1), len2);
+ return;
+ }
+ if (len2 == 1) {
+ dest -= len1;
+ cursor1 -= len1;
+ System.arraycopy(a, cursor1 + 1, a, dest + 1, len1);
+ a[dest] = tmp[cursor2];
+ return;
+ }
+
+ Comparator<? super T> c = this.c; // Use local variable for performance
+ int minGallop = this.minGallop; // " " " " "
+ outer:
+ while (true) {
+ int count1 = 0; // Number of times in a row that first run won
+ int count2 = 0; // Number of times in a row that second run won
+
+ /*
+ * Do the straightforward thing until (if ever) one run
+ * appears to win consistently.
+ */
+ do {
+ assert len1 > 0 && len2 > 1;
+ if (c.compare(tmp[cursor2], a[cursor1]) < 0) {
+ a[dest--] = a[cursor1--];
+ count1++;
+ count2 = 0;
+ if (--len1 == 0)
+ break outer;
+ } else {
+ a[dest--] = tmp[cursor2--];
+ count2++;
+ count1 = 0;
+ if (--len2 == 1)
+ break outer;
+ }
+ } while ((count1 | count2) < minGallop);
+
+ /*
+ * One run is winning so consistently that galloping may be a
+ * huge win. So try that, and continue galloping until (if ever)
+ * neither run appears to be winning consistently anymore.
+ */
+ do {
+ assert len1 > 0 && len2 > 1;
+ count1 = len1 - gallopRight(tmp[cursor2], a, base1, len1, len1 - 1, c);
+ if (count1 != 0) {
+ dest -= count1;
+ cursor1 -= count1;
+ len1 -= count1;
+ System.arraycopy(a, cursor1 + 1, a, dest + 1, count1);
+ if (len1 == 0)
+ break outer;
+ }
+ a[dest--] = tmp[cursor2--];
+ if (--len2 == 1)
+ break outer;
+
+ count2 = len2 - gallopLeft(a[cursor1], tmp, 0, len2, len2 - 1, c);
+ if (count2 != 0) {
+ dest -= count2;
+ cursor2 -= count2;
+ len2 -= count2;
+ System.arraycopy(tmp, cursor2 + 1, a, dest + 1, count2);
+ if (len2 <= 1) // len2 == 1 || len2 == 0
+ break outer;
+ }
+ a[dest--] = a[cursor1--];
+ if (--len1 == 0)
+ break outer;
+ minGallop--;
+ } while (count1 >= MIN_GALLOP | count2 >= MIN_GALLOP);
+ if (minGallop < 0)
+ minGallop = 0;
+ minGallop += 2; // Penalize for leaving gallop mode
+ } // End of "outer" loop
+ this.minGallop = minGallop < 1 ? 1 : minGallop; // Write back to field
+
+ if (len2 == 1) {
+ assert len1 > 0;
+ dest -= len1;
+ cursor1 -= len1;
+ System.arraycopy(a, cursor1 + 1, a, dest + 1, len1);
+ a[dest] = tmp[cursor2]; // Move first elt of run2 to front of merge
+ } else if (len2 == 0) {
+ throw new IllegalArgumentException(
+ "Comparison method violates its general contract!");
+ } else {
+ assert len1 == 0;
+ assert len2 > 0;
+ System.arraycopy(tmp, 0, a, dest - (len2 - 1), len2);
+ }
+ }
+
+ /**
+ * Ensures that the external array tmp has at least the specified
+ * number of elements, increasing its size if necessary. The size
+ * increases exponentially to ensure amortized linear time complexity.
+ *
+ * @param minCapacity the minimum required capacity of the tmp array
+ * @return tmp, whether or not it grew
+ */
+ private T[] ensureCapacity(int minCapacity) {
+ if (tmp.length < minCapacity) {
+ // Compute smallest power of 2 > minCapacity
+ int newSize = minCapacity;
+ newSize |= newSize >> 1;
+ newSize |= newSize >> 2;
+ newSize |= newSize >> 4;
+ newSize |= newSize >> 8;
+ newSize |= newSize >> 16;
+ newSize++;
+
+ if (newSize < 0) // Not bloody likely!
+ newSize = minCapacity;
+ else
+ newSize = Math.min(newSize, a.length >>> 1);
+
+ @SuppressWarnings({"unchecked", "UnnecessaryLocalVariable"})
+ T[] newArray = (T[]) new Object[newSize];
+ tmp = newArray;
+ }
+ return tmp;
+ }
+
+ /**
+ * Checks that fromIndex and toIndex are in range, and throws an
+ * appropriate exception if they aren't.
+ *
+ * @param arrayLen the length of the array
+ * @param fromIndex the index of the first element of the range
+ * @param toIndex the index after the last element of the range
+ * @throws IllegalArgumentException if fromIndex > toIndex
+ * @throws ArrayIndexOutOfBoundsException if fromIndex < 0
+ * or toIndex > arrayLen
+ */
+ private static void rangeCheck(int arrayLen, int fromIndex, int toIndex) {
+ if (fromIndex > toIndex)
+ throw new IllegalArgumentException("fromIndex(" + fromIndex +
+ ") > toIndex(" + toIndex+")");
+ if (fromIndex < 0)
+ throw new ArrayIndexOutOfBoundsException(fromIndex);
+ if (toIndex > arrayLen)
+ throw new ArrayIndexOutOfBoundsException(toIndex);
+ }
+}
--- a/jdk/src/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java Tue Aug 04 08:01:03 2009 -0700
@@ -34,9 +34,13 @@
*/
package java.util.concurrent;
-import java.util.*;
-import java.util.concurrent.atomic.*;
+import java.util.AbstractQueue;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import java.util.Queue;
/**
* An unbounded thread-safe {@linkplain Queue queue} based on linked nodes.
@@ -47,9 +51,9 @@
* queue the shortest time. New elements
* are inserted at the tail of the queue, and the queue retrieval
* operations obtain elements at the head of the queue.
- * A <tt>ConcurrentLinkedQueue</tt> is an appropriate choice when
+ * A {@code ConcurrentLinkedQueue} is an appropriate choice when
* many threads will share access to a common collection.
- * This queue does not permit <tt>null</tt> elements.
+ * This queue does not permit {@code null} elements.
*
* <p>This implementation employs an efficient "wait-free"
* algorithm based on one described in <a
@@ -57,7 +61,7 @@
* Fast, and Practical Non-Blocking and Blocking Concurrent Queue
* Algorithms</a> by Maged M. Michael and Michael L. Scott.
*
- * <p>Beware that, unlike in most collections, the <tt>size</tt> method
+ * <p>Beware that, unlike in most collections, the {@code size} method
* is <em>NOT</em> a constant-time operation. Because of the
* asynchronous nature of these queues, determining the current number
* of elements requires a traversal of the elements.
@@ -87,51 +91,102 @@
private static final long serialVersionUID = 196745693267521676L;
/*
- * This is a straight adaptation of Michael & Scott algorithm.
- * For explanation, read the paper. The only (minor) algorithmic
- * difference is that this version supports lazy deletion of
- * internal nodes (method remove(Object)) -- remove CAS'es item
- * fields to null. The normal queue operations unlink but then
- * pass over nodes with null item fields. Similarly, iteration
- * methods ignore those with nulls.
+ * This is a modification of the Michael & Scott algorithm,
+ * adapted for a garbage-collected environment, with support for
+ * interior node deletion (to support remove(Object)). For
+ * explanation, read the paper.
*
- * Also note that like most non-blocking algorithms in this
- * package, this implementation relies on the fact that in garbage
+ * Note that like most non-blocking algorithms in this package,
+ * this implementation relies on the fact that in garbage
* collected systems, there is no possibility of ABA problems due
* to recycled nodes, so there is no need to use "counted
* pointers" or related techniques seen in versions used in
* non-GC'ed settings.
+ *
+ * The fundamental invariants are:
+ * - There is exactly one (last) Node with a null next reference,
+ * which is CASed when enqueueing. This last Node can be
+ * reached in O(1) time from tail, but tail is merely an
+ * optimization - it can always be reached in O(N) time from
+ * head as well.
+ * - The elements contained in the queue are the non-null items in
+ * Nodes that are reachable from head. CASing the item
+ * reference of a Node to null atomically removes it from the
+ * queue. Reachability of all elements from head must remain
+ * true even in the case of concurrent modifications that cause
+ * head to advance. A dequeued Node may remain in use
+ * indefinitely due to creation of an Iterator or simply a
+ * poll() that has lost its time slice.
+ *
+ * The above might appear to imply that all Nodes are GC-reachable
+ * from a predecessor dequeued Node. That would cause two problems:
+ * - allow a rogue Iterator to cause unbounded memory retention
+ * - cause cross-generational linking of old Nodes to new Nodes if
+ * a Node was tenured while live, which generational GCs have a
+ * hard time dealing with, causing repeated major collections.
+ * However, only non-deleted Nodes need to be reachable from
+ * dequeued Nodes, and reachability does not necessarily have to
+ * be of the kind understood by the GC. We use the trick of
+ * linking a Node that has just been dequeued to itself. Such a
+ * self-link implicitly means to advance to head.
+ *
+ * Both head and tail are permitted to lag. In fact, failing to
+ * update them every time one could is a significant optimization
+ * (fewer CASes). This is controlled by local "hops" variables
+ * that only trigger helping-CASes after experiencing multiple
+ * lags.
+ *
+ * Since head and tail are updated concurrently and independently,
+ * it is possible for tail to lag behind head (why not)?
+ *
+ * CASing a Node's item reference to null atomically removes the
+ * element from the queue. Iterators skip over Nodes with null
+ * items. Prior implementations of this class had a race between
+ * poll() and remove(Object) where the same element would appear
+ * to be successfully removed by two concurrent operations. The
+ * method remove(Object) also lazily unlinks deleted Nodes, but
+ * this is merely an optimization.
+ *
+ * When constructing a Node (before enqueuing it) we avoid paying
+ * for a volatile write to item by using lazySet instead of a
+ * normal write. This allows the cost of enqueue to be
+ * "one-and-a-half" CASes.
+ *
+ * Both head and tail may or may not point to a Node with a
+ * non-null item. If the queue is empty, all items must of course
+ * be null. Upon creation, both head and tail refer to a dummy
+ * Node with null item. Both head and tail are only updated using
+ * CAS, so they never regress, although again this is merely an
+ * optimization.
*/
private static class Node<E> {
private volatile E item;
private volatile Node<E> next;
- private static final
- AtomicReferenceFieldUpdater<Node, Node>
- nextUpdater =
- AtomicReferenceFieldUpdater.newUpdater
- (Node.class, Node.class, "next");
- private static final
- AtomicReferenceFieldUpdater<Node, Object>
- itemUpdater =
- AtomicReferenceFieldUpdater.newUpdater
- (Node.class, Object.class, "item");
-
- Node(E x) { item = x; }
-
- Node(E x, Node<E> n) { item = x; next = n; }
+ Node(E item) {
+ // Piggyback on imminent casNext()
+ lazySetItem(item);
+ }
E getItem() {
return item;
}
boolean casItem(E cmp, E val) {
- return itemUpdater.compareAndSet(this, cmp, val);
+ return UNSAFE.compareAndSwapObject(this, itemOffset, cmp, val);
}
void setItem(E val) {
- itemUpdater.set(this, val);
+ item = val;
+ }
+
+ void lazySetItem(E val) {
+ UNSAFE.putOrderedObject(this, itemOffset, val);
+ }
+
+ void lazySetNext(Node<E> val) {
+ UNSAFE.putOrderedObject(this, nextOffset, val);
}
Node<E> getNext() {
@@ -139,52 +194,55 @@
}
boolean casNext(Node<E> cmp, Node<E> val) {
- return nextUpdater.compareAndSet(this, cmp, val);
+ return UNSAFE.compareAndSwapObject(this, nextOffset, cmp, val);
}
- void setNext(Node<E> val) {
- nextUpdater.set(this, val);
- }
+ // Unsafe mechanics
+ private static final sun.misc.Unsafe UNSAFE =
+ sun.misc.Unsafe.getUnsafe();
+ private static final long nextOffset =
+ objectFieldOffset(UNSAFE, "next", Node.class);
+ private static final long itemOffset =
+ objectFieldOffset(UNSAFE, "item", Node.class);
}
- private static final
- AtomicReferenceFieldUpdater<ConcurrentLinkedQueue, Node>
- tailUpdater =
- AtomicReferenceFieldUpdater.newUpdater
- (ConcurrentLinkedQueue.class, Node.class, "tail");
- private static final
- AtomicReferenceFieldUpdater<ConcurrentLinkedQueue, Node>
- headUpdater =
- AtomicReferenceFieldUpdater.newUpdater
- (ConcurrentLinkedQueue.class, Node.class, "head");
-
- private boolean casTail(Node<E> cmp, Node<E> val) {
- return tailUpdater.compareAndSet(this, cmp, val);
- }
-
- private boolean casHead(Node<E> cmp, Node<E> val) {
- return headUpdater.compareAndSet(this, cmp, val);
- }
-
+ /**
+ * A node from which the first live (non-deleted) node (if any)
+ * can be reached in O(1) time.
+ * Invariants:
+ * - all live nodes are reachable from head via succ()
+ * - head != null
+ * - (tmp = head).next != tmp || tmp != head
+ * Non-invariants:
+ * - head.item may or may not be null.
+ * - it is permitted for tail to lag behind head, that is, for tail
+ * to not be reachable from head!
+ */
+ private transient volatile Node<E> head = new Node<E>(null);
/**
- * Pointer to header node, initialized to a dummy node. The first
- * actual node is at head.getNext().
+ * A node from which the last node on list (that is, the unique
+ * node with node.next == null) can be reached in O(1) time.
+ * Invariants:
+ * - the last node is always reachable from tail via succ()
+ * - tail != null
+ * Non-invariants:
+ * - tail.item may or may not be null.
+ * - it is permitted for tail to lag behind head, that is, for tail
+ * to not be reachable from head!
+ * - tail.next may or may not be self-pointing to tail.
*/
- private transient volatile Node<E> head = new Node<E>(null, null);
-
- /** Pointer to last node on list **/
private transient volatile Node<E> tail = head;
/**
- * Creates a <tt>ConcurrentLinkedQueue</tt> that is initially empty.
+ * Creates a {@code ConcurrentLinkedQueue} that is initially empty.
*/
public ConcurrentLinkedQueue() {}
/**
- * Creates a <tt>ConcurrentLinkedQueue</tt>
+ * Creates a {@code ConcurrentLinkedQueue}
* initially containing the elements of the given collection,
* added in traversal order of the collection's iterator.
* @param c the collection of elements to initially contain
@@ -201,7 +259,7 @@
/**
* Inserts the specified element at the tail of this queue.
*
- * @return <tt>true</tt> (as specified by {@link Collection#add})
+ * @return {@code true} (as specified by {@link Collection#add})
* @throws NullPointerException if the specified element is null
*/
public boolean add(E e) {
@@ -209,107 +267,135 @@
}
/**
+ * We don't bother to update head or tail pointers if fewer than
+ * HOPS links from "true" location. We assume that volatile
+ * writes are significantly more expensive than volatile reads.
+ */
+ private static final int HOPS = 1;
+
+ /**
+ * Try to CAS head to p. If successful, repoint old head to itself
+ * as sentinel for succ(), below.
+ */
+ final void updateHead(Node<E> h, Node<E> p) {
+ if (h != p && casHead(h, p))
+ h.lazySetNext(h);
+ }
+
+ /**
+ * Returns the successor of p, or the head node if p.next has been
+ * linked to self, which will only be true if traversing with a
+ * stale pointer that is now off the list.
+ */
+ final Node<E> succ(Node<E> p) {
+ Node<E> next = p.getNext();
+ return (p == next) ? head : next;
+ }
+
+ /**
* Inserts the specified element at the tail of this queue.
*
- * @return <tt>true</tt> (as specified by {@link Queue#offer})
+ * @return {@code true} (as specified by {@link Queue#offer})
* @throws NullPointerException if the specified element is null
*/
public boolean offer(E e) {
if (e == null) throw new NullPointerException();
- Node<E> n = new Node<E>(e, null);
+ Node<E> n = new Node<E>(e);
+ retry:
for (;;) {
Node<E> t = tail;
- Node<E> s = t.getNext();
- if (t == tail) {
- if (s == null) {
- if (t.casNext(s, n)) {
- casTail(t, n);
- return true;
- }
+ Node<E> p = t;
+ for (int hops = 0; ; hops++) {
+ Node<E> next = succ(p);
+ if (next != null) {
+ if (hops > HOPS && t != tail)
+ continue retry;
+ p = next;
+ } else if (p.casNext(null, n)) {
+ if (hops >= HOPS)
+ casTail(t, n); // Failure is OK.
+ return true;
} else {
- casTail(t, s);
+ p = succ(p);
}
}
}
}
public E poll() {
- for (;;) {
- Node<E> h = head;
- Node<E> t = tail;
- Node<E> first = h.getNext();
- if (h == head) {
- if (h == t) {
- if (first == null)
- return null;
- else
- casTail(t, first);
- } else if (casHead(h, first)) {
- E item = first.getItem();
- if (item != null) {
- first.setItem(null);
- return item;
- }
- // else skip over deleted item, continue loop,
+ Node<E> h = head;
+ Node<E> p = h;
+ for (int hops = 0; ; hops++) {
+ E item = p.getItem();
+
+ if (item != null && p.casItem(item, null)) {
+ if (hops >= HOPS) {
+ Node<E> q = p.getNext();
+ updateHead(h, (q != null) ? q : p);
}
+ return item;
}
+ Node<E> next = succ(p);
+ if (next == null) {
+ updateHead(h, p);
+ break;
+ }
+ p = next;
}
+ return null;
}
- public E peek() { // same as poll except don't remove item
+ public E peek() {
+ Node<E> h = head;
+ Node<E> p = h;
+ E item;
for (;;) {
- Node<E> h = head;
- Node<E> t = tail;
- Node<E> first = h.getNext();
- if (h == head) {
- if (h == t) {
- if (first == null)
- return null;
- else
- casTail(t, first);
- } else {
- E item = first.getItem();
- if (item != null)
- return item;
- else // remove deleted node and continue
- casHead(h, first);
- }
+ item = p.getItem();
+ if (item != null)
+ break;
+ Node<E> next = succ(p);
+ if (next == null) {
+ break;
}
+ p = next;
}
+ updateHead(h, p);
+ return item;
}
/**
- * Returns the first actual (non-header) node on list. This is yet
- * another variant of poll/peek; here returning out the first
- * node, not element (so we cannot collapse with peek() without
- * introducing race.)
+ * Returns the first live (non-deleted) node on list, or null if none.
+ * This is yet another variant of poll/peek; here returning the
+ * first node, not element. We could make peek() a wrapper around
+ * first(), but that would cost an extra volatile read of item,
+ * and the need to add a retry loop to deal with the possibility
+ * of losing a race to a concurrent poll().
*/
Node<E> first() {
+ Node<E> h = head;
+ Node<E> p = h;
+ Node<E> result;
for (;;) {
- Node<E> h = head;
- Node<E> t = tail;
- Node<E> first = h.getNext();
- if (h == head) {
- if (h == t) {
- if (first == null)
- return null;
- else
- casTail(t, first);
- } else {
- if (first.getItem() != null)
- return first;
- else // remove deleted node and continue
- casHead(h, first);
- }
+ E item = p.getItem();
+ if (item != null) {
+ result = p;
+ break;
}
+ Node<E> next = succ(p);
+ if (next == null) {
+ result = null;
+ break;
+ }
+ p = next;
}
+ updateHead(h, p);
+ return result;
}
-
/**
- * Returns <tt>true</tt> if this queue contains no elements.
+ * Returns {@code true} if this queue contains no elements.
*
- * @return <tt>true</tt> if this queue contains no elements
+ * @return {@code true} if this queue contains no elements
*/
public boolean isEmpty() {
return first() == null;
@@ -317,8 +403,8 @@
/**
* Returns the number of elements in this queue. If this queue
- * contains more than <tt>Integer.MAX_VALUE</tt> elements, returns
- * <tt>Integer.MAX_VALUE</tt>.
+ * contains more than {@code Integer.MAX_VALUE} elements, returns
+ * {@code Integer.MAX_VALUE}.
*
* <p>Beware that, unlike in most collections, this method is
* <em>NOT</em> a constant-time operation. Because of the
@@ -329,7 +415,7 @@
*/
public int size() {
int count = 0;
- for (Node<E> p = first(); p != null; p = p.getNext()) {
+ for (Node<E> p = first(); p != null; p = succ(p)) {
if (p.getItem() != null) {
// Collections.size() spec says to max out
if (++count == Integer.MAX_VALUE)
@@ -340,16 +426,16 @@
}
/**
- * Returns <tt>true</tt> if this queue contains the specified element.
- * More formally, returns <tt>true</tt> if and only if this queue contains
- * at least one element <tt>e</tt> such that <tt>o.equals(e)</tt>.
+ * Returns {@code true} if this queue contains the specified element.
+ * More formally, returns {@code true} if and only if this queue contains
+ * at least one element {@code e} such that {@code o.equals(e)}.
*
* @param o object to be checked for containment in this queue
- * @return <tt>true</tt> if this queue contains the specified element
+ * @return {@code true} if this queue contains the specified element
*/
public boolean contains(Object o) {
if (o == null) return false;
- for (Node<E> p = first(); p != null; p = p.getNext()) {
+ for (Node<E> p = first(); p != null; p = succ(p)) {
E item = p.getItem();
if (item != null &&
o.equals(item))
@@ -360,23 +446,29 @@
/**
* Removes a single instance of the specified element from this queue,
- * if it is present. More formally, removes an element <tt>e</tt> such
- * that <tt>o.equals(e)</tt>, if this queue contains one or more such
+ * if it is present. More formally, removes an element {@code e} such
+ * that {@code o.equals(e)}, if this queue contains one or more such
* elements.
- * Returns <tt>true</tt> if this queue contained the specified element
+ * Returns {@code true} if this queue contained the specified element
* (or equivalently, if this queue changed as a result of the call).
*
* @param o element to be removed from this queue, if present
- * @return <tt>true</tt> if this queue changed as a result of the call
+ * @return {@code true} if this queue changed as a result of the call
*/
public boolean remove(Object o) {
if (o == null) return false;
- for (Node<E> p = first(); p != null; p = p.getNext()) {
+ Node<E> pred = null;
+ for (Node<E> p = first(); p != null; p = succ(p)) {
E item = p.getItem();
if (item != null &&
o.equals(item) &&
- p.casItem(item, null))
+ p.casItem(item, null)) {
+ Node<E> next = succ(p);
+ if (pred != null && next != null)
+ pred.casNext(p, next);
return true;
+ }
+ pred = p;
}
return false;
}
@@ -397,7 +489,7 @@
public Object[] toArray() {
// Use ArrayList to deal with resizing.
ArrayList<E> al = new ArrayList<E>();
- for (Node<E> p = first(); p != null; p = p.getNext()) {
+ for (Node<E> p = first(); p != null; p = succ(p)) {
E item = p.getItem();
if (item != null)
al.add(item);
@@ -415,22 +507,22 @@
* <p>If this queue fits in the specified array with room to spare
* (i.e., the array has more elements than this queue), the element in
* the array immediately following the end of the queue is set to
- * <tt>null</tt>.
+ * {@code null}.
*
* <p>Like the {@link #toArray()} method, this method acts as bridge between
* array-based and collection-based APIs. Further, this method allows
* precise control over the runtime type of the output array, and may,
* under certain circumstances, be used to save allocation costs.
*
- * <p>Suppose <tt>x</tt> is a queue known to contain only strings.
+ * <p>Suppose {@code x} is a queue known to contain only strings.
* The following code can be used to dump the queue into a newly
- * allocated array of <tt>String</tt>:
+ * allocated array of {@code String}:
*
* <pre>
* String[] y = x.toArray(new String[0]);</pre>
*
- * Note that <tt>toArray(new Object[0])</tt> is identical in function to
- * <tt>toArray()</tt>.
+ * Note that {@code toArray(new Object[0])} is identical in function to
+ * {@code toArray()}.
*
* @param a the array into which the elements of the queue are to
* be stored, if it is big enough; otherwise, a new array of the
@@ -441,11 +533,12 @@
* this queue
* @throws NullPointerException if the specified array is null
*/
+ @SuppressWarnings("unchecked")
public <T> T[] toArray(T[] a) {
// try to use sent-in array
int k = 0;
Node<E> p;
- for (p = first(); p != null && k < a.length; p = p.getNext()) {
+ for (p = first(); p != null && k < a.length; p = succ(p)) {
E item = p.getItem();
if (item != null)
a[k++] = (T)item;
@@ -458,7 +551,7 @@
// If won't fit, use ArrayList version
ArrayList<E> al = new ArrayList<E>();
- for (Node<E> q = first(); q != null; q = q.getNext()) {
+ for (Node<E> q = first(); q != null; q = succ(q)) {
E item = q.getItem();
if (item != null)
al.add(item);
@@ -469,7 +562,8 @@
/**
* Returns an iterator over the elements in this queue in proper sequence.
* The returned iterator is a "weakly consistent" iterator that
- * will never throw {@link ConcurrentModificationException},
+ * will never throw {@link java.util.ConcurrentModificationException
+ * ConcurrentModificationException},
* and guarantees to traverse elements as they existed upon
* construction of the iterator, and may (but is not guaranteed to)
* reflect any modifications subsequent to construction.
@@ -511,7 +605,15 @@
lastRet = nextNode;
E x = nextItem;
- Node<E> p = (nextNode == null)? first() : nextNode.getNext();
+ Node<E> pred, p;
+ if (nextNode == null) {
+ p = first();
+ pred = null;
+ } else {
+ pred = nextNode;
+ p = succ(nextNode);
+ }
+
for (;;) {
if (p == null) {
nextNode = null;
@@ -523,8 +625,13 @@
nextNode = p;
nextItem = item;
return x;
- } else // skip over nulls
- p = p.getNext();
+ } else {
+ // skip over nulls
+ Node<E> next = succ(p);
+ if (pred != null && next != null)
+ pred.casNext(p, next);
+ p = next;
+ }
}
}
@@ -549,7 +656,7 @@
/**
* Save the state to a stream (that is, serialize it).
*
- * @serialData All of the elements (each an <tt>E</tt>) in
+ * @serialData All of the elements (each an {@code E}) in
* the proper order, followed by a null
* @param s the stream
*/
@@ -560,7 +667,7 @@
s.defaultWriteObject();
// Write out all elements in the proper order.
- for (Node<E> p = first(); p != null; p = p.getNext()) {
+ for (Node<E> p = first(); p != null; p = succ(p)) {
Object item = p.getItem();
if (item != null)
s.writeObject(item);
@@ -579,10 +686,11 @@
throws java.io.IOException, ClassNotFoundException {
// Read in capacity, and any hidden stuff
s.defaultReadObject();
- head = new Node<E>(null, null);
+ head = new Node<E>(null);
tail = head;
// Read in all elements and place in queue
for (;;) {
+ @SuppressWarnings("unchecked")
E item = (E)s.readObject();
if (item == null)
break;
@@ -591,4 +699,35 @@
}
}
+ // Unsafe mechanics
+
+ private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();
+ private static final long headOffset =
+ objectFieldOffset(UNSAFE, "head", ConcurrentLinkedQueue.class);
+ private static final long tailOffset =
+ objectFieldOffset(UNSAFE, "tail", ConcurrentLinkedQueue.class);
+
+ private boolean casTail(Node<E> cmp, Node<E> val) {
+ return UNSAFE.compareAndSwapObject(this, tailOffset, cmp, val);
+ }
+
+ private boolean casHead(Node<E> cmp, Node<E> val) {
+ return UNSAFE.compareAndSwapObject(this, headOffset, cmp, val);
+ }
+
+ private void lazySetHead(Node<E> val) {
+ UNSAFE.putOrderedObject(this, headOffset, val);
+ }
+
+ static long objectFieldOffset(sun.misc.Unsafe UNSAFE,
+ String field, Class<?> klazz) {
+ try {
+ return UNSAFE.objectFieldOffset(klazz.getDeclaredField(field));
+ } catch (NoSuchFieldException e) {
+ // Convert Exception to corresponding Error
+ NoSuchFieldError error = new NoSuchFieldError(field);
+ error.initCause(e);
+ throw error;
+ }
+ }
}
--- a/jdk/src/share/classes/java/util/concurrent/LinkedBlockingDeque.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/java/util/concurrent/LinkedBlockingDeque.java Tue Aug 04 08:01:03 2009 -0700
@@ -34,8 +34,13 @@
*/
package java.util.concurrent;
-import java.util.*;
-import java.util.concurrent.locks.*;
+
+import java.util.AbstractQueue;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.ReentrantLock;
/**
* An optionally-bounded {@linkplain BlockingDeque blocking deque} based on
@@ -73,6 +78,20 @@
/*
* Implemented as a simple doubly-linked list protected by a
* single lock and using conditions to manage blocking.
+ *
+ * To implement weakly consistent iterators, it appears we need to
+ * keep all Nodes GC-reachable from a predecessor dequeued Node.
+ * That would cause two problems:
+ * - allow a rogue Iterator to cause unbounded memory retention
+ * - cause cross-generational linking of old Nodes to new Nodes if
+ * a Node was tenured while live, which generational GCs have a
+ * hard time dealing with, causing repeated major collections.
+ * However, only non-deleted Nodes need to be reachable from
+ * dequeued Nodes, and reachability does not necessarily have to
+ * be of the kind understood by the GC. We use the trick of
+ * linking a Node that has just been dequeued to itself. Such a
+ * self-link implicitly means to jump to "first" (for next links)
+ * or "last" (for prev links).
*/
/*
@@ -86,9 +105,27 @@
/** Doubly-linked list node class */
static final class Node<E> {
+ /**
+ * The item, or null if this node has been removed.
+ */
E item;
+
+ /**
+ * One of:
+ * - the real predecessor Node
+ * - this Node, meaning the predecessor is tail
+ * - null, meaning there is no predecessor
+ */
Node<E> prev;
+
+ /**
+ * One of:
+ * - the real successor Node
+ * - this Node, meaning the successor is head
+ * - null, meaning there is no successor
+ */
Node<E> next;
+
Node(E x, Node<E> p, Node<E> n) {
item = x;
prev = p;
@@ -96,23 +133,37 @@
}
}
- /** Pointer to first node */
- private transient Node<E> first;
- /** Pointer to last node */
- private transient Node<E> last;
+ /**
+ * Pointer to first node.
+ * Invariant: (first == null && last == null) ||
+ * (first.prev == null && first.item != null)
+ */
+ transient Node<E> first;
+
+ /**
+ * Pointer to last node.
+ * Invariant: (first == null && last == null) ||
+ * (last.next == null && last.item != null)
+ */
+ transient Node<E> last;
+
/** Number of items in the deque */
private transient int count;
+
/** Maximum number of items in the deque */
private final int capacity;
+
/** Main lock guarding all access */
- private final ReentrantLock lock = new ReentrantLock();
+ final ReentrantLock lock = new ReentrantLock();
+
/** Condition for waiting takes */
private final Condition notEmpty = lock.newCondition();
+
/** Condition for waiting puts */
private final Condition notFull = lock.newCondition();
/**
- * Creates a <tt>LinkedBlockingDeque</tt> with a capacity of
+ * Creates a {@code LinkedBlockingDeque} with a capacity of
* {@link Integer#MAX_VALUE}.
*/
public LinkedBlockingDeque() {
@@ -120,10 +171,10 @@
}
/**
- * Creates a <tt>LinkedBlockingDeque</tt> with the given (fixed) capacity.
+ * Creates a {@code LinkedBlockingDeque} with the given (fixed) capacity.
*
* @param capacity the capacity of this deque
- * @throws IllegalArgumentException if <tt>capacity</tt> is less than 1
+ * @throws IllegalArgumentException if {@code capacity} is less than 1
*/
public LinkedBlockingDeque(int capacity) {
if (capacity <= 0) throw new IllegalArgumentException();
@@ -131,7 +182,7 @@
}
/**
- * Creates a <tt>LinkedBlockingDeque</tt> with a capacity of
+ * Creates a {@code LinkedBlockingDeque} with a capacity of
* {@link Integer#MAX_VALUE}, initially containing the elements of
* the given collection, added in traversal order of the
* collection's iterator.
@@ -142,8 +193,18 @@
*/
public LinkedBlockingDeque(Collection<? extends E> c) {
this(Integer.MAX_VALUE);
- for (E e : c)
- add(e);
+ final ReentrantLock lock = this.lock;
+ lock.lock(); // Never contended, but necessary for visibility
+ try {
+ for (E e : c) {
+ if (e == null)
+ throw new NullPointerException();
+ if (!linkLast(e))
+ throw new IllegalStateException("Deque full");
+ }
+ } finally {
+ lock.unlock();
+ }
}
@@ -153,9 +214,9 @@
* Links e as first element, or returns false if full.
*/
private boolean linkFirst(E e) {
+ // assert lock.isHeldByCurrentThread();
if (count >= capacity)
return false;
- ++count;
Node<E> f = first;
Node<E> x = new Node<E>(e, null, f);
first = x;
@@ -163,6 +224,7 @@
last = x;
else
f.prev = x;
+ ++count;
notEmpty.signal();
return true;
}
@@ -171,9 +233,9 @@
* Links e as last element, or returns false if full.
*/
private boolean linkLast(E e) {
+ // assert lock.isHeldByCurrentThread();
if (count >= capacity)
return false;
- ++count;
Node<E> l = last;
Node<E> x = new Node<E>(e, l, null);
last = x;
@@ -181,6 +243,7 @@
first = x;
else
l.next = x;
+ ++count;
notEmpty.signal();
return true;
}
@@ -189,10 +252,14 @@
* Removes and returns first element, or null if empty.
*/
private E unlinkFirst() {
+ // assert lock.isHeldByCurrentThread();
Node<E> f = first;
if (f == null)
return null;
Node<E> n = f.next;
+ E item = f.item;
+ f.item = null;
+ f.next = f; // help GC
first = n;
if (n == null)
last = null;
@@ -200,17 +267,21 @@
n.prev = null;
--count;
notFull.signal();
- return f.item;
+ return item;
}
/**
* Removes and returns last element, or null if empty.
*/
private E unlinkLast() {
+ // assert lock.isHeldByCurrentThread();
Node<E> l = last;
if (l == null)
return null;
Node<E> p = l.prev;
+ E item = l.item;
+ l.item = null;
+ l.prev = l; // help GC
last = p;
if (p == null)
first = null;
@@ -218,31 +289,29 @@
p.next = null;
--count;
notFull.signal();
- return l.item;
+ return item;
}
/**
- * Unlink e
+ * Unlinks x.
*/
- private void unlink(Node<E> x) {
+ void unlink(Node<E> x) {
+ // assert lock.isHeldByCurrentThread();
Node<E> p = x.prev;
Node<E> n = x.next;
if (p == null) {
- if (n == null)
- first = last = null;
- else {
- n.prev = null;
- first = n;
- }
+ unlinkFirst();
} else if (n == null) {
- p.next = null;
- last = p;
+ unlinkLast();
} else {
p.next = n;
n.prev = p;
+ x.item = null;
+ // Don't mess with x's links. They may still be in use by
+ // an iterator.
+ --count;
+ notFull.signal();
}
- --count;
- notFull.signalAll();
}
// BlockingDeque methods
@@ -270,6 +339,7 @@
*/
public boolean offerFirst(E e) {
if (e == null) throw new NullPointerException();
+ final ReentrantLock lock = this.lock;
lock.lock();
try {
return linkFirst(e);
@@ -283,6 +353,7 @@
*/
public boolean offerLast(E e) {
if (e == null) throw new NullPointerException();
+ final ReentrantLock lock = this.lock;
lock.lock();
try {
return linkLast(e);
@@ -297,6 +368,7 @@
*/
public void putFirst(E e) throws InterruptedException {
if (e == null) throw new NullPointerException();
+ final ReentrantLock lock = this.lock;
lock.lock();
try {
while (!linkFirst(e))
@@ -312,6 +384,7 @@
*/
public void putLast(E e) throws InterruptedException {
if (e == null) throw new NullPointerException();
+ final ReentrantLock lock = this.lock;
lock.lock();
try {
while (!linkLast(e))
@@ -329,15 +402,15 @@
throws InterruptedException {
if (e == null) throw new NullPointerException();
long nanos = unit.toNanos(timeout);
+ final ReentrantLock lock = this.lock;
lock.lockInterruptibly();
try {
- for (;;) {
- if (linkFirst(e))
- return true;
+ while (!linkFirst(e)) {
if (nanos <= 0)
return false;
nanos = notFull.awaitNanos(nanos);
}
+ return true;
} finally {
lock.unlock();
}
@@ -351,15 +424,15 @@
throws InterruptedException {
if (e == null) throw new NullPointerException();
long nanos = unit.toNanos(timeout);
+ final ReentrantLock lock = this.lock;
lock.lockInterruptibly();
try {
- for (;;) {
- if (linkLast(e))
- return true;
+ while (!linkLast(e)) {
if (nanos <= 0)
return false;
nanos = notFull.awaitNanos(nanos);
}
+ return true;
} finally {
lock.unlock();
}
@@ -384,6 +457,7 @@
}
public E pollFirst() {
+ final ReentrantLock lock = this.lock;
lock.lock();
try {
return unlinkFirst();
@@ -393,6 +467,7 @@
}
public E pollLast() {
+ final ReentrantLock lock = this.lock;
lock.lock();
try {
return unlinkLast();
@@ -402,6 +477,7 @@
}
public E takeFirst() throws InterruptedException {
+ final ReentrantLock lock = this.lock;
lock.lock();
try {
E x;
@@ -414,6 +490,7 @@
}
public E takeLast() throws InterruptedException {
+ final ReentrantLock lock = this.lock;
lock.lock();
try {
E x;
@@ -428,16 +505,16 @@
public E pollFirst(long timeout, TimeUnit unit)
throws InterruptedException {
long nanos = unit.toNanos(timeout);
+ final ReentrantLock lock = this.lock;
lock.lockInterruptibly();
try {
- for (;;) {
- E x = unlinkFirst();
- if (x != null)
- return x;
+ E x;
+ while ( (x = unlinkFirst()) == null) {
if (nanos <= 0)
return null;
nanos = notEmpty.awaitNanos(nanos);
}
+ return x;
} finally {
lock.unlock();
}
@@ -446,16 +523,16 @@
public E pollLast(long timeout, TimeUnit unit)
throws InterruptedException {
long nanos = unit.toNanos(timeout);
+ final ReentrantLock lock = this.lock;
lock.lockInterruptibly();
try {
- for (;;) {
- E x = unlinkLast();
- if (x != null)
- return x;
+ E x;
+ while ( (x = unlinkLast()) == null) {
if (nanos <= 0)
return null;
nanos = notEmpty.awaitNanos(nanos);
}
+ return x;
} finally {
lock.unlock();
}
@@ -480,6 +557,7 @@
}
public E peekFirst() {
+ final ReentrantLock lock = this.lock;
lock.lock();
try {
return (first == null) ? null : first.item;
@@ -489,6 +567,7 @@
}
public E peekLast() {
+ final ReentrantLock lock = this.lock;
lock.lock();
try {
return (last == null) ? null : last.item;
@@ -499,6 +578,7 @@
public boolean removeFirstOccurrence(Object o) {
if (o == null) return false;
+ final ReentrantLock lock = this.lock;
lock.lock();
try {
for (Node<E> p = first; p != null; p = p.next) {
@@ -515,6 +595,7 @@
public boolean removeLastOccurrence(Object o) {
if (o == null) return false;
+ final ReentrantLock lock = this.lock;
lock.lock();
try {
for (Node<E> p = last; p != null; p = p.prev) {
@@ -619,14 +700,15 @@
* Returns the number of additional elements that this deque can ideally
* (in the absence of memory or resource constraints) accept without
* blocking. This is always equal to the initial capacity of this deque
- * less the current <tt>size</tt> of this deque.
+ * less the current {@code size} of this deque.
*
* <p>Note that you <em>cannot</em> always tell if an attempt to insert
- * an element will succeed by inspecting <tt>remainingCapacity</tt>
+ * an element will succeed by inspecting {@code remainingCapacity}
* because it may be the case that another thread is about to
* insert or remove an element.
*/
public int remainingCapacity() {
+ final ReentrantLock lock = this.lock;
lock.lock();
try {
return capacity - count;
@@ -642,22 +724,7 @@
* @throws IllegalArgumentException {@inheritDoc}
*/
public int drainTo(Collection<? super E> c) {
- if (c == null)
- throw new NullPointerException();
- if (c == this)
- throw new IllegalArgumentException();
- lock.lock();
- try {
- for (Node<E> p = first; p != null; p = p.next)
- c.add(p.item);
- int n = count;
- count = 0;
- first = last = null;
- notFull.signalAll();
- return n;
- } finally {
- lock.unlock();
- }
+ return drainTo(c, Integer.MAX_VALUE);
}
/**
@@ -671,19 +738,14 @@
throw new NullPointerException();
if (c == this)
throw new IllegalArgumentException();
+ final ReentrantLock lock = this.lock;
lock.lock();
try {
- int n = 0;
- while (n < maxElements && first != null) {
- c.add(first.item);
- first.prev = null;
- first = first.next;
- --count;
- ++n;
+ int n = Math.min(maxElements, count);
+ for (int i = 0; i < n; i++) {
+ c.add(first.item); // In this order, in case add() throws.
+ unlinkFirst();
}
- if (first == null)
- last = null;
- notFull.signalAll();
return n;
} finally {
lock.unlock();
@@ -712,16 +774,16 @@
/**
* Removes the first occurrence of the specified element from this deque.
* If the deque does not contain the element, it is unchanged.
- * More formally, removes the first element <tt>e</tt> such that
- * <tt>o.equals(e)</tt> (if such an element exists).
- * Returns <tt>true</tt> if this deque contained the specified element
+ * More formally, removes the first element {@code e} such that
+ * {@code o.equals(e)} (if such an element exists).
+ * Returns {@code true} if this deque contained the specified element
* (or equivalently, if this deque changed as a result of the call).
*
* <p>This method is equivalent to
* {@link #removeFirstOccurrence(Object) removeFirstOccurrence}.
*
* @param o element to be removed from this deque, if present
- * @return <tt>true</tt> if this deque changed as a result of the call
+ * @return {@code true} if this deque changed as a result of the call
*/
public boolean remove(Object o) {
return removeFirstOccurrence(o);
@@ -733,6 +795,7 @@
* @return the number of elements in this deque
*/
public int size() {
+ final ReentrantLock lock = this.lock;
lock.lock();
try {
return count;
@@ -742,15 +805,16 @@
}
/**
- * Returns <tt>true</tt> if this deque contains the specified element.
- * More formally, returns <tt>true</tt> if and only if this deque contains
- * at least one element <tt>e</tt> such that <tt>o.equals(e)</tt>.
+ * Returns {@code true} if this deque contains the specified element.
+ * More formally, returns {@code true} if and only if this deque contains
+ * at least one element {@code e} such that {@code o.equals(e)}.
*
* @param o object to be checked for containment in this deque
- * @return <tt>true</tt> if this deque contains the specified element
+ * @return {@code true} if this deque contains the specified element
*/
public boolean contains(Object o) {
if (o == null) return false;
+ final ReentrantLock lock = this.lock;
lock.lock();
try {
for (Node<E> p = first; p != null; p = p.next)
@@ -762,24 +826,46 @@
}
}
- /**
- * Variant of removeFirstOccurrence needed by iterator.remove.
- * Searches for the node, not its contents.
+ /*
+ * TODO: Add support for more efficient bulk operations.
+ *
+ * We don't want to acquire the lock for every iteration, but we
+ * also want other threads a chance to interact with the
+ * collection, especially when count is close to capacity.
*/
- boolean removeNode(Node<E> e) {
- lock.lock();
- try {
- for (Node<E> p = first; p != null; p = p.next) {
- if (p == e) {
- unlink(p);
- return true;
- }
- }
- return false;
- } finally {
- lock.unlock();
- }
- }
+
+// /**
+// * Adds all of the elements in the specified collection to this
+// * queue. Attempts to addAll of a queue to itself result in
+// * {@code IllegalArgumentException}. Further, the behavior of
+// * this operation is undefined if the specified collection is
+// * modified while the operation is in progress.
+// *
+// * @param c collection containing elements to be added to this queue
+// * @return {@code true} if this queue changed as a result of the call
+// * @throws ClassCastException {@inheritDoc}
+// * @throws NullPointerException {@inheritDoc}
+// * @throws IllegalArgumentException {@inheritDoc}
+// * @throws IllegalStateException {@inheritDoc}
+// * @see #add(Object)
+// */
+// public boolean addAll(Collection<? extends E> c) {
+// if (c == null)
+// throw new NullPointerException();
+// if (c == this)
+// throw new IllegalArgumentException();
+// final ReentrantLock lock = this.lock;
+// lock.lock();
+// try {
+// boolean modified = false;
+// for (E e : c)
+// if (linkLast(e))
+// modified = true;
+// return modified;
+// } finally {
+// lock.unlock();
+// }
+// }
/**
* Returns an array containing all of the elements in this deque, in
@@ -794,7 +880,9 @@
*
* @return an array containing all of the elements in this deque
*/
+ @SuppressWarnings("unchecked")
public Object[] toArray() {
+ final ReentrantLock lock = this.lock;
lock.lock();
try {
Object[] a = new Object[count];
@@ -817,22 +905,22 @@
* <p>If this deque fits in the specified array with room to spare
* (i.e., the array has more elements than this deque), the element in
* the array immediately following the end of the deque is set to
- * <tt>null</tt>.
+ * {@code null}.
*
* <p>Like the {@link #toArray()} method, this method acts as bridge between
* array-based and collection-based APIs. Further, this method allows
* precise control over the runtime type of the output array, and may,
* under certain circumstances, be used to save allocation costs.
*
- * <p>Suppose <tt>x</tt> is a deque known to contain only strings.
+ * <p>Suppose {@code x} is a deque known to contain only strings.
* The following code can be used to dump the deque into a newly
- * allocated array of <tt>String</tt>:
+ * allocated array of {@code String}:
*
* <pre>
* String[] y = x.toArray(new String[0]);</pre>
*
- * Note that <tt>toArray(new Object[0])</tt> is identical in function to
- * <tt>toArray()</tt>.
+ * Note that {@code toArray(new Object[0])} is identical in function to
+ * {@code toArray()}.
*
* @param a the array into which the elements of the deque are to
* be stored, if it is big enough; otherwise, a new array of the
@@ -843,14 +931,14 @@
* this deque
* @throws NullPointerException if the specified array is null
*/
+ @SuppressWarnings("unchecked")
public <T> T[] toArray(T[] a) {
+ final ReentrantLock lock = this.lock;
lock.lock();
try {
if (a.length < count)
- a = (T[])java.lang.reflect.Array.newInstance(
- a.getClass().getComponentType(),
- count
- );
+ a = (T[])java.lang.reflect.Array.newInstance
+ (a.getClass().getComponentType(), count);
int k = 0;
for (Node<E> p = first; p != null; p = p.next)
@@ -864,6 +952,7 @@
}
public String toString() {
+ final ReentrantLock lock = this.lock;
lock.lock();
try {
return super.toString();
@@ -877,8 +966,16 @@
* The deque will be empty after this call returns.
*/
public void clear() {
+ final ReentrantLock lock = this.lock;
lock.lock();
try {
+ for (Node<E> f = first; f != null; ) {
+ f.item = null;
+ Node<E> n = f.next;
+ f.prev = null;
+ f.next = null;
+ f = n;
+ }
first = last = null;
count = 0;
notFull.signalAll();
@@ -890,8 +987,9 @@
/**
* Returns an iterator over the elements in this deque in proper sequence.
* The elements will be returned in order from first (head) to last (tail).
- * The returned <tt>Iterator</tt> is a "weakly consistent" iterator that
- * will never throw {@link ConcurrentModificationException},
+ * The returned {@code Iterator} is a "weakly consistent" iterator that
+ * will never throw {@link java.util.ConcurrentModificationException
+ * ConcurrentModificationException},
* and guarantees to traverse elements as they existed upon
* construction of the iterator, and may (but is not guaranteed to)
* reflect any modifications subsequent to construction.
@@ -906,8 +1004,9 @@
* Returns an iterator over the elements in this deque in reverse
* sequential order. The elements will be returned in order from
* last (tail) to first (head).
- * The returned <tt>Iterator</tt> is a "weakly consistent" iterator that
- * will never throw {@link ConcurrentModificationException},
+ * The returned {@code Iterator} is a "weakly consistent" iterator that
+ * will never throw {@link java.util.ConcurrentModificationException
+ * ConcurrentModificationException},
* and guarantees to traverse elements as they existed upon
* construction of the iterator, and may (but is not guaranteed to)
* reflect any modifications subsequent to construction.
@@ -921,7 +1020,7 @@
*/
private abstract class AbstractItr implements Iterator<E> {
/**
- * The next node to return in next
+ * The next node to return in next()
*/
Node<E> next;
@@ -939,15 +1038,44 @@
*/
private Node<E> lastRet;
+ abstract Node<E> firstNode();
+ abstract Node<E> nextNode(Node<E> n);
+
AbstractItr() {
- advance(); // set to initial position
+ // set to initial position
+ final ReentrantLock lock = LinkedBlockingDeque.this.lock;
+ lock.lock();
+ try {
+ next = firstNode();
+ nextItem = (next == null) ? null : next.item;
+ } finally {
+ lock.unlock();
+ }
}
/**
- * Advances next, or if not yet initialized, sets to first node.
- * Implemented to move forward vs backward in the two subclasses.
+ * Advances next.
*/
- abstract void advance();
+ void advance() {
+ final ReentrantLock lock = LinkedBlockingDeque.this.lock;
+ lock.lock();
+ try {
+ // assert next != null;
+ Node<E> s = nextNode(next);
+ if (s == next) {
+ next = firstNode();
+ } else {
+ // Skip over removed nodes.
+ // May be necessary if multiple interior Nodes are removed.
+ while (s != null && s.item == null)
+ s = nextNode(s);
+ next = s;
+ }
+ nextItem = (next == null) ? null : next.item;
+ } finally {
+ lock.unlock();
+ }
+ }
public boolean hasNext() {
return next != null;
@@ -967,52 +1095,39 @@
if (n == null)
throw new IllegalStateException();
lastRet = null;
- // Note: removeNode rescans looking for this node to make
- // sure it was not already removed. Otherwise, trying to
- // re-remove could corrupt list.
- removeNode(n);
- }
- }
-
- /** Forward iterator */
- private class Itr extends AbstractItr {
- void advance() {
final ReentrantLock lock = LinkedBlockingDeque.this.lock;
lock.lock();
try {
- next = (next == null)? first : next.next;
- nextItem = (next == null)? null : next.item;
+ if (n.item != null)
+ unlink(n);
} finally {
lock.unlock();
}
}
}
- /**
- * Descending iterator for LinkedBlockingDeque
- */
+ /** Forward iterator */
+ private class Itr extends AbstractItr {
+ Node<E> firstNode() { return first; }
+ Node<E> nextNode(Node<E> n) { return n.next; }
+ }
+
+ /** Descending iterator */
private class DescendingItr extends AbstractItr {
- void advance() {
- final ReentrantLock lock = LinkedBlockingDeque.this.lock;
- lock.lock();
- try {
- next = (next == null)? last : next.prev;
- nextItem = (next == null)? null : next.item;
- } finally {
- lock.unlock();
- }
- }
+ Node<E> firstNode() { return last; }
+ Node<E> nextNode(Node<E> n) { return n.prev; }
}
/**
* Save the state of this deque to a stream (that is, serialize it).
*
* @serialData The capacity (int), followed by elements (each an
- * <tt>Object</tt>) in the proper order, followed by a null
+ * {@code Object}) in the proper order, followed by a null
* @param s the stream
*/
private void writeObject(java.io.ObjectOutputStream s)
throws java.io.IOException {
+ final ReentrantLock lock = this.lock;
lock.lock();
try {
// Write out capacity and any hidden stuff
@@ -1040,6 +1155,7 @@
last = null;
// Read in all elements and place in queue
for (;;) {
+ @SuppressWarnings("unchecked")
E item = (E)s.readObject();
if (item == null)
break;
--- a/jdk/src/share/classes/java/util/concurrent/LinkedBlockingQueue.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/java/util/concurrent/LinkedBlockingQueue.java Tue Aug 04 08:01:03 2009 -0700
@@ -34,9 +34,14 @@
*/
package java.util.concurrent;
-import java.util.concurrent.atomic.*;
-import java.util.concurrent.locks.*;
-import java.util.*;
+
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.ReentrantLock;
+import java.util.AbstractQueue;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
/**
* An optionally-bounded {@linkplain BlockingQueue blocking queue} based on
@@ -86,15 +91,43 @@
* items have been entered since the signal. And symmetrically for
* takes signalling puts. Operations such as remove(Object) and
* iterators acquire both locks.
+ *
+ * Visibility between writers and readers is provided as follows:
+ *
+ * Whenever an element is enqueued, the putLock is acquired and
+ * count updated. A subsequent reader guarantees visibility to the
+ * enqueued Node by either acquiring the putLock (via fullyLock)
+ * or by acquiring the takeLock, and then reading n = count.get();
+ * this gives visibility to the first n items.
+ *
+ * To implement weakly consistent iterators, it appears we need to
+ * keep all Nodes GC-reachable from a predecessor dequeued Node.
+ * That would cause two problems:
+ * - allow a rogue Iterator to cause unbounded memory retention
+ * - cause cross-generational linking of old Nodes to new Nodes if
+ * a Node was tenured while live, which generational GCs have a
+ * hard time dealing with, causing repeated major collections.
+ * However, only non-deleted Nodes need to be reachable from
+ * dequeued Nodes, and reachability does not necessarily have to
+ * be of the kind understood by the GC. We use the trick of
+ * linking a Node that has just been dequeued to itself. Such a
+ * self-link implicitly means to advance to head.next.
*/
/**
* Linked list node class
*/
static class Node<E> {
- /** The item, volatile to ensure barrier separating write and read */
- volatile E item;
+ E item;
+
+ /**
+ * One of:
+ * - the real successor Node
+ * - this Node, meaning the successor is head.next
+ * - null, meaning there is no successor (this is the last node)
+ */
Node<E> next;
+
Node(E x) { item = x; }
}
@@ -104,10 +137,16 @@
/** Current number of elements */
private final AtomicInteger count = new AtomicInteger(0);
- /** Head of linked list */
+ /**
+ * Head of linked list.
+ * Invariant: head.item == null
+ */
private transient Node<E> head;
- /** Tail of linked list */
+ /**
+ * Tail of linked list.
+ * Invariant: last.next == null
+ */
private transient Node<E> last;
/** Lock held by take, poll, etc */
@@ -151,18 +190,26 @@
/**
* Creates a node and links it at end of queue.
+ *
* @param x the item
*/
- private void insert(E x) {
+ private void enqueue(E x) {
+ // assert putLock.isHeldByCurrentThread();
+ // assert last.next == null;
last = last.next = new Node<E>(x);
}
/**
- * Removes a node from head of queue,
+ * Removes a node from head of queue.
+ *
* @return the node
*/
- private E extract() {
- Node<E> first = head.next;
+ private E dequeue() {
+ // assert takeLock.isHeldByCurrentThread();
+ // assert head.item == null;
+ Node<E> h = head;
+ Node<E> first = h.next;
+ h.next = h; // help GC
head = first;
E x = first.item;
first.item = null;
@@ -172,7 +219,7 @@
/**
* Lock to prevent both puts and takes.
*/
- private void fullyLock() {
+ void fullyLock() {
putLock.lock();
takeLock.lock();
}
@@ -180,14 +227,21 @@
/**
* Unlock to allow both puts and takes.
*/
- private void fullyUnlock() {
+ void fullyUnlock() {
takeLock.unlock();
putLock.unlock();
}
+// /**
+// * Tells whether both locks are held by current thread.
+// */
+// boolean isFullyLocked() {
+// return (putLock.isHeldByCurrentThread() &&
+// takeLock.isHeldByCurrentThread());
+// }
/**
- * Creates a <tt>LinkedBlockingQueue</tt> with a capacity of
+ * Creates a {@code LinkedBlockingQueue} with a capacity of
* {@link Integer#MAX_VALUE}.
*/
public LinkedBlockingQueue() {
@@ -195,10 +249,10 @@
}
/**
- * Creates a <tt>LinkedBlockingQueue</tt> with the given (fixed) capacity.
+ * Creates a {@code LinkedBlockingQueue} with the given (fixed) capacity.
*
* @param capacity the capacity of this queue
- * @throws IllegalArgumentException if <tt>capacity</tt> is not greater
+ * @throws IllegalArgumentException if {@code capacity} is not greater
* than zero
*/
public LinkedBlockingQueue(int capacity) {
@@ -208,7 +262,7 @@
}
/**
- * Creates a <tt>LinkedBlockingQueue</tt> with a capacity of
+ * Creates a {@code LinkedBlockingQueue} with a capacity of
* {@link Integer#MAX_VALUE}, initially containing the elements of the
* given collection,
* added in traversal order of the collection's iterator.
@@ -219,8 +273,22 @@
*/
public LinkedBlockingQueue(Collection<? extends E> c) {
this(Integer.MAX_VALUE);
- for (E e : c)
- add(e);
+ final ReentrantLock putLock = this.putLock;
+ putLock.lock(); // Never contended, but necessary for visibility
+ try {
+ int n = 0;
+ for (E e : c) {
+ if (e == null)
+ throw new NullPointerException();
+ if (n == capacity)
+ throw new IllegalStateException("Queue full");
+ enqueue(e);
+ ++n;
+ }
+ count.set(n);
+ } finally {
+ putLock.unlock();
+ }
}
@@ -241,10 +309,10 @@
* Returns the number of additional elements that this queue can ideally
* (in the absence of memory or resource constraints) accept without
* blocking. This is always equal to the initial capacity of this queue
- * less the current <tt>size</tt> of this queue.
+ * less the current {@code size} of this queue.
*
* <p>Note that you <em>cannot</em> always tell if an attempt to insert
- * an element will succeed by inspecting <tt>remainingCapacity</tt>
+ * an element will succeed by inspecting {@code remainingCapacity}
* because it may be the case that another thread is about to
* insert or remove an element.
*/
@@ -261,8 +329,8 @@
*/
public void put(E e) throws InterruptedException {
if (e == null) throw new NullPointerException();
- // Note: convention in all put/take/etc is to preset
- // local var holding count negative to indicate failure unless set.
+ // Note: convention in all put/take/etc is to preset local var
+ // holding count negative to indicate failure unless set.
int c = -1;
final ReentrantLock putLock = this.putLock;
final AtomicInteger count = this.count;
@@ -273,18 +341,13 @@
* not protected by lock. This works because count can
* only decrease at this point (all other puts are shut
* out by lock), and we (or some other waiting put) are
- * signalled if it ever changes from
- * capacity. Similarly for all other uses of count in
- * other wait guards.
+ * signalled if it ever changes from capacity. Similarly
+ * for all other uses of count in other wait guards.
*/
- try {
- while (count.get() == capacity)
- notFull.await();
- } catch (InterruptedException ie) {
- notFull.signal(); // propagate to a non-interrupted thread
- throw ie;
+ while (count.get() == capacity) {
+ notFull.await();
}
- insert(e);
+ enqueue(e);
c = count.getAndIncrement();
if (c + 1 < capacity)
notFull.signal();
@@ -299,7 +362,7 @@
* Inserts the specified element at the tail of this queue, waiting if
* necessary up to the specified wait time for space to become available.
*
- * @return <tt>true</tt> if successful, or <tt>false</tt> if
+ * @return {@code true} if successful, or {@code false} if
* the specified waiting time elapses before space is available.
* @throws InterruptedException {@inheritDoc}
* @throws NullPointerException {@inheritDoc}
@@ -314,23 +377,15 @@
final AtomicInteger count = this.count;
putLock.lockInterruptibly();
try {
- for (;;) {
- if (count.get() < capacity) {
- insert(e);
- c = count.getAndIncrement();
- if (c + 1 < capacity)
- notFull.signal();
- break;
- }
+ while (count.get() == capacity) {
if (nanos <= 0)
return false;
- try {
- nanos = notFull.awaitNanos(nanos);
- } catch (InterruptedException ie) {
- notFull.signal(); // propagate to a non-interrupted thread
- throw ie;
- }
+ nanos = notFull.awaitNanos(nanos);
}
+ enqueue(e);
+ c = count.getAndIncrement();
+ if (c + 1 < capacity)
+ notFull.signal();
} finally {
putLock.unlock();
}
@@ -342,7 +397,7 @@
/**
* Inserts the specified element at the tail of this queue if it is
* possible to do so immediately without exceeding the queue's capacity,
- * returning <tt>true</tt> upon success and <tt>false</tt> if this queue
+ * returning {@code true} upon success and {@code false} if this queue
* is full.
* When using a capacity-restricted queue, this method is generally
* preferable to method {@link BlockingQueue#add add}, which can fail to
@@ -360,7 +415,7 @@
putLock.lock();
try {
if (count.get() < capacity) {
- insert(e);
+ enqueue(e);
c = count.getAndIncrement();
if (c + 1 < capacity)
notFull.signal();
@@ -381,15 +436,10 @@
final ReentrantLock takeLock = this.takeLock;
takeLock.lockInterruptibly();
try {
- try {
- while (count.get() == 0)
- notEmpty.await();
- } catch (InterruptedException ie) {
- notEmpty.signal(); // propagate to a non-interrupted thread
- throw ie;
+ while (count.get() == 0) {
+ notEmpty.await();
}
-
- x = extract();
+ x = dequeue();
c = count.getAndDecrement();
if (c > 1)
notEmpty.signal();
@@ -409,23 +459,15 @@
final ReentrantLock takeLock = this.takeLock;
takeLock.lockInterruptibly();
try {
- for (;;) {
- if (count.get() > 0) {
- x = extract();
- c = count.getAndDecrement();
- if (c > 1)
- notEmpty.signal();
- break;
- }
+ while (count.get() == 0) {
if (nanos <= 0)
return null;
- try {
- nanos = notEmpty.awaitNanos(nanos);
- } catch (InterruptedException ie) {
- notEmpty.signal(); // propagate to a non-interrupted thread
- throw ie;
- }
+ nanos = notEmpty.awaitNanos(nanos);
}
+ x = dequeue();
+ c = count.getAndDecrement();
+ if (c > 1)
+ notEmpty.signal();
} finally {
takeLock.unlock();
}
@@ -444,7 +486,7 @@
takeLock.lock();
try {
if (count.get() > 0) {
- x = extract();
+ x = dequeue();
c = count.getAndDecrement();
if (c > 1)
notEmpty.signal();
@@ -457,7 +499,6 @@
return x;
}
-
public E peek() {
if (count.get() == 0)
return null;
@@ -475,43 +516,47 @@
}
/**
+ * Unlinks interior Node p with predecessor trail.
+ */
+ void unlink(Node<E> p, Node<E> trail) {
+ // assert isFullyLocked();
+ // p.next is not changed, to allow iterators that are
+ // traversing p to maintain their weak-consistency guarantee.
+ p.item = null;
+ trail.next = p.next;
+ if (last == p)
+ last = trail;
+ if (count.getAndDecrement() == capacity)
+ notFull.signal();
+ }
+
+ /**
* Removes a single instance of the specified element from this queue,
- * if it is present. More formally, removes an element <tt>e</tt> such
- * that <tt>o.equals(e)</tt>, if this queue contains one or more such
+ * if it is present. More formally, removes an element {@code e} such
+ * that {@code o.equals(e)}, if this queue contains one or more such
* elements.
- * Returns <tt>true</tt> if this queue contained the specified element
+ * Returns {@code true} if this queue contained the specified element
* (or equivalently, if this queue changed as a result of the call).
*
* @param o element to be removed from this queue, if present
- * @return <tt>true</tt> if this queue changed as a result of the call
+ * @return {@code true} if this queue changed as a result of the call
*/
public boolean remove(Object o) {
if (o == null) return false;
- boolean removed = false;
fullyLock();
try {
- Node<E> trail = head;
- Node<E> p = head.next;
- while (p != null) {
+ for (Node<E> trail = head, p = trail.next;
+ p != null;
+ trail = p, p = p.next) {
if (o.equals(p.item)) {
- removed = true;
- break;
+ unlink(p, trail);
+ return true;
}
- trail = p;
- p = p.next;
}
- if (removed) {
- p.item = null;
- trail.next = p.next;
- if (last == p)
- last = trail;
- if (count.getAndDecrement() == capacity)
- notFull.signalAll();
- }
+ return false;
} finally {
fullyUnlock();
}
- return removed;
}
/**
@@ -551,22 +596,22 @@
* <p>If this queue fits in the specified array with room to spare
* (i.e., the array has more elements than this queue), the element in
* the array immediately following the end of the queue is set to
- * <tt>null</tt>.
+ * {@code null}.
*
* <p>Like the {@link #toArray()} method, this method acts as bridge between
* array-based and collection-based APIs. Further, this method allows
* precise control over the runtime type of the output array, and may,
* under certain circumstances, be used to save allocation costs.
*
- * <p>Suppose <tt>x</tt> is a queue known to contain only strings.
+ * <p>Suppose {@code x} is a queue known to contain only strings.
* The following code can be used to dump the queue into a newly
- * allocated array of <tt>String</tt>:
+ * allocated array of {@code String}:
*
* <pre>
* String[] y = x.toArray(new String[0]);</pre>
*
- * Note that <tt>toArray(new Object[0])</tt> is identical in function to
- * <tt>toArray()</tt>.
+ * Note that {@code toArray(new Object[0])} is identical in function to
+ * {@code toArray()}.
*
* @param a the array into which the elements of the queue are to
* be stored, if it is big enough; otherwise, a new array of the
@@ -577,6 +622,7 @@
* this queue
* @throws NullPointerException if the specified array is null
*/
+ @SuppressWarnings("unchecked")
public <T> T[] toArray(T[] a) {
fullyLock();
try {
@@ -586,7 +632,7 @@
(a.getClass().getComponentType(), size);
int k = 0;
- for (Node p = head.next; p != null; p = p.next)
+ for (Node<E> p = head.next; p != null; p = p.next)
a[k++] = (T)p.item;
if (a.length > k)
a[k] = null;
@@ -612,11 +658,14 @@
public void clear() {
fullyLock();
try {
- head.next = null;
- assert head.item == null;
- last = head;
+ for (Node<E> p, h = head; (p = h.next) != null; h = p) {
+ h.next = h;
+ p.item = null;
+ }
+ head = last;
+ // assert head.item == null && head.next == null;
if (count.getAndSet(0) == capacity)
- notFull.signalAll();
+ notFull.signal();
} finally {
fullyUnlock();
}
@@ -629,30 +678,7 @@
* @throws IllegalArgumentException {@inheritDoc}
*/
public int drainTo(Collection<? super E> c) {
- if (c == null)
- throw new NullPointerException();
- if (c == this)
- throw new IllegalArgumentException();
- Node<E> first;
- fullyLock();
- try {
- first = head.next;
- head.next = null;
- assert head.item == null;
- last = head;
- if (count.getAndSet(0) == capacity)
- notFull.signalAll();
- } finally {
- fullyUnlock();
- }
- // Transfer the elements outside of locks
- int n = 0;
- for (Node<E> p = first; p != null; p = p.next) {
- c.add(p.item);
- p.item = null;
- ++n;
- }
- return n;
+ return drainTo(c, Integer.MAX_VALUE);
}
/**
@@ -666,34 +692,44 @@
throw new NullPointerException();
if (c == this)
throw new IllegalArgumentException();
- fullyLock();
+ boolean signalNotFull = false;
+ final ReentrantLock takeLock = this.takeLock;
+ takeLock.lock();
try {
- int n = 0;
- Node<E> p = head.next;
- while (p != null && n < maxElements) {
- c.add(p.item);
- p.item = null;
- p = p.next;
- ++n;
+ int n = Math.min(maxElements, count.get());
+ // count.get provides visibility to first n Nodes
+ Node<E> h = head;
+ int i = 0;
+ try {
+ while (i < n) {
+ Node<E> p = h.next;
+ c.add(p.item);
+ p.item = null;
+ h.next = h;
+ h = p;
+ ++i;
+ }
+ return n;
+ } finally {
+ // Restore invariants even if c.add() threw
+ if (i > 0) {
+ // assert h.item == null;
+ head = h;
+ signalNotFull = (count.getAndAdd(-i) == capacity);
+ }
}
- if (n != 0) {
- head.next = p;
- assert head.item == null;
- if (p == null)
- last = head;
- if (count.getAndAdd(-n) == capacity)
- notFull.signalAll();
- }
- return n;
} finally {
- fullyUnlock();
+ takeLock.unlock();
+ if (signalNotFull)
+ signalNotFull();
}
}
/**
* Returns an iterator over the elements in this queue in proper sequence.
- * The returned <tt>Iterator</tt> is a "weakly consistent" iterator that
- * will never throw {@link ConcurrentModificationException},
+ * The returned {@code Iterator} is a "weakly consistent" iterator that
+ * will never throw {@link java.util.ConcurrentModificationException
+ * ConcurrentModificationException},
* and guarantees to traverse elements as they existed upon
* construction of the iterator, and may (but is not guaranteed to)
* reflect any modifications subsequent to construction.
@@ -706,7 +742,7 @@
private class Itr implements Iterator<E> {
/*
- * Basic weak-consistent iterator. At all times hold the next
+ * Basic weakly-consistent iterator. At all times hold the next
* item to hand out so that if hasNext() reports true, we will
* still have it to return even if lost race with a take etc.
*/
@@ -715,17 +751,13 @@
private E currentElement;
Itr() {
- final ReentrantLock putLock = LinkedBlockingQueue.this.putLock;
- final ReentrantLock takeLock = LinkedBlockingQueue.this.takeLock;
- putLock.lock();
- takeLock.lock();
+ fullyLock();
try {
current = head.next;
if (current != null)
currentElement = current.item;
} finally {
- takeLock.unlock();
- putLock.unlock();
+ fullyUnlock();
}
}
@@ -733,54 +765,54 @@
return current != null;
}
+ /**
+ * Unlike other traversal methods, iterators need to handle:
+ * - dequeued nodes (p.next == p)
+ * - interior removed nodes (p.item == null)
+ */
+ private Node<E> nextNode(Node<E> p) {
+ Node<E> s = p.next;
+ if (p == s)
+ return head.next;
+ // Skip over removed nodes.
+ // May be necessary if multiple interior Nodes are removed.
+ while (s != null && s.item == null)
+ s = s.next;
+ return s;
+ }
+
public E next() {
- final ReentrantLock putLock = LinkedBlockingQueue.this.putLock;
- final ReentrantLock takeLock = LinkedBlockingQueue.this.takeLock;
- putLock.lock();
- takeLock.lock();
+ fullyLock();
try {
if (current == null)
throw new NoSuchElementException();
E x = currentElement;
lastRet = current;
- current = current.next;
- if (current != null)
- currentElement = current.item;
+ current = nextNode(current);
+ currentElement = (current == null) ? null : current.item;
return x;
} finally {
- takeLock.unlock();
- putLock.unlock();
+ fullyUnlock();
}
}
public void remove() {
if (lastRet == null)
throw new IllegalStateException();
- final ReentrantLock putLock = LinkedBlockingQueue.this.putLock;
- final ReentrantLock takeLock = LinkedBlockingQueue.this.takeLock;
- putLock.lock();
- takeLock.lock();
+ fullyLock();
try {
Node<E> node = lastRet;
lastRet = null;
- Node<E> trail = head;
- Node<E> p = head.next;
- while (p != null && p != node) {
- trail = p;
- p = p.next;
- }
- if (p == node) {
- p.item = null;
- trail.next = p.next;
- if (last == p)
- last = trail;
- int c = count.getAndDecrement();
- if (c == capacity)
- notFull.signalAll();
+ for (Node<E> trail = head, p = trail.next;
+ p != null;
+ trail = p, p = p.next) {
+ if (p == node) {
+ unlink(p, trail);
+ break;
+ }
}
} finally {
- takeLock.unlock();
- putLock.unlock();
+ fullyUnlock();
}
}
}
@@ -789,7 +821,7 @@
* Save the state to a stream (that is, serialize it).
*
* @serialData The capacity is emitted (int), followed by all of
- * its elements (each an <tt>Object</tt>) in the proper order,
+ * its elements (each an {@code Object}) in the proper order,
* followed by a null
* @param s the stream
*/
@@ -815,6 +847,7 @@
/**
* Reconstitute this queue instance from a stream (that is,
* deserialize it).
+ *
* @param s the stream
*/
private void readObject(java.io.ObjectInputStream s)
@@ -827,6 +860,7 @@
// Read in all elements and place in queue
for (;;) {
+ @SuppressWarnings("unchecked")
E item = (E)s.readObject();
if (item == null)
break;
--- a/jdk/src/share/classes/javax/swing/DefaultDesktopManager.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/javax/swing/DefaultDesktopManager.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -708,7 +708,7 @@
// update window if it's non-opaque
Window topLevel = SwingUtilities.getWindowAncestor(f);
Toolkit tk = Toolkit.getDefaultToolkit();
- if (!AWTAccessor.getWindowAccessor().isOpaque(topLevel) &&
+ if (!topLevel.isOpaque() &&
(tk instanceof SunToolkit) &&
((SunToolkit)tk).needUpdateWindow())
{
--- a/jdk/src/share/classes/javax/swing/RepaintManager.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/javax/swing/RepaintManager.java Tue Aug 04 08:01:03 2009 -0700
@@ -732,7 +732,7 @@
(Window)dirty :
SwingUtilities.getWindowAncestor(dirty);
if (window != null &&
- !AWTAccessor.getWindowAccessor().isOpaque(window))
+ !window.isOpaque())
{
windows.add(window);
}
@@ -996,7 +996,7 @@
// If the window is non-opaque, it's double-buffered at peer's level
Window w = (c instanceof Window) ? (Window)c : SwingUtilities.getWindowAncestor(c);
- if (!AWTAccessor.getWindowAccessor().isOpaque(w)) {
+ if (!w.isOpaque()) {
Toolkit tk = Toolkit.getDefaultToolkit();
if ((tk instanceof SunToolkit) && (((SunToolkit)tk).needUpdateWindow())) {
return null;
@@ -1032,7 +1032,7 @@
// If the window is non-opaque, it's double-buffered at peer's level
Window w = (c instanceof Window) ? (Window)c : SwingUtilities.getWindowAncestor(c);
- if (!AWTAccessor.getWindowAccessor().isOpaque(w)) {
+ if (!w.isOpaque()) {
Toolkit tk = Toolkit.getDefaultToolkit();
if ((tk instanceof SunToolkit) && (((SunToolkit)tk).needUpdateWindow())) {
return null;
--- a/jdk/src/share/classes/sun/awt/AWTAccessor.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/sun/awt/AWTAccessor.java Tue Aug 04 08:01:03 2009 -0700
@@ -137,11 +137,6 @@
*/
void setShape(Window window, Shape shape);
/*
- * Identify whether the given window is opaque (true)
- * or translucent (false).
- */
- boolean isOpaque(Window window);
- /*
* Set the opaque preoperty to the given window.
*/
void setOpaque(Window window, boolean isOpaque);
--- a/jdk/src/share/classes/sun/awt/SunToolkit.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/sun/awt/SunToolkit.java Tue Aug 04 08:01:03 2009 -0700
@@ -1985,8 +1985,7 @@
*/
public static boolean isContainingTopLevelOpaque(Component c) {
Window w = getContainingWindow(c);
- return w != null && ((Window)w).getBackground() != null &&
- ((Window)w).getBackground().getAlpha() == 255;
+ return w != null && w.isOpaque();
}
/**
--- a/jdk/src/share/classes/sun/net/www/http/HttpClient.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/sun/net/www/http/HttpClient.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1994-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1994-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/jdk/src/share/classes/sun/tools/jar/Main.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/classes/sun/tools/jar/Main.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/jdk/src/share/demo/jfc/Notepad/resources/Notepad_ja.properties Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/demo/jfc/Notepad/resources/Notepad_ja.properties Tue Aug 04 08:01:03 2009 -0700
@@ -9,7 +9,7 @@
#
# Each of the strings that follow form a key to be
# used to the actual menu definition.
-menubar=\u30d5\u30a1\u30a4\u30eb\u7de8\u96c6\u30c7\u30d0\u30c3\u30b0
+menubar=file edit debug
# file Menu definition
#
@@ -20,15 +20,15 @@
# new -> Notepad.newAction
# save -> Notepad.saveAction
# exit -> Notepad.exitAction
-file=\u65b0\u898f \u958b\u304f \u4fdd\u5b58 - \u7d42\u4e86
-fileLabel=\u30d5\u30a1\u30a4\u30eb (F)
+file=new open save - exit
+fileLabel=\u30d5\u30a1\u30a4\u30eb
openLabel=\u958b\u304f
openImage=resources/open.gif
newLabel=\u65b0\u898f
newImage=resources/new.gif
saveLabel=\u4fdd\u5b58
saveImage=resources/save.gif
-exitLabel=\u7d42\u4e86 (X)
+exitLabel=\u7d42\u4e86
#
# edit Menu definition
@@ -36,26 +36,26 @@
# cut -> JTextComponent.cutAction
# copy -> JTextComponent.copyAction
# paste -> JTextComponent.pasteAction
-edit=\u30ab\u30c3\u30c8 \u30b3\u30d4\u30fc \u30da\u30fc\u30b9\u30c8 - \u5143\u306b\u623b\u3059 \u518d\u5b9f\u884c
+edit=cut copy paste - undo redo
editLabel=\u7de8\u96c6
-cutLabel=Cut
+cutLabel=\u30ab\u30c3\u30c8
cutAction=cut-to-clipboard
cutImage=resources/cut.gif
-copyLabel=Copy
-copyAction=cut-to-clipboard
+copyLabel=\u30b3\u30d4\u30fc
+copyAction=copy-to-clipboard
copyImage=resources/copy.gif
-pasteLabel=Paste
+pasteLabel=\u30da\u30fc\u30b9\u30c8
pasteAction=paste-from-clipboard
pasteImage=resources/paste.gif
undoLabel=\u5143\u306b\u623b\u3059
-undoAction=\u5143\u306b\u623b\u3059
+undoAction=Undo
redoLabel=\u518d\u5b9f\u884c
-redoAction=\u518d\u5b9f\u884c
+redoAction=Redo
#
# debug Menu definition
#
-debug=showElementTree \u306e\u30c0\u30f3\u30d7
+debug=dump showElementTree
debugLabel=\u30c7\u30d0\u30c3\u30b0
dumpLabel=\u30e2\u30c7\u30eb\u3092 System.err \u306b\u30c0\u30f3\u30d7
dumpAction=dump-model
@@ -67,7 +67,7 @@
# used as the basis of the tool definition. Actions
# are of course sharable, and in this case are shared
# with the menu items.
-toolbar=\u65b0\u898f \u958b\u304f \u4fdd\u5b58 - \u30ab\u30c3\u30c8 \u30b3\u30d4\u30fc \u30da\u30fc\u30b9\u30c8
+toolbar=new open save - cut copy paste
newTooltip=\u30d5\u30a1\u30a4\u30eb\u3092\u65b0\u898f\u4f5c\u6210\u3059\u308b
openTooltip=\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u304f
saveTooltip=\u30d5\u30a1\u30a4\u30eb\u306b\u4fdd\u5b58
--- a/jdk/src/share/demo/jvmti/java_crw_demo/java_crw_demo.c Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/share/demo/jvmti/java_crw_demo/java_crw_demo.c Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
--- a/jdk/src/solaris/classes/sun/awt/X11/XBaseWindow.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XBaseWindow.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -1000,10 +1000,7 @@
int buttonState = 0;
final int buttonsNumber = ((SunToolkit)(Toolkit.getDefaultToolkit())).getNumberOfButtons();
for (int i = 0; i<buttonsNumber; i++){
- // A bug in WM implementation: extra buttons doesn't have state!=0 as they should on Release message.
- if ((i != 4) && (i != 5)){
- buttonState |= (xbe.get_state() & XConstants.buttonsMask[i]);
- }
+ buttonState |= (xbe.get_state() & XConstants.buttonsMask[i]);
}
switch (xev.get_type()) {
case XConstants.ButtonPress:
--- a/jdk/src/solaris/native/java/lang/UNIXProcess_md.c Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/solaris/native/java/lang/UNIXProcess_md.c Tue Aug 04 08:01:03 2009 -0700
@@ -447,14 +447,16 @@
}
/**
- * execvpe should have been included in the Unix standards.
- * execvpe is identical to execvp, except that the child environment is
+ * 'execvpe' should have been included in the Unix standards,
+ * and is a GNU extension in glibc 2.10.
+ *
+ * JDK_execvpe is identical to execvp, except that the child environment is
* specified via the 3rd argument instead of being inherited from environ.
*/
static void
-execvpe(const char *file,
- const char *argv[],
- const char *const envp[])
+JDK_execvpe(const char *file,
+ const char *argv[],
+ const char *const envp[])
{
/* This is one of the rare times it's more portable to declare an
* external symbol explicitly, rather than via a system header.
@@ -644,7 +646,7 @@
if (fcntl(FAIL_FILENO, F_SETFD, FD_CLOEXEC) == -1)
goto WhyCantJohnnyExec;
- execvpe(p->argv[0], p->argv, p->envv);
+ JDK_execvpe(p->argv[0], p->argv, p->envv);
WhyCantJohnnyExec:
/* We used to go to an awful lot of trouble to predict whether the
--- a/jdk/src/solaris/native/java/net/Inet4AddressImpl.c Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/solaris/native/java/net/Inet4AddressImpl.c Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/jdk/src/solaris/native/java/net/Inet6AddressImpl.c Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/solaris/native/java/net/Inet6AddressImpl.c Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/jdk/src/windows/classes/sun/awt/windows/WToolkit.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/windows/classes/sun/awt/windows/WToolkit.java Tue Aug 04 08:01:03 2009 -0700
@@ -886,14 +886,12 @@
* this should be done in lazilyLoadDesktopProperty() only.
*/
protected synchronized void initializeDesktopProperties() {
- desktopProperties.put("DnD.Autoscroll.initialDelay", Integer.valueOf(50));
- desktopProperties.put("DnD.Autoscroll.interval", Integer.valueOf(50));
-
- try {
- desktopProperties.put("Shell.shellFolderManager",
- Class.forName("sun.awt.shell.Win32ShellFolderManager2"));
- } catch (ClassNotFoundException ex) {
- }
+ desktopProperties.put("DnD.Autoscroll.initialDelay",
+ Integer.valueOf(50));
+ desktopProperties.put("DnD.Autoscroll.interval",
+ Integer.valueOf(50));
+ desktopProperties.put("Shell.shellFolderManager",
+ "sun.awt.shell.Win32ShellFolderManager2");
}
/*
--- a/jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java Tue Aug 04 08:01:03 2009 -0700
@@ -194,8 +194,7 @@
// default value of a boolean field is 'false', so set isOpaque to
// true here explicitly
this.isOpaque = true;
- Color bgColor = ((Window)target).getBackground();
- setOpaque((bgColor == null) || (bgColor.getAlpha() == 255));
+ setOpaque(((Window)target).isOpaque());
}
}
--- a/jdk/src/windows/classes/sun/nio/fs/WindowsConstants.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/windows/classes/sun/nio/fs/WindowsConstants.java Tue Aug 04 08:01:03 2009 -0700
@@ -92,6 +92,7 @@
public static final int ERROR_INVALID_DATA = 13;
public static final int ERROR_NOT_SAME_DEVICE = 17;
public static final int ERROR_NOT_READY = 21;
+ public static final int ERROR_SHARING_VIOLATION = 32;
public static final int ERROR_FILE_EXISTS = 80;
public static final int ERROR_INVALID_PARAMATER = 87;
public static final int ERROR_DISK_FULL = 112;
--- a/jdk/src/windows/classes/sun/nio/fs/WindowsFileAttributes.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/windows/classes/sun/nio/fs/WindowsFileAttributes.java Tue Aug 04 08:01:03 2009 -0700
@@ -299,6 +299,9 @@
throws WindowsException
{
if (!ensureAccurateMetadata) {
+ WindowsException firstException = null;
+
+ // GetFileAttributesEx is the fastest way to read the attributes
NativeBuffer buffer =
NativeBuffers.getNativeBuffer(SIZEOF_FILE_ATTRIBUTE_DATA);
try {
@@ -310,9 +313,39 @@
.getInt(address + OFFSETOF_FILE_ATTRIBUTE_DATA_ATTRIBUTES);
if ((fileAttrs & FILE_ATTRIBUTE_REPARSE_POINT) == 0)
return fromFileAttributeData(address, 0);
+ } catch (WindowsException x) {
+ if (x.lastError() != ERROR_SHARING_VIOLATION)
+ throw x;
+ firstException = x;
} finally {
buffer.release();
}
+
+ // For sharing violations, fallback to FindFirstFile if the file
+ // is not a root directory.
+ if (firstException != null) {
+ String search = path.getPathForWin32Calls();
+ char last = search.charAt(search.length() -1);
+ if (last == ':' || last == '\\')
+ throw firstException;
+ buffer = getBufferForFindData();
+ try {
+ long handle = FindFirstFile(search, buffer.address());
+ FindClose(handle);
+ WindowsFileAttributes attrs = fromFindData(buffer.address());
+ // FindFirstFile does not follow sym links. Even if
+ // followLinks is false, there isn't sufficient information
+ // in the WIN32_FIND_DATA structure to know if the reparse
+ // point is a sym link.
+ if (attrs.isReparsePoint())
+ throw firstException;
+ return attrs;
+ } catch (WindowsException ignore) {
+ throw firstException;
+ } finally {
+ buffer.release();
+ }
+ }
}
// file is reparse point so need to open file to get attributes
--- a/jdk/src/windows/native/java/lang/java_props_md.c Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/windows/native/java/lang/java_props_md.c Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/jdk/src/windows/native/sun/windows/ShellFolder2.cpp Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/src/windows/native/sun/windows/ShellFolder2.cpp Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -981,6 +981,15 @@
hBitmap = (HBITMAP)LoadImage(libShell32,
IS_WINVISTA ? TEXT("IDB_TB_SH_DEF_16") : MAKEINTRESOURCE(216),
IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
+
+ if (hBitmap == NULL) {
+ // version of shell32.dll doesn't match OS version.
+ // So we either are in a Vista Compatibility Mode
+ // or shell32.dll was copied from OS of another version
+ hBitmap = (HBITMAP)LoadImage(libShell32,
+ IS_WINVISTA ? MAKEINTRESOURCE(216) : TEXT("IDB_TB_SH_DEF_16"),
+ IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
+ }
}
if (hBitmap == NULL) {
libComCtl32 = LoadLibrary(TEXT("comctl32.dll"));
--- a/jdk/test/demo/jvmti/hprof/HelloWorld.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/test/demo/jvmti/hprof/HelloWorld.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2004-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2004-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/demo/jvmti/hprof/StackMapTableTest.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/test/demo/jvmti/hprof/StackMapTableTest.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Robot/CtorTest/CtorTest.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ @test
+ @bug 6855323
+ @summary Robot(GraphicsDevice) constructor initializes LEGAL_BUTTON_MASK variable improperly
+ @author Dmitry Cherepanov area=awt.robot
+ @run main CtorTest
+*/
+
+/**
+ * CtorRobot.java
+ *
+ * summary: creates Robot using one parameter constructor
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+
+import sun.awt.SunToolkit;
+
+public class CtorTest
+{
+ public static void main(String []s) throws Exception
+ {
+ // one parameter constructor
+ GraphicsDevice graphicsDevice = GraphicsEnvironment.
+ getLocalGraphicsEnvironment().getDefaultScreenDevice();
+ Robot robot = new Robot(graphicsDevice);
+ clickOnFrame(robot);
+ }
+
+ // generate mouse events
+ private static void clickOnFrame(Robot robot) {
+ Frame frame = new Frame();
+ frame.setBounds(100, 100, 100, 100);
+ frame.setVisible(true);
+
+ ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+
+ // click in the middle of the frame
+ robot.mouseMove(150, 150);
+ robot.delay(50);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.delay(50);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+ ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/TrayIcon/CtorTest/CtorTest.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ @test
+ @bug 6759726
+ @summary TrayIcon constructor throws NPE instead of documented IAE
+ @author Dmitry Cherepanov area=awt.tray
+ @run main CtorTest
+*/
+
+/**
+ * CtorTest.java
+ *
+ * summary: TrayIcon ctor throws IAE if image is null
+ */
+
+import java.awt.*;
+
+public class CtorTest
+{
+ public static void main(String []s)
+ {
+ boolean isSupported = SystemTray.isSupported();
+ if (isSupported) {
+ try {
+ TrayIcon tray = new TrayIcon(null);
+ } catch(IllegalArgumentException e) {
+ // ctor should throw IAE
+ }
+ }
+ }
+}
--- a/jdk/test/java/awt/Window/OwnedWindowsLeak/OwnedWindowsLeak.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/test/java/awt/Window/OwnedWindowsLeak/OwnedWindowsLeak.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -65,6 +65,7 @@
break;
}
}
+ garbage = null;
// Third, make sure all the weak references are null
for (WeakReference<Window> ref : children)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Window/SetBackgroundNPE/SetBackgroundNPE.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ @test
+ @bug 6853916
+ @summary Window.setBackground() should not throw NPE
+ @author anthony.petrov@sun.com: area=awt.toplevel
+ @run main SetBackgroundNPE
+*/
+
+import java.awt.Window;
+
+public class SetBackgroundNPE {
+ public static void main(String args[]) {
+ new Window(null).setBackground(null);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/event/MouseWheelEvent/DisabledComponent/DisabledComponent.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ @test
+ @bug 6847958
+ @library ../../../regtesthelpers
+ @summary MouseWheel event is getting triggered for the disabled Textarea in jdk7 b60 pit build.
+ @author Dmitry Cherepanov: area=awt.event
+ @build Util
+ @run main DisabledComponent
+*/
+
+/**
+ * DisabledComponent.java
+ *
+ * summary: Tests that wheel events aren't coming on disabled component
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+
+import sun.awt.SunToolkit;
+
+import test.java.awt.regtesthelpers.Util;
+
+public class DisabledComponent
+{
+
+ private static volatile boolean passed = true;
+
+ public static void main(String []s) throws Exception
+ {
+ Frame frame = new Frame();
+ frame.setBounds(100,100,400,400);
+ frame.setLayout(new FlowLayout());
+
+ TextArea textArea = new TextArea("TextArea", 6, 15);
+ frame.add(textArea);
+
+ List list = new List(3);
+ list.add("1");
+ list.add("2");
+ list.add("3");
+ frame.add(list);
+
+ MouseWheelListener listener = new MouseWheelListener(){
+ @Override
+ public void mouseWheelMoved(MouseWheelEvent mwe){
+ System.err.println(mwe);
+ passed = false;
+ }
+ };
+
+
+ list.addMouseWheelListener(listener);
+ textArea.addMouseWheelListener(listener);
+
+ frame.setVisible(true);
+ ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+
+ Robot robot = new Robot();
+
+ // point and wheel on the list
+ Util.pointOnComp(list, robot);
+ ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+
+ robot.mouseWheel(2);
+ ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+
+ // disable the text area
+ System.err.println(" disable text area ");
+ textArea.setEnabled(false);
+ passed = true;
+
+ // point and wheel on the text area
+ Util.pointOnComp(textArea, robot);
+ ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+
+ robot.mouseWheel(2);
+ ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+
+ if (!passed) {
+ throw new RuntimeException(" wrong wheel events ");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/Introspector/6380849/TestBeanInfo.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,102 @@
+/**
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6380849
+ * @summary Tests BeanInfo finder
+ * @author Sergey Malenkov
+ */
+
+import beans.FirstBean;
+import beans.FirstBeanBeanInfo;
+import beans.SecondBean;
+import beans.ThirdBean;
+
+import infos.SecondBeanBeanInfo;
+import infos.ThirdBeanBeanInfo;
+
+import java.beans.BeanInfo;
+import java.beans.Introspector;
+import java.lang.reflect.Field;
+
+import sun.awt.SunToolkit;
+
+public class TestBeanInfo implements Runnable {
+
+ private static final String[] SEARCH_PATH = { "infos" }; // NON-NLS: package name
+
+ public static void main(String[] args) throws InterruptedException {
+ TestBeanInfo test = new TestBeanInfo();
+ test.run();
+ // the following tests fails on previous build
+ ThreadGroup group = new ThreadGroup("$$$"); // NON-NLS: unique thread name
+ Thread thread = new Thread(group, test);
+ thread.start();
+ thread.join();
+ }
+
+ private static void test(Class<?> type, Class<? extends BeanInfo> expected) {
+ BeanInfo actual;
+ try {
+ actual = Introspector.getBeanInfo(type);
+ type = actual.getClass();
+ Field field = type.getDeclaredField("targetBeanInfo"); // NON-NLS: field name
+ field.setAccessible(true);
+ actual = (BeanInfo) field.get(actual);
+ }
+ catch (Exception exception) {
+ throw new Error("unexpected error", exception);
+ }
+ if ((actual == null) && (expected != null)) {
+ throw new Error("expected info is not found");
+ }
+ if ((actual != null) && !actual.getClass().equals(expected)) {
+ throw new Error("found unexpected info");
+ }
+ }
+
+ private boolean passed;
+
+ public void run() {
+ if (this.passed) {
+ SunToolkit.createNewAppContext();
+ }
+ Introspector.flushCaches();
+
+ test(FirstBean.class, FirstBeanBeanInfo.class);
+ test(SecondBean.class, null);
+ test(ThirdBean.class, null);
+ test(ThirdBeanBeanInfo.class, ThirdBeanBeanInfo.class);
+
+ Introspector.setBeanInfoSearchPath(SEARCH_PATH);
+ Introspector.flushCaches();
+
+ test(FirstBean.class, FirstBeanBeanInfo.class);
+ test(SecondBean.class, SecondBeanBeanInfo.class);
+ test(ThirdBean.class, null);
+ test(ThirdBeanBeanInfo.class, ThirdBeanBeanInfo.class);
+
+ this.passed = true;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/Introspector/6380849/beans/FirstBean.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,4 @@
+package beans;
+
+public class FirstBean {
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/Introspector/6380849/beans/FirstBeanBeanInfo.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,11 @@
+package beans;
+
+import java.beans.BeanDescriptor;
+import java.beans.SimpleBeanInfo;
+
+public class FirstBeanBeanInfo extends SimpleBeanInfo {
+ @Override
+ public BeanDescriptor getBeanDescriptor() {
+ return new BeanDescriptor(FirstBean.class);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/Introspector/6380849/beans/SecondBean.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,4 @@
+package beans;
+
+public class SecondBean {
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/Introspector/6380849/beans/ThirdBean.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,4 @@
+package beans;
+
+public class ThirdBean {
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/Introspector/6380849/infos/SecondBeanBeanInfo.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,13 @@
+package infos;
+
+import beans.SecondBean;
+
+import java.beans.BeanDescriptor;
+import java.beans.SimpleBeanInfo;
+
+public class SecondBeanBeanInfo extends SimpleBeanInfo {
+ @Override
+ public BeanDescriptor getBeanDescriptor() {
+ return new BeanDescriptor(SecondBean.class);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/Introspector/6380849/infos/ThirdBeanBeanInfo.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,11 @@
+package infos;
+
+import java.beans.BeanDescriptor;
+import java.beans.SimpleBeanInfo;
+
+public class ThirdBeanBeanInfo extends SimpleBeanInfo {
+ @Override
+ public BeanDescriptor getBeanDescriptor() {
+ return new BeanDescriptor(ThirdBeanBeanInfo.class);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/Introspector/Test6723447.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6723447
+ * @summary Tests return type for property setters
+ * @author Sergey Malenkov
+ */
+
+import java.beans.IndexedPropertyDescriptor;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Method;
+import java.math.BigDecimal;
+
+public class Test6723447 {
+
+ public static void main(String[] args) {
+ test(Test6723447.class);
+ test(BigDecimal.class);
+ }
+
+ private static void test(Class<?> type) {
+ for (PropertyDescriptor pd : getPropertyDescriptors(type)) {
+ test(pd.getWriteMethod());
+ if (pd instanceof IndexedPropertyDescriptor) {
+ IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor) pd;
+ test(ipd.getIndexedWriteMethod());
+ }
+ }
+ }
+
+ private static void test(Method method) {
+ if (method != null) {
+ Class<?> type = method.getReturnType();
+ if (!type.equals(void.class)) {
+ throw new Error("unexpected return type: " + type);
+ }
+ }
+ }
+
+ private static PropertyDescriptor[] getPropertyDescriptors(Class<?> type) {
+ try {
+ return Introspector.getBeanInfo(type).getPropertyDescriptors();
+ }
+ catch (IntrospectionException exception) {
+ throw new Error("unexpected exception", exception);
+ }
+ }
+
+ public Object getValue() {
+ return null;
+ }
+
+ public Object setValue(Object value) {
+ return value;
+ }
+
+ public Object getValues(int index) {
+ return null;
+ }
+
+ public Object setValues(int index, Object value) {
+ return value;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/PropertyEditor/6380849/FirstBean.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,2 @@
+public class FirstBean {
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/PropertyEditor/6380849/FirstBeanEditor.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,4 @@
+import java.beans.PropertyEditorSupport;
+
+public class FirstBeanEditor extends PropertyEditorSupport {
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/PropertyEditor/6380849/SecondBean.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,2 @@
+public class SecondBean {
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/PropertyEditor/6380849/TestPropertyEditor.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,141 @@
+/**
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6380849
+ * @summary Tests PropertyEditor finder
+ * @author Sergey Malenkov
+ */
+
+import editors.SecondBeanEditor;
+import editors.ThirdBeanEditor;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.beans.PropertyEditor;
+import java.beans.PropertyEditorManager;
+
+import sun.awt.SunToolkit;
+import sun.beans.editors.BooleanEditor;
+import sun.beans.editors.ByteEditor;
+import sun.beans.editors.ColorEditor;
+import sun.beans.editors.DoubleEditor;
+import sun.beans.editors.EnumEditor;
+import sun.beans.editors.FloatEditor;
+import sun.beans.editors.FontEditor;
+import sun.beans.editors.IntegerEditor;
+import sun.beans.editors.LongEditor;
+import sun.beans.editors.ShortEditor;
+import sun.beans.editors.StringEditor;
+
+public class TestPropertyEditor implements Runnable {
+
+ private enum Enumeration {
+ FIRST, SECOND, THIRD
+ }
+
+ private static final String[] SEARCH_PATH = { "editors" }; // NON-NLS: package name
+
+ public static void main(String[] args) throws InterruptedException {
+ TestPropertyEditor test = new TestPropertyEditor();
+ test.run();
+ // the following tests fails on previous build
+ ThreadGroup group = new ThreadGroup("$$$"); // NON-NLS: unique thread name
+ Thread thread = new Thread(group, test);
+ thread.start();
+ thread.join();
+ }
+
+ private static void test(Class<?> type, Class<? extends PropertyEditor> expected) {
+ PropertyEditor actual = PropertyEditorManager.findEditor(type);
+ if ((actual == null) && (expected != null)) {
+ throw new Error("expected editor is not found");
+ }
+ if ((actual != null) && !actual.getClass().equals(expected)) {
+ throw new Error("found unexpected editor");
+ }
+ }
+
+ private boolean passed;
+
+ public void run() {
+ if (this.passed) {
+ SunToolkit.createNewAppContext();
+ }
+ PropertyEditorManager.registerEditor(ThirdBean.class, ThirdBeanEditor.class);
+
+ test(FirstBean.class, FirstBeanEditor.class);
+ test(SecondBean.class, null);
+ test(ThirdBean.class, ThirdBeanEditor.class);
+ // test editors for default primitive types
+ test(Byte.TYPE, ByteEditor.class);
+ test(Short.TYPE, ShortEditor.class);
+ test(Integer.TYPE, IntegerEditor.class);
+ test(Long.TYPE, LongEditor.class);
+ test(Boolean.TYPE, BooleanEditor.class);
+ test(Float.TYPE, FloatEditor.class);
+ test(Double.TYPE, DoubleEditor.class);
+ // test editors for default object types
+ test(Byte.class, ByteEditor.class);
+ test(Short.class, ShortEditor.class);
+ test(Integer.class, IntegerEditor.class);
+ test(Long.class, LongEditor.class);
+ test(Boolean.class, BooleanEditor.class);
+ test(Float.class, FloatEditor.class);
+ test(Double.class, DoubleEditor.class);
+ test(String.class, StringEditor.class);
+ test(Color.class, ColorEditor.class);
+ test(Font.class, FontEditor.class);
+ test(Enumeration.class, EnumEditor.class);
+
+ PropertyEditorManager.registerEditor(ThirdBean.class, null);
+ PropertyEditorManager.setEditorSearchPath(SEARCH_PATH);
+
+ test(FirstBean.class, FirstBeanEditor.class);
+ test(SecondBean.class, SecondBeanEditor.class);
+ test(ThirdBean.class, ThirdBeanEditor.class);
+ // test editors for default primitive types
+ test(Byte.TYPE, ByteEditor.class);
+ test(Short.TYPE, ShortEditor.class);
+ test(Integer.TYPE, IntegerEditor.class);
+ test(Long.TYPE, LongEditor.class);
+ test(Boolean.TYPE, BooleanEditor.class);
+ test(Float.TYPE, FloatEditor.class);
+ test(Double.TYPE, DoubleEditor.class);
+ // test editors for default object types
+ test(Byte.class, null);
+ test(Short.class, null);
+ test(Integer.class, null);
+ test(Long.class, null);
+ test(Boolean.class, null);
+ test(Float.class, null);
+ test(Double.class, null);
+ test(String.class, null);
+ test(Color.class, null);
+ test(Font.class, null);
+ test(Enumeration.class, EnumEditor.class);
+
+ this.passed = true;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/PropertyEditor/6380849/ThirdBean.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,2 @@
+public class ThirdBean {
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/PropertyEditor/6380849/editors/SecondBeanEditor.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,6 @@
+package editors;
+
+import java.beans.PropertyEditorSupport;
+
+public class SecondBeanEditor extends PropertyEditorSupport {
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/PropertyEditor/6380849/editors/ThirdBeanEditor.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,6 @@
+package editors;
+
+import java.beans.PropertyEditorSupport;
+
+public class ThirdBeanEditor extends PropertyEditorSupport {
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/XMLEncoder/6329581/Test6329581.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6329581
+ * @summary Tests encoding of a class with custom ClassLoader
+ * @author Sergey Malenkov
+ */
+
+import java.beans.ExceptionListener;
+import java.beans.XMLDecoder;
+import java.beans.XMLEncoder;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+public class Test6329581 implements ExceptionListener {
+
+ public static void main(String[] args) throws Exception {
+ ExceptionListener listener = new Test6329581();
+ // write bean to byte array
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ XMLEncoder encoder = new XMLEncoder(out);
+ encoder.setExceptionListener(listener);
+ encoder.writeObject(getClassLoader("beans.jar").loadClass("test.Bean").newInstance());
+ encoder.close();
+ // read bean from byte array
+ ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
+ XMLDecoder decoder = new XMLDecoder(in, null, listener, getClassLoader("beans.jar"));
+ Object object = decoder.readObject();
+ decoder.close();
+
+ if (!object.getClass().getClassLoader().getClass().equals(URLClassLoader.class)) {
+ throw new Error("bean is loaded with unexpected class loader");
+ }
+ }
+
+ private static ClassLoader getClassLoader(String name) throws Exception {
+ StringBuilder sb = new StringBuilder(256);
+ sb.append("file:");
+ sb.append(System.getProperty("test.src", "."));
+ sb.append(File.separatorChar);
+ sb.append(name);
+
+ URL[] url = { new URL(sb.toString()) };
+ return new URLClassLoader(url);
+ }
+
+ public void exceptionThrown(Exception exception) {
+ throw new Error("unexpected exception", exception);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/XMLEncoder/6380849/Bean.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,2 @@
+public class Bean {
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/XMLEncoder/6380849/BeanPersistenceDelegate.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,5 @@
+import java.beans.DefaultPersistenceDelegate;
+
+public class BeanPersistenceDelegate
+ extends DefaultPersistenceDelegate {
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/XMLEncoder/6380849/TestPersistenceDelegate.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,60 @@
+/**
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6380849
+ * @summary Tests PersistenceDelegate finder
+ * @author Sergey Malenkov
+ */
+
+import java.beans.PersistenceDelegate;
+import java.beans.XMLEncoder;
+import java.beans.DefaultPersistenceDelegate;
+
+public class TestPersistenceDelegate {
+
+ private static final XMLEncoder ENCODER = new XMLEncoder(System.out);
+
+ public static void main(String[] args) throws InterruptedException {
+ Class<?> type = TestPersistenceDelegate.class;
+ test(type, DefaultPersistenceDelegate.class);
+ ENCODER.setPersistenceDelegate(type, new BeanPersistenceDelegate());
+ test(type, BeanPersistenceDelegate.class);
+ ENCODER.setPersistenceDelegate(type, null);
+ test(type, DefaultPersistenceDelegate.class);
+ // the following tests fails on previous build
+ test(Bean.class, BeanPersistenceDelegate.class);
+ test(BeanPersistenceDelegate.class, BeanPersistenceDelegate.class);
+ }
+
+ private static void test(Class<?> type, Class<? extends PersistenceDelegate> expected) {
+ PersistenceDelegate actual = ENCODER.getPersistenceDelegate(type);
+ if ((actual == null) && (expected != null)) {
+ throw new Error("expected delegate is not found");
+ }
+ if ((actual != null) && !actual.getClass().equals(expected)) {
+ throw new Error("found unexpected delegate");
+ }
+ }
+}
--- a/jdk/test/java/nio/channels/DatagramChannel/BasicMulticastTests.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/test/java/nio/channels/DatagramChannel/BasicMulticastTests.java Tue Aug 04 08:01:03 2009 -0700
@@ -25,6 +25,7 @@
* @bug 4527345
* @summary Unit test for DatagramChannel's multicast support
* @build BasicMulticastTests NetworkConfiguration
+ * @run main BasicMulticastTests
*/
import java.nio.ByteBuffer;
--- a/jdk/test/java/nio/channels/DatagramChannel/MulticastSendReceiveTests.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/test/java/nio/channels/DatagramChannel/MulticastSendReceiveTests.java Tue Aug 04 08:01:03 2009 -0700
@@ -25,6 +25,7 @@
* @bug 4527345
* @summary Unit test for DatagramChannel's multicast support
* @build MulticastSendReceiveTests NetworkConfiguration
+ * @run main MulticastSendReceiveTests
*/
import java.nio.ByteBuffer;
--- a/jdk/test/java/nio/file/Files/ContentType.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/test/java/nio/file/Files/ContentType.java Tue Aug 04 08:01:03 2009 -0700
@@ -26,6 +26,7 @@
* @summary Unit test for probeContentType method
* @library ..
* @build ContentType SimpleFileTypeDetector
+ * @run main ContentType
*/
import java.nio.file.*;
--- a/jdk/test/java/nio/file/Path/Misc.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/test/java/nio/file/Path/Misc.java Tue Aug 04 08:01:03 2009 -0700
@@ -22,7 +22,7 @@
*/
/* @test
- * @bug 4313887 6838333
+ * @bug 4313887 6838333 6866804
* @summary Unit test for java.nio.file.Path for miscellenous methods not
* covered by other tests
* @library ..
@@ -107,6 +107,28 @@
dir.checkAccess(AccessMode.READ, AccessMode.WRITE);
/**
+ * Test: Check access to all files in all root directories.
+ * (A useful test on Windows for special files such as pagefile.sys)
+ */
+ for (Path root: FileSystems.getDefault().getRootDirectories()) {
+ DirectoryStream<Path> stream;
+ try {
+ stream = root.newDirectoryStream();
+ } catch (IOException x) {
+ continue; // skip root directories that aren't accessible
+ }
+ try {
+ for (Path entry: stream) {
+ try {
+ entry.checkAccess();
+ } catch (AccessDeniedException ignore) { }
+ }
+ } finally {
+ stream.close();
+ }
+ }
+
+ /**
* Test: File does not exist
*/
Path doesNotExist = dir.resolve("thisDoesNotExists");
--- a/jdk/test/java/util/Collection/MOAT.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/test/java/util/Collection/MOAT.java Tue Aug 04 08:01:03 2009 -0700
@@ -426,6 +426,36 @@
q.poll();
equal(q.size(), 4);
checkFunctionalInvariants(q);
+ if ((q instanceof LinkedBlockingQueue) ||
+ (q instanceof LinkedBlockingDeque) ||
+ (q instanceof ConcurrentLinkedQueue)) {
+ testQueueIteratorRemove(q);
+ }
+ }
+
+ private static void testQueueIteratorRemove(Queue<Integer> q) {
+ System.err.printf("testQueueIteratorRemove %s%n",
+ q.getClass().getSimpleName());
+ q.clear();
+ for (int i = 0; i < 5; i++)
+ q.add(i);
+ Iterator<Integer> it = q.iterator();
+ check(it.hasNext());
+ for (int i = 3; i >= 0; i--)
+ q.remove(i);
+ equal(it.next(), 0);
+ equal(it.next(), 4);
+
+ q.clear();
+ for (int i = 0; i < 5; i++)
+ q.add(i);
+ it = q.iterator();
+ equal(it.next(), 0);
+ check(it.hasNext());
+ for (int i = 1; i < 4; i++)
+ q.remove(i);
+ equal(it.next(), 1);
+ equal(it.next(), 4);
}
private static void testList(final List<Integer> l) {
@@ -451,6 +481,11 @@
}
private static void testCollection(Collection<Integer> c) {
+ try { testCollection1(c); }
+ catch (Throwable t) { unexpected(t); }
+ }
+
+ private static void testCollection1(Collection<Integer> c) {
System.out.println("\n==> " + c.getClass().getName());
--- a/jdk/test/java/util/Formatter/Basic-X.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/test/java/util/Formatter/Basic-X.java Tue Aug 04 08:01:03 2009 -0700
@@ -486,6 +486,10 @@
//---------------------------------------------------------------------
tryCatch("%-s", MissingFormatWidthException.class);
tryCatch("%--s", DuplicateFormatFlagsException.class);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0.5f);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, "hello");
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, null);
//---------------------------------------------------------------------
// %h
--- a/jdk/test/java/util/Formatter/Basic.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/test/java/util/Formatter/Basic.java Tue Aug 04 08:01:03 2009 -0700
@@ -25,7 +25,7 @@
* @summary Unit test for formatter
* @bug 4906370 4962433 4973103 4989961 5005818 5031150 4970931 4989491 5002937
* 5005104 5007745 5061412 5055180 5066788 5088703 6317248 6318369 6320122
- * 6344623 6369500 6534606 6282094 6286592 6476425
+ * 6344623 6369500 6534606 6282094 6286592 6476425 5063507
*
* @run shell/timeout=240 Basic.sh
*/
--- a/jdk/test/java/util/Formatter/BasicBigDecimal.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/test/java/util/Formatter/BasicBigDecimal.java Tue Aug 04 08:01:03 2009 -0700
@@ -486,6 +486,10 @@
//---------------------------------------------------------------------
tryCatch("%-s", MissingFormatWidthException.class);
tryCatch("%--s", DuplicateFormatFlagsException.class);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0.5f);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, "hello");
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, null);
//---------------------------------------------------------------------
// %h
--- a/jdk/test/java/util/Formatter/BasicBigInteger.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/test/java/util/Formatter/BasicBigInteger.java Tue Aug 04 08:01:03 2009 -0700
@@ -486,6 +486,10 @@
//---------------------------------------------------------------------
tryCatch("%-s", MissingFormatWidthException.class);
tryCatch("%--s", DuplicateFormatFlagsException.class);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0.5f);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, "hello");
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, null);
//---------------------------------------------------------------------
// %h
--- a/jdk/test/java/util/Formatter/BasicBoolean.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/test/java/util/Formatter/BasicBoolean.java Tue Aug 04 08:01:03 2009 -0700
@@ -486,6 +486,10 @@
//---------------------------------------------------------------------
tryCatch("%-s", MissingFormatWidthException.class);
tryCatch("%--s", DuplicateFormatFlagsException.class);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0.5f);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, "hello");
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, null);
//---------------------------------------------------------------------
// %h
--- a/jdk/test/java/util/Formatter/BasicBooleanObject.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/test/java/util/Formatter/BasicBooleanObject.java Tue Aug 04 08:01:03 2009 -0700
@@ -486,6 +486,10 @@
//---------------------------------------------------------------------
tryCatch("%-s", MissingFormatWidthException.class);
tryCatch("%--s", DuplicateFormatFlagsException.class);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0.5f);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, "hello");
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, null);
//---------------------------------------------------------------------
// %h
--- a/jdk/test/java/util/Formatter/BasicByte.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/test/java/util/Formatter/BasicByte.java Tue Aug 04 08:01:03 2009 -0700
@@ -486,6 +486,10 @@
//---------------------------------------------------------------------
tryCatch("%-s", MissingFormatWidthException.class);
tryCatch("%--s", DuplicateFormatFlagsException.class);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0.5f);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, "hello");
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, null);
//---------------------------------------------------------------------
// %h
--- a/jdk/test/java/util/Formatter/BasicByteObject.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/test/java/util/Formatter/BasicByteObject.java Tue Aug 04 08:01:03 2009 -0700
@@ -486,6 +486,10 @@
//---------------------------------------------------------------------
tryCatch("%-s", MissingFormatWidthException.class);
tryCatch("%--s", DuplicateFormatFlagsException.class);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0.5f);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, "hello");
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, null);
//---------------------------------------------------------------------
// %h
--- a/jdk/test/java/util/Formatter/BasicChar.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/test/java/util/Formatter/BasicChar.java Tue Aug 04 08:01:03 2009 -0700
@@ -486,6 +486,10 @@
//---------------------------------------------------------------------
tryCatch("%-s", MissingFormatWidthException.class);
tryCatch("%--s", DuplicateFormatFlagsException.class);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0.5f);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, "hello");
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, null);
//---------------------------------------------------------------------
// %h
--- a/jdk/test/java/util/Formatter/BasicCharObject.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/test/java/util/Formatter/BasicCharObject.java Tue Aug 04 08:01:03 2009 -0700
@@ -486,6 +486,10 @@
//---------------------------------------------------------------------
tryCatch("%-s", MissingFormatWidthException.class);
tryCatch("%--s", DuplicateFormatFlagsException.class);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0.5f);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, "hello");
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, null);
//---------------------------------------------------------------------
// %h
--- a/jdk/test/java/util/Formatter/BasicDateTime.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/test/java/util/Formatter/BasicDateTime.java Tue Aug 04 08:01:03 2009 -0700
@@ -486,6 +486,10 @@
//---------------------------------------------------------------------
tryCatch("%-s", MissingFormatWidthException.class);
tryCatch("%--s", DuplicateFormatFlagsException.class);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0.5f);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, "hello");
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, null);
//---------------------------------------------------------------------
// %h
--- a/jdk/test/java/util/Formatter/BasicDouble.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/test/java/util/Formatter/BasicDouble.java Tue Aug 04 08:01:03 2009 -0700
@@ -486,6 +486,10 @@
//---------------------------------------------------------------------
tryCatch("%-s", MissingFormatWidthException.class);
tryCatch("%--s", DuplicateFormatFlagsException.class);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0.5f);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, "hello");
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, null);
//---------------------------------------------------------------------
// %h
--- a/jdk/test/java/util/Formatter/BasicDoubleObject.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/test/java/util/Formatter/BasicDoubleObject.java Tue Aug 04 08:01:03 2009 -0700
@@ -486,6 +486,10 @@
//---------------------------------------------------------------------
tryCatch("%-s", MissingFormatWidthException.class);
tryCatch("%--s", DuplicateFormatFlagsException.class);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0.5f);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, "hello");
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, null);
//---------------------------------------------------------------------
// %h
--- a/jdk/test/java/util/Formatter/BasicFloat.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/test/java/util/Formatter/BasicFloat.java Tue Aug 04 08:01:03 2009 -0700
@@ -486,6 +486,10 @@
//---------------------------------------------------------------------
tryCatch("%-s", MissingFormatWidthException.class);
tryCatch("%--s", DuplicateFormatFlagsException.class);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0.5f);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, "hello");
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, null);
//---------------------------------------------------------------------
// %h
--- a/jdk/test/java/util/Formatter/BasicFloatObject.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/test/java/util/Formatter/BasicFloatObject.java Tue Aug 04 08:01:03 2009 -0700
@@ -486,6 +486,10 @@
//---------------------------------------------------------------------
tryCatch("%-s", MissingFormatWidthException.class);
tryCatch("%--s", DuplicateFormatFlagsException.class);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0.5f);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, "hello");
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, null);
//---------------------------------------------------------------------
// %h
--- a/jdk/test/java/util/Formatter/BasicInt.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/test/java/util/Formatter/BasicInt.java Tue Aug 04 08:01:03 2009 -0700
@@ -486,6 +486,10 @@
//---------------------------------------------------------------------
tryCatch("%-s", MissingFormatWidthException.class);
tryCatch("%--s", DuplicateFormatFlagsException.class);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0.5f);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, "hello");
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, null);
//---------------------------------------------------------------------
// %h
--- a/jdk/test/java/util/Formatter/BasicIntObject.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/test/java/util/Formatter/BasicIntObject.java Tue Aug 04 08:01:03 2009 -0700
@@ -486,6 +486,10 @@
//---------------------------------------------------------------------
tryCatch("%-s", MissingFormatWidthException.class);
tryCatch("%--s", DuplicateFormatFlagsException.class);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0.5f);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, "hello");
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, null);
//---------------------------------------------------------------------
// %h
--- a/jdk/test/java/util/Formatter/BasicLong.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/test/java/util/Formatter/BasicLong.java Tue Aug 04 08:01:03 2009 -0700
@@ -486,6 +486,10 @@
//---------------------------------------------------------------------
tryCatch("%-s", MissingFormatWidthException.class);
tryCatch("%--s", DuplicateFormatFlagsException.class);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0.5f);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, "hello");
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, null);
//---------------------------------------------------------------------
// %h
--- a/jdk/test/java/util/Formatter/BasicLongObject.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/test/java/util/Formatter/BasicLongObject.java Tue Aug 04 08:01:03 2009 -0700
@@ -486,6 +486,10 @@
//---------------------------------------------------------------------
tryCatch("%-s", MissingFormatWidthException.class);
tryCatch("%--s", DuplicateFormatFlagsException.class);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0.5f);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, "hello");
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, null);
//---------------------------------------------------------------------
// %h
--- a/jdk/test/java/util/Formatter/BasicShort.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/test/java/util/Formatter/BasicShort.java Tue Aug 04 08:01:03 2009 -0700
@@ -486,6 +486,10 @@
//---------------------------------------------------------------------
tryCatch("%-s", MissingFormatWidthException.class);
tryCatch("%--s", DuplicateFormatFlagsException.class);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0.5f);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, "hello");
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, null);
//---------------------------------------------------------------------
// %h
--- a/jdk/test/java/util/Formatter/BasicShortObject.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/test/java/util/Formatter/BasicShortObject.java Tue Aug 04 08:01:03 2009 -0700
@@ -486,6 +486,10 @@
//---------------------------------------------------------------------
tryCatch("%-s", MissingFormatWidthException.class);
tryCatch("%--s", DuplicateFormatFlagsException.class);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0.5f);
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, "hello");
+ tryCatch("%#s", FormatFlagsConversionMismatchException.class, null);
//---------------------------------------------------------------------
// %h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/TimSort/ArrayBuilder.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,142 @@
+/*
+ * Copyright 2009 Google Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+import java.util.Random;
+import java.math.BigInteger;
+
+public enum ArrayBuilder {
+
+ // These seven are from Tim's paper (listsort.txt)
+
+ RANDOM_INT {
+ public Object[] build(int len) {
+ Integer[] result = new Integer[len];
+ for (int i = 0; i < len; i++)
+ result[i] = rnd.nextInt();
+ return result;
+ }
+ },
+
+ DESCENDING_INT {
+ public Object[] build(int len) {
+ Integer[] result = new Integer[len];
+ for (int i = 0; i < len; i++)
+ result[i] = len - i;
+ return result;
+ }
+ },
+
+ ASCENDING_INT {
+ public Object[] build(int len) {
+ Integer[] result = new Integer[len];
+ for (int i = 0; i < len; i++)
+ result[i] = i;
+ return result;
+ }
+ },
+
+ ASCENDING_3_RND_EXCH_INT {
+ public Object[] build(int len) {
+ Integer[] result = new Integer[len];
+ for (int i = 0; i < len; i++)
+ result[i] = i;
+ for (int i = 0; i < 3; i++)
+ swap(result, rnd.nextInt(result.length),
+ rnd.nextInt(result.length));
+ return result;
+ }
+ },
+
+ ASCENDING_10_RND_AT_END_INT {
+ public Object[] build(int len) {
+ Integer[] result = new Integer[len];
+ int endStart = len - 10;
+ for (int i = 0; i < endStart; i++)
+ result[i] = i;
+ for (int i = endStart; i < len; i++)
+ result[i] = rnd.nextInt(endStart + 10);
+ return result;
+ }
+ },
+
+ ALL_EQUAL_INT {
+ public Object[] build(int len) {
+ Integer[] result = new Integer[len];
+ for (int i = 0; i < len; i++)
+ result[i] = 666;
+ return result;
+ }
+ },
+
+ DUPS_GALORE_INT {
+ public Object[] build(int len) {
+ Integer[] result = new Integer[len];
+ for (int i = 0; i < len; i++)
+ result[i] = rnd.nextInt(4);
+ return result;
+ }
+ },
+
+ RANDOM_WITH_DUPS_INT {
+ public Object[] build(int len) {
+ Integer[] result = new Integer[len];
+ for (int i = 0; i < len; i++)
+ result[i] = rnd.nextInt(len);
+ return result;
+ }
+ },
+
+ PSEUDO_ASCENDING_STRING {
+ public String[] build(int len) {
+ String[] result = new String[len];
+ for (int i = 0; i < len; i++)
+ result[i] = Integer.toString(i);
+ return result;
+ }
+ },
+
+ RANDOM_BIGINT {
+ public BigInteger[] build(int len) {
+ BigInteger[] result = new BigInteger[len];
+ for (int i = 0; i < len; i++)
+ result[i] = HUGE.add(BigInteger.valueOf(rnd.nextInt(len)));
+ return result;
+ }
+ };
+
+ public abstract Object[] build(int len);
+
+ public void resetRandom() {
+ rnd = new Random(666);
+ }
+
+ private static Random rnd = new Random(666);
+
+ private static void swap(Object[] a, int i, int j) {
+ Object t = a[i];
+ a[i] = a[j];
+ a[j] = t;
+ }
+
+ private static BigInteger HUGE = BigInteger.ONE.shiftLeft(100);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/TimSort/README Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,4 @@
+This directory contains benchmark programs used to compare the
+performance of the TimSort algorithm against the historic 1997
+implementation of Arrays.sort. Any future benchmarking will require
+minor modifications.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/TimSort/SortPerf.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2009 Google Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+import java.util.Arrays;
+
+public class SortPerf {
+ private static final int NUM_SETS = 5;
+ private static final int[] lengths = { 10, 100, 1000, 10000, 1000000 };
+
+ // Returns the number of repetitions as a function of the list length
+ private static int reps(int n) {
+ return (int) (12000000 / (n * Math.log10(n)));
+ }
+
+ public static void main(String[] args) {
+ Sorter.warmup();
+
+ System.out.print("Strategy,Length");
+ for (Sorter sorter : Sorter.values())
+ System.out.print("," + sorter);
+ System.out.println();
+
+ for (ArrayBuilder ab : ArrayBuilder.values()) {
+ for (int n : lengths) {
+ System.out.printf("%s,%d", ab, n);
+ int reps = reps(n);
+ Object[] proto = ab.build(n);
+ for (Sorter sorter : Sorter.values()) {
+ double minTime = Double.POSITIVE_INFINITY;
+ for (int set = 0; set < NUM_SETS; set++) {
+ long startTime = System.nanoTime();
+ for (int k = 0; k < reps; k++) {
+ Object[] a = proto.clone();
+ sorter.sort(a);
+ }
+ long endTime = System.nanoTime();
+ double time = (endTime - startTime) / (1000000. * reps);
+ minTime = Math.min(minTime, time);
+ }
+ System.out.printf(",%5f", minTime);
+ }
+ System.out.println();
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/TimSort/Sorter.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2009 Google Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+import java.util.*;
+
+public enum Sorter {
+ TIMSORT {
+ public void sort(Object[] array) {
+ ComparableTimSort.sort(array);
+ }
+ },
+ MERGESORT {
+ public void sort(Object[] array) {
+ Arrays.sort(array);
+ }
+ };
+
+ public abstract void sort(Object[] array);
+
+ public static void warmup() {
+ System.out.println("start warm up");
+ Integer[] gold = new Integer[10000];
+ Random random = new java.util.Random();
+ for (int i=0; i < gold.length; i++)
+ gold[i] = random.nextInt();
+
+ for (int i=0; i < 10000; i++) {
+ for (Sorter s : values()) {
+ Integer[] test= gold.clone();
+ s.sort(test);
+ }
+ }
+ System.out.println(" end warm up");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/concurrent/BlockingQueue/OfferDrainToLoops.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,130 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Written by Doug Lea with assistance from members of JCP JSR-166
+ * Expert Group and released to the public domain, as explained at
+ * http://creativecommons.org/licenses/publicdomain
+ */
+
+/*
+ * @test
+ * @bug 6805775 6815766
+ * @summary Test concurrent offer vs. drainTo
+ */
+
+import java.util.*;
+import java.util.concurrent.*;
+
+@SuppressWarnings({"unchecked", "rawtypes"})
+public class OfferDrainToLoops {
+ void checkNotContainsNull(Iterable it) {
+ for (Object x : it)
+ check(x != null);
+ }
+
+ abstract class CheckedThread extends Thread {
+ abstract protected void realRun();
+ public void run() {
+ try { realRun(); } catch (Throwable t) { unexpected(t); }
+ }
+ {
+ setDaemon(true);
+ start();
+ }
+ }
+
+ void test(String[] args) throws Throwable {
+ test(new LinkedBlockingQueue());
+ test(new LinkedBlockingQueue(2000));
+ test(new LinkedBlockingDeque());
+ test(new LinkedBlockingDeque(2000));
+ test(new ArrayBlockingQueue(2000));
+ }
+
+ void test(final BlockingQueue q) throws Throwable {
+ System.out.println(q.getClass().getSimpleName());
+ final long testDurationSeconds = 1L;
+ final long testDurationMillis = testDurationSeconds * 1000L;
+ final long quittingTimeNanos
+ = System.nanoTime() + testDurationSeconds * 1000L * 1000L * 1000L;
+
+ Thread offerer = new CheckedThread() {
+ protected void realRun() {
+ for (long i = 0; ; i++) {
+ if ((i % 1024) == 0 &&
+ System.nanoTime() - quittingTimeNanos > 0)
+ break;
+ while (! q.offer(i))
+ Thread.yield();
+ }}};
+
+ Thread drainer = new CheckedThread() {
+ protected void realRun() {
+ for (long i = 0; ; i++) {
+ if (System.nanoTime() - quittingTimeNanos > 0)
+ break;
+ List list = new ArrayList();
+ int n = q.drainTo(list);
+ equal(list.size(), n);
+ for (int j = 0; j < n - 1; j++)
+ equal((Long) list.get(j) + 1L, list.get(j + 1));
+ Thread.yield();
+ }}};
+
+ Thread scanner = new CheckedThread() {
+ protected void realRun() {
+ for (long i = 0; ; i++) {
+ if (System.nanoTime() - quittingTimeNanos > 0)
+ break;
+ checkNotContainsNull(q);
+ Thread.yield();
+ }}};
+
+ offerer.join(10 * testDurationMillis);
+ drainer.join(10 * testDurationMillis);
+ check(! offerer.isAlive());
+ check(! drainer.isAlive());
+ }
+
+ //--------------------- Infrastructure ---------------------------
+ volatile int passed = 0, failed = 0;
+ void pass() {passed++;}
+ void fail() {failed++; Thread.dumpStack();}
+ void fail(String msg) {System.err.println(msg); fail();}
+ void unexpected(Throwable t) {failed++; t.printStackTrace();}
+ void check(boolean cond) {if (cond) pass(); else fail();}
+ void equal(Object x, Object y) {
+ if (x == null ? y == null : x.equals(y)) pass();
+ else fail(x + " not equal to " + y);}
+ public static void main(String[] args) throws Throwable {
+ new OfferDrainToLoops().instanceMain(args);}
+ public void instanceMain(String[] args) throws Throwable {
+ try {test(args);} catch (Throwable t) {unexpected(t);}
+ System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
+ if (failed > 0) throw new AssertionError("Some tests failed");}
+}
--- a/jdk/test/java/util/concurrent/ConcurrentLinkedQueue/ConcurrentQueueLoops.java Mon Jul 27 22:28:29 2009 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,146 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file:
- *
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- */
-
-/*
- * @test
- * @bug 4486658
- * @compile -source 1.5 ConcurrentQueueLoops.java
- * @run main/timeout=230 ConcurrentQueueLoops
- * @summary Checks that a set of threads can repeatedly get and modify items
- */
-
-import java.util.*;
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.*;
-
-public class ConcurrentQueueLoops {
- static final ExecutorService pool = Executors.newCachedThreadPool();
- static AtomicInteger totalItems;
- static boolean print = false;
-
- public static void main(String[] args) throws Exception {
- int maxStages = 8;
- int items = 100000;
-
- if (args.length > 0)
- maxStages = Integer.parseInt(args[0]);
-
- print = false;
- System.out.println("Warmup...");
- oneRun(1, items);
- Thread.sleep(100);
- oneRun(1, items);
- Thread.sleep(100);
- print = true;
-
- for (int i = 1; i <= maxStages; i += (i+1) >>> 1) {
- oneRun(i, items);
- }
- pool.shutdown();
- if (! pool.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS))
- throw new Error();
- }
-
- static class Stage implements Callable<Integer> {
- final Queue<Integer> queue;
- final CyclicBarrier barrier;
- int items;
- Stage (Queue<Integer> q, CyclicBarrier b, int items) {
- queue = q;
- barrier = b;
- this.items = items;
- }
-
- public Integer call() {
- // Repeatedly take something from queue if possible,
- // transform it, and put back in.
- try {
- barrier.await();
- int l = 4321;
- int takes = 0;
- for (;;) {
- Integer item = queue.poll();
- if (item != null) {
- ++takes;
- l = LoopHelpers.compute2(item.intValue());
- }
- else if (takes != 0) {
- totalItems.getAndAdd(-takes);
- takes = 0;
- }
- else if (totalItems.get() <= 0)
- break;
- l = LoopHelpers.compute1(l);
- if (items > 0) {
- --items;
- queue.offer(new Integer(l));
- }
- else if ( (l & (3 << 5)) == 0) // spinwait
- Thread.sleep(1);
- }
- return new Integer(l);
- }
- catch (Exception ie) {
- ie.printStackTrace();
- throw new Error("Call loop failed");
- }
- }
- }
-
- static void oneRun(int n, int items) throws Exception {
- Queue<Integer> q = new ConcurrentLinkedQueue<Integer>();
- LoopHelpers.BarrierTimer timer = new LoopHelpers.BarrierTimer();
- CyclicBarrier barrier = new CyclicBarrier(n + 1, timer);
- totalItems = new AtomicInteger(n * items);
- ArrayList<Future<Integer>> results = new ArrayList<Future<Integer>>(n);
- for (int i = 0; i < n; ++i)
- results.add(pool.submit(new Stage(q, barrier, items)));
-
- if (print)
- System.out.print("Threads: " + n + "\t:");
- barrier.await();
- int total = 0;
- for (int i = 0; i < n; ++i) {
- Future<Integer> f = results.get(i);
- Integer r = f.get();
- total += r.intValue();
- }
- long endTime = System.nanoTime();
- long time = endTime - timer.startTime;
- if (print)
- System.out.println(LoopHelpers.rightJustify(time / (items * n)) + " ns per item");
- if (total == 0) // avoid overoptimization
- System.out.println("useless result: " + total);
-
- }
-}
--- a/jdk/test/java/util/concurrent/ConcurrentLinkedQueue/LoopHelpers.java Mon Jul 27 22:28:29 2009 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,129 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file:
- *
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- */
-
-/**
- * Misc utilities in JSR166 performance tests
- */
-
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.*;
-
-class LoopHelpers {
-
- // Some mindless computation to do between synchronizations...
-
- /**
- * generates 32 bit pseudo-random numbers.
- * Adapted from http://www.snippets.org
- */
- public static int compute1(int x) {
- int lo = 16807 * (x & 0xFFFF);
- int hi = 16807 * (x >>> 16);
- lo += (hi & 0x7FFF) << 16;
- if ((lo & 0x80000000) != 0) {
- lo &= 0x7fffffff;
- ++lo;
- }
- lo += hi >>> 15;
- if (lo == 0 || (lo & 0x80000000) != 0) {
- lo &= 0x7fffffff;
- ++lo;
- }
- return lo;
- }
-
- /**
- * Computes a linear congruential random number a random number
- * of times.
- */
- public static int compute2(int x) {
- int loops = (x >>> 4) & 7;
- while (loops-- > 0) {
- x = (x * 2147483647) % 16807;
- }
- return x;
- }
-
- /**
- * An actually useful random number generator, but unsynchronized.
- * Basically same as java.util.Random.
- */
- public static class SimpleRandom {
- private final static long multiplier = 0x5DEECE66DL;
- private final static long addend = 0xBL;
- private final static long mask = (1L << 48) - 1;
- static final AtomicLong seq = new AtomicLong(1);
- private long seed = System.nanoTime() + seq.getAndIncrement();
-
- public void setSeed(long s) {
- seed = s;
- }
-
- public int next() {
- long nextseed = (seed * multiplier + addend) & mask;
- seed = nextseed;
- return ((int)(nextseed >>> 17)) & 0x7FFFFFFF;
- }
- }
-
- public static class BarrierTimer implements Runnable {
- public volatile long startTime;
- public volatile long endTime;
- public void run() {
- long t = System.nanoTime();
- if (startTime == 0)
- startTime = t;
- else
- endTime = t;
- }
- public void clear() {
- startTime = 0;
- endTime = 0;
- }
- public long getTime() {
- return endTime - startTime;
- }
- }
-
- public static String rightJustify(long n) {
- // There's probably a better way to do this...
- String field = " ";
- String num = Long.toString(n);
- if (num.length() >= field.length())
- return num;
- StringBuffer b = new StringBuffer(field);
- b.replace(b.length()-num.length(), b.length(), num);
- return b.toString();
- }
-
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/concurrent/ConcurrentQueues/ConcurrentQueueLoops.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,198 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Written by Doug Lea with assistance from members of JCP JSR-166
+ * Expert Group and released to the public domain, as explained at
+ * http://creativecommons.org/licenses/publicdomain
+ */
+
+/*
+ * @test
+ * @bug 4486658 6785442
+ * @run main ConcurrentQueueLoops 8 123456
+ * @summary Checks that a set of threads can repeatedly get and modify items
+ */
+
+import java.util.*;
+import java.util.concurrent.*;
+import java.util.concurrent.atomic.*;
+
+public class ConcurrentQueueLoops {
+ ExecutorService pool;
+ AtomicInteger totalItems;
+ boolean print;
+
+ // Suitable for benchmarking. Overriden by args[0] for testing.
+ int maxStages = 20;
+
+ // Suitable for benchmarking. Overriden by args[1] for testing.
+ int items = 1024 * 1024;
+
+ Collection<Queue<Integer>> concurrentQueues() {
+ List<Queue<Integer>> queues = new ArrayList<Queue<Integer>>();
+ queues.add(new ConcurrentLinkedQueue<Integer>());
+ queues.add(new ArrayBlockingQueue<Integer>(items, false));
+ //queues.add(new ArrayBlockingQueue<Integer>(count, true));
+ queues.add(new LinkedBlockingQueue<Integer>());
+ queues.add(new LinkedBlockingDeque<Integer>());
+
+ try {
+ queues.add((Queue<Integer>)
+ Class.forName("java.util.concurrent.LinkedTransferQueue")
+ .newInstance());
+ } catch (IllegalAccessException e) {
+ } catch (InstantiationException e) {
+ } catch (ClassNotFoundException e) {
+ // OK; not yet added to JDK
+ }
+
+ // Following additional implementations are available from:
+ // http://gee.cs.oswego.edu/dl/concurrency-interest/index.html
+ // queues.add(new LinkedTransferQueue<Integer>());
+ // queues.add(new SynchronizedLinkedListQueue<Integer>());
+
+ // Avoid "first fast, second slow" benchmark effect.
+ Collections.shuffle(queues);
+ return queues;
+ }
+
+ void test(String[] args) throws Throwable {
+ if (args.length > 0)
+ maxStages = Integer.parseInt(args[0]);
+ if (args.length > 1)
+ items = Integer.parseInt(args[1]);
+
+ for (Queue<Integer> queue : concurrentQueues())
+ test(queue);
+ }
+
+ void test(final Queue<Integer> q) throws Throwable {
+ System.out.println(q.getClass().getSimpleName());
+ pool = Executors.newCachedThreadPool();
+ print = false;
+
+ print = false;
+ System.out.println("Warmup...");
+ oneRun(1, items, q);
+ //Thread.sleep(100);
+ oneRun(3, items, q);
+ Thread.sleep(100);
+ print = true;
+
+ for (int i = 1; i <= maxStages; i += (i+1) >>> 1) {
+ oneRun(i, items, q);
+ }
+ pool.shutdown();
+ check(pool.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS));
+ }
+
+ class Stage implements Callable<Integer> {
+ final Queue<Integer> queue;
+ final CyclicBarrier barrier;
+ int items;
+ Stage (Queue<Integer> q, CyclicBarrier b, int items) {
+ queue = q;
+ barrier = b;
+ this.items = items;
+ }
+
+ public Integer call() {
+ // Repeatedly take something from queue if possible,
+ // transform it, and put back in.
+ try {
+ barrier.await();
+ int l = 4321;
+ int takes = 0;
+ for (;;) {
+ Integer item = queue.poll();
+ if (item != null) {
+ ++takes;
+ l = LoopHelpers.compute2(item.intValue());
+ }
+ else if (takes != 0) {
+ totalItems.getAndAdd(-takes);
+ takes = 0;
+ }
+ else if (totalItems.get() <= 0)
+ break;
+ l = LoopHelpers.compute1(l);
+ if (items > 0) {
+ --items;
+ queue.offer(new Integer(l));
+ }
+ else if ( (l & (3 << 5)) == 0) // spinwait
+ Thread.sleep(1);
+ }
+ return new Integer(l);
+ }
+ catch (Throwable t) { unexpected(t); return null; }
+ }
+ }
+
+ void oneRun(int n, int items, final Queue<Integer> q) throws Exception {
+ LoopHelpers.BarrierTimer timer = new LoopHelpers.BarrierTimer();
+ CyclicBarrier barrier = new CyclicBarrier(n + 1, timer);
+ totalItems = new AtomicInteger(n * items);
+ ArrayList<Future<Integer>> results = new ArrayList<Future<Integer>>(n);
+ for (int i = 0; i < n; ++i)
+ results.add(pool.submit(new Stage(q, barrier, items)));
+
+ if (print)
+ System.out.print("Threads: " + n + "\t:");
+ barrier.await();
+ int total = 0;
+ for (int i = 0; i < n; ++i) {
+ Future<Integer> f = results.get(i);
+ Integer r = f.get();
+ total += r.intValue();
+ }
+ long endTime = System.nanoTime();
+ long time = endTime - timer.startTime;
+ if (print)
+ System.out.println(LoopHelpers.rightJustify(time / (items * n)) + " ns per item");
+ if (total == 0) // avoid overoptimization
+ System.out.println("useless result: " + total);
+ }
+
+ //--------------------- Infrastructure ---------------------------
+ volatile int passed = 0, failed = 0;
+ void pass() {passed++;}
+ void fail() {failed++; Thread.dumpStack();}
+ void fail(String msg) {System.err.println(msg); fail();}
+ void unexpected(Throwable t) {failed++; t.printStackTrace();}
+ void check(boolean cond) {if (cond) pass(); else fail();}
+ void equal(Object x, Object y) {
+ if (x == null ? y == null : x.equals(y)) pass();
+ else fail(x + " not equal to " + y);}
+ public static void main(String[] args) throws Throwable {
+ new ConcurrentQueueLoops().instanceMain(args);}
+ public void instanceMain(String[] args) throws Throwable {
+ try {test(args);} catch (Throwable t) {unexpected(t);}
+ System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
+ if (failed > 0) throw new AssertionError("Some tests failed");}
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/concurrent/ConcurrentQueues/GCRetention.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,165 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Written by Doug Lea with assistance from members of JCP JSR-166
+ * Expert Group and released to the public domain, as explained at
+ * http://creativecommons.org/licenses/publicdomain
+ */
+/*
+ * @test
+ * @bug 6785442
+ * @summary Benchmark that tries to GC-tenure head, followed by
+ * many add/remove operations.
+ * @run main GCRetention 12345
+ */
+
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.PriorityBlockingQueue;
+import java.util.LinkedList;
+import java.util.PriorityQueue;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Queue;
+import java.util.Map;
+
+public class GCRetention {
+ // Suitable for benchmarking. Overriden by args[0] for testing.
+ int count = 1024 * 1024;
+
+ final Map<String,String> results = new ConcurrentHashMap<String,String>();
+
+ Collection<Queue<Boolean>> queues() {
+ List<Queue<Boolean>> queues = new ArrayList<Queue<Boolean>>();
+ queues.add(new ConcurrentLinkedQueue<Boolean>());
+ queues.add(new ArrayBlockingQueue<Boolean>(count, false));
+ queues.add(new ArrayBlockingQueue<Boolean>(count, true));
+ queues.add(new LinkedBlockingQueue<Boolean>());
+ queues.add(new LinkedBlockingDeque<Boolean>());
+ queues.add(new PriorityBlockingQueue<Boolean>());
+ queues.add(new PriorityQueue<Boolean>());
+ queues.add(new LinkedList<Boolean>());
+
+ try {
+ queues.add((Queue<Boolean>)
+ Class.forName("java.util.concurrent.LinkedTransferQueue")
+ .newInstance());
+ } catch (IllegalAccessException e) {
+ } catch (InstantiationException e) {
+ } catch (ClassNotFoundException e) {
+ // OK; not yet added to JDK
+ }
+
+ // Following additional implementations are available from:
+ // http://gee.cs.oswego.edu/dl/concurrency-interest/index.html
+ // queues.add(new LinkedTransferQueue<Boolean>());
+ // queues.add(new SynchronizedLinkedListQueue<Boolean>());
+
+ // Avoid "first fast, second slow" benchmark effect.
+ Collections.shuffle(queues);
+ return queues;
+ }
+
+ void prettyPrintResults() {
+ List<String> classNames = new ArrayList<String>(results.keySet());
+ Collections.sort(classNames);
+ int maxClassNameLength = 0;
+ int maxNanosLength = 0;
+ for (String name : classNames) {
+ if (maxClassNameLength < name.length())
+ maxClassNameLength = name.length();
+ if (maxNanosLength < results.get(name).length())
+ maxNanosLength = results.get(name).length();
+ }
+ String format = String.format("%%%ds %%%ds nanos/item%%n",
+ maxClassNameLength, maxNanosLength);
+ for (String name : classNames)
+ System.out.printf(format, name, results.get(name));
+ }
+
+ void test(String[] args) {
+ if (args.length > 0)
+ count = Integer.valueOf(args[0]);
+ // Warmup
+ for (Queue<Boolean> queue : queues())
+ test(queue);
+ results.clear();
+ for (Queue<Boolean> queue : queues())
+ test(queue);
+
+ prettyPrintResults();
+ }
+
+ void test(Queue<Boolean> q) {
+ long t0 = System.nanoTime();
+ for (int i = 0; i < count; i++)
+ check(q.add(Boolean.TRUE));
+ System.gc();
+ System.gc();
+ Boolean x;
+ while ((x = q.poll()) != null)
+ equal(x, Boolean.TRUE);
+ check(q.isEmpty());
+
+ for (int i = 0; i < 10 * count; i++) {
+ for (int k = 0; k < 3; k++)
+ check(q.add(Boolean.TRUE));
+ for (int k = 0; k < 3; k++)
+ if (q.poll() != Boolean.TRUE)
+ fail();
+ }
+ check(q.isEmpty());
+
+ String className = q.getClass().getSimpleName();
+ long elapsed = System.nanoTime() - t0;
+ int nanos = (int) ((double) elapsed / (10 * 3 * count));
+ results.put(className, String.valueOf(nanos));
+ }
+
+ //--------------------- Infrastructure ---------------------------
+ volatile int passed = 0, failed = 0;
+ void pass() {passed++;}
+ void fail() {failed++; Thread.dumpStack();}
+ void fail(String msg) {System.err.println(msg); fail();}
+ void unexpected(Throwable t) {failed++; t.printStackTrace();}
+ void check(boolean cond) {if (cond) pass(); else fail();}
+ void equal(Object x, Object y) {
+ if (x == null ? y == null : x.equals(y)) pass();
+ else fail(x + " not equal to " + y);}
+ public static void main(String[] args) throws Throwable {
+ new GCRetention().instanceMain(args);}
+ public void instanceMain(String[] args) throws Throwable {
+ try {test(args);} catch (Throwable t) {unexpected(t);}
+ System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
+ if (failed > 0) throw new AssertionError("Some tests failed");}
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/concurrent/ConcurrentQueues/IteratorWeakConsistency.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,93 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Written by Doug Lea with assistance from members of JCP JSR-166
+ * Expert Group and released to the public domain, as explained at
+ * http://creativecommons.org/licenses/publicdomain
+ */
+
+import java.util.*;
+import java.util.concurrent.*;
+
+/*
+ * @test
+ * @bug 6805775 6815766
+ * @summary Check weak consistency of concurrent queue iterators
+ */
+
+@SuppressWarnings({"unchecked", "rawtypes"})
+public class IteratorWeakConsistency {
+
+ void test(String[] args) throws Throwable {
+ test(new LinkedBlockingQueue());
+ test(new LinkedBlockingQueue(20));
+ test(new LinkedBlockingDeque());
+ test(new LinkedBlockingDeque(20));
+ test(new ConcurrentLinkedQueue());
+ // Other concurrent queues (e.g. ArrayBlockingQueue) do not
+ // currently have weakly consistent iterators.
+ // test(new ArrayBlockingQueue(20));
+ }
+
+ void test(Queue q) throws Throwable {
+ // TODO: make this more general
+ for (int i = 0; i < 10; i++)
+ q.add(i);
+ Iterator it = q.iterator();
+ q.poll();
+ q.poll();
+ q.poll();
+ q.remove(7);
+ List list = new ArrayList();
+ while (it.hasNext())
+ list.add(it.next());
+ equal(list, Arrays.asList(0, 3, 4, 5, 6, 8, 9));
+ check(! list.contains(null));
+ System.out.printf("%s: %s%n",
+ q.getClass().getSimpleName(),
+ list);
+ }
+
+ //--------------------- Infrastructure ---------------------------
+ volatile int passed = 0, failed = 0;
+ void pass() {passed++;}
+ void fail() {failed++; Thread.dumpStack();}
+ void fail(String msg) {System.err.println(msg); fail();}
+ void unexpected(Throwable t) {failed++; t.printStackTrace();}
+ void check(boolean cond) {if (cond) pass(); else fail();}
+ void equal(Object x, Object y) {
+ if (x == null ? y == null : x.equals(y)) pass();
+ else fail(x + " not equal to " + y);}
+ static Class<?> thisClass = new Object(){}.getClass().getEnclosingClass();
+ public static void main(String[] args) throws Throwable {
+ new IteratorWeakConsistency().instanceMain(args);}
+ public void instanceMain(String[] args) throws Throwable {
+ try {test(args);} catch (Throwable t) {unexpected(t);}
+ System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
+ if (failed > 0) throw new AssertionError("Some tests failed");}
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/concurrent/ConcurrentQueues/LoopHelpers.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,129 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Written by Doug Lea with assistance from members of JCP JSR-166
+ * Expert Group and released to the public domain, as explained at
+ * http://creativecommons.org/licenses/publicdomain
+ */
+
+/**
+ * Misc utilities in JSR166 performance tests
+ */
+
+import java.util.concurrent.*;
+import java.util.concurrent.atomic.*;
+
+class LoopHelpers {
+
+ // Some mindless computation to do between synchronizations...
+
+ /**
+ * generates 32 bit pseudo-random numbers.
+ * Adapted from http://www.snippets.org
+ */
+ public static int compute1(int x) {
+ int lo = 16807 * (x & 0xFFFF);
+ int hi = 16807 * (x >>> 16);
+ lo += (hi & 0x7FFF) << 16;
+ if ((lo & 0x80000000) != 0) {
+ lo &= 0x7fffffff;
+ ++lo;
+ }
+ lo += hi >>> 15;
+ if (lo == 0 || (lo & 0x80000000) != 0) {
+ lo &= 0x7fffffff;
+ ++lo;
+ }
+ return lo;
+ }
+
+ /**
+ * Computes a linear congruential random number a random number
+ * of times.
+ */
+ public static int compute2(int x) {
+ int loops = (x >>> 4) & 7;
+ while (loops-- > 0) {
+ x = (x * 2147483647) % 16807;
+ }
+ return x;
+ }
+
+ /**
+ * An actually useful random number generator, but unsynchronized.
+ * Basically same as java.util.Random.
+ */
+ public static class SimpleRandom {
+ private final static long multiplier = 0x5DEECE66DL;
+ private final static long addend = 0xBL;
+ private final static long mask = (1L << 48) - 1;
+ static final AtomicLong seq = new AtomicLong(1);
+ private long seed = System.nanoTime() + seq.getAndIncrement();
+
+ public void setSeed(long s) {
+ seed = s;
+ }
+
+ public int next() {
+ long nextseed = (seed * multiplier + addend) & mask;
+ seed = nextseed;
+ return ((int)(nextseed >>> 17)) & 0x7FFFFFFF;
+ }
+ }
+
+ public static class BarrierTimer implements Runnable {
+ public volatile long startTime;
+ public volatile long endTime;
+ public void run() {
+ long t = System.nanoTime();
+ if (startTime == 0)
+ startTime = t;
+ else
+ endTime = t;
+ }
+ public void clear() {
+ startTime = 0;
+ endTime = 0;
+ }
+ public long getTime() {
+ return endTime - startTime;
+ }
+ }
+
+ public static String rightJustify(long n) {
+ // There's probably a better way to do this...
+ String field = " ";
+ String num = Long.toString(n);
+ if (num.length() >= field.length())
+ return num;
+ StringBuffer b = new StringBuffer(field);
+ b.replace(b.length()-num.length(), b.length(), num);
+ return b.toString();
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/concurrent/ConcurrentQueues/RemovePollRace.java Tue Aug 04 08:01:03 2009 -0700
@@ -0,0 +1,230 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Written by Doug Lea with assistance from members of JCP JSR-166
+ * Expert Group and released to the public domain, as explained at
+ * http://creativecommons.org/licenses/publicdomain
+ */
+
+/*
+ * @test
+ * @bug 6785442
+ * @summary Checks race between poll and remove(Object), while
+ * occasionally moonlighting as a microbenchmark.
+ * @run main RemovePollRace 12345
+ */
+
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Queue;
+import java.util.Map;
+
+public class RemovePollRace {
+ // Suitable for benchmarking. Overriden by args[0] for testing.
+ int count = 1024 * 1024;
+
+ final Map<String,String> results = new ConcurrentHashMap<String,String>();
+
+ Collection<Queue<Boolean>> concurrentQueues() {
+ List<Queue<Boolean>> queues = new ArrayList<Queue<Boolean>>();
+ queues.add(new ConcurrentLinkedQueue<Boolean>());
+ queues.add(new ArrayBlockingQueue<Boolean>(count, false));
+ queues.add(new ArrayBlockingQueue<Boolean>(count, true));
+ queues.add(new LinkedBlockingQueue<Boolean>());
+ queues.add(new LinkedBlockingDeque<Boolean>());
+
+ try {
+ queues.add((Queue<Boolean>)
+ Class.forName("java.util.concurrent.LinkedTransferQueue")
+ .newInstance());
+ } catch (IllegalAccessException e) {
+ } catch (InstantiationException e) {
+ } catch (ClassNotFoundException e) {
+ // OK; not yet added to JDK
+ }
+
+ // Following additional implementations are available from:
+ // http://gee.cs.oswego.edu/dl/concurrency-interest/index.html
+ // queues.add(new LinkedTransferQueue<Boolean>());
+ // queues.add(new SynchronizedLinkedListQueue<Boolean>());
+
+ // Avoid "first fast, second slow" benchmark effect.
+ Collections.shuffle(queues);
+ return queues;
+ }
+
+ void prettyPrintResults() {
+ List<String> classNames = new ArrayList<String>(results.keySet());
+ Collections.sort(classNames);
+ int maxClassNameLength = 0;
+ int maxNanosLength = 0;
+ for (String name : classNames) {
+ if (maxClassNameLength < name.length())
+ maxClassNameLength = name.length();
+ if (maxNanosLength < results.get(name).length())
+ maxNanosLength = results.get(name).length();
+ }
+ String format = String.format("%%%ds %%%ds nanos/item%%n",
+ maxClassNameLength, maxNanosLength);
+ for (String name : classNames)
+ System.out.printf(format, name, results.get(name));
+ }
+
+ void test(String[] args) throws Throwable {
+ if (args.length > 0)
+ count = Integer.valueOf(args[0]);
+ // Warmup
+ for (Queue<Boolean> queue : concurrentQueues())
+ test(queue);
+ results.clear();
+ for (Queue<Boolean> queue : concurrentQueues())
+ test(queue);
+
+ prettyPrintResults();
+ }
+
+ void await(CountDownLatch latch) {
+ try { latch.await(); }
+ catch (InterruptedException e) { unexpected(e); }
+ }
+
+ void test(final Queue<Boolean> q) throws Throwable {
+ long t0 = System.nanoTime();
+ final int SPINS = 5;
+ final AtomicLong removes = new AtomicLong(0);
+ final AtomicLong polls = new AtomicLong(0);
+ final int adderCount =
+ Math.max(1, Runtime.getRuntime().availableProcessors() / 4);
+ final int removerCount =
+ Math.max(1, Runtime.getRuntime().availableProcessors() / 4);
+ final int pollerCount = removerCount;
+ final int threadCount = adderCount + removerCount + pollerCount;
+ final CountDownLatch startingGate = new CountDownLatch(1);
+ final CountDownLatch addersDone = new CountDownLatch(adderCount);
+ final Runnable remover = new Runnable() {
+ public void run() {
+ await(startingGate);
+ int spins = 0;
+ for (;;) {
+ boolean quittingTime = (addersDone.getCount() == 0);
+ if (q.remove(Boolean.TRUE))
+ removes.getAndIncrement();
+ else if (quittingTime)
+ break;
+ else if (++spins > SPINS) {
+ Thread.yield();
+ spins = 0;
+ }}}};
+ final Runnable poller = new Runnable() {
+ public void run() {
+ await(startingGate);
+ int spins = 0;
+ for (;;) {
+ boolean quittingTime = (addersDone.getCount() == 0);
+ if (q.poll() == Boolean.TRUE)
+ polls.getAndIncrement();
+ else if (quittingTime)
+ break;
+ else if (++spins > SPINS) {
+ Thread.yield();
+ spins = 0;
+ }}}};
+ final Runnable adder = new Runnable() {
+ public void run() {
+ await(startingGate);
+ for (int i = 0; i < count; i++) {
+ for (;;) {
+ try { q.add(Boolean.TRUE); break; }
+ catch (IllegalStateException e) { Thread.yield(); }
+ }
+ }
+ addersDone.countDown();
+ }};
+
+ final List<Thread> adders = new ArrayList<Thread>();
+ final List<Thread> removers = new ArrayList<Thread>();
+ final List<Thread> pollers = new ArrayList<Thread>();
+ for (int i = 0; i < adderCount; i++)
+ adders.add(checkedThread(adder));
+ for (int i = 0; i < removerCount; i++)
+ removers.add(checkedThread(remover));
+ for (int i = 0; i < pollerCount; i++)
+ pollers.add(checkedThread(poller));
+
+ final List<Thread> allThreads = new ArrayList<Thread>();
+ allThreads.addAll(removers);
+ allThreads.addAll(pollers);
+ allThreads.addAll(adders);
+
+ for (Thread t : allThreads)
+ t.start();
+ startingGate.countDown();
+ for (Thread t : allThreads)
+ t.join();
+
+ String className = q.getClass().getSimpleName();
+ long elapsed = System.nanoTime() - t0;
+ int nanos = (int) ((double) elapsed / (adderCount * count));
+ results.put(className, String.valueOf(nanos));
+ if (removes.get() + polls.get() != adderCount * count) {
+ String msg = String.format
+ ("class=%s removes=%s polls=%d count=%d",
+ className, removes.get(), polls.get(), count);
+ fail(msg);
+ }
+ }
+
+ //--------------------- Infrastructure ---------------------------
+ volatile int passed = 0, failed = 0;
+ void pass() {passed++;}
+ void fail() {failed++; Thread.dumpStack();}
+ void fail(String msg) {System.err.println(msg); fail();}
+ void unexpected(Throwable t) {failed++; t.printStackTrace();}
+ void check(boolean cond) {if (cond) pass(); else fail();}
+ void equal(Object x, Object y) {
+ if (x == null ? y == null : x.equals(y)) pass();
+ else fail(x + " not equal to " + y);}
+ public static void main(String[] args) throws Throwable {
+ new RemovePollRace().instanceMain(args);}
+ public void instanceMain(String[] args) throws Throwable {
+ try {test(args);} catch (Throwable t) {unexpected(t);}
+ System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
+ if (failed > 0) throw new AssertionError("Some tests failed");}
+ Thread checkedThread(final Runnable r) {
+ return new Thread() {public void run() {
+ try {r.run();} catch (Throwable t) {unexpected(t);}}};}
+}
--- a/jdk/test/java/util/concurrent/LinkedBlockingQueue/OfferRemoveLoops.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/test/java/util/concurrent/LinkedBlockingQueue/OfferRemoveLoops.java Tue Aug 04 08:01:03 2009 -0700
@@ -28,62 +28,74 @@
* @author Martin Buchholz
*/
+import java.util.*;
import java.util.concurrent.*;
public class OfferRemoveLoops {
- private static void realMain(String[] args) throws Throwable {
+ void test(String[] args) throws Throwable {
testQueue(new LinkedBlockingQueue<String>(10));
testQueue(new LinkedBlockingQueue<String>());
testQueue(new LinkedBlockingDeque<String>(10));
testQueue(new LinkedBlockingDeque<String>());
testQueue(new ArrayBlockingQueue<String>(10));
testQueue(new PriorityBlockingQueue<String>(10));
+ testQueue(new ConcurrentLinkedQueue<String>());
}
- private abstract static class ControlledThread extends Thread {
+ abstract class CheckedThread extends Thread {
abstract protected void realRun();
public void run() {
try { realRun(); } catch (Throwable t) { unexpected(t); }
}
}
- private static void testQueue(final BlockingQueue<String> q) throws Throwable {
- System.out.println(q.getClass());
- final int count = 10000;
- final long quittingTime = System.nanoTime() + 1L * 1000L * 1000L * 1000L;
- Thread t1 = new ControlledThread() {
- protected void realRun() {
- for (int i = 0, j = 0; i < count; i++)
- while (! q.remove(String.valueOf(i))
- && System.nanoTime() - quittingTime < 0)
- Thread.yield();}};
- Thread t2 = new ControlledThread() {
- protected void realRun() {
- for (int i = 0, j = 0; i < count; i++)
- while (! q.offer(String.valueOf(i))
- && System.nanoTime() - quittingTime < 0)
- Thread.yield();}};
+ void testQueue(final Queue<String> q) throws Throwable {
+ System.out.println(q.getClass().getSimpleName());
+ final int count = 1000 * 1000;
+ final long testDurationSeconds = 1L;
+ final long testDurationMillis = testDurationSeconds * 1000L;
+ final long quittingTimeNanos
+ = System.nanoTime() + testDurationSeconds * 1000L * 1000L * 1000L;
+ Thread t1 = new CheckedThread() {
+ protected void realRun() {
+ for (int i = 0; i < count; i++) {
+ if ((i % 1024) == 0 &&
+ System.nanoTime() - quittingTimeNanos > 0)
+ return;
+ while (! q.remove(String.valueOf(i)))
+ Thread.yield();
+ }}};
+ Thread t2 = new CheckedThread() {
+ protected void realRun() {
+ for (int i = 0; i < count; i++) {
+ if ((i % 1024) == 0 &&
+ System.nanoTime() - quittingTimeNanos > 0)
+ return;
+ while (! q.offer(String.valueOf(i)))
+ Thread.yield();
+ }}};
t1.setDaemon(true); t2.setDaemon(true);
t1.start(); t2.start();
- t1.join(10000); t2.join(10000);
+ t1.join(10 * testDurationMillis);
+ t2.join(10 * testDurationMillis);
check(! t1.isAlive());
check(! t2.isAlive());
}
//--------------------- Infrastructure ---------------------------
- static volatile int passed = 0, failed = 0;
- static void pass() { passed++; }
- static void fail() { failed++; Thread.dumpStack(); }
- static void unexpected(Throwable t) { failed++; t.printStackTrace(); }
- static void check(boolean cond) { if (cond) pass(); else fail(); }
- static void equal(Object x, Object y) {
+ volatile int passed = 0, failed = 0;
+ void pass() {passed++;}
+ void fail() {failed++; Thread.dumpStack();}
+ void fail(String msg) {System.err.println(msg); fail();}
+ void unexpected(Throwable t) {failed++; t.printStackTrace();}
+ void check(boolean cond) {if (cond) pass(); else fail();}
+ void equal(Object x, Object y) {
if (x == null ? y == null : x.equals(y)) pass();
- else {System.out.println(x + " not equal to " + y); fail(); }}
-
+ else fail(x + " not equal to " + y);}
public static void main(String[] args) throws Throwable {
- try { realMain(args); } catch (Throwable t) { unexpected(t); }
-
+ new OfferRemoveLoops().instanceMain(args);}
+ public void instanceMain(String[] args) throws Throwable {
+ try {test(args);} catch (Throwable t) {unexpected(t);}
System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
- if (failed > 0) throw new Exception("Some tests failed");
- }
+ if (failed > 0) throw new AssertionError("Some tests failed");}
}
--- a/jdk/test/sun/security/krb5/ConfPlusProp.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/test/sun/security/krb5/ConfPlusProp.java Tue Aug 04 08:01:03 2009 -0700
@@ -23,7 +23,7 @@
/*
* @test
* @bug 6857795
- * @buf 6858589
+ * @bug 6858589
* @summary krb5.conf ignored if system properties on realm and kdc are provided
*/
--- a/jdk/test/sun/security/tools/keytool/standard.sh Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/test/sun/security/tools/keytool/standard.sh Tue Aug 04 08:01:03 2009 -0700
@@ -24,6 +24,7 @@
# @test
# @summary (almost) all keytool behaviors
# @author Weijun Wang
+# @run shell/timeout=600 standard.sh
#
# This test is always excecuted.
#
--- a/jdk/test/tools/jar/index/MetaInf.java Mon Jul 27 22:28:29 2009 -0700
+++ b/jdk/test/tools/jar/index/MetaInf.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/langtools/.hgtags Mon Jul 27 22:28:29 2009 -0700
+++ b/langtools/.hgtags Tue Aug 04 08:01:03 2009 -0700
@@ -39,3 +39,5 @@
6855e5aa3348f185fe5b443ee43a1b00ec5d390e jdk7-b62
5c2c8112055565b4980b6756e001e45eb7b88d6e jdk7-b63
d8f23a81d46f47a4186f1044dd9e44841bbeab84 jdk7-b64
+7e0056ded28c802609d2bd79bfcda551d72a3fec jdk7-b65
+634f519d6f9a602b16bba1c7cd4a17242a8f6889 jdk7-b66
--- a/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java Mon Jul 27 22:28:29 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java Mon Jul 27 22:28:29 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Mon Jul 27 22:28:29 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java Mon Jul 27 22:28:29 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java Mon Jul 27 22:28:29 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Mon Jul 27 22:28:29 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/langtools/src/share/classes/com/sun/tools/javac/resources/legacy.properties Mon Jul 27 22:28:29 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/resources/legacy.properties Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 2006-2007 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2006-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/langtools/test/tools/javac/typeAnnotations/failures/OldArray.java Mon Jul 27 22:28:29 2009 -0700
+++ b/langtools/test/tools/javac/typeAnnotations/failures/OldArray.java Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
--- a/make/deploy-rules.gmk Mon Jul 27 22:28:29 2009 -0700
+++ b/make/deploy-rules.gmk Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2002-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/make/jprt.properties Mon Jul 27 22:28:29 2009 -0700
+++ b/make/jprt.properties Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 2006-2007 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2006-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
--- a/make/sanity-rules.gmk Mon Jul 27 22:28:29 2009 -0700
+++ b/make/sanity-rules.gmk Tue Aug 04 08:01:03 2009 -0700
@@ -1,5 +1,5 @@
#
-# Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it